Use new code style
This commit is contained in:
@ -9,8 +9,8 @@
|
||||
// Exit if accessed directly
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use \WP_Ultimo\Models\Payment;
|
||||
use \WP_Ultimo\Database\Payments\Payment_Status;
|
||||
use WP_Ultimo\Models\Payment;
|
||||
use WP_Ultimo\Database\Payments\Payment_Status;
|
||||
|
||||
/**
|
||||
* Returns a payment.
|
||||
@ -23,8 +23,7 @@ use \WP_Ultimo\Database\Payments\Payment_Status;
|
||||
function wu_get_payment($payment_id) {
|
||||
|
||||
return \WP_Ultimo\Models\Payment::get_by_id($payment_id);
|
||||
|
||||
} // end wu_get_payment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries payments.
|
||||
@ -37,8 +36,7 @@ function wu_get_payment($payment_id) {
|
||||
function wu_get_payments($query = array()) {
|
||||
|
||||
return \WP_Ultimo\Models\Payment::query($query);
|
||||
|
||||
} // end wu_get_payments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a line-item.
|
||||
@ -53,17 +51,14 @@ function wu_get_line_item($line_item_id, $payment_id) {
|
||||
|
||||
$payment = wu_get_payment($payment_id);
|
||||
|
||||
if (!$payment) {
|
||||
|
||||
if ( ! $payment) {
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$line_items = $payment->get_line_items();
|
||||
|
||||
return wu_get_isset($line_items, $line_item_id, false);
|
||||
|
||||
} // end wu_get_line_item;
|
||||
}
|
||||
/**
|
||||
* Gets a payment based on the hash.
|
||||
*
|
||||
@ -75,8 +70,7 @@ function wu_get_line_item($line_item_id, $payment_id) {
|
||||
function wu_get_payment_by_hash($hash) {
|
||||
|
||||
return \WP_Ultimo\Models\Payment::get_by_hash($hash);
|
||||
|
||||
} // end wu_get_payment_by_hash;
|
||||
}
|
||||
/**
|
||||
* Returns a single payment defined by a particular column and value.
|
||||
*
|
||||
@ -89,8 +83,7 @@ function wu_get_payment_by_hash($hash) {
|
||||
function wu_get_payment_by($column, $value) {
|
||||
|
||||
return \WP_Ultimo\Models\Payment::get_by($column, $value);
|
||||
|
||||
} // end wu_get_payment_by;
|
||||
}
|
||||
/**
|
||||
* Creates a new payment.
|
||||
*
|
||||
@ -105,41 +98,41 @@ function wu_create_payment($payment_data, $save = true) {
|
||||
* Why do we use shortcode atts here?
|
||||
* Shortcode atts clean the array from not-allowed keys, so we don't need to worry much.
|
||||
*/
|
||||
$payment_data = shortcode_atts(array(
|
||||
'line_items' => array(),
|
||||
'meta' => array(),
|
||||
'customer_id' => false,
|
||||
'membership_id' => false,
|
||||
'parent_id' => '',
|
||||
'product_id' => false,
|
||||
'currency' => wu_get_setting('currency_symbol', 'USD'),
|
||||
'discount_code' => '',
|
||||
'subtotal' => 0.00,
|
||||
'discount_total' => 0.00,
|
||||
'tax_total' => 0.00,
|
||||
'total' => 0.00,
|
||||
'status' => Payment_Status::COMPLETED,
|
||||
'gateway' => '',
|
||||
'gateway_payment_id' => '',
|
||||
'date_created' => wu_get_current_time('mysql', true),
|
||||
'date_modified' => wu_get_current_time('mysql', true),
|
||||
'migrated_from_id' => 0,
|
||||
'skip_validation' => false,
|
||||
), $payment_data);
|
||||
$payment_data = shortcode_atts(
|
||||
array(
|
||||
'line_items' => array(),
|
||||
'meta' => array(),
|
||||
'customer_id' => false,
|
||||
'membership_id' => false,
|
||||
'parent_id' => '',
|
||||
'product_id' => false,
|
||||
'currency' => wu_get_setting('currency_symbol', 'USD'),
|
||||
'discount_code' => '',
|
||||
'subtotal' => 0.00,
|
||||
'discount_total' => 0.00,
|
||||
'tax_total' => 0.00,
|
||||
'total' => 0.00,
|
||||
'status' => Payment_Status::COMPLETED,
|
||||
'gateway' => '',
|
||||
'gateway_payment_id' => '',
|
||||
'date_created' => wu_get_current_time('mysql', true),
|
||||
'date_modified' => wu_get_current_time('mysql', true),
|
||||
'migrated_from_id' => 0,
|
||||
'skip_validation' => false,
|
||||
),
|
||||
$payment_data
|
||||
);
|
||||
|
||||
$payment = new Payment($payment_data);
|
||||
|
||||
if (!$save) {
|
||||
|
||||
if ( ! $save) {
|
||||
return $payment;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$saved = $payment->save();
|
||||
|
||||
return is_wp_error($saved) ? $saved : $payment;
|
||||
|
||||
} // end wu_create_payment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the refundable payment types.
|
||||
@ -158,8 +151,7 @@ function wu_get_refundable_payment_types() {
|
||||
);
|
||||
|
||||
return apply_filters('wu_get_refundable_payment_type', $refundable_payment_types);
|
||||
|
||||
} // end wu_get_refundable_payment_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icon classes for a payment status.
|
||||
@ -174,5 +166,4 @@ function wu_get_payment_icon_classes($payment_status) {
|
||||
$payment_status_instance = new Payment_Status($payment_status);
|
||||
|
||||
return $payment_status_instance->get_icon_classes();
|
||||
|
||||
} // end wu_get_payment_icon_classes;
|
||||
}
|
||||
|
Reference in New Issue
Block a user