@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; // Exit if accessed directly |
11 | 11 | } |
12 | 12 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param WP_Post $post |
22 | 22 | */ |
23 | - public static function output( $post ) { |
|
23 | + public static function output($post) { |
|
24 | 24 | ?> |
25 | 25 | <style> |
26 | 26 | .wpinv-form-builder-edit-field-wrapper label.d-block > span:first-child{ |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | <div class="col-sm-4"> |
34 | 34 | |
35 | 35 | <!-- Builder tabs --> |
36 | - <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e( 'Go Back', 'invoicing' ); ?></button> |
|
36 | + <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e('Go Back', 'invoicing'); ?></button> |
|
37 | 37 | |
38 | 38 | <!-- Builder tab content --> |
39 | 39 | <div class="mt-4"> |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | <!-- Available builder elements --> |
42 | 42 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'"> |
43 | 43 | <div class="wpinv-form-builder-add-field-types"> |
44 | - <small class='form-text text-muted'><?php _e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small> |
|
44 | + <small class='form-text text-muted'><?php _e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small> |
|
45 | 45 | <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable"> |
46 | 46 | <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }"> |
47 | 47 | <button class="button btn text-dark"> |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | <!-- Edit an element --> |
57 | 57 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 14px;"> |
58 | 58 | <div class="wpinv-form-builder-edit-field-wrapper"> |
59 | - <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?> |
|
60 | - <?php do_action( 'getpaid_payment_form_edit_element_template', $post ); ?> |
|
59 | + <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?> |
|
60 | + <?php do_action('getpaid_payment_form_edit_element_template', $post); ?> |
|
61 | 61 | <div class='form-group'> |
62 | - <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e( 'Width', 'invoicing' ) ?></label> |
|
62 | + <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e('Width', 'invoicing') ?></label> |
|
63 | 63 | <select class='form-control custom-select' :id="active_form_element.id + '_grid_width'" v-model='gridWidth'> |
64 | - <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option> |
|
65 | - <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option> |
|
66 | - <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option> |
|
64 | + <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option> |
|
65 | + <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option> |
|
66 | + <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option> |
|
67 | 67 | </select> |
68 | 68 | </div> |
69 | 69 | <div> |
70 | - <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e( 'Delete Element', 'invoicing' ); ?></button> |
|
70 | + <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e('Delete Element', 'invoicing'); ?></button> |
|
71 | 71 | </div> |
72 | 72 | </div> |
73 | 73 | </div> |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | |
77 | 77 | </div> |
78 | 78 | <div class="col-sm-8 border-left"> |
79 | - <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small> |
|
80 | - <p class='form-text text-muted' v-if='! form_elements.length'><?php _e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p> |
|
79 | + <small class='form-text text-muted' v-if='form_elements.length'><?php _e('Click on any element to edit or delete it.', 'invoicing'); ?></small> |
|
80 | + <p class='form-text text-muted' v-if='! form_elements.length'><?php _e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p> |
|
81 | 81 | |
82 | 82 | <div class="container-fluid"> |
83 | 83 | <draggable class="section row" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 14px;"> |
84 | 84 | <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="[{ active: active_form_element==form_element && active_tab=='edit_item' }, form_element.type, grid_class( form_element ) ]" @click="active_tab = 'edit_item'; active_form_element = form_element"> |
85 | 85 | <div class="wpinv-form-builder-element-preview-inner"> |
86 | 86 | <div class="wpinv-payment-form-field-preview-overlay"></div> |
87 | - <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?> |
|
87 | + <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?> |
|
88 | 88 | </div> |
89 | 89 | </div> |
90 | 90 | </draggable> |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | </div> |
99 | 99 | <?php |
100 | 100 | |
101 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
101 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -106,33 +106,33 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param int $post_id |
108 | 108 | */ |
109 | - public static function save( $post_id ) { |
|
109 | + public static function save($post_id) { |
|
110 | 110 | |
111 | 111 | // Prepare the form. |
112 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
112 | + $form = new GetPaid_Payment_Form($post_id); |
|
113 | 113 | |
114 | 114 | // Fetch form items. |
115 | - $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true ); |
|
115 | + $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true); |
|
116 | 116 | |
117 | 117 | // Ensure that we have an array... |
118 | - if ( empty( $form_items ) ) { |
|
118 | + if (empty($form_items)) { |
|
119 | 119 | $form_items = array(); |
120 | 120 | } |
121 | 121 | |
122 | 122 | // Add it to the form. |
123 | - $form->set_items( self::item_to_objects( $form_items ) ); |
|
123 | + $form->set_items(self::item_to_objects($form_items)); |
|
124 | 124 | |
125 | 125 | // Save form elements. |
126 | - $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true ); |
|
127 | - if ( empty( $form_elements ) ) { |
|
126 | + $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true); |
|
127 | + if (empty($form_elements)) { |
|
128 | 128 | $form_elements = array(); |
129 | 129 | } |
130 | 130 | |
131 | - $form->set_elements( $form_elements ); |
|
131 | + $form->set_elements($form_elements); |
|
132 | 132 | |
133 | 133 | // Persist data to the datastore. |
134 | 134 | $form->save(); |
135 | - do_action( 'getpaid_payment_form_metabox_save', $post_id, $form ); |
|
135 | + do_action('getpaid_payment_form_metabox_save', $post_id, $form); |
|
136 | 136 | |
137 | 137 | } |
138 | 138 | |
@@ -141,14 +141,14 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @param array $items |
143 | 143 | */ |
144 | - public static function item_to_objects( $items ) { |
|
144 | + public static function item_to_objects($items) { |
|
145 | 145 | |
146 | 146 | $objects = array(); |
147 | 147 | |
148 | - foreach ( $items as $item ) { |
|
149 | - $_item = new GetPaid_Form_Item( $item['id'] ); |
|
150 | - $_item->set_allow_quantities( (bool) $item['allow_quantities'] ); |
|
151 | - $_item->set_is_required( (bool) $item['required'] ); |
|
148 | + foreach ($items as $item) { |
|
149 | + $_item = new GetPaid_Form_Item($item['id']); |
|
150 | + $_item->set_allow_quantities((bool) $item['allow_quantities']); |
|
151 | + $_item->set_is_required((bool) $item['required']); |
|
152 | 152 | $objects[] = $_item; |
153 | 153 | } |
154 | 154 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Class GetPaid_Tax |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | * @param boolean $price_includes_tax Whether the passed price has taxes included. |
22 | 22 | * @return array Array of tax name => tax amount. |
23 | 23 | */ |
24 | - public static function calc_tax( $price, $rates, $price_includes_tax = false ) { |
|
24 | + public static function calc_tax($price, $rates, $price_includes_tax = false) { |
|
25 | 25 | |
26 | - if ( $price_includes_tax ) { |
|
27 | - $taxes = self::calc_inclusive_tax( $price, $rates ); |
|
26 | + if ($price_includes_tax) { |
|
27 | + $taxes = self::calc_inclusive_tax($price, $rates); |
|
28 | 28 | } else { |
29 | - $taxes = self::calc_exclusive_tax( $price, $rates ); |
|
29 | + $taxes = self::calc_exclusive_tax($price, $rates); |
|
30 | 30 | } |
31 | 31 | |
32 | - return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax ); |
|
32 | + return apply_filters('getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax); |
|
33 | 33 | |
34 | 34 | } |
35 | 35 | |
@@ -40,22 +40,22 @@ discard block |
||
40 | 40 | * @param array $rates Array of tax rates. |
41 | 41 | * @return array |
42 | 42 | */ |
43 | - public static function calc_inclusive_tax( $price, $rates ) { |
|
43 | + public static function calc_inclusive_tax($price, $rates) { |
|
44 | 44 | $taxes = array(); |
45 | - $tax_rates = wp_list_pluck( $rates, 'rate', 'name' ); |
|
45 | + $tax_rates = wp_list_pluck($rates, 'rate', 'name'); |
|
46 | 46 | |
47 | 47 | // Add tax rates. |
48 | - $tax_rate = 1 + ( array_sum( $tax_rates ) / 100 ); |
|
48 | + $tax_rate = 1 + (array_sum($tax_rates) / 100); |
|
49 | 49 | |
50 | - foreach ( $tax_rates as $name => $rate ) { |
|
51 | - $the_rate = ( $rate / 100 ) / $tax_rate; |
|
52 | - $net_price = $price - ( $the_rate * $price ); |
|
53 | - $tax_amount = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price ); |
|
54 | - $taxes[ $name ] = $tax_amount; |
|
50 | + foreach ($tax_rates as $name => $rate) { |
|
51 | + $the_rate = ($rate / 100) / $tax_rate; |
|
52 | + $net_price = $price - ($the_rate * $price); |
|
53 | + $tax_amount = apply_filters('getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price); |
|
54 | + $taxes[$name] = $tax_amount; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // Round all taxes to precision (4DP) before passing them back. |
58 | - $taxes = array_map( array( __CLASS__, 'round' ), $taxes ); |
|
58 | + $taxes = array_map(array(__CLASS__, 'round'), $taxes); |
|
59 | 59 | |
60 | 60 | return $taxes; |
61 | 61 | } |
@@ -67,19 +67,19 @@ discard block |
||
67 | 67 | * @param array $rates Array of tax rates. |
68 | 68 | * @return array |
69 | 69 | */ |
70 | - public static function calc_exclusive_tax( $price, $rates ) { |
|
70 | + public static function calc_exclusive_tax($price, $rates) { |
|
71 | 71 | $taxes = array(); |
72 | - $tax_rates = wp_list_pluck( $rates, 'rate', 'name' ); |
|
72 | + $tax_rates = wp_list_pluck($rates, 'rate', 'name'); |
|
73 | 73 | |
74 | - foreach ( $tax_rates as $name => $rate ) { |
|
74 | + foreach ($tax_rates as $name => $rate) { |
|
75 | 75 | |
76 | - $tax_amount = $price * ( $rate / 100 ); |
|
77 | - $taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price ); |
|
76 | + $tax_amount = $price * ($rate / 100); |
|
77 | + $taxes[$name] = apply_filters('getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | 81 | // Round all taxes to precision (4DP) before passing them back. |
82 | - $taxes = array_map( array( __CLASS__, 'round' ), $taxes ); |
|
82 | + $taxes = array_map(array(__CLASS__, 'round'), $taxes); |
|
83 | 83 | |
84 | 84 | return $taxes; |
85 | 85 | } |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function get_all_tax_rates() { |
93 | 93 | |
94 | - $rates = get_option( 'wpinv_tax_rates', array() ); |
|
94 | + $rates = get_option('wpinv_tax_rates', array()); |
|
95 | 95 | |
96 | 96 | return apply_filters( |
97 | 97 | 'getpaid_get_all_tax_rates', |
98 | - array_filter( wpinv_parse_list( $rates ) ) |
|
98 | + array_filter(wpinv_parse_list($rates)) |
|
99 | 99 | ); |
100 | 100 | |
101 | 101 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | 'state' => wpinv_get_default_state(), |
116 | 116 | 'global' => true, |
117 | 117 | 'rate' => wpinv_get_default_tax_rate(), |
118 | - 'name' => __( 'Base Tax', 'invoicing' ), |
|
118 | + 'name' => __('Base Tax', 'invoicing'), |
|
119 | 119 | ) |
120 | 120 | ) |
121 | 121 | ); |
@@ -129,24 +129,24 @@ discard block |
||
129 | 129 | * @param string $state |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - public static function get_address_tax_rates( $country, $state ) { |
|
132 | + public static function get_address_tax_rates($country, $state) { |
|
133 | 133 | |
134 | 134 | $all_tax_rates = self::get_all_tax_rates(); |
135 | 135 | $matching_rates = array_merge( |
136 | - wp_list_filter( $all_tax_rates, array( 'country' => $country ) ), |
|
137 | - wp_list_filter( $all_tax_rates, array( 'country' => '' ) ) |
|
136 | + wp_list_filter($all_tax_rates, array('country' => $country)), |
|
137 | + wp_list_filter($all_tax_rates, array('country' => '')) |
|
138 | 138 | ); |
139 | 139 | |
140 | - foreach ( $matching_rates as $i => $rate ) { |
|
140 | + foreach ($matching_rates as $i => $rate) { |
|
141 | 141 | |
142 | - $states = array_filter( wpinv_clean( explode( ',', strtolower( $rate['state'] ) ) ) ); |
|
143 | - if ( empty( $rate['global'] ) && ! in_array( strtolower( $state ), $states ) ) { |
|
144 | - unset( $matching_rates[ $i ] ); |
|
142 | + $states = array_filter(wpinv_clean(explode(',', strtolower($rate['state'])))); |
|
143 | + if (empty($rate['global']) && !in_array(strtolower($state), $states)) { |
|
144 | + unset($matching_rates[$i]); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | } |
148 | 148 | |
149 | - return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state ); |
|
149 | + return apply_filters('getpaid_get_address_tax_rates', $matching_rates, $country, $state); |
|
150 | 150 | |
151 | 151 | } |
152 | 152 | |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * @param array $taxes Array of taxes. |
157 | 157 | * @return float |
158 | 158 | */ |
159 | - public static function get_tax_total( $taxes ) { |
|
160 | - return self::round( array_sum( $taxes ) ); |
|
159 | + public static function get_tax_total($taxes) { |
|
160 | + return self::round(array_sum($taxes)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @param float|int $in Value to round. |
174 | 174 | * @return float |
175 | 175 | */ |
176 | - public static function round( $in ) { |
|
177 | - return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in ); |
|
176 | + public static function round($in) { |
|
177 | + return apply_filters('getpaid_tax_round', round($in, 4), $in); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @deprecated |
@@ -19,48 +19,48 @@ discard block |
||
19 | 19 | * @deprecated |
20 | 20 | */ |
21 | 21 | function wpinv_get_invoice_cart() { |
22 | - return wpinv_get_invoice( getpaid_get_current_invoice_id() ); |
|
22 | + return wpinv_get_invoice(getpaid_get_current_invoice_id()); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @deprecated |
27 | 27 | */ |
28 | -function wpinv_get_invoice_description( $invoice ) { |
|
29 | - $invoice = new WPInv_Invoice( $invoice ); |
|
28 | +function wpinv_get_invoice_description($invoice) { |
|
29 | + $invoice = new WPInv_Invoice($invoice); |
|
30 | 30 | return $invoice->get_description(); |
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @deprecated |
35 | 35 | */ |
36 | -function wpinv_get_invoice_currency_code( $invoice ) { |
|
37 | - $invoice = new WPInv_Invoice( $invoice ); |
|
36 | +function wpinv_get_invoice_currency_code($invoice) { |
|
37 | + $invoice = new WPInv_Invoice($invoice); |
|
38 | 38 | return $invoice->get_currency(); |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @deprecated |
43 | 43 | */ |
44 | -function wpinv_get_payment_user_email( $invoice ) { |
|
45 | - $invoice = new WPInv_Invoice( $invoice ); |
|
44 | +function wpinv_get_payment_user_email($invoice) { |
|
45 | + $invoice = new WPInv_Invoice($invoice); |
|
46 | 46 | return $invoice->get_email(); |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @deprecated |
51 | 51 | */ |
52 | -function wpinv_get_user_id( $invoice ) { |
|
53 | - $invoice = new WPInv_Invoice( $invoice ); |
|
52 | +function wpinv_get_user_id($invoice) { |
|
53 | + $invoice = new WPInv_Invoice($invoice); |
|
54 | 54 | return $invoice->get_user_id(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @deprecated |
59 | 59 | */ |
60 | -function wpinv_get_invoice_status( $invoice, $return_label = false ) { |
|
61 | - $invoice = new WPInv_Invoice( $invoice ); |
|
60 | +function wpinv_get_invoice_status($invoice, $return_label = false) { |
|
61 | + $invoice = new WPInv_Invoice($invoice); |
|
62 | 62 | |
63 | - if ( $return_label ) { |
|
63 | + if ($return_label) { |
|
64 | 64 | return $invoice->get_status_nicename(); |
65 | 65 | } |
66 | 66 | |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * @deprecated |
72 | 72 | */ |
73 | -function wpinv_get_payment_gateway( $invoice, $return_label = false ) { |
|
74 | - $invoice = new WPInv_Invoice( $invoice ); |
|
73 | +function wpinv_get_payment_gateway($invoice, $return_label = false) { |
|
74 | + $invoice = new WPInv_Invoice($invoice); |
|
75 | 75 | |
76 | - if ( $return_label ) { |
|
76 | + if ($return_label) { |
|
77 | 77 | return $invoice->get_gateway_title(); |
78 | 78 | } |
79 | 79 | |
@@ -83,75 +83,75 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @deprecated |
85 | 85 | */ |
86 | -function wpinv_get_payment_gateway_name( $invoice ) { |
|
87 | - return wpinv_get_payment_gateway( $invoice, true ); |
|
86 | +function wpinv_get_payment_gateway_name($invoice) { |
|
87 | + return wpinv_get_payment_gateway($invoice, true); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @deprecated |
92 | 92 | */ |
93 | -function wpinv_get_payment_transaction_id( $invoice ) { |
|
94 | - $invoice = new WPInv_Invoice( $invoice ); |
|
93 | +function wpinv_get_payment_transaction_id($invoice) { |
|
94 | + $invoice = new WPInv_Invoice($invoice); |
|
95 | 95 | return $invoice->get_transaction_id(); |
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * @deprecated |
100 | 100 | */ |
101 | -function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
102 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
103 | - return $invoice->get_meta( $meta_key, $single ); |
|
101 | +function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) { |
|
102 | + $invoice = new WPInv_Invoice($invoice_id); |
|
103 | + return $invoice->get_meta($meta_key, $single); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @deprecated |
108 | 108 | */ |
109 | -function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '' ) { |
|
110 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
111 | - return $invoice->update_meta_data( $meta_key, $meta_value ); |
|
109 | +function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '') { |
|
110 | + $invoice = new WPInv_Invoice($invoice_id); |
|
111 | + return $invoice->update_meta_data($meta_key, $meta_value); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @deprecated |
116 | 116 | */ |
117 | -function wpinv_get_items( $invoice = 0 ) { |
|
118 | - $invoice = new WPInv_Invoice( $invoice ); |
|
117 | +function wpinv_get_items($invoice = 0) { |
|
118 | + $invoice = new WPInv_Invoice($invoice); |
|
119 | 119 | return $invoice->get_items(); |
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * @deprecated |
124 | 124 | */ |
125 | -function wpinv_get_fees( $invoice = 0 ) { |
|
126 | - $invoice = new WPInv_Invoice( $invoice ); |
|
125 | +function wpinv_get_fees($invoice = 0) { |
|
126 | + $invoice = new WPInv_Invoice($invoice); |
|
127 | 127 | return $invoice->get_fees(); |
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | 131 | * @deprecated |
132 | 132 | */ |
133 | -function wpinv_get_invoice_ip( $invoice ) { |
|
134 | - $invoice = new WPInv_Invoice( $invoice ); |
|
133 | +function wpinv_get_invoice_ip($invoice) { |
|
134 | + $invoice = new WPInv_Invoice($invoice); |
|
135 | 135 | return $invoice->get_ip(); |
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | 139 | * @deprecated |
140 | 140 | */ |
141 | -function wpinv_get_invoice_user_info( $invoice ) { |
|
142 | - $invoice = new WPInv_Invoice( $invoice ); |
|
141 | +function wpinv_get_invoice_user_info($invoice) { |
|
142 | + $invoice = new WPInv_Invoice($invoice); |
|
143 | 143 | return $invoice->get_user_info(); |
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | 147 | * @deprecated |
148 | 148 | */ |
149 | -function wpinv_subtotal( $invoice = 0, $currency = false ) { |
|
150 | - $invoice = new WPInv_Invoice( $invoice ); |
|
149 | +function wpinv_subtotal($invoice = 0, $currency = false) { |
|
150 | + $invoice = new WPInv_Invoice($invoice); |
|
151 | 151 | $subtotal = $invoice->get_subtotal(); |
152 | 152 | |
153 | - if ( $currency ) { |
|
154 | - return wpinv_price( $subtotal, $invoice->get_currency() ); |
|
153 | + if ($currency) { |
|
154 | + return wpinv_price($subtotal, $invoice->get_currency()); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $subtotal; |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | /** |
161 | 161 | * @deprecated |
162 | 162 | */ |
163 | -function wpinv_tax( $invoice = 0, $currency = false ) { |
|
164 | - $invoice = new WPInv_Invoice( $invoice ); |
|
163 | +function wpinv_tax($invoice = 0, $currency = false) { |
|
164 | + $invoice = new WPInv_Invoice($invoice); |
|
165 | 165 | $tax = $invoice->get_total_tax(); |
166 | 166 | |
167 | - if ( $currency ) { |
|
168 | - return wpinv_price( $tax, $invoice->get_currency() ); |
|
167 | + if ($currency) { |
|
168 | + return wpinv_price($tax, $invoice->get_currency()); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | return $tax; |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * @deprecated |
176 | 176 | */ |
177 | -function wpinv_discount( $invoice = 0, $currency = false, $deprecated ) { |
|
178 | - $invoice = new WPInv_Invoice( $invoice ); |
|
177 | +function wpinv_discount($invoice = 0, $currency = false, $deprecated) { |
|
178 | + $invoice = new WPInv_Invoice($invoice); |
|
179 | 179 | $discount = $invoice->get_total_discount(); |
180 | 180 | |
181 | - if ( $currency ) { |
|
182 | - return wpinv_price( $discount, $invoice->get_currency() ); |
|
181 | + if ($currency) { |
|
182 | + return wpinv_price($discount, $invoice->get_currency()); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | return $discount; |
@@ -188,20 +188,20 @@ discard block |
||
188 | 188 | /** |
189 | 189 | * @deprecated |
190 | 190 | */ |
191 | -function wpinv_discount_code( $invoice = 0 ) { |
|
192 | - $invoice = new WPInv_Invoice( $invoice ); |
|
191 | +function wpinv_discount_code($invoice = 0) { |
|
192 | + $invoice = new WPInv_Invoice($invoice); |
|
193 | 193 | return $invoice->get_discount_code(); |
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
197 | 197 | * @deprecated |
198 | 198 | */ |
199 | -function wpinv_payment_total( $invoice = 0, $currency = false ) { |
|
200 | - $invoice = new WPInv_Invoice( $invoice ); |
|
199 | +function wpinv_payment_total($invoice = 0, $currency = false) { |
|
200 | + $invoice = new WPInv_Invoice($invoice); |
|
201 | 201 | $total = $invoice->get_total(); |
202 | 202 | |
203 | - if ( $currency ) { |
|
204 | - return wpinv_price( $total, $invoice->get_currency() ); |
|
203 | + if ($currency) { |
|
204 | + return wpinv_price($total, $invoice->get_currency()); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | return $total; |
@@ -210,51 +210,51 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * @deprecated |
212 | 212 | */ |
213 | -function wpinv_get_date_created( $invoice = 0, $format = '' ) { |
|
214 | - $invoice = new WPInv_Invoice( $invoice ); |
|
213 | +function wpinv_get_date_created($invoice = 0, $format = '') { |
|
214 | + $invoice = new WPInv_Invoice($invoice); |
|
215 | 215 | |
216 | - $format = ! empty( $format ) ? $format : get_option( 'date_format' ); |
|
216 | + $format = !empty($format) ? $format : get_option('date_format'); |
|
217 | 217 | $date_created = $invoice->get_created_date(); |
218 | 218 | |
219 | - return empty( $date_created ) ? date_i18n( $format, strtotime( $date_created ) ) : ''; |
|
219 | + return empty($date_created) ? date_i18n($format, strtotime($date_created)) : ''; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | 223 | * @deprecated |
224 | 224 | */ |
225 | -function wpinv_get_invoice_date( $invoice = 0, $format = '' ) { |
|
226 | - wpinv_get_date_created( $invoice, $format ); |
|
225 | +function wpinv_get_invoice_date($invoice = 0, $format = '') { |
|
226 | + wpinv_get_date_created($invoice, $format); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
230 | 230 | * @deprecated |
231 | 231 | */ |
232 | -function wpinv_get_invoice_vat_number( $invoice = 0 ) { |
|
233 | - $invoice = new WPInv_Invoice( $invoice ); |
|
232 | +function wpinv_get_invoice_vat_number($invoice = 0) { |
|
233 | + $invoice = new WPInv_Invoice($invoice); |
|
234 | 234 | return $invoice->get_vat_number(); |
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
238 | 238 | * @deprecated |
239 | 239 | */ |
240 | -function wpinv_insert_payment_note( $invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false ) { |
|
241 | - $invoice = new WPInv_Invoice( $invoice ); |
|
242 | - return $invoice->add_note( $note, $user_type, $added_by_user, $system ); |
|
240 | +function wpinv_insert_payment_note($invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false) { |
|
241 | + $invoice = new WPInv_Invoice($invoice); |
|
242 | + return $invoice->add_note($note, $user_type, $added_by_user, $system); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | 246 | * @deprecated |
247 | 247 | */ |
248 | -function wpinv_get_payment_key( $invoice = 0 ) { |
|
249 | - $invoice = new WPInv_Invoice( $invoice ); |
|
248 | +function wpinv_get_payment_key($invoice = 0) { |
|
249 | + $invoice = new WPInv_Invoice($invoice); |
|
250 | 250 | return $invoice->get_key(); |
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
254 | 254 | * @deprecated |
255 | 255 | */ |
256 | -function wpinv_get_invoice_number( $invoice = 0 ) { |
|
257 | - $invoice = new WPInv_Invoice( $invoice ); |
|
256 | +function wpinv_get_invoice_number($invoice = 0) { |
|
257 | + $invoice = new WPInv_Invoice($invoice); |
|
258 | 258 | return $invoice->get_number(); |
259 | 259 | } |
260 | 260 | |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | /** |
402 | 402 | * @deprecated |
403 | 403 | */ |
404 | -function wpinv_update_payment_status( $invoice, $new_status = 'publish' ) { |
|
405 | - $invoice = new WPInv_Invoice( $invoice ); |
|
406 | - return $invoice->update_status( $new_status ); |
|
404 | +function wpinv_update_payment_status($invoice, $new_status = 'publish') { |
|
405 | + $invoice = new WPInv_Invoice($invoice); |
|
406 | + return $invoice->update_status($new_status); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -456,22 +456,22 @@ discard block |
||
456 | 456 | /** |
457 | 457 | * @deprecated |
458 | 458 | */ |
459 | -function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) { |
|
459 | +function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') { |
|
460 | 460 | |
461 | 461 | // Fetch the invoice. |
462 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
462 | + $invoice = new WPInv_Invoice($invoice_id); |
|
463 | 463 | |
464 | - if ( 0 == $invoice->get_id() ) { |
|
464 | + if (0 == $invoice->get_id()) { |
|
465 | 465 | return false; |
466 | 466 | } |
467 | 467 | |
468 | 468 | // Prepare the transaction id. |
469 | - if ( empty( $transaction_id ) ) { |
|
469 | + if (empty($transaction_id)) { |
|
470 | 470 | $transaction_id = $invoice_id; |
471 | 471 | } |
472 | 472 | |
473 | 473 | // Set the transaction id; |
474 | - $invoice->set_transaction_id( apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice ) ); |
|
474 | + $invoice->set_transaction_id(apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice)); |
|
475 | 475 | |
476 | 476 | // Save the invoice. |
477 | 477 | return $invoice->save(); |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | * @param WPInv_Invoice $invoice |
485 | 485 | * @param string $gateway |
486 | 486 | */ |
487 | -function wpinv_send_to_gateway( $gateway, $invoice ) { |
|
487 | +function wpinv_send_to_gateway($gateway, $invoice) { |
|
488 | 488 | |
489 | 489 | $payment_data = array( |
490 | 490 | 'invoice_id' => $invoice->get_id(), |
491 | 491 | 'items' => $invoice->get_cart_details(), |
492 | - 'cart_discounts' => array( $invoice->get_discount_code() ), |
|
492 | + 'cart_discounts' => array($invoice->get_discount_code()), |
|
493 | 493 | 'fees' => $invoice->get_total_fees(), |
494 | 494 | 'subtotal' => $invoice->get_subtotal(), |
495 | 495 | 'discount' => $invoice->get_total_discount(), |
@@ -497,16 +497,16 @@ discard block |
||
497 | 497 | 'price' => $invoice->get_total(), |
498 | 498 | 'invoice_key' => $invoice->get_key(), |
499 | 499 | 'user_email' => $invoice->get_email(), |
500 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
500 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
501 | 501 | 'user_info' => $invoice->get_user_info(), |
502 | - 'post_data' => stripslashes_deep( $_POST ), |
|
502 | + 'post_data' => stripslashes_deep($_POST), |
|
503 | 503 | 'cart_details' => $invoice->get_cart_details(), |
504 | 504 | 'gateway' => $gateway, |
505 | 505 | 'card_info' => array(), |
506 | 506 | 'gateway_nonce' => wp_create_nonce('wpi-gateway'), |
507 | 507 | ); |
508 | 508 | |
509 | - do_action( 'wpinv_gateway_' . $gateway, $payment_data ); |
|
509 | + do_action('wpinv_gateway_' . $gateway, $payment_data); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | /** |
520 | 520 | * @deprecated |
521 | 521 | */ |
522 | -function wpinv_die( $message = '', $title = '', $status = 400 ) { |
|
523 | - add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 ); |
|
524 | - add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 ); |
|
525 | - wp_die( $message, $title, array( 'response' => $status )); |
|
522 | +function wpinv_die($message = '', $title = '', $status = 400) { |
|
523 | + add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3); |
|
524 | + add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3); |
|
525 | + wp_die($message, $title, array('response' => $status)); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -640,14 +640,14 @@ discard block |
||
640 | 640 | /** |
641 | 641 | * @deprecated |
642 | 642 | */ |
643 | -function wpinv_invoice_status_label( $status, $status_display = '' ) { |
|
644 | - return empty( $status_display ) ? sanitize_text_field( $status ) : sanitize_text_field( $status_display ); |
|
643 | +function wpinv_invoice_status_label($status, $status_display = '') { |
|
644 | + return empty($status_display) ? sanitize_text_field($status) : sanitize_text_field($status_display); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
648 | 648 | * @deprecated |
649 | 649 | */ |
650 | -function wpinv_clean_invoice_number( $number ) { |
|
650 | +function wpinv_clean_invoice_number($number) { |
|
651 | 651 | return $number; |
652 | 652 | } |
653 | 653 | |
@@ -852,12 +852,12 @@ discard block |
||
852 | 852 | /** |
853 | 853 | * @deprecated |
854 | 854 | */ |
855 | -function wpinv_item_show_price( $item_id = 0, $echo = true ) { |
|
855 | +function wpinv_item_show_price($item_id = 0, $echo = true) { |
|
856 | 856 | |
857 | - if ( $echo ) { |
|
858 | - echo wpinv_item_price( $item_id ); |
|
857 | + if ($echo) { |
|
858 | + echo wpinv_item_price($item_id); |
|
859 | 859 | } else { |
860 | - return wpinv_item_price( $item_id ); |
|
860 | + return wpinv_item_price($item_id); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | } |
@@ -1272,6 +1272,6 @@ discard block |
||
1272 | 1272 | * @return WPInv_Subscription|bool |
1273 | 1273 | * @deprecated |
1274 | 1274 | */ |
1275 | -function wpinv_get_subscription( $invoice ) { |
|
1276 | - return wpinv_get_invoice_subscription( $invoice ); |
|
1275 | +function wpinv_get_subscription($invoice) { |
|
1276 | + return wpinv_get_invoice_subscription($invoice); |
|
1277 | 1277 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * GetPaid_Subscription_Data_Store class file. |
5 | 5 | * |
6 | 6 | */ |
7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
7 | +if (!defined('ABSPATH')) { |
|
8 | 8 | exit; |
9 | 9 | } |
10 | 10 | |
@@ -50,29 +50,29 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @param WPInv_Subscription $subscription Subscription object. |
52 | 52 | */ |
53 | - public function create( &$subscription ) { |
|
53 | + public function create(&$subscription) { |
|
54 | 54 | global $wpdb; |
55 | 55 | |
56 | 56 | $values = array(); |
57 | 57 | $formats = array(); |
58 | 58 | |
59 | 59 | $fields = $this->database_fields_to_data_type; |
60 | - unset( $fields['id'] ); |
|
60 | + unset($fields['id']); |
|
61 | 61 | |
62 | - foreach ( $fields as $key => $format ) { |
|
62 | + foreach ($fields as $key => $format) { |
|
63 | 63 | $method = "get_$key"; |
64 | - $values[$key] = $subscription->$method( 'edit' ); |
|
64 | + $values[$key] = $subscription->$method('edit'); |
|
65 | 65 | $formats[] = $format; |
66 | 66 | } |
67 | 67 | |
68 | - $result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $values, $formats ); |
|
68 | + $result = $wpdb->insert($wpdb->prefix . 'wpinv_subscriptions', $values, $formats); |
|
69 | 69 | |
70 | - if ( $result ) { |
|
71 | - $subscription->set_id( $wpdb->insert_id ); |
|
70 | + if ($result) { |
|
71 | + $subscription->set_id($wpdb->insert_id); |
|
72 | 72 | $subscription->apply_changes(); |
73 | 73 | $subscription->clear_cache(); |
74 | - update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() ); |
|
75 | - do_action( 'getpaid_new_subscription', $subscription ); |
|
74 | + update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id()); |
|
75 | + do_action('getpaid_new_subscription', $subscription); |
|
76 | 76 | return true; |
77 | 77 | } |
78 | 78 | |
@@ -85,22 +85,22 @@ discard block |
||
85 | 85 | * @param WPInv_Subscription $subscription Subscription object. |
86 | 86 | * |
87 | 87 | */ |
88 | - public function read( &$subscription ) { |
|
88 | + public function read(&$subscription) { |
|
89 | 89 | global $wpdb; |
90 | 90 | |
91 | 91 | $subscription->set_defaults(); |
92 | 92 | |
93 | - if ( ! $subscription->get_id() ) { |
|
94 | - $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' ); |
|
95 | - $subscription->set_id( 0 ); |
|
93 | + if (!$subscription->get_id()) { |
|
94 | + $subscription->last_error = __('Invalid subscription ID.', 'invoicing'); |
|
95 | + $subscription->set_id(0); |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | 99 | // Maybe retrieve from the cache. |
100 | - $raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' ); |
|
100 | + $raw_subscription = wp_cache_get($subscription->get_id(), 'getpaid_subscriptions'); |
|
101 | 101 | |
102 | 102 | // If not found, retrieve from the db. |
103 | - if ( false === $raw_subscription ) { |
|
103 | + if (false === $raw_subscription) { |
|
104 | 104 | |
105 | 105 | $raw_subscription = $wpdb->get_row( |
106 | 106 | $wpdb->prepare( |
@@ -110,23 +110,23 @@ discard block |
||
110 | 110 | ); |
111 | 111 | |
112 | 112 | // Update the cache with our data |
113 | - wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' ); |
|
113 | + wp_cache_set($subscription->get_id(), $raw_subscription, 'getpaid_subscriptions'); |
|
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | - if ( ! $raw_subscription ) { |
|
118 | - $subscription->set_id( 0 ); |
|
119 | - $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' ); |
|
117 | + if (!$raw_subscription) { |
|
118 | + $subscription->set_id(0); |
|
119 | + $subscription->last_error = __('Invalid subscription ID.', 'invoicing'); |
|
120 | 120 | return false; |
121 | 121 | } |
122 | 122 | |
123 | - foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) { |
|
124 | - $method = "set_$key"; |
|
125 | - $subscription->$method( $raw_subscription->$key ); |
|
123 | + foreach (array_keys($this->database_fields_to_data_type) as $key) { |
|
124 | + $method = "set_$key"; |
|
125 | + $subscription->$method($raw_subscription->$key); |
|
126 | 126 | } |
127 | 127 | |
128 | - $subscription->set_object_read( true ); |
|
129 | - do_action( 'getpaid_read_subscription', $subscription ); |
|
128 | + $subscription->set_object_read(true); |
|
129 | + do_action('getpaid_read_subscription', $subscription); |
|
130 | 130 | |
131 | 131 | } |
132 | 132 | |
@@ -135,22 +135,22 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param WPInv_Subscription $subscription Subscription object. |
137 | 137 | */ |
138 | - public function update( &$subscription ) { |
|
138 | + public function update(&$subscription) { |
|
139 | 139 | global $wpdb; |
140 | 140 | |
141 | 141 | $changes = $subscription->get_changes(); |
142 | 142 | $values = array(); |
143 | 143 | $formats = array(); |
144 | 144 | |
145 | - foreach ( $this->database_fields_to_data_type as $key => $format ) { |
|
146 | - if ( array_key_exists( $key, $changes ) ) { |
|
145 | + foreach ($this->database_fields_to_data_type as $key => $format) { |
|
146 | + if (array_key_exists($key, $changes)) { |
|
147 | 147 | $method = "get_$key"; |
148 | - $values[$key] = $subscription->$method( 'edit' ); |
|
148 | + $values[$key] = $subscription->$method('edit'); |
|
149 | 149 | $formats[] = $format; |
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | - if ( empty( $values ) ) { |
|
153 | + if (empty($values)) { |
|
154 | 154 | return; |
155 | 155 | } |
156 | 156 | |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | // Delete cache. |
171 | 171 | $subscription->clear_cache(); |
172 | 172 | |
173 | - update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id() ); |
|
174 | - update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() ); |
|
173 | + update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id()); |
|
174 | + update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id()); |
|
175 | 175 | |
176 | 176 | // Fire a hook. |
177 | - do_action( 'getpaid_update_subscription', $subscription ); |
|
177 | + do_action('getpaid_update_subscription', $subscription); |
|
178 | 178 | |
179 | 179 | } |
180 | 180 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param WPInv_Subscription $subscription |
185 | 185 | */ |
186 | - public function delete( &$subscription ) { |
|
186 | + public function delete(&$subscription) { |
|
187 | 187 | global $wpdb; |
188 | 188 | |
189 | 189 | $wpdb->query( |
@@ -194,16 +194,16 @@ discard block |
||
194 | 194 | ) |
195 | 195 | ); |
196 | 196 | |
197 | - delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id' ); |
|
198 | - delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id' ); |
|
197 | + delete_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id'); |
|
198 | + delete_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id'); |
|
199 | 199 | |
200 | 200 | // Delete cache. |
201 | 201 | $subscription->clear_cache(); |
202 | 202 | |
203 | 203 | // Fire a hook. |
204 | - do_action( 'getpaid_delete_subscription', $subscription ); |
|
204 | + do_action('getpaid_delete_subscription', $subscription); |
|
205 | 205 | |
206 | - $subscription->set_id( 0 ); |
|
206 | + $subscription->set_id(0); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /* |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if (!defined('ABSPATH')) { |
|
9 | 9 | exit; // Exit if accessed directly |
10 | 10 | } |
11 | 11 | |
@@ -19,16 +19,16 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @param WP_Post $post |
21 | 21 | */ |
22 | - public static function output( $post ) { |
|
22 | + public static function output($post) { |
|
23 | 23 | |
24 | 24 | // Fetch the invoice. |
25 | - $invoice = new WPInv_Invoice( $post ); |
|
25 | + $invoice = new WPInv_Invoice($post); |
|
26 | 26 | |
27 | 27 | // Fetch the subscription. |
28 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
28 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
29 | 29 | |
30 | 30 | echo '<div class="bsui">'; |
31 | - getpaid_admin_subscription_details_metabox( /** @scrutinizer ignore-type */$subscription ); |
|
31 | + getpaid_admin_subscription_details_metabox(/** @scrutinizer ignore-type */$subscription); |
|
32 | 32 | echo '</div>'; |
33 | 33 | |
34 | 34 | } |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param WP_Post $post |
40 | 40 | */ |
41 | - public static function output_invoices( $post ) { |
|
41 | + public static function output_invoices($post) { |
|
42 | 42 | |
43 | 43 | // Fetch the invoice. |
44 | - $invoice = new WPInv_Invoice( $post ); |
|
44 | + $invoice = new WPInv_Invoice($post); |
|
45 | 45 | |
46 | 46 | // Fetch the subscription. |
47 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
47 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
48 | 48 | |
49 | 49 | echo '<div class="bsui">'; |
50 | - getpaid_admin_subscription_invoice_details_metabox( /** @scrutinizer ignore-type */$subscription, false ); |
|
50 | + getpaid_admin_subscription_invoice_details_metabox(/** @scrutinizer ignore-type */$subscription, false); |
|
51 | 51 | echo '</div>'; |
52 | 52 | |
53 | 53 | } |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @param WP_Post $post |
59 | 59 | */ |
60 | - public static function output_related( $post ) { |
|
60 | + public static function output_related($post) { |
|
61 | 61 | |
62 | 62 | // Fetch the invoice. |
63 | - $invoice = new WPInv_Invoice( $post ); |
|
63 | + $invoice = new WPInv_Invoice($post); |
|
64 | 64 | |
65 | 65 | // Fetch the subscription. |
66 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
66 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
67 | 67 | |
68 | 68 | echo '<div class="bsui">'; |
69 | - getpaid_admin_subscription_related_subscriptions_metabox( /** @scrutinizer ignore-type */$subscription, false ); |
|
69 | + getpaid_admin_subscription_related_subscriptions_metabox(/** @scrutinizer ignore-type */$subscription, false); |
|
70 | 70 | echo '</div>'; |
71 | 71 | |
72 | 72 | } |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | * Displays a list of all subscriptions rules |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
6 | +if (!defined('ABSPATH')) exit; |
|
7 | 7 | |
8 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
8 | +if (!class_exists('WP_List_Table')) { |
|
9 | 9 | include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
10 | 10 | } |
11 | 11 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $this->prepare_query(); |
80 | 80 | |
81 | - $this->base_url = remove_query_arg( 'status' ); |
|
81 | + $this->base_url = remove_query_arg('status'); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | |
@@ -91,21 +91,21 @@ discard block |
||
91 | 91 | $query = array( |
92 | 92 | 'number' => $this->per_page, |
93 | 93 | 'paged' => $this->get_paged(), |
94 | - 'status' => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? $_GET['status'] : 'all', |
|
95 | - 'orderby' => ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id', |
|
96 | - 'order' => ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC', |
|
94 | + 'status' => (isset($_GET['status']) && array_key_exists($_GET['status'], getpaid_get_subscription_statuses())) ? $_GET['status'] : 'all', |
|
95 | + 'orderby' => (isset($_GET['orderby'])) ? $_GET['orderby'] : 'id', |
|
96 | + 'order' => (isset($_GET['order'])) ? $_GET['order'] : 'DESC', |
|
97 | 97 | ); |
98 | 98 | |
99 | 99 | // Prepare class properties. |
100 | - $this->query = new GetPaid_Subscriptions_Query( $query ); |
|
100 | + $this->query = new GetPaid_Subscriptions_Query($query); |
|
101 | 101 | $this->total_count = $this->query->get_total(); |
102 | 102 | $this->current_total_count = $this->query->get_total(); |
103 | 103 | $this->items = $this->query->get_results(); |
104 | - $this->status_counts = getpaid_get_subscription_status_counts( $query ); |
|
104 | + $this->status_counts = getpaid_get_subscription_status_counts($query); |
|
105 | 105 | |
106 | - if ( 'all' != $query['status'] ) { |
|
107 | - unset( $query['status'] ); |
|
108 | - $this->total_count = getpaid_get_subscriptions( $query, 'count' ); |
|
106 | + if ('all' != $query['status']) { |
|
107 | + unset($query['status']); |
|
108 | + $this->total_count = getpaid_get_subscriptions($query, 'count'); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | } |
@@ -122,26 +122,26 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function get_views() { |
124 | 124 | |
125 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : 'all'; |
|
125 | + $current = isset($_GET['status']) ? $_GET['status'] : 'all'; |
|
126 | 126 | $views = array( |
127 | 127 | |
128 | 128 | 'all' => sprintf( |
129 | 129 | '<a href="%s" %s>%s <span class="count">(%d)</span></a>', |
130 | - esc_url( add_query_arg( 'status', false, $this->base_url ) ), |
|
130 | + esc_url(add_query_arg('status', false, $this->base_url)), |
|
131 | 131 | $current === 'all' ? ' class="current"' : '', |
132 | - __('All','invoicing' ), |
|
132 | + __('All', 'invoicing'), |
|
133 | 133 | $this->total_count |
134 | 134 | ) |
135 | 135 | |
136 | 136 | ); |
137 | 137 | |
138 | - foreach ( array_filter( $this->status_counts ) as $status => $count ) { |
|
138 | + foreach (array_filter($this->status_counts) as $status => $count) { |
|
139 | 139 | |
140 | - $views[ $status ] = sprintf( |
|
140 | + $views[$status] = sprintf( |
|
141 | 141 | '<a href="%s" %s>%s <span class="count">(%d)</span></a>', |
142 | - esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ), |
|
142 | + esc_url(add_query_arg('status', urlencode($status), $this->base_url)), |
|
143 | 143 | $current === $status ? ' class="current"' : '', |
144 | - sanitize_text_field( getpaid_get_subscription_status_label( $status ) ), |
|
144 | + sanitize_text_field(getpaid_get_subscription_status_label($status)), |
|
145 | 145 | $count |
146 | 146 | ); |
147 | 147 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @since 1.0.0 |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - public function column_default( $item, $column_name ) { |
|
162 | - return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name ); |
|
161 | + public function column_default($item, $column_name) { |
|
162 | + return apply_filters("getpaid_subscriptions_table_column_$column_name", $item->$column_name); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * @param WPInv_Subscription $item |
169 | 169 | * @return string |
170 | 170 | */ |
171 | - public function column_cb( $item ) { |
|
172 | - return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) ); |
|
171 | + public function column_cb($item) { |
|
172 | + return sprintf('<input type="checkbox" name="id[]" value="%s" />', esc_html($item->get_id())); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @since 1.0.0 |
180 | 180 | * @return string |
181 | 181 | */ |
182 | - public function column_status( $item ) { |
|
182 | + public function column_status($item) { |
|
183 | 183 | return $item->get_status_label_html(); |
184 | 184 | } |
185 | 185 | |
@@ -190,44 +190,44 @@ discard block |
||
190 | 190 | * @since 1.0.0 |
191 | 191 | * @return string |
192 | 192 | */ |
193 | - public function column_subscription( $item ) { |
|
193 | + public function column_subscription($item) { |
|
194 | 194 | |
195 | - $username = __( '(Missing User)', 'invoicing' ); |
|
195 | + $username = __('(Missing User)', 'invoicing'); |
|
196 | 196 | |
197 | - $user = get_userdata( $item->get_customer_id() ); |
|
198 | - if ( $user ) { |
|
197 | + $user = get_userdata($item->get_customer_id()); |
|
198 | + if ($user) { |
|
199 | 199 | |
200 | 200 | $username = sprintf( |
201 | 201 | '<a href="user-edit.php?user_id=%s">%s</a>', |
202 | - absint( $user->ID ), |
|
203 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
202 | + absint($user->ID), |
|
203 | + !empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email) |
|
204 | 204 | ); |
205 | 205 | |
206 | 206 | } |
207 | 207 | |
208 | 208 | // translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name |
209 | 209 | $column_content = sprintf( |
210 | - _x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ), |
|
211 | - '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">', |
|
212 | - '<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>', |
|
210 | + _x('%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing'), |
|
211 | + '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($item->get_id()))) . '">', |
|
212 | + '<strong>' . esc_attr($item->get_id()) . '</strong>', '</a>', |
|
213 | 213 | $username |
214 | 214 | ); |
215 | 215 | |
216 | 216 | $row_actions = array(); |
217 | 217 | |
218 | 218 | // View subscription. |
219 | - $view_url = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) )); |
|
220 | - $row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>'; |
|
219 | + $view_url = esc_url(add_query_arg('id', $item->get_id(), admin_url('admin.php?page=wpinv-subscriptions'))); |
|
220 | + $row_actions['view'] = '<a href="' . $view_url . '">' . __('View Subscription', 'invoicing') . '</a>'; |
|
221 | 221 | |
222 | 222 | // View invoice. |
223 | - $invoice = get_post( $item->get_parent_invoice_id() ); |
|
223 | + $invoice = get_post($item->get_parent_invoice_id()); |
|
224 | 224 | |
225 | - if ( ! empty( $invoice ) ) { |
|
226 | - $invoice_url = get_edit_post_link( $invoice ); |
|
227 | - $row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>'; |
|
225 | + if (!empty($invoice)) { |
|
226 | + $invoice_url = get_edit_post_link($invoice); |
|
227 | + $row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __('View Invoice', 'invoicing') . '</a>'; |
|
228 | 228 | } |
229 | 229 | |
230 | - $delete_url = esc_url( |
|
230 | + $delete_url = esc_url( |
|
231 | 231 | wp_nonce_url( |
232 | 232 | add_query_arg( |
233 | 233 | array( |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | 'getpaid-nonce' |
240 | 240 | ) |
241 | 241 | ); |
242 | - $row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __( 'Delete Subscription', 'invoicing' ) . '</a>'; |
|
242 | + $row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __('Delete Subscription', 'invoicing') . '</a>'; |
|
243 | 243 | |
244 | - $row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) ); |
|
244 | + $row_actions = $this->row_actions(apply_filters('getpaid_subscription_table_row_actions', $row_actions, $item)); |
|
245 | 245 | |
246 | - return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions; |
|
246 | + return "<strong>$column_content</strong>" . $this->column_amount($item) . $row_actions; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * @since 1.0.0 |
254 | 254 | * @return string |
255 | 255 | */ |
256 | - public function column_renewal_date( $item ) { |
|
257 | - return getpaid_format_date_value( $item->get_expiration() ); |
|
256 | + public function column_renewal_date($item) { |
|
257 | + return getpaid_format_date_value($item->get_expiration()); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -264,8 +264,8 @@ discard block |
||
264 | 264 | * @since 1.0.0 |
265 | 265 | * @return string |
266 | 266 | */ |
267 | - public function column_start_date( $item ) { |
|
268 | - return getpaid_format_date_value( $item->get_date_created() ); |
|
267 | + public function column_start_date($item) { |
|
268 | + return getpaid_format_date_value($item->get_date_created()); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -275,8 +275,8 @@ discard block |
||
275 | 275 | * @since 1.0.19 |
276 | 276 | * @return string |
277 | 277 | */ |
278 | - public static function column_amount( $item ) { |
|
279 | - $amount = getpaid_get_formatted_subscription_amount( $item ); |
|
278 | + public static function column_amount($item) { |
|
279 | + $amount = getpaid_get_formatted_subscription_amount($item); |
|
280 | 280 | return "<span class='text-muted form-text mt-2 mb-2'>$amount</span>"; |
281 | 281 | } |
282 | 282 | |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | * @since 1.0.0 |
288 | 288 | * @return string |
289 | 289 | */ |
290 | - public function column_renewals( $item ) { |
|
290 | + public function column_renewals($item) { |
|
291 | 291 | $max_bills = $item->get_bill_times(); |
292 | - return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
292 | + return $item->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | * @since 1.0.0 |
300 | 300 | * @return string |
301 | 301 | */ |
302 | - public function column_item( $item ) { |
|
303 | - $subscription_group = getpaid_get_invoice_subscription_group( $item->get_parent_invoice_id(), $item->get_id() ); |
|
302 | + public function column_item($item) { |
|
303 | + $subscription_group = getpaid_get_invoice_subscription_group($item->get_parent_invoice_id(), $item->get_id()); |
|
304 | 304 | |
305 | - if ( empty( $subscription_group ) ) { |
|
306 | - return $this->generate_item_markup( $item->get_product_id() ); |
|
305 | + if (empty($subscription_group)) { |
|
306 | + return $this->generate_item_markup($item->get_product_id()); |
|
307 | 307 | } |
308 | 308 | |
309 | - $markup = array_map( array( $this, 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
310 | - return implode( ' | ', $markup ); |
|
309 | + $markup = array_map(array($this, 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
310 | + return implode(' | ', $markup); |
|
311 | 311 | |
312 | 312 | } |
313 | 313 | |
@@ -318,16 +318,16 @@ discard block |
||
318 | 318 | * @since 1.0.0 |
319 | 319 | * @return string |
320 | 320 | */ |
321 | - public static function generate_item_markup( $item_id ) { |
|
322 | - $item = get_post( $item_id ); |
|
321 | + public static function generate_item_markup($item_id) { |
|
322 | + $item = get_post($item_id); |
|
323 | 323 | |
324 | - if ( ! empty( $item ) ) { |
|
325 | - $link = get_edit_post_link( $item ); |
|
326 | - $link = esc_url( $link ); |
|
327 | - $name = esc_html( get_the_title( $item ) ); |
|
324 | + if (!empty($item)) { |
|
325 | + $link = get_edit_post_link($item); |
|
326 | + $link = esc_url($link); |
|
327 | + $name = esc_html(get_the_title($item)); |
|
328 | 328 | return wpinv_current_user_can_manage_invoicing() ? "<a href='$link'>$name</a>" : $name; |
329 | 329 | } else { |
330 | - return sprintf( __( 'Item #%s', 'invoicing' ), $item_id ); |
|
330 | + return sprintf(__('Item #%s', 'invoicing'), $item_id); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @return int |
339 | 339 | */ |
340 | 340 | public function get_paged() { |
341 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
341 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -351,13 +351,13 @@ discard block |
||
351 | 351 | $hidden = array(); |
352 | 352 | $sortable = $this->get_sortable_columns(); |
353 | 353 | |
354 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
354 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
355 | 355 | |
356 | 356 | $this->set_pagination_args( |
357 | 357 | array( |
358 | 358 | 'total_items' => $this->current_total_count, |
359 | 359 | 'per_page' => $this->per_page, |
360 | - 'total_pages' => ceil( $this->current_total_count / $this->per_page ) |
|
360 | + 'total_pages' => ceil($this->current_total_count / $this->per_page) |
|
361 | 361 | ) |
362 | 362 | ); |
363 | 363 | } |
@@ -367,18 +367,18 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @return array |
369 | 369 | */ |
370 | - public function get_columns(){ |
|
370 | + public function get_columns() { |
|
371 | 371 | $columns = array( |
372 | 372 | 'cb' => '<input type="checkbox" />', |
373 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
374 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
375 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
376 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
377 | - 'item' => __( 'Items', 'invoicing' ), |
|
378 | - 'status' => __( 'Status', 'invoicing' ), |
|
373 | + 'subscription' => __('Subscription', 'invoicing'), |
|
374 | + 'start_date' => __('Start Date', 'invoicing'), |
|
375 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
376 | + 'renewals' => __('Payments', 'invoicing'), |
|
377 | + 'item' => __('Items', 'invoicing'), |
|
378 | + 'status' => __('Status', 'invoicing'), |
|
379 | 379 | ); |
380 | 380 | |
381 | - return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns ); |
|
381 | + return apply_filters('manage_getpaid_subscriptions_table_columns', $columns); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -388,15 +388,15 @@ discard block |
||
388 | 388 | */ |
389 | 389 | public function get_sortable_columns() { |
390 | 390 | $sortable = array( |
391 | - 'subscription' => array( 'id', true ), |
|
392 | - 'start_date' => array( 'created', true ), |
|
393 | - 'renewal_date' => array( 'expiration', true ), |
|
394 | - 'renewals' => array( 'bill_times', true ), |
|
395 | - 'item' => array( 'product_id', true ), |
|
396 | - 'status' => array( 'status', true ), |
|
391 | + 'subscription' => array('id', true), |
|
392 | + 'start_date' => array('created', true), |
|
393 | + 'renewal_date' => array('expiration', true), |
|
394 | + 'renewals' => array('bill_times', true), |
|
395 | + 'item' => array('product_id', true), |
|
396 | + 'status' => array('status', true), |
|
397 | 397 | ); |
398 | 398 | |
399 | - return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable ); |
|
399 | + return apply_filters('manage_getpaid_subscriptions_sortable_table_columns', $sortable); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @return bool |
406 | 406 | */ |
407 | 407 | public function has_items() { |
408 | - return ! empty( $this->current_total_count ); |
|
408 | + return !empty($this->current_total_count); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @version 1.0.0 |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Contains the subscriptions widget. |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | 'block-keywords'=> "['invoicing','subscriptions', 'getpaid']", |
28 | 28 | 'class_name' => __CLASS__, |
29 | 29 | 'base_id' => 'wpinv_subscriptions', |
30 | - 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
30 | + 'name' => __('GetPaid > Subscriptions', 'invoicing'), |
|
31 | 31 | 'widget_ops' => array( |
32 | 32 | 'classname' => 'getpaid-subscriptions bsui', |
33 | - 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
33 | + 'description' => esc_html__("Displays the current user's subscriptions.", 'invoicing'), |
|
34 | 34 | ), |
35 | 35 | 'arguments' => array( |
36 | 36 | 'title' => array( |
37 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
38 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
37 | + 'title' => __('Widget title', 'invoicing'), |
|
38 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
39 | 39 | 'type' => 'text', |
40 | 40 | 'desc_tip' => true, |
41 | 41 | 'default' => '', |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | ); |
47 | 47 | |
48 | 48 | |
49 | - parent::__construct( $options ); |
|
49 | + parent::__construct($options); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | public function get_subscriptions() { |
58 | 58 | |
59 | 59 | // Prepare license args. |
60 | - $args = array( |
|
60 | + $args = array( |
|
61 | 61 | 'customer_in' => get_current_user_id(), |
62 | - 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
62 | + 'paged' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
63 | 63 | ); |
64 | 64 | |
65 | - return new GetPaid_Subscriptions_Query( $args ); |
|
65 | + return new GetPaid_Subscriptions_Query($args); |
|
66 | 66 | |
67 | 67 | } |
68 | 68 | |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return mixed|string|bool |
77 | 77 | */ |
78 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
78 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
79 | 79 | |
80 | 80 | // Ensure that the user is logged in. |
81 | - if ( ! is_user_logged_in() ) { |
|
81 | + if (!is_user_logged_in()) { |
|
82 | 82 | |
83 | 83 | return aui()->alert( |
84 | 84 | array( |
85 | - 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
85 | + 'content' => wp_kses_post(__('You need to log-in or create an account to view this section.', 'invoicing')), |
|
86 | 86 | 'type' => 'error', |
87 | 87 | ) |
88 | 88 | ); |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | // Are we displaying a single subscription? |
93 | - if ( isset( $_GET['subscription'] ) ) { |
|
94 | - return $this->display_single_subscription( trim( $_GET['subscription'] ) ); |
|
93 | + if (isset($_GET['subscription'])) { |
|
94 | + return $this->display_single_subscription(trim($_GET['subscription'])); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | // Retrieve the user's subscriptions. |
@@ -101,27 +101,27 @@ discard block |
||
101 | 101 | ob_start(); |
102 | 102 | |
103 | 103 | // Backwards compatibility. |
104 | - do_action( 'wpinv_before_user_subscriptions' ); |
|
104 | + do_action('wpinv_before_user_subscriptions'); |
|
105 | 105 | |
106 | 106 | // Display errors and notices. |
107 | 107 | wpinv_print_errors(); |
108 | 108 | |
109 | - do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
109 | + do_action('getpaid_license_manager_before_subscriptions', $subscriptions); |
|
110 | 110 | |
111 | 111 | // Print the table header. |
112 | 112 | $this->print_table_header(); |
113 | 113 | |
114 | 114 | // Print table body. |
115 | - $this->print_table_body( $subscriptions->get_results() ); |
|
115 | + $this->print_table_body($subscriptions->get_results()); |
|
116 | 116 | |
117 | 117 | // Print table footer. |
118 | 118 | $this->print_table_footer(); |
119 | 119 | |
120 | 120 | // Print the navigation. |
121 | - $this->print_navigation( $subscriptions->get_total() ); |
|
121 | + $this->print_navigation($subscriptions->get_total()); |
|
122 | 122 | |
123 | 123 | // Backwards compatibility. |
124 | - do_action( 'wpinv_after_user_subscriptions' ); |
|
124 | + do_action('wpinv_after_user_subscriptions'); |
|
125 | 125 | |
126 | 126 | // Return the output. |
127 | 127 | return ob_get_clean(); |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | public function get_subscriptions_table_columns() { |
137 | 137 | |
138 | 138 | $columns = array( |
139 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
140 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
141 | - 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
142 | - 'status' => __( 'Status', 'invoicing' ), |
|
139 | + 'subscription' => __('Subscription', 'invoicing'), |
|
140 | + 'amount' => __('Amount', 'invoicing'), |
|
141 | + 'renewal-date' => __('Next payment', 'invoicing'), |
|
142 | + 'status' => __('Status', 'invoicing'), |
|
143 | 143 | ); |
144 | 144 | |
145 | - return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
145 | + return apply_filters('getpaid_frontend_subscriptions_table_columns', $columns); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | |
158 | 158 | <thead> |
159 | 159 | <tr> |
160 | - <?php foreach ( $this->get_subscriptions_table_columns() as $key => $label ) : ?> |
|
161 | - <th scope="col" class="font-weight-bold getpaid-subscriptions-table-<?php echo sanitize_html_class( $key ); ?>"> |
|
162 | - <?php echo sanitize_text_field( $label ); ?> |
|
160 | + <?php foreach ($this->get_subscriptions_table_columns() as $key => $label) : ?> |
|
161 | + <th scope="col" class="font-weight-bold getpaid-subscriptions-table-<?php echo sanitize_html_class($key); ?>"> |
|
162 | + <?php echo sanitize_text_field($label); ?> |
|
163 | 163 | </th> |
164 | 164 | <?php endforeach; ?> |
165 | 165 | </tr> |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @param WPInv_Subscription[] $subscriptions |
176 | 176 | */ |
177 | - public function print_table_body( $subscriptions ) { |
|
177 | + public function print_table_body($subscriptions) { |
|
178 | 178 | |
179 | - if ( empty( $subscriptions ) ) { |
|
179 | + if (empty($subscriptions)) { |
|
180 | 180 | $this->print_table_body_no_subscriptions(); |
181 | 181 | } else { |
182 | - $this->print_table_body_subscriptions( $subscriptions ); |
|
182 | + $this->print_table_body_subscriptions($subscriptions); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | } |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | <tbody> |
195 | 195 | |
196 | 196 | <tr> |
197 | - <td colspan="<?php echo count( $this->get_subscriptions_table_columns() ); ?>"> |
|
197 | + <td colspan="<?php echo count($this->get_subscriptions_table_columns()); ?>"> |
|
198 | 198 | |
199 | 199 | <?php |
200 | 200 | echo aui()->alert( |
201 | 201 | array( |
202 | - 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
202 | + 'content' => wp_kses_post(__('No subscriptions found.', 'invoicing')), |
|
203 | 203 | 'type' => 'warning', |
204 | 204 | ) |
205 | 205 | ); |
@@ -217,12 +217,12 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @param WPInv_Subscription[] $subscriptions |
219 | 219 | */ |
220 | - public function print_table_body_subscriptions( $subscriptions ) { |
|
220 | + public function print_table_body_subscriptions($subscriptions) { |
|
221 | 221 | |
222 | 222 | ?> |
223 | 223 | <tbody> |
224 | 224 | |
225 | - <?php foreach ( $subscriptions as $subscription ) : ?> |
|
225 | + <?php foreach ($subscriptions as $subscription) : ?> |
|
226 | 226 | <tr class="getpaid-subscriptions-table-row subscription-<?php echo (int) $subscription->get_id(); ?>"> |
227 | 227 | <?php |
228 | 228 | wpinv_get_template( |
@@ -248,28 +248,28 @@ discard block |
||
248 | 248 | * @since 1.0.0 |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function add_row_actions( $content, $subscription ) { |
|
251 | + public function add_row_actions($content, $subscription) { |
|
252 | 252 | |
253 | 253 | // Prepare row actions. |
254 | 254 | $actions = array(); |
255 | 255 | |
256 | 256 | // View subscription action. |
257 | - $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
258 | - $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
259 | - $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
257 | + $view_url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page'))); |
|
258 | + $view_url = esc_url(add_query_arg('subscription', (int) $subscription->get_id(), $view_url)); |
|
259 | + $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __('Manage Subscription', 'invoicing') . '</a>'; |
|
260 | 260 | |
261 | 261 | // Filter the actions. |
262 | - $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
262 | + $actions = apply_filters('getpaid_subscriptions_table_subscription_actions', $actions, $subscription); |
|
263 | 263 | |
264 | - $sanitized = array(); |
|
265 | - foreach ( $actions as $key => $action ) { |
|
266 | - $key = sanitize_html_class( $key ); |
|
267 | - $action = wp_kses_post( $action ); |
|
264 | + $sanitized = array(); |
|
265 | + foreach ($actions as $key => $action) { |
|
266 | + $key = sanitize_html_class($key); |
|
267 | + $action = wp_kses_post($action); |
|
268 | 268 | $sanitized[] = "<span class='$key'>$action</span>"; |
269 | 269 | } |
270 | 270 | |
271 | 271 | $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
272 | - $row_actions .= implode( ' | ', $sanitized ); |
|
272 | + $row_actions .= implode(' | ', $sanitized); |
|
273 | 273 | $row_actions .= '</small>'; |
274 | 274 | |
275 | 275 | return $content . $row_actions; |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | |
286 | 286 | <tfoot> |
287 | 287 | <tr> |
288 | - <?php foreach ( $this->get_subscriptions_table_columns() as $key => $label ) : ?> |
|
289 | - <th class="font-weight-bold getpaid-subscriptions-<?php echo sanitize_html_class( $key ); ?>"> |
|
290 | - <?php echo sanitize_text_field( $label ); ?> |
|
288 | + <?php foreach ($this->get_subscriptions_table_columns() as $key => $label) : ?> |
|
289 | + <th class="font-weight-bold getpaid-subscriptions-<?php echo sanitize_html_class($key); ?>"> |
|
290 | + <?php echo sanitize_text_field($label); ?> |
|
291 | 291 | </th> |
292 | 292 | <?php endforeach; ?> |
293 | 293 | </tr> |
@@ -303,22 +303,22 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @param int $total |
305 | 305 | */ |
306 | - public function print_navigation( $total ) { |
|
306 | + public function print_navigation($total) { |
|
307 | 307 | |
308 | - if ( $total < 1 ) { |
|
308 | + if ($total < 1) { |
|
309 | 309 | |
310 | 310 | // Out-of-bounds, run the query again without LIMIT for total count. |
311 | - $args = array( |
|
311 | + $args = array( |
|
312 | 312 | 'customer_in' => get_current_user_id(), |
313 | 313 | 'fields' => 'id', |
314 | 314 | ); |
315 | 315 | |
316 | - $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
316 | + $count_query = new GetPaid_Subscriptions_Query($args); |
|
317 | 317 | $total = $count_query->get_total(); |
318 | 318 | } |
319 | 319 | |
320 | 320 | // Abort if we do not have pages. |
321 | - if ( 2 > $total ) { |
|
321 | + if (2 > $total) { |
|
322 | 322 | return; |
323 | 323 | } |
324 | 324 | |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | |
331 | 331 | echo getpaid_paginate_links( |
332 | 332 | array( |
333 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
333 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
334 | 334 | 'format' => '?paged=%#%', |
335 | - 'total' => (int) ceil( $total / 10 ), |
|
335 | + 'total' => (int) ceil($total / 10), |
|
336 | 336 | ) |
337 | 337 | ); |
338 | 338 | ?> |
@@ -348,43 +348,43 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return array |
350 | 350 | */ |
351 | - public function get_single_subscription_columns( $subscription ) { |
|
351 | + public function get_single_subscription_columns($subscription) { |
|
352 | 352 | |
353 | 353 | // Prepare subscription detail columns. |
354 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
355 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
354 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_invoice_id(), $subscription->get_id()); |
|
355 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
356 | 356 | $fields = apply_filters( |
357 | 357 | 'getpaid_single_subscription_details_fields', |
358 | 358 | array( |
359 | - 'status' => __( 'Status', 'invoicing' ), |
|
360 | - 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
361 | - 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
362 | - 'start_date' => __( 'Start date', 'invoicing' ), |
|
363 | - 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
364 | - 'payments' => __( 'Payments', 'invoicing' ), |
|
365 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
359 | + 'status' => __('Status', 'invoicing'), |
|
360 | + 'initial_amount' => __('Initial amount', 'invoicing'), |
|
361 | + 'recurring_amount' => __('Recurring amount', 'invoicing'), |
|
362 | + 'start_date' => __('Start date', 'invoicing'), |
|
363 | + 'expiry_date' => __('Next payment', 'invoicing'), |
|
364 | + 'payments' => __('Payments', 'invoicing'), |
|
365 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
366 | 366 | ), |
367 | 367 | $subscription |
368 | 368 | ); |
369 | 369 | |
370 | - if ( isset( $fields['expiry_date'] ) ) { |
|
370 | + if (isset($fields['expiry_date'])) { |
|
371 | 371 | |
372 | - if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
373 | - $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
372 | + if (!$subscription->is_active() || $subscription->is_last_renewal()) { |
|
373 | + $fields['expiry_date'] = __('End date', 'invoicing'); |
|
374 | 374 | } |
375 | 375 | |
376 | - if ( 'pending' == $subscription->get_status() ) { |
|
377 | - unset( $fields['expiry_date'] ); |
|
376 | + if ('pending' == $subscription->get_status()) { |
|
377 | + unset($fields['expiry_date']); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | } |
381 | 381 | |
382 | - if ( isset( $fields['start_date'] ) && 'pending' == $subscription->get_status() ) { |
|
383 | - unset( $fields['start_date'] ); |
|
382 | + if (isset($fields['start_date']) && 'pending' == $subscription->get_status()) { |
|
383 | + unset($fields['start_date']); |
|
384 | 384 | } |
385 | 385 | |
386 | - if ( $subscription->get_initial_amount() == $subscription->get_recurring_amount() ) { |
|
387 | - unset( $fields['initial_amount'] ); |
|
386 | + if ($subscription->get_initial_amount() == $subscription->get_recurring_amount()) { |
|
387 | + unset($fields['initial_amount']); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | return $fields; |
@@ -397,16 +397,16 @@ discard block |
||
397 | 397 | * |
398 | 398 | * @return string |
399 | 399 | */ |
400 | - public function display_single_subscription( $subscription ) { |
|
400 | + public function display_single_subscription($subscription) { |
|
401 | 401 | |
402 | 402 | // Fetch the subscription. |
403 | - $subscription = new WPInv_Subscription( (int) $subscription ); |
|
403 | + $subscription = new WPInv_Subscription((int) $subscription); |
|
404 | 404 | |
405 | - if ( ! $subscription->exists() ) { |
|
405 | + if (!$subscription->exists()) { |
|
406 | 406 | |
407 | 407 | return aui()->alert( |
408 | 408 | array( |
409 | - 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
409 | + 'content' => wp_kses_post(__('Subscription not found.', 'invoicing')), |
|
410 | 410 | 'type' => 'error', |
411 | 411 | ) |
412 | 412 | ); |
@@ -414,11 +414,11 @@ discard block |
||
414 | 414 | } |
415 | 415 | |
416 | 416 | // Ensure that the user owns this subscription key. |
417 | - if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
417 | + if (get_current_user_id() != $subscription->get_customer_id() && !wpinv_current_user_can_manage_invoicing()) { |
|
418 | 418 | |
419 | 419 | return aui()->alert( |
420 | 420 | array( |
421 | - 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
421 | + 'content' => wp_kses_post(__('You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing')), |
|
422 | 422 | 'type' => 'error', |
423 | 423 | ) |
424 | 424 | ); |
@@ -9,17 +9,17 @@ discard block |
||
9 | 9 | * @var WPInv_Subscriptions_Widget $widget |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | -do_action( 'getpaid_single_subscription_before_notices', $subscription ); |
|
14 | +do_action('getpaid_single_subscription_before_notices', $subscription); |
|
15 | 15 | |
16 | 16 | // Display errors and notices. |
17 | 17 | wpinv_print_errors(); |
18 | 18 | |
19 | -$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_invoice_id() ); |
|
20 | -$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
19 | +$subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_invoice_id()); |
|
20 | +$subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_invoice_id(), $subscription->get_id()); |
|
21 | 21 | |
22 | -do_action( 'getpaid_before_single_subscription', $subscription, $subscription_groups ); |
|
22 | +do_action('getpaid_before_single_subscription', $subscription, $subscription_groups); |
|
23 | 23 | |
24 | 24 | ?> |
25 | 25 | |
@@ -31,44 +31,44 @@ discard block |
||
31 | 31 | |
32 | 32 | </style> |
33 | 33 | |
34 | -<h2 class="mb-1 h4"><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
|
34 | +<h2 class="mb-1 h4"><?php _e('Subscription Details', 'invoicing'); ?></h2> |
|
35 | 35 | <table class="table table-bordered"> |
36 | 36 | <tbody> |
37 | 37 | |
38 | - <?php foreach ( $widget->get_single_subscription_columns( $subscription ) as $key => $label ) : ?> |
|
38 | + <?php foreach ($widget->get_single_subscription_columns($subscription) as $key => $label) : ?> |
|
39 | 39 | |
40 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
40 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
41 | 41 | |
42 | 42 | <th class="font-weight-bold" style="width: 35%"> |
43 | - <?php echo sanitize_text_field( $label ); ?> |
|
43 | + <?php echo sanitize_text_field($label); ?> |
|
44 | 44 | </th> |
45 | 45 | |
46 | 46 | <td style="width: 65%"> |
47 | 47 | <?php |
48 | 48 | |
49 | - switch ( $key ) { |
|
49 | + switch ($key) { |
|
50 | 50 | |
51 | 51 | case 'status': |
52 | - echo sanitize_text_field( $subscription->get_status_label() ); |
|
52 | + echo sanitize_text_field($subscription->get_status_label()); |
|
53 | 53 | break; |
54 | 54 | |
55 | 55 | case 'start_date': |
56 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
56 | + echo sanitize_text_field(getpaid_format_date_value($subscription->get_date_created())); |
|
57 | 57 | break; |
58 | 58 | |
59 | 59 | case 'expiry_date': |
60 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) ); |
|
60 | + echo sanitize_text_field(getpaid_format_date_value($subscription->get_next_renewal_date())); |
|
61 | 61 | break; |
62 | 62 | |
63 | 63 | case 'initial_amount': |
64 | - echo wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
64 | + echo wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency()); |
|
65 | 65 | |
66 | - if ( $subscription->has_trial_period() ) { |
|
66 | + if ($subscription->has_trial_period()) { |
|
67 | 67 | |
68 | 68 | echo "<small class='text-muted'> "; |
69 | 69 | printf( |
70 | - _x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ), |
|
71 | - sanitize_text_field( $subscription->get_trial_period() ) |
|
70 | + _x('( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing'), |
|
71 | + sanitize_text_field($subscription->get_trial_period()) |
|
72 | 72 | ); |
73 | 73 | echo '</small>'; |
74 | 74 | |
@@ -77,18 +77,18 @@ discard block |
||
77 | 77 | break; |
78 | 78 | |
79 | 79 | case 'recurring_amount': |
80 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
81 | - $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
82 | - echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
80 | + $frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
81 | + $amount = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()); |
|
82 | + echo strtolower("<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>"); |
|
83 | 83 | break; |
84 | 84 | |
85 | 85 | case 'item': |
86 | 86 | |
87 | - if ( empty( $subscription_group ) ) { |
|
88 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
87 | + if (empty($subscription_group)) { |
|
88 | + echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()); |
|
89 | 89 | } else { |
90 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
91 | - echo implode( ' | ', $markup ); |
|
90 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
91 | + echo implode(' | ', $markup); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | break; |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | case 'payments': |
97 | 97 | |
98 | 98 | $max_activations = (int) $subscription->get_bill_times(); |
99 | - echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "∞" : $max_activations ); |
|
99 | + echo (int) $subscription->get_times_billed() . ' / ' . (empty($max_activations) ? "∞" : $max_activations); |
|
100 | 100 | |
101 | 101 | break; |
102 | 102 | |
103 | 103 | } |
104 | - do_action( "getpaid_render_single_subscription_column_$key", $subscription ); |
|
104 | + do_action("getpaid_render_single_subscription_column_$key", $subscription); |
|
105 | 105 | |
106 | 106 | ?> |
107 | 107 | </td> |
@@ -113,34 +113,34 @@ discard block |
||
113 | 113 | </tbody> |
114 | 114 | </table> |
115 | 115 | |
116 | -<?php if ( ! empty( $subscription_group ) ) : ?> |
|
117 | - <h2 class='mt-5 mb-1 h4'><?php _e( 'Subscription Items', 'invoicing' ); ?></h2> |
|
118 | - <?php getpaid_admin_subscription_item_details_metabox( $subscription ); ?> |
|
116 | +<?php if (!empty($subscription_group)) : ?> |
|
117 | + <h2 class='mt-5 mb-1 h4'><?php _e('Subscription Items', 'invoicing'); ?></h2> |
|
118 | + <?php getpaid_admin_subscription_item_details_metabox($subscription); ?> |
|
119 | 119 | <?php endif; ?> |
120 | 120 | |
121 | -<h2 class='mt-5 mb-1 h4'><?php _e( 'Related Invoices', 'invoicing' ); ?></h2> |
|
121 | +<h2 class='mt-5 mb-1 h4'><?php _e('Related Invoices', 'invoicing'); ?></h2> |
|
122 | 122 | |
123 | -<?php echo getpaid_admin_subscription_invoice_details_metabox( $subscription ); ?> |
|
123 | +<?php echo getpaid_admin_subscription_invoice_details_metabox($subscription); ?> |
|
124 | 124 | |
125 | -<?php if ( 1 < count( $subscription_groups ) ) : ?> |
|
126 | - <h2 class='mt-5 mb-1 h4'><?php _e( 'Related Subscriptions', 'invoicing' ); ?></h2> |
|
127 | - <?php getpaid_admin_subscription_related_subscriptions_metabox( $subscription ); ?> |
|
125 | +<?php if (1 < count($subscription_groups)) : ?> |
|
126 | + <h2 class='mt-5 mb-1 h4'><?php _e('Related Subscriptions', 'invoicing'); ?></h2> |
|
127 | + <?php getpaid_admin_subscription_related_subscriptions_metabox($subscription); ?> |
|
128 | 128 | <?php endif; ?> |
129 | 129 | |
130 | 130 | <span class="form-text"> |
131 | 131 | |
132 | 132 | <?php |
133 | - if ( $subscription->can_cancel() ) { |
|
133 | + if ($subscription->can_cancel()) { |
|
134 | 134 | printf( |
135 | 135 | '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a> ', |
136 | - esc_url( $subscription->get_cancel_url() ), |
|
137 | - esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ), |
|
138 | - __( 'Cancel Subscription', 'invoicing' ) |
|
136 | + esc_url($subscription->get_cancel_url()), |
|
137 | + esc_attr__('Are you sure you want to cancel this subscription?', 'invoicing'), |
|
138 | + __('Cancel Subscription', 'invoicing') |
|
139 | 139 | ); |
140 | 140 | } |
141 | 141 | |
142 | - do_action( 'getpaid-single-subscription-page-actions', $subscription ); |
|
142 | + do_action('getpaid-single-subscription-page-actions', $subscription); |
|
143 | 143 | ?> |
144 | 144 | |
145 | - <a href="<?php echo esc_url( getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); ?>" class="btn btn-secondary btn-sm"><?php _e( 'Go Back', 'invoicing' ); ?></a> |
|
145 | + <a href="<?php echo esc_url(getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page')))); ?>" class="btn btn-secondary btn-sm"><?php _e('Go Back', 'invoicing'); ?></a> |
|
146 | 146 | </span> |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | /** |
9 | 9 | * Main Subscriptions class. |
10 | 10 | * |
@@ -14,31 +14,31 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * Class constructor. |
16 | 16 | */ |
17 | - public function __construct(){ |
|
17 | + public function __construct() { |
|
18 | 18 | |
19 | 19 | // Fire gateway specific hooks when a subscription changes. |
20 | - add_action( 'getpaid_subscription_status_changed', array( $this, 'process_subscription_status_change' ), 10, 3 ); |
|
20 | + add_action('getpaid_subscription_status_changed', array($this, 'process_subscription_status_change'), 10, 3); |
|
21 | 21 | |
22 | 22 | // De-activate a subscription whenever the invoice changes payment statuses. |
23 | - add_action( 'getpaid_invoice_status_wpi-refunded', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
24 | - add_action( 'getpaid_invoice_status_wpi-failed', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
25 | - add_action( 'getpaid_invoice_status_wpi-cancelled', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
26 | - add_action( 'getpaid_invoice_status_wpi-pending', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
23 | + add_action('getpaid_invoice_status_wpi-refunded', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
24 | + add_action('getpaid_invoice_status_wpi-failed', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
25 | + add_action('getpaid_invoice_status_wpi-cancelled', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
26 | + add_action('getpaid_invoice_status_wpi-pending', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
27 | 27 | |
28 | 28 | // Handles subscription cancelations. |
29 | - add_action( 'getpaid_authenticated_action_subscription_cancel', array( $this, 'user_cancel_single_subscription' ) ); |
|
29 | + add_action('getpaid_authenticated_action_subscription_cancel', array($this, 'user_cancel_single_subscription')); |
|
30 | 30 | |
31 | 31 | // Create a subscription whenever an invoice is created, (and update it when it is updated). |
32 | - add_action( 'getpaid_new_invoice', array( $this, 'maybe_create_invoice_subscription' ), 5 ); |
|
33 | - add_action( 'getpaid_update_invoice', array( $this, 'maybe_update_invoice_subscription' ), 5 ); |
|
32 | + add_action('getpaid_new_invoice', array($this, 'maybe_create_invoice_subscription'), 5); |
|
33 | + add_action('getpaid_update_invoice', array($this, 'maybe_update_invoice_subscription'), 5); |
|
34 | 34 | |
35 | 35 | // Handles admin subscription update actions. |
36 | - add_action( 'getpaid_authenticated_admin_action_update_single_subscription', array( $this, 'admin_update_single_subscription' ) ); |
|
37 | - add_action( 'getpaid_authenticated_admin_action_subscription_manual_renew', array( $this, 'admin_renew_single_subscription' ) ); |
|
38 | - add_action( 'getpaid_authenticated_admin_action_subscription_manual_delete', array( $this, 'admin_delete_single_subscription' ) ); |
|
36 | + add_action('getpaid_authenticated_admin_action_update_single_subscription', array($this, 'admin_update_single_subscription')); |
|
37 | + add_action('getpaid_authenticated_admin_action_subscription_manual_renew', array($this, 'admin_renew_single_subscription')); |
|
38 | + add_action('getpaid_authenticated_admin_action_subscription_manual_delete', array($this, 'admin_delete_single_subscription')); |
|
39 | 39 | |
40 | 40 | // Filter invoice item row actions. |
41 | - add_action( 'getpaid-invoice-page-line-item-actions', array( $this, 'filter_invoice_line_item_actions' ), 10, 3 ); |
|
41 | + add_action('getpaid-invoice-page-line-item-actions', array($this, 'filter_invoice_line_item_actions'), 10, 3); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | * @param WPInv_Invoice $invoice |
48 | 48 | * @return WPInv_Subscription|bool |
49 | 49 | */ |
50 | - public function get_invoice_subscription( $invoice ) { |
|
50 | + public function get_invoice_subscription($invoice) { |
|
51 | 51 | $subscription_id = $invoice->get_subscription_id(); |
52 | 52 | |
53 | 53 | // Fallback to the parent invoice if the child invoice has no subscription id. |
54 | - if ( empty( $subscription_id ) && $invoice->is_renewal() ) { |
|
54 | + if (empty($subscription_id) && $invoice->is_renewal()) { |
|
55 | 55 | $subscription_id = $invoice->get_parent_payment()->get_subscription_id(); |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Fetch the subscription. |
59 | - $subscription = new WPInv_Subscription( $subscription_id ); |
|
59 | + $subscription = new WPInv_Subscription($subscription_id); |
|
60 | 60 | |
61 | 61 | // Return subscription or use a fallback for backwards compatibility. |
62 | - return $subscription->exists() ? $subscription : wpinv_get_invoice_subscription( $invoice ); |
|
62 | + return $subscription->exists() ? $subscription : wpinv_get_invoice_subscription($invoice); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -67,21 +67,21 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @param WPInv_Invoice $invoice |
69 | 69 | */ |
70 | - public function maybe_deactivate_invoice_subscription( $invoice ) { |
|
70 | + public function maybe_deactivate_invoice_subscription($invoice) { |
|
71 | 71 | |
72 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
72 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
73 | 73 | |
74 | - if ( empty( $subscriptions ) ) { |
|
74 | + if (empty($subscriptions)) { |
|
75 | 75 | return; |
76 | 76 | } |
77 | 77 | |
78 | - if ( ! is_array( $subscriptions ) ) { |
|
79 | - $subscriptions = array( $subscriptions ); |
|
78 | + if (!is_array($subscriptions)) { |
|
79 | + $subscriptions = array($subscriptions); |
|
80 | 80 | } |
81 | 81 | |
82 | - foreach ( $subscriptions as $subscription ) { |
|
83 | - if ( $subscription->is_active() ) { |
|
84 | - $subscription->set_status( 'pending' ); |
|
82 | + foreach ($subscriptions as $subscription) { |
|
83 | + if ($subscription->is_active()) { |
|
84 | + $subscription->set_status('pending'); |
|
85 | 85 | $subscription->save(); |
86 | 86 | } |
87 | 87 | } |
@@ -95,15 +95,15 @@ discard block |
||
95 | 95 | * @param string $from |
96 | 96 | * @param string $to |
97 | 97 | */ |
98 | - public function process_subscription_status_change( $subscription, $from, $to ) { |
|
98 | + public function process_subscription_status_change($subscription, $from, $to) { |
|
99 | 99 | |
100 | 100 | $gateway = $subscription->get_gateway(); |
101 | 101 | |
102 | - if ( ! empty( $gateway ) ) { |
|
103 | - $gateway = sanitize_key( $gateway ); |
|
104 | - $from = sanitize_key( $from ); |
|
105 | - $to = sanitize_key( $to ); |
|
106 | - do_action( "getpaid_{$gateway}_subscription_$to", $subscription, $from ); |
|
102 | + if (!empty($gateway)) { |
|
103 | + $gateway = sanitize_key($gateway); |
|
104 | + $from = sanitize_key($from); |
|
105 | + $to = sanitize_key($to); |
|
106 | + do_action("getpaid_{$gateway}_subscription_$to", $subscription, $from); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | } |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * @deprecated |
117 | 117 | * @return mixed|string|void |
118 | 118 | */ |
119 | - public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1 ) { |
|
120 | - return getpaid_get_subscription_period_label( $period, $frequency_count ); |
|
119 | + public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) { |
|
120 | + return getpaid_get_subscription_period_label($period, $frequency_count); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -127,33 +127,33 @@ discard block |
||
127 | 127 | * @since 1.0.0 |
128 | 128 | * @return void |
129 | 129 | */ |
130 | - public function user_cancel_single_subscription( $data ) { |
|
130 | + public function user_cancel_single_subscription($data) { |
|
131 | 131 | |
132 | 132 | // Ensure there is a subscription to cancel. |
133 | - if ( empty( $data['subscription'] ) ) { |
|
133 | + if (empty($data['subscription'])) { |
|
134 | 134 | return; |
135 | 135 | } |
136 | 136 | |
137 | - $subscription = new WPInv_Subscription( (int) $data['subscription'] ); |
|
137 | + $subscription = new WPInv_Subscription((int) $data['subscription']); |
|
138 | 138 | |
139 | 139 | // Ensure that it exists and that it belongs to the current user. |
140 | - if ( ! $subscription->exists() || $subscription->get_customer_id() != get_current_user_id() ) { |
|
141 | - wpinv_set_error( 'invalid_subscription', __( 'You do not have permission to cancel this subscription', 'invoicing' ) ); |
|
140 | + if (!$subscription->exists() || $subscription->get_customer_id() != get_current_user_id()) { |
|
141 | + wpinv_set_error('invalid_subscription', __('You do not have permission to cancel this subscription', 'invoicing')); |
|
142 | 142 | |
143 | 143 | // Can it be cancelled. |
144 | - } else if ( ! $subscription->can_cancel() ) { |
|
145 | - wpinv_set_error( 'cannot_cancel', __( 'This subscription cannot be cancelled as it is not active.', 'invoicing' ) ); |
|
144 | + } else if (!$subscription->can_cancel()) { |
|
145 | + wpinv_set_error('cannot_cancel', __('This subscription cannot be cancelled as it is not active.', 'invoicing')); |
|
146 | 146 | |
147 | 147 | // Cancel it. |
148 | 148 | } else { |
149 | 149 | |
150 | 150 | $subscription->cancel(); |
151 | - wpinv_set_error( 'cancelled', __( 'This subscription has been cancelled.', 'invoicing' ), 'info' ); |
|
151 | + wpinv_set_error('cancelled', __('This subscription has been cancelled.', 'invoicing'), 'info'); |
|
152 | 152 | } |
153 | 153 | |
154 | - $redirect = remove_query_arg( array( 'getpaid-action', 'getpaid-nonce' ) ); |
|
154 | + $redirect = remove_query_arg(array('getpaid-action', 'getpaid-nonce')); |
|
155 | 155 | |
156 | - wp_safe_redirect( $redirect ); |
|
156 | + wp_safe_redirect($redirect); |
|
157 | 157 | exit; |
158 | 158 | |
159 | 159 | } |
@@ -165,41 +165,41 @@ discard block |
||
165 | 165 | * @param WPInv_Invoice $invoice |
166 | 166 | * @since 1.0.0 |
167 | 167 | */ |
168 | - public function maybe_create_invoice_subscription( $invoice ) { |
|
168 | + public function maybe_create_invoice_subscription($invoice) { |
|
169 | 169 | global $getpaid_subscriptions_skip_invoice_update; |
170 | 170 | |
171 | 171 | // Abort if it is not recurring. |
172 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_free() || ! $invoice->is_recurring() || $invoice->is_renewal() ) { |
|
172 | + if (!$invoice->is_type('invoice') || $invoice->is_free() || !$invoice->is_recurring() || $invoice->is_renewal()) { |
|
173 | 173 | return; |
174 | 174 | } |
175 | 175 | |
176 | 176 | // Either group the subscriptions or only process a single suscription. |
177 | - if ( getpaid_should_group_subscriptions( $invoice ) ) { |
|
177 | + if (getpaid_should_group_subscriptions($invoice)) { |
|
178 | 178 | |
179 | 179 | $subscription_groups = array(); |
180 | 180 | $is_first = true; |
181 | 181 | |
182 | - foreach ( getpaid_calculate_subscription_totals( $invoice ) as $group_key => $totals ) { |
|
183 | - $subscription_groups[ $group_key ] = $this->create_invoice_subscription_group( $totals, $invoice, 0, $is_first ); |
|
182 | + foreach (getpaid_calculate_subscription_totals($invoice) as $group_key => $totals) { |
|
183 | + $subscription_groups[$group_key] = $this->create_invoice_subscription_group($totals, $invoice, 0, $is_first); |
|
184 | 184 | |
185 | - if ( $is_first ) { |
|
185 | + if ($is_first) { |
|
186 | 186 | $getpaid_subscriptions_skip_invoice_update = true; |
187 | - $invoice->set_subscription_id( $subscription_groups[ $group_key ]['subscription_id'] ); |
|
187 | + $invoice->set_subscription_id($subscription_groups[$group_key]['subscription_id']); |
|
188 | 188 | $invoice->save(); |
189 | 189 | $getpaid_subscriptions_skip_invoice_update = false; |
190 | 190 | } |
191 | 191 | |
192 | - $is_first = false; |
|
192 | + $is_first = false; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | // Cache subscription groups. |
196 | - update_post_meta( $invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups ); |
|
196 | + update_post_meta($invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups); |
|
197 | 197 | return true; |
198 | 198 | |
199 | 199 | } |
200 | 200 | |
201 | 201 | $subscription = new WPInv_Subscription(); |
202 | - return $this->update_invoice_subscription( $subscription, $invoice ); |
|
202 | + return $this->update_invoice_subscription($subscription, $invoice); |
|
203 | 203 | |
204 | 204 | } |
205 | 205 | |
@@ -214,47 +214,47 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @since 2.3.0 |
216 | 216 | */ |
217 | - public function create_invoice_subscription_group( $totals, $invoice, $subscription_id = 0, $is_first = false ) { |
|
217 | + public function create_invoice_subscription_group($totals, $invoice, $subscription_id = 0, $is_first = false) { |
|
218 | 218 | |
219 | - $subscription = new WPInv_Subscription( (int) $subscription_id ); |
|
219 | + $subscription = new WPInv_Subscription((int) $subscription_id); |
|
220 | 220 | $initial_amt = $totals['initial_total']; |
221 | 221 | $recurring_amt = $totals['recurring_total']; |
222 | 222 | $fees = array(); |
223 | 223 | |
224 | 224 | // Maybe add recurring fees. |
225 | - if ( $is_first ) { |
|
225 | + if ($is_first) { |
|
226 | 226 | |
227 | - foreach ( $invoice->get_fees() as $i => $fee ) { |
|
228 | - if ( ! empty( $fee['recurring_fee'] ) ) { |
|
229 | - $initial_amt += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
230 | - $recurring_amt += wpinv_sanitize_amount( $fee['recurring_fee'] ); |
|
227 | + foreach ($invoice->get_fees() as $i => $fee) { |
|
228 | + if (!empty($fee['recurring_fee'])) { |
|
229 | + $initial_amt += wpinv_sanitize_amount($fee['initial_fee']); |
|
230 | + $recurring_amt += wpinv_sanitize_amount($fee['recurring_fee']); |
|
231 | 231 | $fees[$i] = $fee; |
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | 235 | } |
236 | 236 | |
237 | - $subscription->set_customer_id( $invoice->get_customer_id() ); |
|
238 | - $subscription->set_parent_invoice_id( $invoice->get_id() ); |
|
239 | - $subscription->set_initial_amount( $initial_amt ); |
|
240 | - $subscription->set_recurring_amount( $recurring_amt ); |
|
241 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
242 | - $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' ); |
|
243 | - $subscription->set_product_id( $totals['item_id'] ); |
|
244 | - $subscription->set_period( $totals['period'] ); |
|
245 | - $subscription->set_frequency( $totals['interval'] ); |
|
246 | - $subscription->set_bill_times( $totals['recurring_limit'] ); |
|
247 | - $subscription->set_next_renewal_date( $totals['renews_on'] ); |
|
237 | + $subscription->set_customer_id($invoice->get_customer_id()); |
|
238 | + $subscription->set_parent_invoice_id($invoice->get_id()); |
|
239 | + $subscription->set_initial_amount($initial_amt); |
|
240 | + $subscription->set_recurring_amount($recurring_amt); |
|
241 | + $subscription->set_date_created(current_time('mysql')); |
|
242 | + $subscription->set_status($invoice->is_paid() ? 'active' : 'pending'); |
|
243 | + $subscription->set_product_id($totals['item_id']); |
|
244 | + $subscription->set_period($totals['period']); |
|
245 | + $subscription->set_frequency($totals['interval']); |
|
246 | + $subscription->set_bill_times($totals['recurring_limit']); |
|
247 | + $subscription->set_next_renewal_date($totals['renews_on']); |
|
248 | 248 | |
249 | 249 | // Trial periods. |
250 | - if ( ! empty( $totals['trialling'] ) ) { |
|
251 | - $subscription->set_trial_period( $totals['trialling'] ); |
|
252 | - $subscription->set_status( 'trialling' ); |
|
250 | + if (!empty($totals['trialling'])) { |
|
251 | + $subscription->set_trial_period($totals['trialling']); |
|
252 | + $subscription->set_status('trialling'); |
|
253 | 253 | |
254 | 254 | // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial. |
255 | - } else if ( empty( $initial_amt ) ) { |
|
256 | - $subscription->set_trial_period( $totals['interval'] . ' ' . $totals['period'] ); |
|
257 | - $subscription->set_status( 'trialling' ); |
|
255 | + } else if (empty($initial_amt)) { |
|
256 | + $subscription->set_trial_period($totals['interval'] . ' ' . $totals['period']); |
|
257 | + $subscription->set_status('trialling'); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | $subscription->save(); |
@@ -272,87 +272,87 @@ discard block |
||
272 | 272 | * @param WPInv_Invoice $invoice |
273 | 273 | * @since 1.0.19 |
274 | 274 | */ |
275 | - public function maybe_update_invoice_subscription( $invoice ) { |
|
275 | + public function maybe_update_invoice_subscription($invoice) { |
|
276 | 276 | global $getpaid_subscriptions_skip_invoice_update; |
277 | 277 | |
278 | 278 | // Avoid infinite loops. |
279 | - if ( ! empty( $getpaid_subscriptions_skip_invoice_update ) ) { |
|
279 | + if (!empty($getpaid_subscriptions_skip_invoice_update)) { |
|
280 | 280 | return; |
281 | 281 | } |
282 | 282 | |
283 | 283 | // Do not process renewals. |
284 | - if ( $invoice->is_renewal() ) { |
|
284 | + if ($invoice->is_renewal()) { |
|
285 | 285 | return; |
286 | 286 | } |
287 | 287 | |
288 | 288 | // Delete existing subscriptions if available and the invoice is not recurring. |
289 | - if ( ! $invoice->is_recurring() ) { |
|
290 | - $this->delete_invoice_subscriptions( $invoice ); |
|
289 | + if (!$invoice->is_recurring()) { |
|
290 | + $this->delete_invoice_subscriptions($invoice); |
|
291 | 291 | return; |
292 | 292 | } |
293 | 293 | |
294 | 294 | // Fetch existing subscriptions. |
295 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
295 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
296 | 296 | |
297 | 297 | // Create new ones if no existing subscriptions. |
298 | - if ( empty( $subscriptions ) ) { |
|
299 | - return $this->maybe_create_invoice_subscription( $invoice ); |
|
298 | + if (empty($subscriptions)) { |
|
299 | + return $this->maybe_create_invoice_subscription($invoice); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | // Abort if an invoice is paid and already has a subscription. |
303 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
303 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
304 | 304 | return; |
305 | 305 | } |
306 | 306 | |
307 | - $is_grouped = is_array( $subscriptions ); |
|
308 | - $should_group = getpaid_should_group_subscriptions( $invoice ); |
|
307 | + $is_grouped = is_array($subscriptions); |
|
308 | + $should_group = getpaid_should_group_subscriptions($invoice); |
|
309 | 309 | |
310 | 310 | // Ensure that the subscriptions are only grouped if there are more than 1 recurring items. |
311 | - if ( $is_grouped != $should_group ) { |
|
312 | - $this->delete_invoice_subscriptions( $invoice ); |
|
313 | - delete_post_meta( $invoice->get_id(), 'getpaid_subscription_groups' ); |
|
314 | - return $this->maybe_create_invoice_subscription( $invoice ); |
|
311 | + if ($is_grouped != $should_group) { |
|
312 | + $this->delete_invoice_subscriptions($invoice); |
|
313 | + delete_post_meta($invoice->get_id(), 'getpaid_subscription_groups'); |
|
314 | + return $this->maybe_create_invoice_subscription($invoice); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | // If there is only one recurring item... |
318 | - if ( ! $is_grouped ) { |
|
319 | - return $this->update_invoice_subscription( $subscriptions, $invoice ); |
|
318 | + if (!$is_grouped) { |
|
319 | + return $this->update_invoice_subscription($subscriptions, $invoice); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | // Process subscription groups. |
323 | - $current_groups = getpaid_get_invoice_subscription_groups( $invoice->get_id() ); |
|
323 | + $current_groups = getpaid_get_invoice_subscription_groups($invoice->get_id()); |
|
324 | 324 | $subscription_groups = array(); |
325 | 325 | $is_first = true; |
326 | 326 | |
327 | 327 | // Create new subscription groups. |
328 | - foreach ( getpaid_calculate_subscription_totals( $invoice ) as $group_key => $totals ) { |
|
329 | - $subscription_id = isset( $current_groups[ $group_key ] ) ? $current_groups[ $group_key ]['subscription_id'] : 0; |
|
330 | - $subscription_groups[ $group_key ] = $this->create_invoice_subscription_group( $totals, $invoice, $subscription_id, $is_first ); |
|
328 | + foreach (getpaid_calculate_subscription_totals($invoice) as $group_key => $totals) { |
|
329 | + $subscription_id = isset($current_groups[$group_key]) ? $current_groups[$group_key]['subscription_id'] : 0; |
|
330 | + $subscription_groups[$group_key] = $this->create_invoice_subscription_group($totals, $invoice, $subscription_id, $is_first); |
|
331 | 331 | |
332 | - if ( $is_first && $invoice->get_subscription_id() !== $subscription_groups[ $group_key ]['subscription_id'] ) { |
|
332 | + if ($is_first && $invoice->get_subscription_id() !== $subscription_groups[$group_key]['subscription_id']) { |
|
333 | 333 | $getpaid_subscriptions_skip_invoice_update = true; |
334 | - $invoice->set_subscription_id( $subscription_groups[ $group_key ]['subscription_id'] ); |
|
334 | + $invoice->set_subscription_id($subscription_groups[$group_key]['subscription_id']); |
|
335 | 335 | $invoice->save(); |
336 | 336 | $getpaid_subscriptions_skip_invoice_update = false; |
337 | 337 | } |
338 | 338 | |
339 | - $is_first = false; |
|
339 | + $is_first = false; |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | // Delete non-existent subscription groups. |
343 | - foreach ( $current_groups as $group_key => $data ) { |
|
344 | - if ( ! isset( $subscription_groups[ $group_key ] ) ) { |
|
345 | - $subscription = new WPInv_Subscription( (int) $data['subscription_id'] ); |
|
343 | + foreach ($current_groups as $group_key => $data) { |
|
344 | + if (!isset($subscription_groups[$group_key])) { |
|
345 | + $subscription = new WPInv_Subscription((int) $data['subscription_id']); |
|
346 | 346 | |
347 | - if ( $subscription->exists() ) { |
|
348 | - $subscription->delete( true ); |
|
347 | + if ($subscription->exists()) { |
|
348 | + $subscription->delete(true); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | 354 | // Cache subscription groups. |
355 | - update_post_meta( $invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups ); |
|
355 | + update_post_meta($invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups); |
|
356 | 356 | return true; |
357 | 357 | |
358 | 358 | } |
@@ -362,20 +362,20 @@ discard block |
||
362 | 362 | * |
363 | 363 | * @param WPInv_Invoice $invoice |
364 | 364 | */ |
365 | - public function delete_invoice_subscriptions( $invoice ) { |
|
365 | + public function delete_invoice_subscriptions($invoice) { |
|
366 | 366 | |
367 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
367 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
368 | 368 | |
369 | - if ( empty( $subscriptions ) ) { |
|
369 | + if (empty($subscriptions)) { |
|
370 | 370 | return; |
371 | 371 | } |
372 | 372 | |
373 | - if ( ! is_array( $subscriptions ) ) { |
|
374 | - $subscriptions = array( $subscriptions ); |
|
373 | + if (!is_array($subscriptions)) { |
|
374 | + $subscriptions = array($subscriptions); |
|
375 | 375 | } |
376 | 376 | |
377 | - foreach ( $subscriptions as $subscription ) { |
|
378 | - $subscription->delete( true ); |
|
377 | + foreach ($subscriptions as $subscription) { |
|
378 | + $subscription->delete(true); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | } |
@@ -388,57 +388,57 @@ discard block |
||
388 | 388 | * @param WPInv_Invoice $invoice |
389 | 389 | * @since 1.0.19 |
390 | 390 | */ |
391 | - public function update_invoice_subscription( $subscription, $invoice ) { |
|
391 | + public function update_invoice_subscription($subscription, $invoice) { |
|
392 | 392 | |
393 | 393 | // Delete the subscription if an invoice is free or nolonger recurring. |
394 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_free() || ! $invoice->is_recurring() ) { |
|
394 | + if (!$invoice->is_type('invoice') || $invoice->is_free() || !$invoice->is_recurring()) { |
|
395 | 395 | return $subscription->delete(); |
396 | 396 | } |
397 | 397 | |
398 | - $subscription->set_customer_id( $invoice->get_customer_id() ); |
|
399 | - $subscription->set_parent_invoice_id( $invoice->get_id() ); |
|
400 | - $subscription->set_initial_amount( $invoice->get_initial_total() ); |
|
401 | - $subscription->set_recurring_amount( $invoice->get_recurring_total() ); |
|
402 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
403 | - $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' ); |
|
398 | + $subscription->set_customer_id($invoice->get_customer_id()); |
|
399 | + $subscription->set_parent_invoice_id($invoice->get_id()); |
|
400 | + $subscription->set_initial_amount($invoice->get_initial_total()); |
|
401 | + $subscription->set_recurring_amount($invoice->get_recurring_total()); |
|
402 | + $subscription->set_date_created(current_time('mysql')); |
|
403 | + $subscription->set_status($invoice->is_paid() ? 'active' : 'pending'); |
|
404 | 404 | |
405 | 405 | // Get the recurring item and abort if it does not exist. |
406 | - $subscription_item = $invoice->get_recurring( true ); |
|
407 | - if ( ! $subscription_item->get_id() ) { |
|
406 | + $subscription_item = $invoice->get_recurring(true); |
|
407 | + if (!$subscription_item->get_id()) { |
|
408 | 408 | $invoice->set_subscription_id(0); |
409 | 409 | $invoice->save(); |
410 | 410 | return $subscription->delete(); |
411 | 411 | } |
412 | 412 | |
413 | - $subscription->set_product_id( $subscription_item->get_id() ); |
|
414 | - $subscription->set_period( $subscription_item->get_recurring_period( true ) ); |
|
415 | - $subscription->set_frequency( $subscription_item->get_recurring_interval() ); |
|
416 | - $subscription->set_bill_times( $subscription_item->get_recurring_limit() ); |
|
413 | + $subscription->set_product_id($subscription_item->get_id()); |
|
414 | + $subscription->set_period($subscription_item->get_recurring_period(true)); |
|
415 | + $subscription->set_frequency($subscription_item->get_recurring_interval()); |
|
416 | + $subscription->set_bill_times($subscription_item->get_recurring_limit()); |
|
417 | 417 | |
418 | 418 | // Calculate the next renewal date. |
419 | - $period = $subscription_item->get_recurring_period( true ); |
|
419 | + $period = $subscription_item->get_recurring_period(true); |
|
420 | 420 | $interval = $subscription_item->get_recurring_interval(); |
421 | 421 | |
422 | 422 | // If the subscription item has a trial period... |
423 | - if ( $subscription_item->has_free_trial() ) { |
|
424 | - $period = $subscription_item->get_trial_period( true ); |
|
423 | + if ($subscription_item->has_free_trial()) { |
|
424 | + $period = $subscription_item->get_trial_period(true); |
|
425 | 425 | $interval = $subscription_item->get_trial_interval(); |
426 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
427 | - $subscription->set_status( 'trialling' ); |
|
426 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
427 | + $subscription->set_status('trialling'); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial. |
431 | - if ( $invoice->has_free_trial() ) { |
|
432 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
433 | - $subscription->set_status( 'trialling' ); |
|
431 | + if ($invoice->has_free_trial()) { |
|
432 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
433 | + $subscription->set_status('trialling'); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | // Calculate the next renewal date. |
437 | - $expiration = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", strtotime( $subscription->get_date_created() ) ) ); |
|
437 | + $expiration = date('Y-m-d H:i:s', strtotime("+$interval $period", strtotime($subscription->get_date_created()))); |
|
438 | 438 | |
439 | - $subscription->set_next_renewal_date( $expiration ); |
|
439 | + $subscription->set_next_renewal_date($expiration); |
|
440 | 440 | $subscription->save(); |
441 | - $invoice->set_subscription_id( $subscription->get_id() ); |
|
441 | + $invoice->set_subscription_id($subscription->get_id()); |
|
442 | 442 | return $subscription->get_id(); |
443 | 443 | |
444 | 444 | } |
@@ -449,27 +449,27 @@ discard block |
||
449 | 449 | * @param array $data |
450 | 450 | * @since 1.0.19 |
451 | 451 | */ |
452 | - public function admin_update_single_subscription( $args ) { |
|
452 | + public function admin_update_single_subscription($args) { |
|
453 | 453 | |
454 | 454 | // Ensure the subscription exists and that a status has been given. |
455 | - if ( empty( $args['subscription_id'] ) ) { |
|
455 | + if (empty($args['subscription_id'])) { |
|
456 | 456 | return; |
457 | 457 | } |
458 | 458 | |
459 | 459 | // Retrieve the subscriptions. |
460 | - $subscription = new WPInv_Subscription( $args['subscription_id'] ); |
|
460 | + $subscription = new WPInv_Subscription($args['subscription_id']); |
|
461 | 461 | |
462 | - if ( $subscription->get_id() ) { |
|
462 | + if ($subscription->get_id()) { |
|
463 | 463 | |
464 | 464 | $subscription->set_props( |
465 | 465 | array( |
466 | - 'status' => isset( $args['subscription_status'] ) ? $args['subscription_status'] : null, |
|
467 | - 'profile_id' => isset( $args['wpinv_subscription_profile_id'] ) ? $args['wpinv_subscription_profile_id'] : null, |
|
466 | + 'status' => isset($args['subscription_status']) ? $args['subscription_status'] : null, |
|
467 | + 'profile_id' => isset($args['wpinv_subscription_profile_id']) ? $args['wpinv_subscription_profile_id'] : null, |
|
468 | 468 | ) |
469 | 469 | ); |
470 | 470 | |
471 | 471 | $subscription->save(); |
472 | - getpaid_admin()->show_info( __( 'Subscription updated', 'invoicing' ) ); |
|
472 | + getpaid_admin()->show_info(__('Subscription updated', 'invoicing')); |
|
473 | 473 | |
474 | 474 | } |
475 | 475 | |
@@ -481,27 +481,27 @@ discard block |
||
481 | 481 | * @param array $data |
482 | 482 | * @since 1.0.19 |
483 | 483 | */ |
484 | - public function admin_renew_single_subscription( $args ) { |
|
484 | + public function admin_renew_single_subscription($args) { |
|
485 | 485 | |
486 | 486 | // Ensure the subscription exists and that a status has been given. |
487 | - if ( empty( $args['id'] ) ) { |
|
487 | + if (empty($args['id'])) { |
|
488 | 488 | return; |
489 | 489 | } |
490 | 490 | |
491 | 491 | // Retrieve the subscriptions. |
492 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
492 | + $subscription = new WPInv_Subscription($args['id']); |
|
493 | 493 | |
494 | - if ( $subscription->get_id() ) { |
|
494 | + if ($subscription->get_id()) { |
|
495 | 495 | |
496 | - do_action( 'getpaid_admin_renew_subscription', $subscription ); |
|
496 | + do_action('getpaid_admin_renew_subscription', $subscription); |
|
497 | 497 | |
498 | - $args = array( 'transaction_id', $subscription->get_parent_invoice()->generate_key( 'renewal_' ) ); |
|
498 | + $args = array('transaction_id', $subscription->get_parent_invoice()->generate_key('renewal_')); |
|
499 | 499 | |
500 | - if ( ! $subscription->add_payment( $args ) ) { |
|
501 | - getpaid_admin()->show_error( __( 'We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing' ) ); |
|
500 | + if (!$subscription->add_payment($args)) { |
|
501 | + getpaid_admin()->show_error(__('We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing')); |
|
502 | 502 | } else { |
503 | 503 | $subscription->renew(); |
504 | - getpaid_admin()->show_info( __( 'This subscription has been renewed and extended.', 'invoicing' ) ); |
|
504 | + getpaid_admin()->show_info(__('This subscription has been renewed and extended.', 'invoicing')); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | wp_safe_redirect( |
@@ -524,20 +524,20 @@ discard block |
||
524 | 524 | * @param array $data |
525 | 525 | * @since 1.0.19 |
526 | 526 | */ |
527 | - public function admin_delete_single_subscription( $args ) { |
|
527 | + public function admin_delete_single_subscription($args) { |
|
528 | 528 | |
529 | 529 | // Ensure the subscription exists and that a status has been given. |
530 | - if ( empty( $args['id'] ) ) { |
|
530 | + if (empty($args['id'])) { |
|
531 | 531 | return; |
532 | 532 | } |
533 | 533 | |
534 | 534 | // Retrieve the subscriptions. |
535 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
535 | + $subscription = new WPInv_Subscription($args['id']); |
|
536 | 536 | |
537 | - if ( $subscription->delete() ) { |
|
538 | - getpaid_admin()->show_info( __( 'This subscription has been deleted.', 'invoicing' ) ); |
|
537 | + if ($subscription->delete()) { |
|
538 | + getpaid_admin()->show_info(__('This subscription has been deleted.', 'invoicing')); |
|
539 | 539 | } else { |
540 | - getpaid_admin()->show_error( __( 'We are unable to delete this subscription. Please try again.', 'invoicing' ) ); |
|
540 | + getpaid_admin()->show_error(__('We are unable to delete this subscription. Please try again.', 'invoicing')); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | $redirected = wp_safe_redirect( |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | ) |
551 | 551 | ); |
552 | 552 | |
553 | - if ( $redirected ) { |
|
553 | + if ($redirected) { |
|
554 | 554 | exit; |
555 | 555 | } |
556 | 556 | |
@@ -563,16 +563,16 @@ discard block |
||
563 | 563 | * @param WPInv_Item $item |
564 | 564 | * @param WPInv_Invoice $invoice |
565 | 565 | */ |
566 | - public function filter_invoice_line_item_actions( $actions, $item, $invoice ) { |
|
566 | + public function filter_invoice_line_item_actions($actions, $item, $invoice) { |
|
567 | 567 | |
568 | 568 | // Abort if this invoice uses subscription groups. |
569 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
570 | - if ( ! $invoice->is_recurring() || ! is_object( $subscriptions ) ) { |
|
569 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
570 | + if (!$invoice->is_recurring() || !is_object($subscriptions)) { |
|
571 | 571 | return $actions; |
572 | 572 | } |
573 | 573 | |
574 | 574 | // Fetch item subscription. |
575 | - $args = array( |
|
575 | + $args = array( |
|
576 | 576 | 'invoice_in' => $invoice->is_parent() ? $invoice->get_id() : $invoice->get_parent_id(), |
577 | 577 | 'product_in' => $item->get_id(), |
578 | 578 | 'number' => 1, |
@@ -580,13 +580,13 @@ discard block |
||
580 | 580 | 'fields' => 'id', |
581 | 581 | ); |
582 | 582 | |
583 | - $subscription = new GetPaid_Subscriptions_Query( $args ); |
|
583 | + $subscription = new GetPaid_Subscriptions_Query($args); |
|
584 | 584 | $subscription = $subscription->get_results(); |
585 | 585 | |
586 | 586 | // In case we found a match... |
587 | - if ( ! empty( $subscription ) ) { |
|
588 | - $url = esc_url( add_query_arg( 'subscription', (int) $subscription[0], get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); |
|
589 | - $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
587 | + if (!empty($subscription)) { |
|
588 | + $url = esc_url(add_query_arg('subscription', (int) $subscription[0], get_permalink((int) wpinv_get_option('invoice_subscription_page')))); |
|
589 | + $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __('Manage Subscription', 'invoicing') . '</a>'; |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | return $actions; |