public function update_status($status = false)
{
//standardize the 'complete(d)' status
if ($status == 'completed' || $status == 'complete') {
$status = 'publish';
}
$old_status = !empty($this->old_status) ? $this->old_status : false;
if ($old_status === $status) {
return false;
// Don't permit status changes that aren't changes
}
$do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status);
$updated = false;
if ($do_change) {
do_action('give_before_payment_status_change', $this->ID, $status, $old_status);
$update_fields = array('ID' => $this->ID, 'post_status' => $status, 'edit_date' => current_time('mysql'));
$updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
$all_payment_statuses = give_get_payment_statuses();
$this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
// Process any specific status functions
switch ($status) {
case 'refunded':
$this->process_refund();
break;
case 'failed':
$this->process_failure();
break;
case 'pending':
$this->process_pending();
break;
case 'cancelled':
$this->process_cancelled();
break;
case 'revoked':
$this->process_revoked();
break;
}
do_action('give_update_payment_status', $this->ID, $status, $old_status);
}
return $updated;
}