@@ -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 | * |
@@ -17,28 +17,28 @@ discard block |
||
17 | 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( 'wpinv_invoice_metabox_saved', array( $this, 'maybe_update_invoice_subscription' ), 5 ); |
|
33 | - add_action( 'getpaid_checkout_invoice_updated', array( $this, 'maybe_update_invoice_subscription' ), 5 ); |
|
32 | + add_action('wpinv_invoice_metabox_saved', array($this, 'maybe_update_invoice_subscription'), 5); |
|
33 | + add_action('getpaid_checkout_invoice_updated', 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,21 +127,21 @@ 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() ) { |
|
140 | + if (!$subscription->exists() || $subscription->get_customer_id() != get_current_user_id()) { |
|
141 | 141 | $notice = 'perm_cancel_subscription'; |
142 | 142 | |
143 | 143 | // Can it be cancelled. |
144 | - } elseif ( ! $subscription->can_cancel() ) { |
|
144 | + } elseif (!$subscription->can_cancel()) { |
|
145 | 145 | $notice = 'cannot_cancel_subscription'; |
146 | 146 | |
147 | 147 | // Cancel it. |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | 'wpinv-notice' => $notice, |
158 | 158 | ); |
159 | 159 | |
160 | - wp_safe_redirect( add_query_arg( $redirect ) ); |
|
160 | + wp_safe_redirect(add_query_arg($redirect)); |
|
161 | 161 | exit; |
162 | 162 | |
163 | 163 | } |
@@ -169,41 +169,41 @@ discard block |
||
169 | 169 | * @param WPInv_Invoice $invoice |
170 | 170 | * @since 1.0.0 |
171 | 171 | */ |
172 | - public function maybe_create_invoice_subscription( $invoice ) { |
|
172 | + public function maybe_create_invoice_subscription($invoice) { |
|
173 | 173 | global $getpaid_subscriptions_skip_invoice_update; |
174 | 174 | |
175 | 175 | // Abort if it is not recurring. |
176 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_free() || ! $invoice->is_recurring() || $invoice->is_renewal() ) { |
|
176 | + if (!$invoice->is_type('invoice') || $invoice->is_free() || !$invoice->is_recurring() || $invoice->is_renewal()) { |
|
177 | 177 | return; |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Either group the subscriptions or only process a single suscription. |
181 | - if ( getpaid_should_group_subscriptions( $invoice ) ) { |
|
181 | + if (getpaid_should_group_subscriptions($invoice)) { |
|
182 | 182 | |
183 | 183 | $subscription_groups = array(); |
184 | 184 | $is_first = true; |
185 | 185 | |
186 | - foreach ( getpaid_calculate_subscription_totals( $invoice ) as $group_key => $totals ) { |
|
187 | - $subscription_groups[ $group_key ] = $this->create_invoice_subscription_group( $totals, $invoice, 0, $is_first ); |
|
186 | + foreach (getpaid_calculate_subscription_totals($invoice) as $group_key => $totals) { |
|
187 | + $subscription_groups[$group_key] = $this->create_invoice_subscription_group($totals, $invoice, 0, $is_first); |
|
188 | 188 | |
189 | - if ( $is_first ) { |
|
189 | + if ($is_first) { |
|
190 | 190 | $getpaid_subscriptions_skip_invoice_update = true; |
191 | - $invoice->set_subscription_id( $subscription_groups[ $group_key ]['subscription_id'] ); |
|
191 | + $invoice->set_subscription_id($subscription_groups[$group_key]['subscription_id']); |
|
192 | 192 | $invoice->save(); |
193 | 193 | $getpaid_subscriptions_skip_invoice_update = false; |
194 | 194 | } |
195 | 195 | |
196 | - $is_first = false; |
|
196 | + $is_first = false; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | // Cache subscription groups. |
200 | - update_post_meta( $invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups ); |
|
200 | + update_post_meta($invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups); |
|
201 | 201 | return true; |
202 | 202 | |
203 | 203 | } |
204 | 204 | |
205 | 205 | $subscription = new WPInv_Subscription(); |
206 | - return $this->update_invoice_subscription( $subscription, $invoice ); |
|
206 | + return $this->update_invoice_subscription($subscription, $invoice); |
|
207 | 207 | |
208 | 208 | } |
209 | 209 | |
@@ -218,46 +218,46 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @since 2.3.0 |
220 | 220 | */ |
221 | - public function create_invoice_subscription_group( $totals, $invoice, $subscription_id = 0, $is_first = false ) { |
|
221 | + public function create_invoice_subscription_group($totals, $invoice, $subscription_id = 0, $is_first = false) { |
|
222 | 222 | |
223 | - $subscription = new WPInv_Subscription( (int) $subscription_id ); |
|
223 | + $subscription = new WPInv_Subscription((int) $subscription_id); |
|
224 | 224 | $initial_amt = $totals['initial_total']; |
225 | 225 | $recurring_amt = $totals['recurring_total']; |
226 | 226 | $fees = array(); |
227 | 227 | |
228 | 228 | // Maybe add recurring fees. |
229 | - if ( $is_first ) { |
|
229 | + if ($is_first) { |
|
230 | 230 | |
231 | - foreach ( $invoice->get_fees() as $i => $fee ) { |
|
232 | - if ( ! empty( $fee['recurring_fee'] ) ) { |
|
233 | - $initial_amt += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
234 | - $recurring_amt += wpinv_sanitize_amount( $fee['recurring_fee'] ); |
|
235 | - $fees[ $i ] = $fee; |
|
231 | + foreach ($invoice->get_fees() as $i => $fee) { |
|
232 | + if (!empty($fee['recurring_fee'])) { |
|
233 | + $initial_amt += wpinv_sanitize_amount($fee['initial_fee']); |
|
234 | + $recurring_amt += wpinv_sanitize_amount($fee['recurring_fee']); |
|
235 | + $fees[$i] = $fee; |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
240 | - $subscription->set_customer_id( $invoice->get_customer_id() ); |
|
241 | - $subscription->set_parent_invoice_id( $invoice->get_id() ); |
|
242 | - $subscription->set_initial_amount( $initial_amt ); |
|
243 | - $subscription->set_recurring_amount( $recurring_amt ); |
|
244 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
245 | - $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' ); |
|
246 | - $subscription->set_product_id( $totals['item_id'] ); |
|
247 | - $subscription->set_period( $totals['period'] ); |
|
248 | - $subscription->set_frequency( $totals['interval'] ); |
|
249 | - $subscription->set_bill_times( $totals['recurring_limit'] ); |
|
250 | - $subscription->set_next_renewal_date( $totals['renews_on'] ); |
|
240 | + $subscription->set_customer_id($invoice->get_customer_id()); |
|
241 | + $subscription->set_parent_invoice_id($invoice->get_id()); |
|
242 | + $subscription->set_initial_amount($initial_amt); |
|
243 | + $subscription->set_recurring_amount($recurring_amt); |
|
244 | + $subscription->set_date_created(current_time('mysql')); |
|
245 | + $subscription->set_status($invoice->is_paid() ? 'active' : 'pending'); |
|
246 | + $subscription->set_product_id($totals['item_id']); |
|
247 | + $subscription->set_period($totals['period']); |
|
248 | + $subscription->set_frequency($totals['interval']); |
|
249 | + $subscription->set_bill_times($totals['recurring_limit']); |
|
250 | + $subscription->set_next_renewal_date($totals['renews_on']); |
|
251 | 251 | |
252 | 252 | // Trial periods. |
253 | - if ( ! empty( $totals['trialling'] ) ) { |
|
254 | - $subscription->set_trial_period( $totals['trialling'] ); |
|
255 | - $subscription->set_status( 'trialling' ); |
|
253 | + if (!empty($totals['trialling'])) { |
|
254 | + $subscription->set_trial_period($totals['trialling']); |
|
255 | + $subscription->set_status('trialling'); |
|
256 | 256 | |
257 | 257 | // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial. |
258 | - } elseif ( empty( $initial_amt ) ) { |
|
259 | - $subscription->set_trial_period( $totals['interval'] . ' ' . $totals['period'] ); |
|
260 | - $subscription->set_status( 'trialling' ); |
|
258 | + } elseif (empty($initial_amt)) { |
|
259 | + $subscription->set_trial_period($totals['interval'] . ' ' . $totals['period']); |
|
260 | + $subscription->set_status('trialling'); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | $subscription->save(); |
@@ -275,86 +275,86 @@ discard block |
||
275 | 275 | * @param WPInv_Invoice $invoice |
276 | 276 | * @since 1.0.19 |
277 | 277 | */ |
278 | - public function maybe_update_invoice_subscription( $invoice ) { |
|
278 | + public function maybe_update_invoice_subscription($invoice) { |
|
279 | 279 | global $getpaid_subscriptions_skip_invoice_update; |
280 | 280 | |
281 | 281 | // Avoid infinite loops. |
282 | - if ( ! empty( $getpaid_subscriptions_skip_invoice_update ) ) { |
|
282 | + if (!empty($getpaid_subscriptions_skip_invoice_update)) { |
|
283 | 283 | return; |
284 | 284 | } |
285 | 285 | |
286 | 286 | // Do not process renewals. |
287 | - if ( $invoice->is_renewal() ) { |
|
287 | + if ($invoice->is_renewal()) { |
|
288 | 288 | return; |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Delete existing subscriptions if available and the invoice is not recurring. |
292 | - if ( ! $invoice->is_recurring() ) { |
|
293 | - $this->delete_invoice_subscriptions( $invoice ); |
|
292 | + if (!$invoice->is_recurring()) { |
|
293 | + $this->delete_invoice_subscriptions($invoice); |
|
294 | 294 | return; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Fetch existing subscriptions. |
298 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
298 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
299 | 299 | |
300 | 300 | // Create new ones if no existing subscriptions. |
301 | - if ( empty( $subscriptions ) ) { |
|
302 | - return $this->maybe_create_invoice_subscription( $invoice ); |
|
301 | + if (empty($subscriptions)) { |
|
302 | + return $this->maybe_create_invoice_subscription($invoice); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | // Abort if an invoice is paid and already has a subscription. |
306 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
306 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | - $is_grouped = is_array( $subscriptions ); |
|
311 | - $should_group = getpaid_should_group_subscriptions( $invoice ); |
|
310 | + $is_grouped = is_array($subscriptions); |
|
311 | + $should_group = getpaid_should_group_subscriptions($invoice); |
|
312 | 312 | |
313 | 313 | // Ensure that the subscriptions are only grouped if there are more than 1 recurring items. |
314 | - if ( $is_grouped != $should_group ) { |
|
315 | - $this->delete_invoice_subscriptions( $invoice ); |
|
316 | - delete_post_meta( $invoice->get_id(), 'getpaid_subscription_groups' ); |
|
317 | - return $this->maybe_create_invoice_subscription( $invoice ); |
|
314 | + if ($is_grouped != $should_group) { |
|
315 | + $this->delete_invoice_subscriptions($invoice); |
|
316 | + delete_post_meta($invoice->get_id(), 'getpaid_subscription_groups'); |
|
317 | + return $this->maybe_create_invoice_subscription($invoice); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | // If there is only one recurring item... |
321 | - if ( ! $is_grouped ) { |
|
322 | - return $this->update_invoice_subscription( $subscriptions, $invoice ); |
|
321 | + if (!$is_grouped) { |
|
322 | + return $this->update_invoice_subscription($subscriptions, $invoice); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | // Process subscription groups. |
326 | - $current_groups = getpaid_get_invoice_subscription_groups( $invoice->get_id() ); |
|
326 | + $current_groups = getpaid_get_invoice_subscription_groups($invoice->get_id()); |
|
327 | 327 | $subscription_groups = array(); |
328 | 328 | $is_first = true; |
329 | 329 | |
330 | 330 | // Create new subscription groups. |
331 | - foreach ( getpaid_calculate_subscription_totals( $invoice ) as $group_key => $totals ) { |
|
332 | - $subscription_id = isset( $current_groups[ $group_key ] ) ? $current_groups[ $group_key ]['subscription_id'] : 0; |
|
333 | - $subscription_groups[ $group_key ] = $this->create_invoice_subscription_group( $totals, $invoice, $subscription_id, $is_first ); |
|
331 | + foreach (getpaid_calculate_subscription_totals($invoice) as $group_key => $totals) { |
|
332 | + $subscription_id = isset($current_groups[$group_key]) ? $current_groups[$group_key]['subscription_id'] : 0; |
|
333 | + $subscription_groups[$group_key] = $this->create_invoice_subscription_group($totals, $invoice, $subscription_id, $is_first); |
|
334 | 334 | |
335 | - if ( $is_first && $invoice->get_subscription_id() !== $subscription_groups[ $group_key ]['subscription_id'] ) { |
|
335 | + if ($is_first && $invoice->get_subscription_id() !== $subscription_groups[$group_key]['subscription_id']) { |
|
336 | 336 | $getpaid_subscriptions_skip_invoice_update = true; |
337 | - $invoice->set_subscription_id( $subscription_groups[ $group_key ]['subscription_id'] ); |
|
337 | + $invoice->set_subscription_id($subscription_groups[$group_key]['subscription_id']); |
|
338 | 338 | $invoice->save(); |
339 | 339 | $getpaid_subscriptions_skip_invoice_update = false; |
340 | 340 | } |
341 | 341 | |
342 | - $is_first = false; |
|
342 | + $is_first = false; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | // Delete non-existent subscription groups. |
346 | - foreach ( $current_groups as $group_key => $data ) { |
|
347 | - if ( ! isset( $subscription_groups[ $group_key ] ) ) { |
|
348 | - $subscription = new WPInv_Subscription( (int) $data['subscription_id'] ); |
|
346 | + foreach ($current_groups as $group_key => $data) { |
|
347 | + if (!isset($subscription_groups[$group_key])) { |
|
348 | + $subscription = new WPInv_Subscription((int) $data['subscription_id']); |
|
349 | 349 | |
350 | - if ( $subscription->exists() ) { |
|
351 | - $subscription->delete( true ); |
|
350 | + if ($subscription->exists()) { |
|
351 | + $subscription->delete(true); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
356 | 356 | // Cache subscription groups. |
357 | - update_post_meta( $invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups ); |
|
357 | + update_post_meta($invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups); |
|
358 | 358 | return true; |
359 | 359 | |
360 | 360 | } |
@@ -364,20 +364,20 @@ discard block |
||
364 | 364 | * |
365 | 365 | * @param WPInv_Invoice $invoice |
366 | 366 | */ |
367 | - public function delete_invoice_subscriptions( $invoice ) { |
|
367 | + public function delete_invoice_subscriptions($invoice) { |
|
368 | 368 | |
369 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
369 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
370 | 370 | |
371 | - if ( empty( $subscriptions ) ) { |
|
371 | + if (empty($subscriptions)) { |
|
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | - if ( ! is_array( $subscriptions ) ) { |
|
376 | - $subscriptions = array( $subscriptions ); |
|
375 | + if (!is_array($subscriptions)) { |
|
376 | + $subscriptions = array($subscriptions); |
|
377 | 377 | } |
378 | 378 | |
379 | - foreach ( $subscriptions as $subscription ) { |
|
380 | - $subscription->delete( true ); |
|
379 | + foreach ($subscriptions as $subscription) { |
|
380 | + $subscription->delete(true); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | } |
@@ -390,57 +390,57 @@ discard block |
||
390 | 390 | * @param WPInv_Invoice $invoice |
391 | 391 | * @since 1.0.19 |
392 | 392 | */ |
393 | - public function update_invoice_subscription( $subscription, $invoice ) { |
|
393 | + public function update_invoice_subscription($subscription, $invoice) { |
|
394 | 394 | |
395 | 395 | // Delete the subscription if an invoice is free or nolonger recurring. |
396 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_free() || ! $invoice->is_recurring() ) { |
|
396 | + if (!$invoice->is_type('invoice') || $invoice->is_free() || !$invoice->is_recurring()) { |
|
397 | 397 | return $subscription->delete(); |
398 | 398 | } |
399 | 399 | |
400 | - $subscription->set_customer_id( $invoice->get_customer_id() ); |
|
401 | - $subscription->set_parent_invoice_id( $invoice->get_id() ); |
|
402 | - $subscription->set_initial_amount( $invoice->get_initial_total() ); |
|
403 | - $subscription->set_recurring_amount( $invoice->get_recurring_total() ); |
|
404 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
405 | - $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' ); |
|
400 | + $subscription->set_customer_id($invoice->get_customer_id()); |
|
401 | + $subscription->set_parent_invoice_id($invoice->get_id()); |
|
402 | + $subscription->set_initial_amount($invoice->get_initial_total()); |
|
403 | + $subscription->set_recurring_amount($invoice->get_recurring_total()); |
|
404 | + $subscription->set_date_created(current_time('mysql')); |
|
405 | + $subscription->set_status($invoice->is_paid() ? 'active' : 'pending'); |
|
406 | 406 | |
407 | 407 | // Get the recurring item and abort if it does not exist. |
408 | - $subscription_item = $invoice->get_recurring( true ); |
|
409 | - if ( ! $subscription_item->get_id() ) { |
|
410 | - $invoice->set_subscription_id( 0 ); |
|
408 | + $subscription_item = $invoice->get_recurring(true); |
|
409 | + if (!$subscription_item->get_id()) { |
|
410 | + $invoice->set_subscription_id(0); |
|
411 | 411 | $invoice->save(); |
412 | 412 | return $subscription->delete(); |
413 | 413 | } |
414 | 414 | |
415 | - $subscription->set_product_id( $subscription_item->get_id() ); |
|
416 | - $subscription->set_period( $subscription_item->get_recurring_period( true ) ); |
|
417 | - $subscription->set_frequency( $subscription_item->get_recurring_interval() ); |
|
418 | - $subscription->set_bill_times( $subscription_item->get_recurring_limit() ); |
|
415 | + $subscription->set_product_id($subscription_item->get_id()); |
|
416 | + $subscription->set_period($subscription_item->get_recurring_period(true)); |
|
417 | + $subscription->set_frequency($subscription_item->get_recurring_interval()); |
|
418 | + $subscription->set_bill_times($subscription_item->get_recurring_limit()); |
|
419 | 419 | |
420 | 420 | // Calculate the next renewal date. |
421 | - $period = $subscription_item->get_recurring_period( true ); |
|
421 | + $period = $subscription_item->get_recurring_period(true); |
|
422 | 422 | $interval = $subscription_item->get_recurring_interval(); |
423 | 423 | |
424 | 424 | // If the subscription item has a trial period... |
425 | - if ( $subscription_item->has_free_trial() ) { |
|
426 | - $period = $subscription_item->get_trial_period( true ); |
|
425 | + if ($subscription_item->has_free_trial()) { |
|
426 | + $period = $subscription_item->get_trial_period(true); |
|
427 | 427 | $interval = $subscription_item->get_trial_interval(); |
428 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
429 | - $subscription->set_status( 'trialling' ); |
|
428 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
429 | + $subscription->set_status('trialling'); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial. |
433 | - if ( $invoice->has_free_trial() ) { |
|
434 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
435 | - $subscription->set_status( 'trialling' ); |
|
433 | + if ($invoice->has_free_trial()) { |
|
434 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
435 | + $subscription->set_status('trialling'); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | // Calculate the next renewal date. |
439 | - $expiration = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", strtotime( $subscription->get_date_created() ) ) ); |
|
439 | + $expiration = date('Y-m-d H:i:s', strtotime("+$interval $period", strtotime($subscription->get_date_created()))); |
|
440 | 440 | |
441 | - $subscription->set_next_renewal_date( $expiration ); |
|
441 | + $subscription->set_next_renewal_date($expiration); |
|
442 | 442 | $subscription->save(); |
443 | - $invoice->set_subscription_id( $subscription->get_id() ); |
|
443 | + $invoice->set_subscription_id($subscription->get_id()); |
|
444 | 444 | return $subscription->get_id(); |
445 | 445 | |
446 | 446 | } |
@@ -451,34 +451,34 @@ discard block |
||
451 | 451 | * @param array $data |
452 | 452 | * @since 1.0.19 |
453 | 453 | */ |
454 | - public function admin_update_single_subscription( $args ) { |
|
454 | + public function admin_update_single_subscription($args) { |
|
455 | 455 | |
456 | 456 | // Ensure the subscription exists and that a status has been given. |
457 | - if ( empty( $args['subscription_id'] ) ) { |
|
457 | + if (empty($args['subscription_id'])) { |
|
458 | 458 | return; |
459 | 459 | } |
460 | 460 | |
461 | 461 | // Retrieve the subscriptions. |
462 | - $subscription = new WPInv_Subscription( $args['subscription_id'] ); |
|
462 | + $subscription = new WPInv_Subscription($args['subscription_id']); |
|
463 | 463 | |
464 | - if ( $subscription->get_id() ) { |
|
464 | + if ($subscription->get_id()) { |
|
465 | 465 | |
466 | 466 | $subscription->set_props( |
467 | 467 | array( |
468 | - 'status' => isset( $args['subscription_status'] ) ? $args['subscription_status'] : null, |
|
469 | - 'profile_id' => isset( $args['wpinv_subscription_profile_id'] ) ? $args['wpinv_subscription_profile_id'] : null, |
|
470 | - 'date_created' => ! empty( $args['wpinv_subscription_date_created'] ) ? $args['wpinv_subscription_date_created'] : null, |
|
471 | - 'expiration' => ! empty( $args['wpinv_subscription_expiration'] ) ? $args['wpinv_subscription_expiration'] : null, |
|
472 | - 'bill_times' => ! empty( $args['wpinv_subscription_max_bill_times'] ) ? $args['wpinv_subscription_max_bill_times'] : null, |
|
468 | + 'status' => isset($args['subscription_status']) ? $args['subscription_status'] : null, |
|
469 | + 'profile_id' => isset($args['wpinv_subscription_profile_id']) ? $args['wpinv_subscription_profile_id'] : null, |
|
470 | + 'date_created' => !empty($args['wpinv_subscription_date_created']) ? $args['wpinv_subscription_date_created'] : null, |
|
471 | + 'expiration' => !empty($args['wpinv_subscription_expiration']) ? $args['wpinv_subscription_expiration'] : null, |
|
472 | + 'bill_times' => !empty($args['wpinv_subscription_max_bill_times']) ? $args['wpinv_subscription_max_bill_times'] : null, |
|
473 | 473 | ) |
474 | 474 | ); |
475 | 475 | |
476 | 476 | $changes = $subscription->get_changes(); |
477 | 477 | |
478 | 478 | $subscription->save(); |
479 | - getpaid_admin()->show_info( __( 'Subscription updated', 'invoicing' ) ); |
|
479 | + getpaid_admin()->show_info(__('Subscription updated', 'invoicing')); |
|
480 | 480 | |
481 | - do_action( 'getpaid_admin_updated_subscription', $subscription, $args, $changes ); |
|
481 | + do_action('getpaid_admin_updated_subscription', $subscription, $args, $changes); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | } |
@@ -489,27 +489,27 @@ discard block |
||
489 | 489 | * @param array $data |
490 | 490 | * @since 1.0.19 |
491 | 491 | */ |
492 | - public function admin_renew_single_subscription( $args ) { |
|
492 | + public function admin_renew_single_subscription($args) { |
|
493 | 493 | |
494 | 494 | // Ensure the subscription exists and that a status has been given. |
495 | - if ( empty( $args['id'] ) ) { |
|
495 | + if (empty($args['id'])) { |
|
496 | 496 | return; |
497 | 497 | } |
498 | 498 | |
499 | 499 | // Retrieve the subscriptions. |
500 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
500 | + $subscription = new WPInv_Subscription($args['id']); |
|
501 | 501 | |
502 | - if ( $subscription->get_id() ) { |
|
502 | + if ($subscription->get_id()) { |
|
503 | 503 | |
504 | - do_action( 'getpaid_admin_renew_subscription', $subscription ); |
|
504 | + do_action('getpaid_admin_renew_subscription', $subscription); |
|
505 | 505 | |
506 | - $args = array( 'transaction_id', $subscription->get_parent_invoice()->generate_key( 'renewal_' ) ); |
|
506 | + $args = array('transaction_id', $subscription->get_parent_invoice()->generate_key('renewal_')); |
|
507 | 507 | |
508 | - if ( ! $subscription->add_payment( $args ) ) { |
|
509 | - getpaid_admin()->show_error( __( 'We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing' ) ); |
|
508 | + if (!$subscription->add_payment($args)) { |
|
509 | + getpaid_admin()->show_error(__('We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing')); |
|
510 | 510 | } else { |
511 | 511 | $subscription->renew(); |
512 | - getpaid_admin()->show_info( __( 'This subscription has been renewed and extended.', 'invoicing' ) ); |
|
512 | + getpaid_admin()->show_info(__('This subscription has been renewed and extended.', 'invoicing')); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | wp_safe_redirect( |
@@ -532,20 +532,20 @@ discard block |
||
532 | 532 | * @param array $data |
533 | 533 | * @since 1.0.19 |
534 | 534 | */ |
535 | - public function admin_delete_single_subscription( $args ) { |
|
535 | + public function admin_delete_single_subscription($args) { |
|
536 | 536 | |
537 | 537 | // Ensure the subscription exists and that a status has been given. |
538 | - if ( empty( $args['id'] ) ) { |
|
538 | + if (empty($args['id'])) { |
|
539 | 539 | return; |
540 | 540 | } |
541 | 541 | |
542 | 542 | // Retrieve the subscriptions. |
543 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
543 | + $subscription = new WPInv_Subscription($args['id']); |
|
544 | 544 | |
545 | - if ( $subscription->delete() ) { |
|
546 | - getpaid_admin()->show_info( __( 'This subscription has been deleted.', 'invoicing' ) ); |
|
545 | + if ($subscription->delete()) { |
|
546 | + getpaid_admin()->show_info(__('This subscription has been deleted.', 'invoicing')); |
|
547 | 547 | } else { |
548 | - getpaid_admin()->show_error( __( 'We are unable to delete this subscription. Please try again.', 'invoicing' ) ); |
|
548 | + getpaid_admin()->show_error(__('We are unable to delete this subscription. Please try again.', 'invoicing')); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | $redirected = wp_safe_redirect( |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | ) |
559 | 559 | ); |
560 | 560 | |
561 | - if ( $redirected ) { |
|
561 | + if ($redirected) { |
|
562 | 562 | exit; |
563 | 563 | } |
564 | 564 | |
@@ -571,16 +571,16 @@ discard block |
||
571 | 571 | * @param WPInv_Item $item |
572 | 572 | * @param WPInv_Invoice $invoice |
573 | 573 | */ |
574 | - public function filter_invoice_line_item_actions( $actions, $item, $invoice ) { |
|
574 | + public function filter_invoice_line_item_actions($actions, $item, $invoice) { |
|
575 | 575 | |
576 | 576 | // Abort if this invoice uses subscription groups. |
577 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
578 | - if ( ! $invoice->is_recurring() || ! is_object( $subscriptions ) ) { |
|
577 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
578 | + if (!$invoice->is_recurring() || !is_object($subscriptions)) { |
|
579 | 579 | return $actions; |
580 | 580 | } |
581 | 581 | |
582 | 582 | // Fetch item subscription. |
583 | - $args = array( |
|
583 | + $args = array( |
|
584 | 584 | 'invoice_in' => $invoice->is_parent() ? $invoice->get_id() : $invoice->get_parent_id(), |
585 | 585 | 'product_in' => $item->get_id(), |
586 | 586 | 'number' => 1, |
@@ -588,13 +588,13 @@ discard block |
||
588 | 588 | 'fields' => 'id', |
589 | 589 | ); |
590 | 590 | |
591 | - $subscription = new GetPaid_Subscriptions_Query( $args ); |
|
591 | + $subscription = new GetPaid_Subscriptions_Query($args); |
|
592 | 592 | $subscription = $subscription->get_results(); |
593 | 593 | |
594 | 594 | // In case we found a match... |
595 | - if ( ! empty( $subscription ) ) { |
|
596 | - $url = esc_url( add_query_arg( 'subscription', (int) $subscription[0], get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); |
|
597 | - $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
595 | + if (!empty($subscription)) { |
|
596 | + $url = esc_url(add_query_arg('subscription', (int) $subscription[0], get_permalink((int) wpinv_get_option('invoice_subscription_page')))); |
|
597 | + $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __('Manage Subscription', 'invoicing') . '</a>'; |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | return $actions; |
@@ -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 | * Invoice class. |
@@ -145,39 +145,39 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
147 | 147 | */ |
148 | - public function __construct( $invoice = 0 ) { |
|
148 | + public function __construct($invoice = 0) { |
|
149 | 149 | |
150 | - parent::__construct( $invoice ); |
|
150 | + parent::__construct($invoice); |
|
151 | 151 | |
152 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) { |
|
153 | - $this->set_id( (int) $invoice ); |
|
154 | - } elseif ( $invoice instanceof self ) { |
|
155 | - $this->set_id( $invoice->get_id() ); |
|
156 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
157 | - $this->set_id( $invoice->ID ); |
|
158 | - } elseif ( is_array( $invoice ) ) { |
|
159 | - $this->set_props( $invoice ); |
|
152 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) { |
|
153 | + $this->set_id((int) $invoice); |
|
154 | + } elseif ($invoice instanceof self) { |
|
155 | + $this->set_id($invoice->get_id()); |
|
156 | + } elseif (!empty($invoice->ID)) { |
|
157 | + $this->set_id($invoice->ID); |
|
158 | + } elseif (is_array($invoice)) { |
|
159 | + $this->set_props($invoice); |
|
160 | 160 | |
161 | - if ( isset( $invoice['ID'] ) ) { |
|
162 | - $this->set_id( $invoice['ID'] ); |
|
161 | + if (isset($invoice['ID'])) { |
|
162 | + $this->set_id($invoice['ID']); |
|
163 | 163 | } |
164 | -} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
165 | - $this->set_id( $invoice_id ); |
|
166 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
167 | - $this->set_id( $invoice_id ); |
|
168 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
169 | - $this->set_id( $invoice_id ); |
|
164 | +} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
165 | + $this->set_id($invoice_id); |
|
166 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
167 | + $this->set_id($invoice_id); |
|
168 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
169 | + $this->set_id($invoice_id); |
|
170 | 170 | } else { |
171 | - $this->set_object_read( true ); |
|
171 | + $this->set_object_read(true); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Load the datastore. |
175 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
175 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
176 | 176 | |
177 | - if ( $this->get_id() > 0 ) { |
|
178 | - $this->post = get_post( $this->get_id() ); |
|
177 | + if ($this->get_id() > 0) { |
|
178 | + $this->post = get_post($this->get_id()); |
|
179 | 179 | $this->ID = $this->get_id(); |
180 | - $this->data_store->read( $this ); |
|
180 | + $this->data_store->read($this); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | } |
@@ -192,38 +192,38 @@ discard block |
||
192 | 192 | * @since 1.0.15 |
193 | 193 | * @return int |
194 | 194 | */ |
195 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
195 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
196 | 196 | global $wpdb; |
197 | 197 | |
198 | 198 | // Trim the value. |
199 | - $value = trim( $value ); |
|
199 | + $value = trim($value); |
|
200 | 200 | |
201 | - if ( empty( $value ) ) { |
|
201 | + if (empty($value)) { |
|
202 | 202 | return 0; |
203 | 203 | } |
204 | 204 | |
205 | 205 | // Valid fields. |
206 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
206 | + $fields = array('key', 'number', 'transaction_id'); |
|
207 | 207 | |
208 | 208 | // Ensure a field has been passed. |
209 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
209 | + if (empty($field) || !in_array($field, $fields)) { |
|
210 | 210 | return 0; |
211 | 211 | } |
212 | 212 | |
213 | 213 | // Maybe retrieve from the cache. |
214 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
215 | - if ( false !== $invoice_id ) { |
|
214 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
215 | + if (false !== $invoice_id) { |
|
216 | 216 | return $invoice_id; |
217 | 217 | } |
218 | 218 | |
219 | 219 | // Fetch from the db. |
220 | 220 | $table = $wpdb->prefix . 'getpaid_invoices'; |
221 | 221 | $invoice_id = (int) $wpdb->get_var( |
222 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
222 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
223 | 223 | ); |
224 | 224 | |
225 | 225 | // Update the cache with our data |
226 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
226 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
227 | 227 | |
228 | 228 | return $invoice_id; |
229 | 229 | } |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | /** |
232 | 232 | * Checks if an invoice key is set. |
233 | 233 | */ |
234 | - public function _isset( $key ) { |
|
235 | - return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" ); |
|
234 | + public function _isset($key) { |
|
235 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /* |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | * @param string $context View or edit context. |
258 | 258 | * @return int |
259 | 259 | */ |
260 | - public function get_parent_id( $context = 'view' ) { |
|
261 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
260 | + public function get_parent_id($context = 'view') { |
|
261 | + return (int) $this->get_prop('parent_id', $context); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @return WPInv_Invoice |
269 | 269 | */ |
270 | 270 | public function get_parent_payment() { |
271 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
271 | + return new WPInv_Invoice($this->get_parent_id()); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -288,8 +288,8 @@ discard block |
||
288 | 288 | * @param string $context View or edit context. |
289 | 289 | * @return string |
290 | 290 | */ |
291 | - public function get_status( $context = 'view' ) { |
|
292 | - return $this->get_prop( 'status', $context ); |
|
291 | + public function get_status($context = 'view') { |
|
292 | + return $this->get_prop('status', $context); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @return array |
300 | 300 | */ |
301 | 301 | public function get_all_statuses() { |
302 | - return wpinv_get_invoice_statuses( true, true, $this ); |
|
302 | + return wpinv_get_invoice_statuses(true, true, $this); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | public function get_status_nicename() { |
312 | 312 | $statuses = $this->get_all_statuses(); |
313 | 313 | |
314 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
314 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
315 | 315 | |
316 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
316 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | */ |
325 | 325 | public function get_status_class() { |
326 | 326 | $statuses = getpaid_get_invoice_status_classes(); |
327 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark'; |
|
327 | + return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'bg-dark'; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public function get_status_label_html() { |
337 | 337 | |
338 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
339 | - $status = sanitize_html_class( $this->get_status() ); |
|
340 | - $class = esc_attr( $this->get_status_class() ); |
|
338 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
339 | + $status = sanitize_html_class($this->get_status()); |
|
340 | + $class = esc_attr($this->get_status_class()); |
|
341 | 341 | |
342 | 342 | return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
343 | 343 | } |
@@ -349,23 +349,23 @@ discard block |
||
349 | 349 | * @param string $context View or edit context. |
350 | 350 | * @return string |
351 | 351 | */ |
352 | - public function get_version( $context = 'view' ) { |
|
353 | - return $this->get_prop( 'version', $context ); |
|
352 | + public function get_version($context = 'view') { |
|
353 | + return $this->get_prop('version', $context); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | 357 | * @deprecated |
358 | 358 | */ |
359 | - public function get_invoice_date( $format = true ) { |
|
360 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
361 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
362 | - $formatted = getpaid_format_date( $date ); |
|
359 | + public function get_invoice_date($format = true) { |
|
360 | + $date = getpaid_format_date($this->get_date_completed()); |
|
361 | + $date = empty($date) ? $this->get_date_created() : $this->get_date_completed(); |
|
362 | + $formatted = getpaid_format_date($date); |
|
363 | 363 | |
364 | - if ( $format ) { |
|
364 | + if ($format) { |
|
365 | 365 | return $formatted; |
366 | 366 | } |
367 | 367 | |
368 | - return empty( $formatted ) ? '' : $date; |
|
368 | + return empty($formatted) ? '' : $date; |
|
369 | 369 | |
370 | 370 | } |
371 | 371 | |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | * @param string $context View or edit context. |
377 | 377 | * @return string |
378 | 378 | */ |
379 | - public function get_date_created( $context = 'view' ) { |
|
380 | - return $this->get_prop( 'date_created', $context ); |
|
379 | + public function get_date_created($context = 'view') { |
|
380 | + return $this->get_prop('date_created', $context); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -387,8 +387,8 @@ discard block |
||
387 | 387 | * @param string $context View or edit context. |
388 | 388 | * @return string |
389 | 389 | */ |
390 | - public function get_created_date( $context = 'view' ) { |
|
391 | - return $this->get_date_created( $context ); |
|
390 | + public function get_created_date($context = 'view') { |
|
391 | + return $this->get_date_created($context); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -398,11 +398,11 @@ discard block |
||
398 | 398 | * @param string $context View or edit context. |
399 | 399 | * @return string |
400 | 400 | */ |
401 | - public function get_date_created_gmt( $context = 'view' ) { |
|
402 | - $date = $this->get_date_created( $context ); |
|
401 | + public function get_date_created_gmt($context = 'view') { |
|
402 | + $date = $this->get_date_created($context); |
|
403 | 403 | |
404 | - if ( $date ) { |
|
405 | - $date = get_gmt_from_date( $date ); |
|
404 | + if ($date) { |
|
405 | + $date = get_gmt_from_date($date); |
|
406 | 406 | } |
407 | 407 | return $date; |
408 | 408 | } |
@@ -414,8 +414,8 @@ discard block |
||
414 | 414 | * @param string $context View or edit context. |
415 | 415 | * @return string |
416 | 416 | */ |
417 | - public function get_date_modified( $context = 'view' ) { |
|
418 | - return $this->get_prop( 'date_modified', $context ); |
|
417 | + public function get_date_modified($context = 'view') { |
|
418 | + return $this->get_prop('date_modified', $context); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * @param string $context View or edit context. |
426 | 426 | * @return string |
427 | 427 | */ |
428 | - public function get_modified_date( $context = 'view' ) { |
|
429 | - return $this->get_date_modified( $context ); |
|
428 | + public function get_modified_date($context = 'view') { |
|
429 | + return $this->get_date_modified($context); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -436,11 +436,11 @@ discard block |
||
436 | 436 | * @param string $context View or edit context. |
437 | 437 | * @return string |
438 | 438 | */ |
439 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
440 | - $date = $this->get_date_modified( $context ); |
|
439 | + public function get_date_modified_gmt($context = 'view') { |
|
440 | + $date = $this->get_date_modified($context); |
|
441 | 441 | |
442 | - if ( $date ) { |
|
443 | - $date = get_gmt_from_date( $date ); |
|
442 | + if ($date) { |
|
443 | + $date = get_gmt_from_date($date); |
|
444 | 444 | } |
445 | 445 | return $date; |
446 | 446 | } |
@@ -452,8 +452,8 @@ discard block |
||
452 | 452 | * @param string $context View or edit context. |
453 | 453 | * @return string |
454 | 454 | */ |
455 | - public function get_due_date( $context = 'view' ) { |
|
456 | - return $this->get_prop( 'due_date', $context ); |
|
455 | + public function get_due_date($context = 'view') { |
|
456 | + return $this->get_prop('due_date', $context); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | /** |
@@ -463,8 +463,8 @@ discard block |
||
463 | 463 | * @param string $context View or edit context. |
464 | 464 | * @return string |
465 | 465 | */ |
466 | - public function get_date_due( $context = 'view' ) { |
|
467 | - return $this->get_due_date( $context ); |
|
466 | + public function get_date_due($context = 'view') { |
|
467 | + return $this->get_due_date($context); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
@@ -474,11 +474,11 @@ discard block |
||
474 | 474 | * @param string $context View or edit context. |
475 | 475 | * @return string |
476 | 476 | */ |
477 | - public function get_due_date_gmt( $context = 'view' ) { |
|
478 | - $date = $this->get_due_date( $context ); |
|
477 | + public function get_due_date_gmt($context = 'view') { |
|
478 | + $date = $this->get_due_date($context); |
|
479 | 479 | |
480 | - if ( $date ) { |
|
481 | - $date = get_gmt_from_date( $date ); |
|
480 | + if ($date) { |
|
481 | + $date = get_gmt_from_date($date); |
|
482 | 482 | } |
483 | 483 | return $date; |
484 | 484 | } |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | * @param string $context View or edit context. |
491 | 491 | * @return string |
492 | 492 | */ |
493 | - public function get_gmt_date_due( $context = 'view' ) { |
|
494 | - return $this->get_due_date_gmt( $context ); |
|
493 | + public function get_gmt_date_due($context = 'view') { |
|
494 | + return $this->get_due_date_gmt($context); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | /** |
@@ -501,8 +501,8 @@ discard block |
||
501 | 501 | * @param string $context View or edit context. |
502 | 502 | * @return string |
503 | 503 | */ |
504 | - public function get_completed_date( $context = 'view' ) { |
|
505 | - return $this->get_prop( 'completed_date', $context ); |
|
504 | + public function get_completed_date($context = 'view') { |
|
505 | + return $this->get_prop('completed_date', $context); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -512,8 +512,8 @@ discard block |
||
512 | 512 | * @param string $context View or edit context. |
513 | 513 | * @return string |
514 | 514 | */ |
515 | - public function get_date_completed( $context = 'view' ) { |
|
516 | - return $this->get_completed_date( $context ); |
|
515 | + public function get_date_completed($context = 'view') { |
|
516 | + return $this->get_completed_date($context); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | /** |
@@ -523,11 +523,11 @@ discard block |
||
523 | 523 | * @param string $context View or edit context. |
524 | 524 | * @return string |
525 | 525 | */ |
526 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
527 | - $date = $this->get_completed_date( $context ); |
|
526 | + public function get_completed_date_gmt($context = 'view') { |
|
527 | + $date = $this->get_completed_date($context); |
|
528 | 528 | |
529 | - if ( $date ) { |
|
530 | - $date = get_gmt_from_date( $date ); |
|
529 | + if ($date) { |
|
530 | + $date = get_gmt_from_date($date); |
|
531 | 531 | } |
532 | 532 | return $date; |
533 | 533 | } |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | * @param string $context View or edit context. |
540 | 540 | * @return string |
541 | 541 | */ |
542 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
543 | - return $this->get_completed_date_gmt( $context ); |
|
542 | + public function get_gmt_completed_date($context = 'view') { |
|
543 | + return $this->get_completed_date_gmt($context); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -550,12 +550,12 @@ discard block |
||
550 | 550 | * @param string $context View or edit context. |
551 | 551 | * @return string |
552 | 552 | */ |
553 | - public function get_number( $context = 'view' ) { |
|
554 | - $number = $this->get_prop( 'number', $context ); |
|
553 | + public function get_number($context = 'view') { |
|
554 | + $number = $this->get_prop('number', $context); |
|
555 | 555 | |
556 | - if ( empty( $number ) ) { |
|
556 | + if (empty($number)) { |
|
557 | 557 | $number = $this->generate_number(); |
558 | - $this->set_number( $this->generate_number() ); |
|
558 | + $this->set_number($this->generate_number()); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | return $number; |
@@ -569,8 +569,8 @@ discard block |
||
569 | 569 | public function maybe_set_number() { |
570 | 570 | $number = $this->get_number(); |
571 | 571 | |
572 | - if ( empty( $number ) || $this->get_id() == $number ) { |
|
573 | - $this->set_number( $this->generate_number() ); |
|
572 | + if (empty($number) || $this->get_id() == $number) { |
|
573 | + $this->set_number($this->generate_number()); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | } |
@@ -582,8 +582,8 @@ discard block |
||
582 | 582 | * @param string $context View or edit context. |
583 | 583 | * @return string |
584 | 584 | */ |
585 | - public function get_key( $context = 'view' ) { |
|
586 | - return $this->get_prop( 'key', $context ); |
|
585 | + public function get_key($context = 'view') { |
|
586 | + return $this->get_prop('key', $context); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
@@ -594,9 +594,9 @@ discard block |
||
594 | 594 | public function maybe_set_key() { |
595 | 595 | $key = $this->get_key(); |
596 | 596 | |
597 | - if ( empty( $key ) ) { |
|
598 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
599 | - $this->set_key( $key ); |
|
597 | + if (empty($key)) { |
|
598 | + $key = $this->generate_key($this->get_type() . '_'); |
|
599 | + $this->set_key($key); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | } |
@@ -608,8 +608,8 @@ discard block |
||
608 | 608 | * @param string $context View or edit context. |
609 | 609 | * @return string |
610 | 610 | */ |
611 | - public function get_type( $context = 'view' ) { |
|
612 | - return $this->get_prop( 'type', $context ); |
|
611 | + public function get_type($context = 'view') { |
|
612 | + return $this->get_prop('type', $context); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | * @return string |
620 | 620 | */ |
621 | 621 | public function get_invoice_quote_type() { |
622 | - return getpaid_get_post_type_label( $this->get_post_type(), false ); |
|
622 | + return getpaid_get_post_type_label($this->get_post_type(), false); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | /** |
@@ -629,8 +629,8 @@ discard block |
||
629 | 629 | * @param string $context View or edit context. |
630 | 630 | * @return string |
631 | 631 | */ |
632 | - public function get_label( $context = 'view' ) { |
|
633 | - return getpaid_get_post_type_label( $this->get_post_type( $context ), false ); |
|
632 | + public function get_label($context = 'view') { |
|
633 | + return getpaid_get_post_type_label($this->get_post_type($context), false); |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | /** |
@@ -640,8 +640,8 @@ discard block |
||
640 | 640 | * @param string $context View or edit context. |
641 | 641 | * @return string |
642 | 642 | */ |
643 | - public function get_post_type( $context = 'view' ) { |
|
644 | - return $this->get_prop( 'post_type', $context ); |
|
643 | + public function get_post_type($context = 'view') { |
|
644 | + return $this->get_prop('post_type', $context); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
@@ -651,8 +651,8 @@ discard block |
||
651 | 651 | * @param string $context View or edit context. |
652 | 652 | * @return string |
653 | 653 | */ |
654 | - public function get_mode( $context = 'view' ) { |
|
655 | - return $this->get_prop( 'mode', $context ); |
|
654 | + public function get_mode($context = 'view') { |
|
655 | + return $this->get_prop('mode', $context); |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | /** |
@@ -662,13 +662,13 @@ discard block |
||
662 | 662 | * @param string $context View or edit context. |
663 | 663 | * @return string |
664 | 664 | */ |
665 | - public function get_path( $context = 'view' ) { |
|
666 | - $path = $this->get_prop( 'path', $context ); |
|
665 | + public function get_path($context = 'view') { |
|
666 | + $path = $this->get_prop('path', $context); |
|
667 | 667 | $prefix = $this->get_type(); |
668 | 668 | |
669 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
670 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
671 | - $this->set_path( $path ); |
|
669 | + if (0 !== strpos($path, $prefix)) { |
|
670 | + $path = sanitize_title($prefix . '-' . $this->get_id()); |
|
671 | + $this->set_path($path); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | return $path; |
@@ -681,8 +681,8 @@ discard block |
||
681 | 681 | * @param string $context View or edit context. |
682 | 682 | * @return string |
683 | 683 | */ |
684 | - public function get_name( $context = 'view' ) { |
|
685 | - return $this->get_prop( 'title', $context ); |
|
684 | + public function get_name($context = 'view') { |
|
685 | + return $this->get_prop('title', $context); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | /** |
@@ -692,8 +692,8 @@ discard block |
||
692 | 692 | * @param string $context View or edit context. |
693 | 693 | * @return string |
694 | 694 | */ |
695 | - public function get_title( $context = 'view' ) { |
|
696 | - return $this->get_name( $context ); |
|
695 | + public function get_title($context = 'view') { |
|
696 | + return $this->get_name($context); |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | /** |
@@ -703,8 +703,8 @@ discard block |
||
703 | 703 | * @param string $context View or edit context. |
704 | 704 | * @return string |
705 | 705 | */ |
706 | - public function get_description( $context = 'view' ) { |
|
707 | - return $this->get_prop( 'description', $context ); |
|
706 | + public function get_description($context = 'view') { |
|
707 | + return $this->get_prop('description', $context); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | /** |
@@ -714,8 +714,8 @@ discard block |
||
714 | 714 | * @param string $context View or edit context. |
715 | 715 | * @return string |
716 | 716 | */ |
717 | - public function get_excerpt( $context = 'view' ) { |
|
718 | - return $this->get_description( $context ); |
|
717 | + public function get_excerpt($context = 'view') { |
|
718 | + return $this->get_description($context); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | /** |
@@ -725,8 +725,8 @@ discard block |
||
725 | 725 | * @param string $context View or edit context. |
726 | 726 | * @return string |
727 | 727 | */ |
728 | - public function get_summary( $context = 'view' ) { |
|
729 | - return $this->get_description( $context ); |
|
728 | + public function get_summary($context = 'view') { |
|
729 | + return $this->get_description($context); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | /** |
@@ -736,26 +736,26 @@ discard block |
||
736 | 736 | * @param string $context View or edit context. |
737 | 737 | * @return array |
738 | 738 | */ |
739 | - public function get_user_info( $context = 'view' ) { |
|
739 | + public function get_user_info($context = 'view') { |
|
740 | 740 | |
741 | 741 | $user_info = array( |
742 | - 'user_id' => $this->get_user_id( $context ), |
|
743 | - 'email' => $this->get_email( $context ), |
|
744 | - 'first_name' => $this->get_first_name( $context ), |
|
745 | - 'last_name' => $this->get_last_name( $context ), |
|
746 | - 'address' => $this->get_address( $context ), |
|
747 | - 'phone' => $this->get_phone( $context ), |
|
748 | - 'city' => $this->get_city( $context ), |
|
749 | - 'country' => $this->get_country( $context ), |
|
750 | - 'state' => $this->get_state( $context ), |
|
751 | - 'zip' => $this->get_zip( $context ), |
|
752 | - 'company' => $this->get_company( $context ), |
|
753 | - 'company_id' => $this->get_company_id( $context ), |
|
754 | - 'vat_number' => $this->get_vat_number( $context ), |
|
755 | - 'discount' => $this->get_discount_code( $context ), |
|
742 | + 'user_id' => $this->get_user_id($context), |
|
743 | + 'email' => $this->get_email($context), |
|
744 | + 'first_name' => $this->get_first_name($context), |
|
745 | + 'last_name' => $this->get_last_name($context), |
|
746 | + 'address' => $this->get_address($context), |
|
747 | + 'phone' => $this->get_phone($context), |
|
748 | + 'city' => $this->get_city($context), |
|
749 | + 'country' => $this->get_country($context), |
|
750 | + 'state' => $this->get_state($context), |
|
751 | + 'zip' => $this->get_zip($context), |
|
752 | + 'company' => $this->get_company($context), |
|
753 | + 'company_id' => $this->get_company_id($context), |
|
754 | + 'vat_number' => $this->get_vat_number($context), |
|
755 | + 'discount' => $this->get_discount_code($context), |
|
756 | 756 | ); |
757 | 757 | |
758 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
758 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
759 | 759 | |
760 | 760 | } |
761 | 761 | |
@@ -766,8 +766,8 @@ discard block |
||
766 | 766 | * @param string $context View or edit context. |
767 | 767 | * @return int |
768 | 768 | */ |
769 | - public function get_author( $context = 'view' ) { |
|
770 | - return (int) $this->get_prop( 'author', $context ); |
|
769 | + public function get_author($context = 'view') { |
|
770 | + return (int) $this->get_prop('author', $context); |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | /** |
@@ -777,8 +777,8 @@ discard block |
||
777 | 777 | * @param string $context View or edit context. |
778 | 778 | * @return int |
779 | 779 | */ |
780 | - public function get_user_id( $context = 'view' ) { |
|
781 | - return $this->get_author( $context ); |
|
780 | + public function get_user_id($context = 'view') { |
|
781 | + return $this->get_author($context); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | /** |
@@ -788,8 +788,8 @@ discard block |
||
788 | 788 | * @param string $context View or edit context. |
789 | 789 | * @return int |
790 | 790 | */ |
791 | - public function get_customer_id( $context = 'view' ) { |
|
792 | - return $this->get_author( $context ); |
|
791 | + public function get_customer_id($context = 'view') { |
|
792 | + return $this->get_author($context); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | /** |
@@ -799,8 +799,8 @@ discard block |
||
799 | 799 | * @param string $context View or edit context. |
800 | 800 | * @return string |
801 | 801 | */ |
802 | - public function get_ip( $context = 'view' ) { |
|
803 | - return $this->get_prop( 'user_ip', $context ); |
|
802 | + public function get_ip($context = 'view') { |
|
803 | + return $this->get_prop('user_ip', $context); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | /** |
@@ -810,8 +810,8 @@ discard block |
||
810 | 810 | * @param string $context View or edit context. |
811 | 811 | * @return string |
812 | 812 | */ |
813 | - public function get_user_ip( $context = 'view' ) { |
|
814 | - return $this->get_ip( $context ); |
|
813 | + public function get_user_ip($context = 'view') { |
|
814 | + return $this->get_ip($context); |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | /** |
@@ -821,8 +821,8 @@ discard block |
||
821 | 821 | * @param string $context View or edit context. |
822 | 822 | * @return string |
823 | 823 | */ |
824 | - public function get_customer_ip( $context = 'view' ) { |
|
825 | - return $this->get_ip( $context ); |
|
824 | + public function get_customer_ip($context = 'view') { |
|
825 | + return $this->get_ip($context); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -832,8 +832,8 @@ discard block |
||
832 | 832 | * @param string $context View or edit context. |
833 | 833 | * @return string |
834 | 834 | */ |
835 | - public function get_first_name( $context = 'view' ) { |
|
836 | - return $this->get_prop( 'first_name', $context ); |
|
835 | + public function get_first_name($context = 'view') { |
|
836 | + return $this->get_prop('first_name', $context); |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | /** |
@@ -843,8 +843,8 @@ discard block |
||
843 | 843 | * @param string $context View or edit context. |
844 | 844 | * @return string |
845 | 845 | */ |
846 | - public function get_user_first_name( $context = 'view' ) { |
|
847 | - return $this->get_first_name( $context ); |
|
846 | + public function get_user_first_name($context = 'view') { |
|
847 | + return $this->get_first_name($context); |
|
848 | 848 | } |
849 | 849 | |
850 | 850 | /** |
@@ -854,8 +854,8 @@ discard block |
||
854 | 854 | * @param string $context View or edit context. |
855 | 855 | * @return string |
856 | 856 | */ |
857 | - public function get_customer_first_name( $context = 'view' ) { |
|
858 | - return $this->get_first_name( $context ); |
|
857 | + public function get_customer_first_name($context = 'view') { |
|
858 | + return $this->get_first_name($context); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | /** |
@@ -865,8 +865,8 @@ discard block |
||
865 | 865 | * @param string $context View or edit context. |
866 | 866 | * @return string |
867 | 867 | */ |
868 | - public function get_last_name( $context = 'view' ) { |
|
869 | - return $this->get_prop( 'last_name', $context ); |
|
868 | + public function get_last_name($context = 'view') { |
|
869 | + return $this->get_prop('last_name', $context); |
|
870 | 870 | } |
871 | 871 | |
872 | 872 | /** |
@@ -876,8 +876,8 @@ discard block |
||
876 | 876 | * @param string $context View or edit context. |
877 | 877 | * @return string |
878 | 878 | */ |
879 | - public function get_user_last_name( $context = 'view' ) { |
|
880 | - return $this->get_last_name( $context ); |
|
879 | + public function get_user_last_name($context = 'view') { |
|
880 | + return $this->get_last_name($context); |
|
881 | 881 | } |
882 | 882 | |
883 | 883 | /** |
@@ -887,8 +887,8 @@ discard block |
||
887 | 887 | * @param string $context View or edit context. |
888 | 888 | * @return string |
889 | 889 | */ |
890 | - public function get_customer_last_name( $context = 'view' ) { |
|
891 | - return $this->get_last_name( $context ); |
|
890 | + public function get_customer_last_name($context = 'view') { |
|
891 | + return $this->get_last_name($context); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | /** |
@@ -898,22 +898,22 @@ discard block |
||
898 | 898 | * @param string $context View or edit context. |
899 | 899 | * @return string |
900 | 900 | */ |
901 | - public function get_full_name( $context = 'view' ) { |
|
902 | - $name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
901 | + public function get_full_name($context = 'view') { |
|
902 | + $name = trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
903 | 903 | |
904 | - if ( ! $name ) { |
|
905 | - $user = get_userdata( $this->get_author( $context ) ); |
|
904 | + if (!$name) { |
|
905 | + $user = get_userdata($this->get_author($context)); |
|
906 | 906 | |
907 | - if ( $user ) { |
|
907 | + if ($user) { |
|
908 | 908 | $name = $user->display_name; |
909 | 909 | } |
910 | 910 | } |
911 | 911 | |
912 | - if ( ! $name ) { |
|
913 | - $name = $this->get_email( $context ); |
|
912 | + if (!$name) { |
|
913 | + $name = $this->get_email($context); |
|
914 | 914 | } |
915 | 915 | |
916 | - return apply_filters( 'wpinv_invoice_user_full_name', $name, $this ); |
|
916 | + return apply_filters('wpinv_invoice_user_full_name', $name, $this); |
|
917 | 917 | } |
918 | 918 | |
919 | 919 | /** |
@@ -923,8 +923,8 @@ discard block |
||
923 | 923 | * @param string $context View or edit context. |
924 | 924 | * @return string |
925 | 925 | */ |
926 | - public function get_user_full_name( $context = 'view' ) { |
|
927 | - return $this->get_full_name( $context ); |
|
926 | + public function get_user_full_name($context = 'view') { |
|
927 | + return $this->get_full_name($context); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | /** |
@@ -934,8 +934,8 @@ discard block |
||
934 | 934 | * @param string $context View or edit context. |
935 | 935 | * @return string |
936 | 936 | */ |
937 | - public function get_customer_full_name( $context = 'view' ) { |
|
938 | - return $this->get_full_name( $context ); |
|
937 | + public function get_customer_full_name($context = 'view') { |
|
938 | + return $this->get_full_name($context); |
|
939 | 939 | } |
940 | 940 | |
941 | 941 | /** |
@@ -945,8 +945,8 @@ discard block |
||
945 | 945 | * @param string $context View or edit context. |
946 | 946 | * @return string |
947 | 947 | */ |
948 | - public function get_phone( $context = 'view' ) { |
|
949 | - return $this->get_prop( 'phone', $context ); |
|
948 | + public function get_phone($context = 'view') { |
|
949 | + return $this->get_prop('phone', $context); |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | /** |
@@ -956,8 +956,8 @@ discard block |
||
956 | 956 | * @param string $context View or edit context. |
957 | 957 | * @return string |
958 | 958 | */ |
959 | - public function get_phone_number( $context = 'view' ) { |
|
960 | - return $this->get_phone( $context ); |
|
959 | + public function get_phone_number($context = 'view') { |
|
960 | + return $this->get_phone($context); |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | /** |
@@ -967,8 +967,8 @@ discard block |
||
967 | 967 | * @param string $context View or edit context. |
968 | 968 | * @return string |
969 | 969 | */ |
970 | - public function get_user_phone( $context = 'view' ) { |
|
971 | - return $this->get_phone( $context ); |
|
970 | + public function get_user_phone($context = 'view') { |
|
971 | + return $this->get_phone($context); |
|
972 | 972 | } |
973 | 973 | |
974 | 974 | /** |
@@ -978,8 +978,8 @@ discard block |
||
978 | 978 | * @param string $context View or edit context. |
979 | 979 | * @return string |
980 | 980 | */ |
981 | - public function get_customer_phone( $context = 'view' ) { |
|
982 | - return $this->get_phone( $context ); |
|
981 | + public function get_customer_phone($context = 'view') { |
|
982 | + return $this->get_phone($context); |
|
983 | 983 | } |
984 | 984 | |
985 | 985 | /** |
@@ -989,8 +989,8 @@ discard block |
||
989 | 989 | * @param string $context View or edit context. |
990 | 990 | * @return string |
991 | 991 | */ |
992 | - public function get_email( $context = 'view' ) { |
|
993 | - return $this->get_prop( 'email', $context ); |
|
992 | + public function get_email($context = 'view') { |
|
993 | + return $this->get_prop('email', $context); |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | /** |
@@ -1000,8 +1000,8 @@ discard block |
||
1000 | 1000 | * @param string $context View or edit context. |
1001 | 1001 | * @return string |
1002 | 1002 | */ |
1003 | - public function get_email_address( $context = 'view' ) { |
|
1004 | - return $this->get_email( $context ); |
|
1003 | + public function get_email_address($context = 'view') { |
|
1004 | + return $this->get_email($context); |
|
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | /** |
@@ -1011,8 +1011,8 @@ discard block |
||
1011 | 1011 | * @param string $context View or edit context. |
1012 | 1012 | * @return string |
1013 | 1013 | */ |
1014 | - public function get_user_email( $context = 'view' ) { |
|
1015 | - return $this->get_email( $context ); |
|
1014 | + public function get_user_email($context = 'view') { |
|
1015 | + return $this->get_email($context); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | /** |
@@ -1022,8 +1022,8 @@ discard block |
||
1022 | 1022 | * @param string $context View or edit context. |
1023 | 1023 | * @return string |
1024 | 1024 | */ |
1025 | - public function get_customer_email( $context = 'view' ) { |
|
1026 | - return $this->get_email( $context ); |
|
1025 | + public function get_customer_email($context = 'view') { |
|
1026 | + return $this->get_email($context); |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | /** |
@@ -1033,9 +1033,9 @@ discard block |
||
1033 | 1033 | * @param string $context View or edit context. |
1034 | 1034 | * @return string |
1035 | 1035 | */ |
1036 | - public function get_country( $context = 'view' ) { |
|
1037 | - $country = $this->get_prop( 'country', $context ); |
|
1038 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
1036 | + public function get_country($context = 'view') { |
|
1037 | + $country = $this->get_prop('country', $context); |
|
1038 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | /** |
@@ -1045,8 +1045,8 @@ discard block |
||
1045 | 1045 | * @param string $context View or edit context. |
1046 | 1046 | * @return string |
1047 | 1047 | */ |
1048 | - public function get_user_country( $context = 'view' ) { |
|
1049 | - return $this->get_country( $context ); |
|
1048 | + public function get_user_country($context = 'view') { |
|
1049 | + return $this->get_country($context); |
|
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | /** |
@@ -1056,8 +1056,8 @@ discard block |
||
1056 | 1056 | * @param string $context View or edit context. |
1057 | 1057 | * @return string |
1058 | 1058 | */ |
1059 | - public function get_customer_country( $context = 'view' ) { |
|
1060 | - return $this->get_country( $context ); |
|
1059 | + public function get_customer_country($context = 'view') { |
|
1060 | + return $this->get_country($context); |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | /** |
@@ -1067,9 +1067,9 @@ discard block |
||
1067 | 1067 | * @param string $context View or edit context. |
1068 | 1068 | * @return string |
1069 | 1069 | */ |
1070 | - public function get_state( $context = 'view' ) { |
|
1071 | - $state = $this->get_prop( 'state', $context ); |
|
1072 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
1070 | + public function get_state($context = 'view') { |
|
1071 | + $state = $this->get_prop('state', $context); |
|
1072 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | /** |
@@ -1079,8 +1079,8 @@ discard block |
||
1079 | 1079 | * @param string $context View or edit context. |
1080 | 1080 | * @return string |
1081 | 1081 | */ |
1082 | - public function get_user_state( $context = 'view' ) { |
|
1083 | - return $this->get_state( $context ); |
|
1082 | + public function get_user_state($context = 'view') { |
|
1083 | + return $this->get_state($context); |
|
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | /** |
@@ -1090,8 +1090,8 @@ discard block |
||
1090 | 1090 | * @param string $context View or edit context. |
1091 | 1091 | * @return string |
1092 | 1092 | */ |
1093 | - public function get_customer_state( $context = 'view' ) { |
|
1094 | - return $this->get_state( $context ); |
|
1093 | + public function get_customer_state($context = 'view') { |
|
1094 | + return $this->get_state($context); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | /** |
@@ -1101,8 +1101,8 @@ discard block |
||
1101 | 1101 | * @param string $context View or edit context. |
1102 | 1102 | * @return string |
1103 | 1103 | */ |
1104 | - public function get_city( $context = 'view' ) { |
|
1105 | - return $this->get_prop( 'city', $context ); |
|
1104 | + public function get_city($context = 'view') { |
|
1105 | + return $this->get_prop('city', $context); |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | /** |
@@ -1112,8 +1112,8 @@ discard block |
||
1112 | 1112 | * @param string $context View or edit context. |
1113 | 1113 | * @return string |
1114 | 1114 | */ |
1115 | - public function get_user_city( $context = 'view' ) { |
|
1116 | - return $this->get_city( $context ); |
|
1115 | + public function get_user_city($context = 'view') { |
|
1116 | + return $this->get_city($context); |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | /** |
@@ -1123,8 +1123,8 @@ discard block |
||
1123 | 1123 | * @param string $context View or edit context. |
1124 | 1124 | * @return string |
1125 | 1125 | */ |
1126 | - public function get_customer_city( $context = 'view' ) { |
|
1127 | - return $this->get_city( $context ); |
|
1126 | + public function get_customer_city($context = 'view') { |
|
1127 | + return $this->get_city($context); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | /** |
@@ -1134,8 +1134,8 @@ discard block |
||
1134 | 1134 | * @param string $context View or edit context. |
1135 | 1135 | * @return string |
1136 | 1136 | */ |
1137 | - public function get_zip( $context = 'view' ) { |
|
1138 | - return $this->get_prop( 'zip', $context ); |
|
1137 | + public function get_zip($context = 'view') { |
|
1138 | + return $this->get_prop('zip', $context); |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | /** |
@@ -1145,8 +1145,8 @@ discard block |
||
1145 | 1145 | * @param string $context View or edit context. |
1146 | 1146 | * @return string |
1147 | 1147 | */ |
1148 | - public function get_user_zip( $context = 'view' ) { |
|
1149 | - return $this->get_zip( $context ); |
|
1148 | + public function get_user_zip($context = 'view') { |
|
1149 | + return $this->get_zip($context); |
|
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | /** |
@@ -1156,8 +1156,8 @@ discard block |
||
1156 | 1156 | * @param string $context View or edit context. |
1157 | 1157 | * @return string |
1158 | 1158 | */ |
1159 | - public function get_customer_zip( $context = 'view' ) { |
|
1160 | - return $this->get_zip( $context ); |
|
1159 | + public function get_customer_zip($context = 'view') { |
|
1160 | + return $this->get_zip($context); |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | /** |
@@ -1167,8 +1167,8 @@ discard block |
||
1167 | 1167 | * @param string $context View or edit context. |
1168 | 1168 | * @return string |
1169 | 1169 | */ |
1170 | - public function get_company( $context = 'view' ) { |
|
1171 | - return $this->get_prop( 'company', $context ); |
|
1170 | + public function get_company($context = 'view') { |
|
1171 | + return $this->get_prop('company', $context); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | /** |
@@ -1178,8 +1178,8 @@ discard block |
||
1178 | 1178 | * @param string $context View or edit context. |
1179 | 1179 | * @return string |
1180 | 1180 | */ |
1181 | - public function get_user_company( $context = 'view' ) { |
|
1182 | - return $this->get_company( $context ); |
|
1181 | + public function get_user_company($context = 'view') { |
|
1182 | + return $this->get_company($context); |
|
1183 | 1183 | } |
1184 | 1184 | |
1185 | 1185 | /** |
@@ -1189,8 +1189,8 @@ discard block |
||
1189 | 1189 | * @param string $context View or edit context. |
1190 | 1190 | * @return string |
1191 | 1191 | */ |
1192 | - public function get_customer_company( $context = 'view' ) { |
|
1193 | - return $this->get_company( $context ); |
|
1192 | + public function get_customer_company($context = 'view') { |
|
1193 | + return $this->get_company($context); |
|
1194 | 1194 | } |
1195 | 1195 | |
1196 | 1196 | /** |
@@ -1200,8 +1200,8 @@ discard block |
||
1200 | 1200 | * @param string $context View or edit context. |
1201 | 1201 | * @return string |
1202 | 1202 | */ |
1203 | - public function get_company_id( $context = 'view' ) { |
|
1204 | - return $this->get_prop( 'company_id', $context ); |
|
1203 | + public function get_company_id($context = 'view') { |
|
1204 | + return $this->get_prop('company_id', $context); |
|
1205 | 1205 | } |
1206 | 1206 | |
1207 | 1207 | /** |
@@ -1211,8 +1211,8 @@ discard block |
||
1211 | 1211 | * @param string $context View or edit context. |
1212 | 1212 | * @return string |
1213 | 1213 | */ |
1214 | - public function get_vat_number( $context = 'view' ) { |
|
1215 | - return $this->get_prop( 'vat_number', $context ); |
|
1214 | + public function get_vat_number($context = 'view') { |
|
1215 | + return $this->get_prop('vat_number', $context); |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | /** |
@@ -1222,8 +1222,8 @@ discard block |
||
1222 | 1222 | * @param string $context View or edit context. |
1223 | 1223 | * @return string |
1224 | 1224 | */ |
1225 | - public function get_user_vat_number( $context = 'view' ) { |
|
1226 | - return $this->get_vat_number( $context ); |
|
1225 | + public function get_user_vat_number($context = 'view') { |
|
1226 | + return $this->get_vat_number($context); |
|
1227 | 1227 | } |
1228 | 1228 | |
1229 | 1229 | /** |
@@ -1233,8 +1233,8 @@ discard block |
||
1233 | 1233 | * @param string $context View or edit context. |
1234 | 1234 | * @return string |
1235 | 1235 | */ |
1236 | - public function get_customer_vat_number( $context = 'view' ) { |
|
1237 | - return $this->get_vat_number( $context ); |
|
1236 | + public function get_customer_vat_number($context = 'view') { |
|
1237 | + return $this->get_vat_number($context); |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | /** |
@@ -1244,8 +1244,8 @@ discard block |
||
1244 | 1244 | * @param string $context View or edit context. |
1245 | 1245 | * @return string |
1246 | 1246 | */ |
1247 | - public function get_vat_rate( $context = 'view' ) { |
|
1248 | - return $this->get_prop( 'vat_rate', $context ); |
|
1247 | + public function get_vat_rate($context = 'view') { |
|
1248 | + return $this->get_prop('vat_rate', $context); |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | /** |
@@ -1255,8 +1255,8 @@ discard block |
||
1255 | 1255 | * @param string $context View or edit context. |
1256 | 1256 | * @return string |
1257 | 1257 | */ |
1258 | - public function get_user_vat_rate( $context = 'view' ) { |
|
1259 | - return $this->get_vat_rate( $context ); |
|
1258 | + public function get_user_vat_rate($context = 'view') { |
|
1259 | + return $this->get_vat_rate($context); |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | /** |
@@ -1266,8 +1266,8 @@ discard block |
||
1266 | 1266 | * @param string $context View or edit context. |
1267 | 1267 | * @return string |
1268 | 1268 | */ |
1269 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
1270 | - return $this->get_vat_rate( $context ); |
|
1269 | + public function get_customer_vat_rate($context = 'view') { |
|
1270 | + return $this->get_vat_rate($context); |
|
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | /** |
@@ -1277,8 +1277,8 @@ discard block |
||
1277 | 1277 | * @param string $context View or edit context. |
1278 | 1278 | * @return string |
1279 | 1279 | */ |
1280 | - public function get_address( $context = 'view' ) { |
|
1281 | - return $this->get_prop( 'address', $context ); |
|
1280 | + public function get_address($context = 'view') { |
|
1281 | + return $this->get_prop('address', $context); |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | 1284 | /** |
@@ -1288,8 +1288,8 @@ discard block |
||
1288 | 1288 | * @param string $context View or edit context. |
1289 | 1289 | * @return string |
1290 | 1290 | */ |
1291 | - public function get_user_address( $context = 'view' ) { |
|
1292 | - return $this->get_address( $context ); |
|
1291 | + public function get_user_address($context = 'view') { |
|
1292 | + return $this->get_address($context); |
|
1293 | 1293 | } |
1294 | 1294 | |
1295 | 1295 | /** |
@@ -1299,8 +1299,8 @@ discard block |
||
1299 | 1299 | * @param string $context View or edit context. |
1300 | 1300 | * @return string |
1301 | 1301 | */ |
1302 | - public function get_customer_address( $context = 'view' ) { |
|
1303 | - return $this->get_address( $context ); |
|
1302 | + public function get_customer_address($context = 'view') { |
|
1303 | + return $this->get_address($context); |
|
1304 | 1304 | } |
1305 | 1305 | |
1306 | 1306 | /** |
@@ -1310,8 +1310,8 @@ discard block |
||
1310 | 1310 | * @param string $context View or edit context. |
1311 | 1311 | * @return bool |
1312 | 1312 | */ |
1313 | - public function get_is_viewed( $context = 'view' ) { |
|
1314 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
1313 | + public function get_is_viewed($context = 'view') { |
|
1314 | + return (bool) $this->get_prop('is_viewed', $context); |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | /** |
@@ -1321,8 +1321,8 @@ discard block |
||
1321 | 1321 | * @param string $context View or edit context. |
1322 | 1322 | * @return bool |
1323 | 1323 | */ |
1324 | - public function get_email_cc( $context = 'view' ) { |
|
1325 | - return $this->get_prop( 'email_cc', $context ); |
|
1324 | + public function get_email_cc($context = 'view') { |
|
1325 | + return $this->get_prop('email_cc', $context); |
|
1326 | 1326 | } |
1327 | 1327 | |
1328 | 1328 | /** |
@@ -1332,8 +1332,8 @@ discard block |
||
1332 | 1332 | * @param string $context View or edit context. |
1333 | 1333 | * @return bool |
1334 | 1334 | */ |
1335 | - public function get_template( $context = 'view' ) { |
|
1336 | - return $this->get_prop( 'template', $context ); |
|
1335 | + public function get_template($context = 'view') { |
|
1336 | + return $this->get_prop('template', $context); |
|
1337 | 1337 | } |
1338 | 1338 | |
1339 | 1339 | /** |
@@ -1343,8 +1343,8 @@ discard block |
||
1343 | 1343 | * @param string $context View or edit context. |
1344 | 1344 | * @return bool |
1345 | 1345 | */ |
1346 | - public function get_created_via( $context = 'view' ) { |
|
1347 | - return $this->get_prop( 'created_via', $context ); |
|
1346 | + public function get_created_via($context = 'view') { |
|
1347 | + return $this->get_prop('created_via', $context); |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | /** |
@@ -1354,8 +1354,8 @@ discard block |
||
1354 | 1354 | * @param string $context View or edit context. |
1355 | 1355 | * @return bool |
1356 | 1356 | */ |
1357 | - public function get_address_confirmed( $context = 'view' ) { |
|
1358 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
1357 | + public function get_address_confirmed($context = 'view') { |
|
1358 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | /** |
@@ -1365,8 +1365,8 @@ discard block |
||
1365 | 1365 | * @param string $context View or edit context. |
1366 | 1366 | * @return bool |
1367 | 1367 | */ |
1368 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
1369 | - return $this->get_address_confirmed( $context ); |
|
1368 | + public function get_user_address_confirmed($context = 'view') { |
|
1369 | + return $this->get_address_confirmed($context); |
|
1370 | 1370 | } |
1371 | 1371 | |
1372 | 1372 | /** |
@@ -1376,8 +1376,8 @@ discard block |
||
1376 | 1376 | * @param string $context View or edit context. |
1377 | 1377 | * @return bool |
1378 | 1378 | */ |
1379 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
1380 | - return $this->get_address_confirmed( $context ); |
|
1379 | + public function get_customer_address_confirmed($context = 'view') { |
|
1380 | + return $this->get_address_confirmed($context); |
|
1381 | 1381 | } |
1382 | 1382 | |
1383 | 1383 | /** |
@@ -1388,8 +1388,8 @@ discard block |
||
1388 | 1388 | */ |
1389 | 1389 | public function get_shipping_address() { |
1390 | 1390 | |
1391 | - $shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true ); |
|
1392 | - return is_array( $shipping_address ) ? $shipping_address : false; |
|
1391 | + $shipping_address = get_post_meta($this->get_id(), 'shipping_address', true); |
|
1392 | + return is_array($shipping_address) ? $shipping_address : false; |
|
1393 | 1393 | } |
1394 | 1394 | |
1395 | 1395 | /** |
@@ -1406,17 +1406,17 @@ discard block |
||
1406 | 1406 | * @param string $context View or edit context. |
1407 | 1407 | * @return float |
1408 | 1408 | */ |
1409 | - public function get_shipping( $context = 'view' ) { |
|
1409 | + public function get_shipping($context = 'view') { |
|
1410 | 1410 | |
1411 | - if ( $context = 'view' ) { |
|
1412 | - return floatval( $this->get_prop( 'shipping', $context ) ); |
|
1411 | + if ($context = 'view') { |
|
1412 | + return floatval($this->get_prop('shipping', $context)); |
|
1413 | 1413 | } |
1414 | 1414 | |
1415 | - return $this->get_prop( 'shipping', $context ); |
|
1415 | + return $this->get_prop('shipping', $context); |
|
1416 | 1416 | } |
1417 | 1417 | |
1418 | 1418 | public function has_shipping() { |
1419 | - return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' ); |
|
1419 | + return defined('GETPAID_SHIPPING_CALCULATOR_VERSION') && null !== $this->get_prop('shipping', 'edit'); |
|
1420 | 1420 | } |
1421 | 1421 | |
1422 | 1422 | /** |
@@ -1426,12 +1426,12 @@ discard block |
||
1426 | 1426 | * @param string $context View or edit context. |
1427 | 1427 | * @return float |
1428 | 1428 | */ |
1429 | - public function get_subtotal( $context = 'view' ) { |
|
1430 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
1429 | + public function get_subtotal($context = 'view') { |
|
1430 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
1431 | 1431 | |
1432 | 1432 | // Backwards compatibility. |
1433 | - if ( is_bool( $context ) && $context ) { |
|
1434 | - return wpinv_price( $subtotal, $this->get_currency() ); |
|
1433 | + if (is_bool($context) && $context) { |
|
1434 | + return wpinv_price($subtotal, $this->get_currency()); |
|
1435 | 1435 | } |
1436 | 1436 | |
1437 | 1437 | return $subtotal; |
@@ -1444,8 +1444,8 @@ discard block |
||
1444 | 1444 | * @param string $context View or edit context. |
1445 | 1445 | * @return float |
1446 | 1446 | */ |
1447 | - public function get_total_discount( $context = 'view' ) { |
|
1448 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) ); |
|
1447 | + public function get_total_discount($context = 'view') { |
|
1448 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context))); |
|
1449 | 1449 | } |
1450 | 1450 | |
1451 | 1451 | /** |
@@ -1455,18 +1455,18 @@ discard block |
||
1455 | 1455 | * @param string $context View or edit context. |
1456 | 1456 | * @return float |
1457 | 1457 | */ |
1458 | - public function get_total_tax( $context = 'view' ) { |
|
1459 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) ); |
|
1458 | + public function get_total_tax($context = 'view') { |
|
1459 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context))); |
|
1460 | 1460 | } |
1461 | 1461 | |
1462 | 1462 | /** |
1463 | 1463 | * @deprecated |
1464 | 1464 | */ |
1465 | - public function get_final_tax( $currency = false ) { |
|
1465 | + public function get_final_tax($currency = false) { |
|
1466 | 1466 | $tax = $this->get_total_tax(); |
1467 | 1467 | |
1468 | - if ( $currency ) { |
|
1469 | - return wpinv_price( $tax, $this->get_currency() ); |
|
1468 | + if ($currency) { |
|
1469 | + return wpinv_price($tax, $this->get_currency()); |
|
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | return $tax; |
@@ -1479,8 +1479,8 @@ discard block |
||
1479 | 1479 | * @param string $context View or edit context. |
1480 | 1480 | * @return float |
1481 | 1481 | */ |
1482 | - public function get_total_fees( $context = 'view' ) { |
|
1483 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) ); |
|
1482 | + public function get_total_fees($context = 'view') { |
|
1483 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context))); |
|
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | /** |
@@ -1490,8 +1490,8 @@ discard block |
||
1490 | 1490 | * @param string $context View or edit context. |
1491 | 1491 | * @return float |
1492 | 1492 | */ |
1493 | - public function get_fees_total( $context = 'view' ) { |
|
1494 | - return $this->get_total_fees( $context ); |
|
1493 | + public function get_fees_total($context = 'view') { |
|
1494 | + return $this->get_total_fees($context); |
|
1495 | 1495 | } |
1496 | 1496 | |
1497 | 1497 | /** |
@@ -1500,14 +1500,14 @@ discard block |
||
1500 | 1500 | * @since 1.0.19 |
1501 | 1501 | * @return float |
1502 | 1502 | */ |
1503 | - public function get_total( $context = 'view' ) { |
|
1504 | - $total = $this->get_prop( 'total', $context ); |
|
1503 | + public function get_total($context = 'view') { |
|
1504 | + $total = $this->get_prop('total', $context); |
|
1505 | 1505 | |
1506 | - if ( $this->has_shipping() && $context == 'view' ) { |
|
1507 | - $total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context ); |
|
1506 | + if ($this->has_shipping() && $context == 'view') { |
|
1507 | + $total = $this->get_prop('total', $context) + $this->get_shipping($context); |
|
1508 | 1508 | } |
1509 | 1509 | |
1510 | - return wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
1510 | + return wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
1511 | 1511 | } |
1512 | 1512 | |
1513 | 1513 | /** |
@@ -1519,20 +1519,20 @@ discard block |
||
1519 | 1519 | public function get_non_recurring_total() { |
1520 | 1520 | |
1521 | 1521 | $subtotal = 0; |
1522 | - foreach ( $this->get_items() as $item ) { |
|
1523 | - if ( ! $item->is_recurring() ) { |
|
1522 | + foreach ($this->get_items() as $item) { |
|
1523 | + if (!$item->is_recurring()) { |
|
1524 | 1524 | $subtotal += $item->get_sub_total(); |
1525 | 1525 | } |
1526 | 1526 | } |
1527 | 1527 | |
1528 | - foreach ( $this->get_fees() as $fee ) { |
|
1529 | - if ( empty( $fee['recurring_fee'] ) ) { |
|
1530 | - $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
1528 | + foreach ($this->get_fees() as $fee) { |
|
1529 | + if (empty($fee['recurring_fee'])) { |
|
1530 | + $subtotal += wpinv_sanitize_amount($fee['initial_fee']); |
|
1531 | 1531 | } |
1532 | 1532 | } |
1533 | 1533 | |
1534 | - $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) ); |
|
1535 | - return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this ); |
|
1534 | + $subtotal = wpinv_round_amount(wpinv_sanitize_amount($subtotal)); |
|
1535 | + return apply_filters('wpinv_get_non_recurring_invoice_total', $subtotal, $this); |
|
1536 | 1536 | |
1537 | 1537 | } |
1538 | 1538 | |
@@ -1555,7 +1555,7 @@ discard block |
||
1555 | 1555 | */ |
1556 | 1556 | public function get_initial_total() { |
1557 | 1557 | |
1558 | - if ( empty( $this->totals ) ) { |
|
1558 | + if (empty($this->totals)) { |
|
1559 | 1559 | $this->recalculate_total(); |
1560 | 1560 | } |
1561 | 1561 | |
@@ -1565,12 +1565,12 @@ discard block |
||
1565 | 1565 | $subtotal = $this->totals['subtotal']['initial']; |
1566 | 1566 | $total = $tax + $fee - $discount + $subtotal; |
1567 | 1567 | |
1568 | - if ( 0 > $total ) { |
|
1568 | + if (0 > $total) { |
|
1569 | 1569 | $total = 0; |
1570 | 1570 | } |
1571 | 1571 | |
1572 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
1573 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
1572 | + $total = wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
1573 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
1574 | 1574 | } |
1575 | 1575 | |
1576 | 1576 | /** |
@@ -1582,7 +1582,7 @@ discard block |
||
1582 | 1582 | */ |
1583 | 1583 | public function get_recurring_total() { |
1584 | 1584 | |
1585 | - if ( empty( $this->totals ) ) { |
|
1585 | + if (empty($this->totals)) { |
|
1586 | 1586 | $this->recalculate_total(); |
1587 | 1587 | } |
1588 | 1588 | |
@@ -1592,12 +1592,12 @@ discard block |
||
1592 | 1592 | $subtotal = $this->totals['subtotal']['recurring']; |
1593 | 1593 | $total = $tax + $fee - $discount + $subtotal; |
1594 | 1594 | |
1595 | - if ( 0 > $total ) { |
|
1595 | + if (0 > $total) { |
|
1596 | 1596 | $total = 0; |
1597 | 1597 | } |
1598 | 1598 | |
1599 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
1600 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
1599 | + $total = wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
1600 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
1601 | 1601 | } |
1602 | 1602 | |
1603 | 1603 | /** |
@@ -1608,10 +1608,10 @@ discard block |
||
1608 | 1608 | * @param string $currency Whether to include the currency. |
1609 | 1609 | * @return float|string |
1610 | 1610 | */ |
1611 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
1611 | + public function get_recurring_details($field = '', $currency = false) { |
|
1612 | 1612 | |
1613 | 1613 | // Maybe recalculate totals. |
1614 | - if ( empty( $this->totals ) ) { |
|
1614 | + if (empty($this->totals)) { |
|
1615 | 1615 | $this->recalculate_total(); |
1616 | 1616 | } |
1617 | 1617 | |
@@ -1631,8 +1631,8 @@ discard block |
||
1631 | 1631 | $currency |
1632 | 1632 | ); |
1633 | 1633 | |
1634 | - if ( isset( $data[ $field ] ) ) { |
|
1635 | - return ( $currency ? wpinv_price( $data[ $field ], $this->get_currency() ) : $data[ $field ] ); |
|
1634 | + if (isset($data[$field])) { |
|
1635 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
1636 | 1636 | } |
1637 | 1637 | |
1638 | 1638 | return $data; |
@@ -1645,8 +1645,8 @@ discard block |
||
1645 | 1645 | * @param string $context View or edit context. |
1646 | 1646 | * @return array |
1647 | 1647 | */ |
1648 | - public function get_fees( $context = 'view' ) { |
|
1649 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
1648 | + public function get_fees($context = 'view') { |
|
1649 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
1650 | 1650 | } |
1651 | 1651 | |
1652 | 1652 | /** |
@@ -1656,8 +1656,8 @@ discard block |
||
1656 | 1656 | * @param string $context View or edit context. |
1657 | 1657 | * @return array |
1658 | 1658 | */ |
1659 | - public function get_discounts( $context = 'view' ) { |
|
1660 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
1659 | + public function get_discounts($context = 'view') { |
|
1660 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
1661 | 1661 | } |
1662 | 1662 | |
1663 | 1663 | /** |
@@ -1667,8 +1667,8 @@ discard block |
||
1667 | 1667 | * @param string $context View or edit context. |
1668 | 1668 | * @return array |
1669 | 1669 | */ |
1670 | - public function get_taxes( $context = 'view' ) { |
|
1671 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
1670 | + public function get_taxes($context = 'view') { |
|
1671 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
1672 | 1672 | } |
1673 | 1673 | |
1674 | 1674 | /** |
@@ -1678,8 +1678,8 @@ discard block |
||
1678 | 1678 | * @param string $context View or edit context. |
1679 | 1679 | * @return GetPaid_Form_Item[] |
1680 | 1680 | */ |
1681 | - public function get_items( $context = 'view' ) { |
|
1682 | - return $this->get_prop( 'items', $context ); |
|
1681 | + public function get_items($context = 'view') { |
|
1682 | + return $this->get_prop('items', $context); |
|
1683 | 1683 | } |
1684 | 1684 | |
1685 | 1685 | /** |
@@ -1689,7 +1689,7 @@ discard block |
||
1689 | 1689 | * @return string |
1690 | 1690 | */ |
1691 | 1691 | public function get_item_ids() { |
1692 | - return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) ); |
|
1692 | + return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id')); |
|
1693 | 1693 | } |
1694 | 1694 | |
1695 | 1695 | /** |
@@ -1699,8 +1699,8 @@ discard block |
||
1699 | 1699 | * @param string $context View or edit context. |
1700 | 1700 | * @return int |
1701 | 1701 | */ |
1702 | - public function get_payment_form( $context = 'view' ) { |
|
1703 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
1702 | + public function get_payment_form($context = 'view') { |
|
1703 | + return intval($this->get_prop('payment_form', $context)); |
|
1704 | 1704 | } |
1705 | 1705 | |
1706 | 1706 | /** |
@@ -1710,8 +1710,8 @@ discard block |
||
1710 | 1710 | * @param string $context View or edit context. |
1711 | 1711 | * @return string |
1712 | 1712 | */ |
1713 | - public function get_submission_id( $context = 'view' ) { |
|
1714 | - return $this->get_prop( 'submission_id', $context ); |
|
1713 | + public function get_submission_id($context = 'view') { |
|
1714 | + return $this->get_prop('submission_id', $context); |
|
1715 | 1715 | } |
1716 | 1716 | |
1717 | 1717 | /** |
@@ -1721,8 +1721,8 @@ discard block |
||
1721 | 1721 | * @param string $context View or edit context. |
1722 | 1722 | * @return string |
1723 | 1723 | */ |
1724 | - public function get_discount_code( $context = 'view' ) { |
|
1725 | - return $this->get_prop( 'discount_code', $context ); |
|
1724 | + public function get_discount_code($context = 'view') { |
|
1725 | + return $this->get_prop('discount_code', $context); |
|
1726 | 1726 | } |
1727 | 1727 | |
1728 | 1728 | /** |
@@ -1732,8 +1732,8 @@ discard block |
||
1732 | 1732 | * @param string $context View or edit context. |
1733 | 1733 | * @return string |
1734 | 1734 | */ |
1735 | - public function get_gateway( $context = 'view' ) { |
|
1736 | - return $this->get_prop( 'gateway', $context ); |
|
1735 | + public function get_gateway($context = 'view') { |
|
1736 | + return $this->get_prop('gateway', $context); |
|
1737 | 1737 | } |
1738 | 1738 | |
1739 | 1739 | /** |
@@ -1743,8 +1743,8 @@ discard block |
||
1743 | 1743 | * @return string |
1744 | 1744 | */ |
1745 | 1745 | public function get_gateway_title() { |
1746 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
1747 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
1746 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
1747 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
1748 | 1748 | } |
1749 | 1749 | |
1750 | 1750 | /** |
@@ -1754,8 +1754,8 @@ discard block |
||
1754 | 1754 | * @param string $context View or edit context. |
1755 | 1755 | * @return string |
1756 | 1756 | */ |
1757 | - public function get_transaction_id( $context = 'view' ) { |
|
1758 | - return $this->get_prop( 'transaction_id', $context ); |
|
1757 | + public function get_transaction_id($context = 'view') { |
|
1758 | + return $this->get_prop('transaction_id', $context); |
|
1759 | 1759 | } |
1760 | 1760 | |
1761 | 1761 | /** |
@@ -1765,9 +1765,9 @@ discard block |
||
1765 | 1765 | * @param string $context View or edit context. |
1766 | 1766 | * @return string |
1767 | 1767 | */ |
1768 | - public function get_currency( $context = 'view' ) { |
|
1769 | - $currency = $this->get_prop( 'currency', $context ); |
|
1770 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
1768 | + public function get_currency($context = 'view') { |
|
1769 | + $currency = $this->get_prop('currency', $context); |
|
1770 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
1771 | 1771 | } |
1772 | 1772 | |
1773 | 1773 | /** |
@@ -1777,8 +1777,8 @@ discard block |
||
1777 | 1777 | * @param string $context View or edit context. |
1778 | 1778 | * @return bool |
1779 | 1779 | */ |
1780 | - public function get_disable_taxes( $context = 'view' ) { |
|
1781 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
1780 | + public function get_disable_taxes($context = 'view') { |
|
1781 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
1782 | 1782 | } |
1783 | 1783 | |
1784 | 1784 | /** |
@@ -1788,8 +1788,8 @@ discard block |
||
1788 | 1788 | * @param string $context View or edit context. |
1789 | 1789 | * @return int |
1790 | 1790 | */ |
1791 | - public function get_subscription_id( $context = 'view' ) { |
|
1792 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
1791 | + public function get_subscription_id($context = 'view') { |
|
1792 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
1793 | 1793 | } |
1794 | 1794 | |
1795 | 1795 | /** |
@@ -1799,12 +1799,12 @@ discard block |
||
1799 | 1799 | * @param string $context View or edit context. |
1800 | 1800 | * @return int |
1801 | 1801 | */ |
1802 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
1803 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
1802 | + public function get_remote_subscription_id($context = 'view') { |
|
1803 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
1804 | 1804 | |
1805 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
1805 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
1806 | 1806 | $parent = $this->get_parent(); |
1807 | - return $parent->get_remote_subscription_id( $context ); |
|
1807 | + return $parent->get_remote_subscription_id($context); |
|
1808 | 1808 | } |
1809 | 1809 | |
1810 | 1810 | return $subscription_id; |
@@ -1817,20 +1817,20 @@ discard block |
||
1817 | 1817 | * @param string $context View or edit context. |
1818 | 1818 | * @return array |
1819 | 1819 | */ |
1820 | - public function get_payment_meta( $context = 'view' ) { |
|
1820 | + public function get_payment_meta($context = 'view') { |
|
1821 | 1821 | |
1822 | 1822 | return array( |
1823 | - 'price' => $this->get_total( $context ), |
|
1824 | - 'date' => $this->get_date_created( $context ), |
|
1825 | - 'user_email' => $this->get_email( $context ), |
|
1826 | - 'invoice_key' => $this->get_key( $context ), |
|
1827 | - 'currency' => $this->get_currency( $context ), |
|
1828 | - 'items' => $this->get_items( $context ), |
|
1829 | - 'user_info' => $this->get_user_info( $context ), |
|
1823 | + 'price' => $this->get_total($context), |
|
1824 | + 'date' => $this->get_date_created($context), |
|
1825 | + 'user_email' => $this->get_email($context), |
|
1826 | + 'invoice_key' => $this->get_key($context), |
|
1827 | + 'currency' => $this->get_currency($context), |
|
1828 | + 'items' => $this->get_items($context), |
|
1829 | + 'user_info' => $this->get_user_info($context), |
|
1830 | 1830 | 'cart_details' => $this->get_cart_details(), |
1831 | - 'status' => $this->get_status( $context ), |
|
1832 | - 'fees' => $this->get_fees( $context ), |
|
1833 | - 'taxes' => $this->get_taxes( $context ), |
|
1831 | + 'status' => $this->get_status($context), |
|
1832 | + 'fees' => $this->get_fees($context), |
|
1833 | + 'taxes' => $this->get_taxes($context), |
|
1834 | 1834 | ); |
1835 | 1835 | |
1836 | 1836 | } |
@@ -1845,9 +1845,9 @@ discard block |
||
1845 | 1845 | $items = $this->get_items(); |
1846 | 1846 | $cart_details = array(); |
1847 | 1847 | |
1848 | - foreach ( $items as $item ) { |
|
1848 | + foreach ($items as $item) { |
|
1849 | 1849 | $item->invoice_id = $this->get_id(); |
1850 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
1850 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
1851 | 1851 | } |
1852 | 1852 | |
1853 | 1853 | return $cart_details; |
@@ -1858,11 +1858,11 @@ discard block |
||
1858 | 1858 | * |
1859 | 1859 | * @return null|GetPaid_Form_Item|int |
1860 | 1860 | */ |
1861 | - public function get_recurring( $object = false ) { |
|
1861 | + public function get_recurring($object = false) { |
|
1862 | 1862 | |
1863 | 1863 | // Are we returning an object? |
1864 | - if ( $object ) { |
|
1865 | - return $this->get_item( $this->recurring_item ); |
|
1864 | + if ($object) { |
|
1865 | + return $this->get_item($this->recurring_item); |
|
1866 | 1866 | } |
1867 | 1867 | |
1868 | 1868 | return $this->recurring_item; |
@@ -1877,15 +1877,15 @@ discard block |
||
1877 | 1877 | public function get_subscription_name() { |
1878 | 1878 | |
1879 | 1879 | // Retrieve the recurring name |
1880 | - $item = $this->get_recurring( true ); |
|
1880 | + $item = $this->get_recurring(true); |
|
1881 | 1881 | |
1882 | 1882 | // Abort if it does not exist. |
1883 | - if ( empty( $item ) ) { |
|
1883 | + if (empty($item)) { |
|
1884 | 1884 | return ''; |
1885 | 1885 | } |
1886 | 1886 | |
1887 | 1887 | // Return the item name. |
1888 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
1888 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
1889 | 1889 | } |
1890 | 1890 | |
1891 | 1891 | /** |
@@ -1895,9 +1895,9 @@ discard block |
||
1895 | 1895 | * @return string |
1896 | 1896 | */ |
1897 | 1897 | public function get_view_url() { |
1898 | - $invoice_url = get_permalink( $this->get_id() ); |
|
1899 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
1900 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
1898 | + $invoice_url = get_permalink($this->get_id()); |
|
1899 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
1900 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
1901 | 1901 | } |
1902 | 1902 | |
1903 | 1903 | /** |
@@ -1906,25 +1906,25 @@ discard block |
||
1906 | 1906 | * @since 1.0.19 |
1907 | 1907 | * @return string |
1908 | 1908 | */ |
1909 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
1909 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
1910 | 1910 | |
1911 | 1911 | // Retrieve the checkout url. |
1912 | 1912 | $pay_url = wpinv_get_checkout_uri(); |
1913 | 1913 | |
1914 | 1914 | // Maybe force ssl. |
1915 | - if ( is_ssl() ) { |
|
1916 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
1915 | + if (is_ssl()) { |
|
1916 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
1917 | 1917 | } |
1918 | 1918 | |
1919 | 1919 | // Add the invoice key. |
1920 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
1920 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
1921 | 1921 | |
1922 | 1922 | // (Maybe?) add a secret |
1923 | - if ( $secret ) { |
|
1924 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
1923 | + if ($secret) { |
|
1924 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
1925 | 1925 | } |
1926 | 1926 | |
1927 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
1927 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
1928 | 1928 | } |
1929 | 1929 | |
1930 | 1930 | /** |
@@ -1939,14 +1939,14 @@ discard block |
||
1939 | 1939 | $receipt_url = wpinv_get_success_page_uri(); |
1940 | 1940 | |
1941 | 1941 | // Maybe force ssl. |
1942 | - if ( is_ssl() ) { |
|
1943 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
1942 | + if (is_ssl()) { |
|
1943 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
1944 | 1944 | } |
1945 | 1945 | |
1946 | 1946 | // Add the invoice key. |
1947 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
1947 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
1948 | 1948 | |
1949 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
1949 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
1950 | 1950 | } |
1951 | 1951 | |
1952 | 1952 | /** |
@@ -1956,7 +1956,7 @@ discard block |
||
1956 | 1956 | * @return string |
1957 | 1957 | */ |
1958 | 1958 | public function get_transaction_url() { |
1959 | - return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this ); |
|
1959 | + return apply_filters('getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this); |
|
1960 | 1960 | } |
1961 | 1961 | |
1962 | 1962 | /** |
@@ -1969,7 +1969,7 @@ discard block |
||
1969 | 1969 | |
1970 | 1970 | $type = $this->get_type(); |
1971 | 1971 | $status = "wpi-$type-pending"; |
1972 | - return str_replace( '-invoice', '', $status ); |
|
1972 | + return str_replace('-invoice', '', $status); |
|
1973 | 1973 | |
1974 | 1974 | } |
1975 | 1975 | |
@@ -1983,14 +1983,14 @@ discard block |
||
1983 | 1983 | * @param string $context View or edit context. |
1984 | 1984 | * @return mixed Value of the given invoice property (if set). |
1985 | 1985 | */ |
1986 | - public function get( $key, $context = 'view' ) { |
|
1986 | + public function get($key, $context = 'view') { |
|
1987 | 1987 | $method = "get_$key"; |
1988 | 1988 | |
1989 | - if ( is_callable( array( $this, $method ) ) ) { |
|
1990 | - return $this->$method( $context ); |
|
1989 | + if (is_callable(array($this, $method))) { |
|
1990 | + return $this->$method($context); |
|
1991 | 1991 | } |
1992 | 1992 | |
1993 | - return $this->get_prop( $key, $context ); |
|
1993 | + return $this->get_prop($key, $context); |
|
1994 | 1994 | } |
1995 | 1995 | |
1996 | 1996 | /* |
@@ -2013,11 +2013,11 @@ discard block |
||
2013 | 2013 | * @param mixed $value new value. |
2014 | 2014 | * @return mixed Value of the given invoice property (if set). |
2015 | 2015 | */ |
2016 | - public function set( $key, $value ) { |
|
2016 | + public function set($key, $value) { |
|
2017 | 2017 | |
2018 | 2018 | $setter = "set_$key"; |
2019 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
2020 | - $this->{$setter}( $value ); |
|
2019 | + if (is_callable(array($this, $setter))) { |
|
2020 | + $this->{$setter}($value); |
|
2021 | 2021 | } |
2022 | 2022 | |
2023 | 2023 | } |
@@ -2031,45 +2031,45 @@ discard block |
||
2031 | 2031 | * @param bool $manual_update Is this a manual status change?. |
2032 | 2032 | * @return array details of change. |
2033 | 2033 | */ |
2034 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
2034 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
2035 | 2035 | $old_status = $this->get_status(); |
2036 | 2036 | |
2037 | 2037 | $statuses = $this->get_all_statuses(); |
2038 | 2038 | |
2039 | - if ( isset( $statuses['draft'] ) ) { |
|
2040 | - unset( $statuses['draft'] ); |
|
2039 | + if (isset($statuses['draft'])) { |
|
2040 | + unset($statuses['draft']); |
|
2041 | 2041 | } |
2042 | 2042 | |
2043 | - $this->set_prop( 'status', $new_status ); |
|
2043 | + $this->set_prop('status', $new_status); |
|
2044 | 2044 | |
2045 | 2045 | // If setting the status, ensure it's set to a valid status. |
2046 | - if ( true === $this->object_read ) { |
|
2046 | + if (true === $this->object_read) { |
|
2047 | 2047 | |
2048 | 2048 | // Only allow valid new status. |
2049 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
2049 | + if (!array_key_exists($new_status, $statuses)) { |
|
2050 | 2050 | $new_status = $this->get_default_status(); |
2051 | 2051 | } |
2052 | 2052 | |
2053 | 2053 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
2054 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
2054 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
2055 | 2055 | $old_status = $this->get_default_status(); |
2056 | 2056 | } |
2057 | 2057 | |
2058 | 2058 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
2059 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
2059 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
2060 | 2060 | $old_status = 'wpi-pending'; |
2061 | 2061 | } |
2062 | 2062 | |
2063 | - if ( $old_status !== $new_status ) { |
|
2063 | + if ($old_status !== $new_status) { |
|
2064 | 2064 | $this->status_transition = array( |
2065 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
2065 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
2066 | 2066 | 'to' => $new_status, |
2067 | 2067 | 'note' => $note, |
2068 | 2068 | 'manual' => (bool) $manual_update, |
2069 | 2069 | ); |
2070 | 2070 | |
2071 | - if ( $manual_update ) { |
|
2072 | - do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status ); |
|
2071 | + if ($manual_update) { |
|
2072 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
2073 | 2073 | } |
2074 | 2074 | |
2075 | 2075 | $this->maybe_set_date_paid(); |
@@ -2093,8 +2093,8 @@ discard block |
||
2093 | 2093 | */ |
2094 | 2094 | public function maybe_set_date_paid() { |
2095 | 2095 | |
2096 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
2097 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
2096 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
2097 | + $this->set_date_completed(current_time('mysql')); |
|
2098 | 2098 | } |
2099 | 2099 | } |
2100 | 2100 | |
@@ -2103,11 +2103,11 @@ discard block |
||
2103 | 2103 | * |
2104 | 2104 | * @since 1.0.19 |
2105 | 2105 | */ |
2106 | - public function set_parent_id( $value ) { |
|
2107 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
2106 | + public function set_parent_id($value) { |
|
2107 | + if ($value && ($value === $this->get_id())) { |
|
2108 | 2108 | return; |
2109 | 2109 | } |
2110 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
2110 | + $this->set_prop('parent_id', absint($value)); |
|
2111 | 2111 | } |
2112 | 2112 | |
2113 | 2113 | /** |
@@ -2115,8 +2115,8 @@ discard block |
||
2115 | 2115 | * |
2116 | 2116 | * @since 1.0.19 |
2117 | 2117 | */ |
2118 | - public function set_version( $value ) { |
|
2119 | - $this->set_prop( 'version', $value ); |
|
2118 | + public function set_version($value) { |
|
2119 | + $this->set_prop('version', $value); |
|
2120 | 2120 | } |
2121 | 2121 | |
2122 | 2122 | /** |
@@ -2126,15 +2126,15 @@ discard block |
||
2126 | 2126 | * @param string $value Value to set. |
2127 | 2127 | * @return bool Whether or not the date was set. |
2128 | 2128 | */ |
2129 | - public function set_date_created( $value ) { |
|
2130 | - $date = strtotime( $value ); |
|
2129 | + public function set_date_created($value) { |
|
2130 | + $date = strtotime($value); |
|
2131 | 2131 | |
2132 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2133 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
2132 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2133 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
2134 | 2134 | return true; |
2135 | 2135 | } |
2136 | 2136 | |
2137 | - $this->set_prop( 'date_created', '' ); |
|
2137 | + $this->set_prop('date_created', ''); |
|
2138 | 2138 | return false; |
2139 | 2139 | |
2140 | 2140 | } |
@@ -2146,15 +2146,15 @@ discard block |
||
2146 | 2146 | * @param string $value Value to set. |
2147 | 2147 | * @return bool Whether or not the date was set. |
2148 | 2148 | */ |
2149 | - public function set_due_date( $value ) { |
|
2150 | - $date = strtotime( $value ); |
|
2149 | + public function set_due_date($value) { |
|
2150 | + $date = strtotime($value); |
|
2151 | 2151 | |
2152 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2153 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2152 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2153 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
2154 | 2154 | return true; |
2155 | 2155 | } |
2156 | 2156 | |
2157 | - $this->set_prop( 'due_date', '' ); |
|
2157 | + $this->set_prop('due_date', ''); |
|
2158 | 2158 | return false; |
2159 | 2159 | |
2160 | 2160 | } |
@@ -2165,8 +2165,8 @@ discard block |
||
2165 | 2165 | * @since 1.0.19 |
2166 | 2166 | * @param string $value New name. |
2167 | 2167 | */ |
2168 | - public function set_date_due( $value ) { |
|
2169 | - $this->set_due_date( $value ); |
|
2168 | + public function set_date_due($value) { |
|
2169 | + $this->set_due_date($value); |
|
2170 | 2170 | } |
2171 | 2171 | |
2172 | 2172 | /** |
@@ -2176,15 +2176,15 @@ discard block |
||
2176 | 2176 | * @param string $value Value to set. |
2177 | 2177 | * @return bool Whether or not the date was set. |
2178 | 2178 | */ |
2179 | - public function set_completed_date( $value ) { |
|
2180 | - $date = strtotime( $value ); |
|
2179 | + public function set_completed_date($value) { |
|
2180 | + $date = strtotime($value); |
|
2181 | 2181 | |
2182 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2183 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2182 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2183 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
2184 | 2184 | return true; |
2185 | 2185 | } |
2186 | 2186 | |
2187 | - $this->set_prop( 'completed_date', '' ); |
|
2187 | + $this->set_prop('completed_date', ''); |
|
2188 | 2188 | return false; |
2189 | 2189 | |
2190 | 2190 | } |
@@ -2195,8 +2195,8 @@ discard block |
||
2195 | 2195 | * @since 1.0.19 |
2196 | 2196 | * @param string $value New name. |
2197 | 2197 | */ |
2198 | - public function set_date_completed( $value ) { |
|
2199 | - $this->set_completed_date( $value ); |
|
2198 | + public function set_date_completed($value) { |
|
2199 | + $this->set_completed_date($value); |
|
2200 | 2200 | } |
2201 | 2201 | |
2202 | 2202 | /** |
@@ -2206,15 +2206,15 @@ discard block |
||
2206 | 2206 | * @param string $value Value to set. |
2207 | 2207 | * @return bool Whether or not the date was set. |
2208 | 2208 | */ |
2209 | - public function set_date_modified( $value ) { |
|
2210 | - $date = strtotime( $value ); |
|
2209 | + public function set_date_modified($value) { |
|
2210 | + $date = strtotime($value); |
|
2211 | 2211 | |
2212 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2213 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
2212 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2213 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
2214 | 2214 | return true; |
2215 | 2215 | } |
2216 | 2216 | |
2217 | - $this->set_prop( 'date_modified', '' ); |
|
2217 | + $this->set_prop('date_modified', ''); |
|
2218 | 2218 | return false; |
2219 | 2219 | |
2220 | 2220 | } |
@@ -2225,9 +2225,9 @@ discard block |
||
2225 | 2225 | * @since 1.0.19 |
2226 | 2226 | * @param string $value New number. |
2227 | 2227 | */ |
2228 | - public function set_number( $value ) { |
|
2229 | - $number = sanitize_text_field( $value ); |
|
2230 | - $this->set_prop( 'number', $number ); |
|
2228 | + public function set_number($value) { |
|
2229 | + $number = sanitize_text_field($value); |
|
2230 | + $this->set_prop('number', $number); |
|
2231 | 2231 | } |
2232 | 2232 | |
2233 | 2233 | /** |
@@ -2236,9 +2236,9 @@ discard block |
||
2236 | 2236 | * @since 1.0.19 |
2237 | 2237 | * @param string $value Type. |
2238 | 2238 | */ |
2239 | - public function set_type( $value ) { |
|
2240 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
2241 | - $this->set_prop( 'type', $type ); |
|
2239 | + public function set_type($value) { |
|
2240 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
2241 | + $this->set_prop('type', $type); |
|
2242 | 2242 | } |
2243 | 2243 | |
2244 | 2244 | /** |
@@ -2247,10 +2247,10 @@ discard block |
||
2247 | 2247 | * @since 1.0.19 |
2248 | 2248 | * @param string $value Post type. |
2249 | 2249 | */ |
2250 | - public function set_post_type( $value ) { |
|
2251 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
2252 | - $this->set_type( $value ); |
|
2253 | - $this->set_prop( 'post_type', $value ); |
|
2250 | + public function set_post_type($value) { |
|
2251 | + if (getpaid_is_invoice_post_type($value)) { |
|
2252 | + $this->set_type($value); |
|
2253 | + $this->set_prop('post_type', $value); |
|
2254 | 2254 | } |
2255 | 2255 | } |
2256 | 2256 | |
@@ -2260,9 +2260,9 @@ discard block |
||
2260 | 2260 | * @since 1.0.19 |
2261 | 2261 | * @param string $value New key. |
2262 | 2262 | */ |
2263 | - public function set_key( $value ) { |
|
2264 | - $key = sanitize_text_field( $value ); |
|
2265 | - $this->set_prop( 'key', $key ); |
|
2263 | + public function set_key($value) { |
|
2264 | + $key = sanitize_text_field($value); |
|
2265 | + $this->set_prop('key', $key); |
|
2266 | 2266 | } |
2267 | 2267 | |
2268 | 2268 | /** |
@@ -2271,9 +2271,9 @@ discard block |
||
2271 | 2271 | * @since 1.0.19 |
2272 | 2272 | * @param string $value mode. |
2273 | 2273 | */ |
2274 | - public function set_mode( $value ) { |
|
2275 | - if ( in_array( $value, array( 'live', 'test' ) ) ) { |
|
2276 | - $this->set_prop( 'mode', $value ); |
|
2274 | + public function set_mode($value) { |
|
2275 | + if (in_array($value, array('live', 'test'))) { |
|
2276 | + $this->set_prop('mode', $value); |
|
2277 | 2277 | } |
2278 | 2278 | } |
2279 | 2279 | |
@@ -2283,8 +2283,8 @@ discard block |
||
2283 | 2283 | * @since 1.0.19 |
2284 | 2284 | * @param string $value path. |
2285 | 2285 | */ |
2286 | - public function set_path( $value ) { |
|
2287 | - $this->set_prop( 'path', $value ); |
|
2286 | + public function set_path($value) { |
|
2287 | + $this->set_prop('path', $value); |
|
2288 | 2288 | } |
2289 | 2289 | |
2290 | 2290 | /** |
@@ -2293,9 +2293,9 @@ discard block |
||
2293 | 2293 | * @since 1.0.19 |
2294 | 2294 | * @param string $value New name. |
2295 | 2295 | */ |
2296 | - public function set_name( $value ) { |
|
2297 | - $name = sanitize_text_field( $value ); |
|
2298 | - $this->set_prop( 'name', $name ); |
|
2296 | + public function set_name($value) { |
|
2297 | + $name = sanitize_text_field($value); |
|
2298 | + $this->set_prop('name', $name); |
|
2299 | 2299 | } |
2300 | 2300 | |
2301 | 2301 | /** |
@@ -2304,8 +2304,8 @@ discard block |
||
2304 | 2304 | * @since 1.0.19 |
2305 | 2305 | * @param string $value New name. |
2306 | 2306 | */ |
2307 | - public function set_title( $value ) { |
|
2308 | - $this->set_name( $value ); |
|
2307 | + public function set_title($value) { |
|
2308 | + $this->set_name($value); |
|
2309 | 2309 | } |
2310 | 2310 | |
2311 | 2311 | /** |
@@ -2314,9 +2314,9 @@ discard block |
||
2314 | 2314 | * @since 1.0.19 |
2315 | 2315 | * @param string $value New description. |
2316 | 2316 | */ |
2317 | - public function set_description( $value ) { |
|
2318 | - $description = wp_kses_post( $value ); |
|
2319 | - $this->set_prop( 'description', $description ); |
|
2317 | + public function set_description($value) { |
|
2318 | + $description = wp_kses_post($value); |
|
2319 | + $this->set_prop('description', $description); |
|
2320 | 2320 | } |
2321 | 2321 | |
2322 | 2322 | /** |
@@ -2325,8 +2325,8 @@ discard block |
||
2325 | 2325 | * @since 1.0.19 |
2326 | 2326 | * @param string $value New description. |
2327 | 2327 | */ |
2328 | - public function set_excerpt( $value ) { |
|
2329 | - $this->set_description( $value ); |
|
2328 | + public function set_excerpt($value) { |
|
2329 | + $this->set_description($value); |
|
2330 | 2330 | } |
2331 | 2331 | |
2332 | 2332 | /** |
@@ -2335,8 +2335,8 @@ discard block |
||
2335 | 2335 | * @since 1.0.19 |
2336 | 2336 | * @param string $value New description. |
2337 | 2337 | */ |
2338 | - public function set_summary( $value ) { |
|
2339 | - $this->set_description( $value ); |
|
2338 | + public function set_summary($value) { |
|
2339 | + $this->set_description($value); |
|
2340 | 2340 | } |
2341 | 2341 | |
2342 | 2342 | /** |
@@ -2345,12 +2345,12 @@ discard block |
||
2345 | 2345 | * @since 1.0.19 |
2346 | 2346 | * @param int $value New author. |
2347 | 2347 | */ |
2348 | - public function set_author( $value ) { |
|
2349 | - $user = get_user_by( 'id', (int) $value ); |
|
2348 | + public function set_author($value) { |
|
2349 | + $user = get_user_by('id', (int) $value); |
|
2350 | 2350 | |
2351 | - if ( $user && $user->ID ) { |
|
2352 | - $this->set_prop( 'author', $user->ID ); |
|
2353 | - $this->set_prop( 'email', $user->user_email ); |
|
2351 | + if ($user && $user->ID) { |
|
2352 | + $this->set_prop('author', $user->ID); |
|
2353 | + $this->set_prop('email', $user->user_email); |
|
2354 | 2354 | } |
2355 | 2355 | |
2356 | 2356 | } |
@@ -2361,8 +2361,8 @@ discard block |
||
2361 | 2361 | * @since 1.0.19 |
2362 | 2362 | * @param int $value New user id. |
2363 | 2363 | */ |
2364 | - public function set_user_id( $value ) { |
|
2365 | - $this->set_author( $value ); |
|
2364 | + public function set_user_id($value) { |
|
2365 | + $this->set_author($value); |
|
2366 | 2366 | } |
2367 | 2367 | |
2368 | 2368 | /** |
@@ -2371,8 +2371,8 @@ discard block |
||
2371 | 2371 | * @since 1.0.19 |
2372 | 2372 | * @param int $value New user id. |
2373 | 2373 | */ |
2374 | - public function set_customer_id( $value ) { |
|
2375 | - $this->set_author( $value ); |
|
2374 | + public function set_customer_id($value) { |
|
2375 | + $this->set_author($value); |
|
2376 | 2376 | } |
2377 | 2377 | |
2378 | 2378 | /** |
@@ -2381,8 +2381,8 @@ discard block |
||
2381 | 2381 | * @since 1.0.19 |
2382 | 2382 | * @param string $value ip address. |
2383 | 2383 | */ |
2384 | - public function set_ip( $value ) { |
|
2385 | - $this->set_prop( 'ip', $value ); |
|
2384 | + public function set_ip($value) { |
|
2385 | + $this->set_prop('ip', $value); |
|
2386 | 2386 | } |
2387 | 2387 | |
2388 | 2388 | /** |
@@ -2391,8 +2391,8 @@ discard block |
||
2391 | 2391 | * @since 1.0.19 |
2392 | 2392 | * @param string $value ip address. |
2393 | 2393 | */ |
2394 | - public function set_user_ip( $value ) { |
|
2395 | - $this->set_ip( $value ); |
|
2394 | + public function set_user_ip($value) { |
|
2395 | + $this->set_ip($value); |
|
2396 | 2396 | } |
2397 | 2397 | |
2398 | 2398 | /** |
@@ -2401,8 +2401,8 @@ discard block |
||
2401 | 2401 | * @since 1.0.19 |
2402 | 2402 | * @param string $value first name. |
2403 | 2403 | */ |
2404 | - public function set_first_name( $value ) { |
|
2405 | - $this->set_prop( 'first_name', $value ); |
|
2404 | + public function set_first_name($value) { |
|
2405 | + $this->set_prop('first_name', $value); |
|
2406 | 2406 | } |
2407 | 2407 | |
2408 | 2408 | /** |
@@ -2411,8 +2411,8 @@ discard block |
||
2411 | 2411 | * @since 1.0.19 |
2412 | 2412 | * @param string $value first name. |
2413 | 2413 | */ |
2414 | - public function set_user_first_name( $value ) { |
|
2415 | - $this->set_first_name( $value ); |
|
2414 | + public function set_user_first_name($value) { |
|
2415 | + $this->set_first_name($value); |
|
2416 | 2416 | } |
2417 | 2417 | |
2418 | 2418 | /** |
@@ -2421,8 +2421,8 @@ discard block |
||
2421 | 2421 | * @since 1.0.19 |
2422 | 2422 | * @param string $value first name. |
2423 | 2423 | */ |
2424 | - public function set_customer_first_name( $value ) { |
|
2425 | - $this->set_first_name( $value ); |
|
2424 | + public function set_customer_first_name($value) { |
|
2425 | + $this->set_first_name($value); |
|
2426 | 2426 | } |
2427 | 2427 | |
2428 | 2428 | /** |
@@ -2431,8 +2431,8 @@ discard block |
||
2431 | 2431 | * @since 1.0.19 |
2432 | 2432 | * @param string $value last name. |
2433 | 2433 | */ |
2434 | - public function set_last_name( $value ) { |
|
2435 | - $this->set_prop( 'last_name', $value ); |
|
2434 | + public function set_last_name($value) { |
|
2435 | + $this->set_prop('last_name', $value); |
|
2436 | 2436 | } |
2437 | 2437 | |
2438 | 2438 | /** |
@@ -2441,8 +2441,8 @@ discard block |
||
2441 | 2441 | * @since 1.0.19 |
2442 | 2442 | * @param string $value last name. |
2443 | 2443 | */ |
2444 | - public function set_user_last_name( $value ) { |
|
2445 | - $this->set_last_name( $value ); |
|
2444 | + public function set_user_last_name($value) { |
|
2445 | + $this->set_last_name($value); |
|
2446 | 2446 | } |
2447 | 2447 | |
2448 | 2448 | /** |
@@ -2451,8 +2451,8 @@ discard block |
||
2451 | 2451 | * @since 1.0.19 |
2452 | 2452 | * @param string $value last name. |
2453 | 2453 | */ |
2454 | - public function set_customer_last_name( $value ) { |
|
2455 | - $this->set_last_name( $value ); |
|
2454 | + public function set_customer_last_name($value) { |
|
2455 | + $this->set_last_name($value); |
|
2456 | 2456 | } |
2457 | 2457 | |
2458 | 2458 | /** |
@@ -2461,8 +2461,8 @@ discard block |
||
2461 | 2461 | * @since 1.0.19 |
2462 | 2462 | * @param string $value phone. |
2463 | 2463 | */ |
2464 | - public function set_phone( $value ) { |
|
2465 | - $this->set_prop( 'phone', $value ); |
|
2464 | + public function set_phone($value) { |
|
2465 | + $this->set_prop('phone', $value); |
|
2466 | 2466 | } |
2467 | 2467 | |
2468 | 2468 | /** |
@@ -2471,8 +2471,8 @@ discard block |
||
2471 | 2471 | * @since 1.0.19 |
2472 | 2472 | * @param string $value phone. |
2473 | 2473 | */ |
2474 | - public function set_user_phone( $value ) { |
|
2475 | - $this->set_phone( $value ); |
|
2474 | + public function set_user_phone($value) { |
|
2475 | + $this->set_phone($value); |
|
2476 | 2476 | } |
2477 | 2477 | |
2478 | 2478 | /** |
@@ -2481,8 +2481,8 @@ discard block |
||
2481 | 2481 | * @since 1.0.19 |
2482 | 2482 | * @param string $value phone. |
2483 | 2483 | */ |
2484 | - public function set_customer_phone( $value ) { |
|
2485 | - $this->set_phone( $value ); |
|
2484 | + public function set_customer_phone($value) { |
|
2485 | + $this->set_phone($value); |
|
2486 | 2486 | } |
2487 | 2487 | |
2488 | 2488 | /** |
@@ -2491,8 +2491,8 @@ discard block |
||
2491 | 2491 | * @since 1.0.19 |
2492 | 2492 | * @param string $value phone. |
2493 | 2493 | */ |
2494 | - public function set_phone_number( $value ) { |
|
2495 | - $this->set_phone( $value ); |
|
2494 | + public function set_phone_number($value) { |
|
2495 | + $this->set_phone($value); |
|
2496 | 2496 | } |
2497 | 2497 | |
2498 | 2498 | /** |
@@ -2501,8 +2501,8 @@ discard block |
||
2501 | 2501 | * @since 1.0.19 |
2502 | 2502 | * @param string $value email address. |
2503 | 2503 | */ |
2504 | - public function set_email( $value ) { |
|
2505 | - $this->set_prop( 'email', $value ); |
|
2504 | + public function set_email($value) { |
|
2505 | + $this->set_prop('email', $value); |
|
2506 | 2506 | } |
2507 | 2507 | |
2508 | 2508 | /** |
@@ -2511,8 +2511,8 @@ discard block |
||
2511 | 2511 | * @since 1.0.19 |
2512 | 2512 | * @param string $value email address. |
2513 | 2513 | */ |
2514 | - public function set_user_email( $value ) { |
|
2515 | - $this->set_email( $value ); |
|
2514 | + public function set_user_email($value) { |
|
2515 | + $this->set_email($value); |
|
2516 | 2516 | } |
2517 | 2517 | |
2518 | 2518 | /** |
@@ -2521,8 +2521,8 @@ discard block |
||
2521 | 2521 | * @since 1.0.19 |
2522 | 2522 | * @param string $value email address. |
2523 | 2523 | */ |
2524 | - public function set_email_address( $value ) { |
|
2525 | - $this->set_email( $value ); |
|
2524 | + public function set_email_address($value) { |
|
2525 | + $this->set_email($value); |
|
2526 | 2526 | } |
2527 | 2527 | |
2528 | 2528 | /** |
@@ -2531,8 +2531,8 @@ discard block |
||
2531 | 2531 | * @since 1.0.19 |
2532 | 2532 | * @param string $value email address. |
2533 | 2533 | */ |
2534 | - public function set_customer_email( $value ) { |
|
2535 | - $this->set_email( $value ); |
|
2534 | + public function set_customer_email($value) { |
|
2535 | + $this->set_email($value); |
|
2536 | 2536 | } |
2537 | 2537 | |
2538 | 2538 | /** |
@@ -2541,8 +2541,8 @@ discard block |
||
2541 | 2541 | * @since 1.0.19 |
2542 | 2542 | * @param string $value country. |
2543 | 2543 | */ |
2544 | - public function set_country( $value ) { |
|
2545 | - $this->set_prop( 'country', $value ); |
|
2544 | + public function set_country($value) { |
|
2545 | + $this->set_prop('country', $value); |
|
2546 | 2546 | } |
2547 | 2547 | |
2548 | 2548 | /** |
@@ -2551,8 +2551,8 @@ discard block |
||
2551 | 2551 | * @since 1.0.19 |
2552 | 2552 | * @param string $value country. |
2553 | 2553 | */ |
2554 | - public function set_user_country( $value ) { |
|
2555 | - $this->set_country( $value ); |
|
2554 | + public function set_user_country($value) { |
|
2555 | + $this->set_country($value); |
|
2556 | 2556 | } |
2557 | 2557 | |
2558 | 2558 | /** |
@@ -2561,8 +2561,8 @@ discard block |
||
2561 | 2561 | * @since 1.0.19 |
2562 | 2562 | * @param string $value country. |
2563 | 2563 | */ |
2564 | - public function set_customer_country( $value ) { |
|
2565 | - $this->set_country( $value ); |
|
2564 | + public function set_customer_country($value) { |
|
2565 | + $this->set_country($value); |
|
2566 | 2566 | } |
2567 | 2567 | |
2568 | 2568 | /** |
@@ -2571,8 +2571,8 @@ discard block |
||
2571 | 2571 | * @since 1.0.19 |
2572 | 2572 | * @param string $value state. |
2573 | 2573 | */ |
2574 | - public function set_state( $value ) { |
|
2575 | - $this->set_prop( 'state', $value ); |
|
2574 | + public function set_state($value) { |
|
2575 | + $this->set_prop('state', $value); |
|
2576 | 2576 | } |
2577 | 2577 | |
2578 | 2578 | /** |
@@ -2581,8 +2581,8 @@ discard block |
||
2581 | 2581 | * @since 1.0.19 |
2582 | 2582 | * @param string $value state. |
2583 | 2583 | */ |
2584 | - public function set_user_state( $value ) { |
|
2585 | - $this->set_state( $value ); |
|
2584 | + public function set_user_state($value) { |
|
2585 | + $this->set_state($value); |
|
2586 | 2586 | } |
2587 | 2587 | |
2588 | 2588 | /** |
@@ -2591,8 +2591,8 @@ discard block |
||
2591 | 2591 | * @since 1.0.19 |
2592 | 2592 | * @param string $value state. |
2593 | 2593 | */ |
2594 | - public function set_customer_state( $value ) { |
|
2595 | - $this->set_state( $value ); |
|
2594 | + public function set_customer_state($value) { |
|
2595 | + $this->set_state($value); |
|
2596 | 2596 | } |
2597 | 2597 | |
2598 | 2598 | /** |
@@ -2601,8 +2601,8 @@ discard block |
||
2601 | 2601 | * @since 1.0.19 |
2602 | 2602 | * @param string $value city. |
2603 | 2603 | */ |
2604 | - public function set_city( $value ) { |
|
2605 | - $this->set_prop( 'city', $value ); |
|
2604 | + public function set_city($value) { |
|
2605 | + $this->set_prop('city', $value); |
|
2606 | 2606 | } |
2607 | 2607 | |
2608 | 2608 | /** |
@@ -2611,8 +2611,8 @@ discard block |
||
2611 | 2611 | * @since 1.0.19 |
2612 | 2612 | * @param string $value city. |
2613 | 2613 | */ |
2614 | - public function set_user_city( $value ) { |
|
2615 | - $this->set_city( $value ); |
|
2614 | + public function set_user_city($value) { |
|
2615 | + $this->set_city($value); |
|
2616 | 2616 | } |
2617 | 2617 | |
2618 | 2618 | /** |
@@ -2621,8 +2621,8 @@ discard block |
||
2621 | 2621 | * @since 1.0.19 |
2622 | 2622 | * @param string $value city. |
2623 | 2623 | */ |
2624 | - public function set_customer_city( $value ) { |
|
2625 | - $this->set_city( $value ); |
|
2624 | + public function set_customer_city($value) { |
|
2625 | + $this->set_city($value); |
|
2626 | 2626 | } |
2627 | 2627 | |
2628 | 2628 | /** |
@@ -2631,8 +2631,8 @@ discard block |
||
2631 | 2631 | * @since 1.0.19 |
2632 | 2632 | * @param string $value zip. |
2633 | 2633 | */ |
2634 | - public function set_zip( $value ) { |
|
2635 | - $this->set_prop( 'zip', $value ); |
|
2634 | + public function set_zip($value) { |
|
2635 | + $this->set_prop('zip', $value); |
|
2636 | 2636 | } |
2637 | 2637 | |
2638 | 2638 | /** |
@@ -2641,8 +2641,8 @@ discard block |
||
2641 | 2641 | * @since 1.0.19 |
2642 | 2642 | * @param string $value zip. |
2643 | 2643 | */ |
2644 | - public function set_user_zip( $value ) { |
|
2645 | - $this->set_zip( $value ); |
|
2644 | + public function set_user_zip($value) { |
|
2645 | + $this->set_zip($value); |
|
2646 | 2646 | } |
2647 | 2647 | |
2648 | 2648 | /** |
@@ -2651,8 +2651,8 @@ discard block |
||
2651 | 2651 | * @since 1.0.19 |
2652 | 2652 | * @param string $value zip. |
2653 | 2653 | */ |
2654 | - public function set_customer_zip( $value ) { |
|
2655 | - $this->set_zip( $value ); |
|
2654 | + public function set_customer_zip($value) { |
|
2655 | + $this->set_zip($value); |
|
2656 | 2656 | } |
2657 | 2657 | |
2658 | 2658 | /** |
@@ -2661,8 +2661,8 @@ discard block |
||
2661 | 2661 | * @since 1.0.19 |
2662 | 2662 | * @param string $value company. |
2663 | 2663 | */ |
2664 | - public function set_company( $value ) { |
|
2665 | - $this->set_prop( 'company', $value ); |
|
2664 | + public function set_company($value) { |
|
2665 | + $this->set_prop('company', $value); |
|
2666 | 2666 | } |
2667 | 2667 | |
2668 | 2668 | /** |
@@ -2671,8 +2671,8 @@ discard block |
||
2671 | 2671 | * @since 1.0.19 |
2672 | 2672 | * @param string $value company. |
2673 | 2673 | */ |
2674 | - public function set_user_company( $value ) { |
|
2675 | - $this->set_company( $value ); |
|
2674 | + public function set_user_company($value) { |
|
2675 | + $this->set_company($value); |
|
2676 | 2676 | } |
2677 | 2677 | |
2678 | 2678 | /** |
@@ -2681,8 +2681,8 @@ discard block |
||
2681 | 2681 | * @since 1.0.19 |
2682 | 2682 | * @param string $value company. |
2683 | 2683 | */ |
2684 | - public function set_customer_company( $value ) { |
|
2685 | - $this->set_company( $value ); |
|
2684 | + public function set_customer_company($value) { |
|
2685 | + $this->set_company($value); |
|
2686 | 2686 | } |
2687 | 2687 | |
2688 | 2688 | /** |
@@ -2691,8 +2691,8 @@ discard block |
||
2691 | 2691 | * @since 1.0.19 |
2692 | 2692 | * @param string $value company id. |
2693 | 2693 | */ |
2694 | - public function set_company_id( $value ) { |
|
2695 | - $this->set_prop( 'company_id', $value ); |
|
2694 | + public function set_company_id($value) { |
|
2695 | + $this->set_prop('company_id', $value); |
|
2696 | 2696 | } |
2697 | 2697 | |
2698 | 2698 | /** |
@@ -2701,8 +2701,8 @@ discard block |
||
2701 | 2701 | * @since 1.0.19 |
2702 | 2702 | * @param string $value var number. |
2703 | 2703 | */ |
2704 | - public function set_vat_number( $value ) { |
|
2705 | - $this->set_prop( 'vat_number', $value ); |
|
2704 | + public function set_vat_number($value) { |
|
2705 | + $this->set_prop('vat_number', $value); |
|
2706 | 2706 | } |
2707 | 2707 | |
2708 | 2708 | /** |
@@ -2711,8 +2711,8 @@ discard block |
||
2711 | 2711 | * @since 1.0.19 |
2712 | 2712 | * @param string $value var number. |
2713 | 2713 | */ |
2714 | - public function set_user_vat_number( $value ) { |
|
2715 | - $this->set_vat_number( $value ); |
|
2714 | + public function set_user_vat_number($value) { |
|
2715 | + $this->set_vat_number($value); |
|
2716 | 2716 | } |
2717 | 2717 | |
2718 | 2718 | /** |
@@ -2721,8 +2721,8 @@ discard block |
||
2721 | 2721 | * @since 1.0.19 |
2722 | 2722 | * @param string $value var number. |
2723 | 2723 | */ |
2724 | - public function set_customer_vat_number( $value ) { |
|
2725 | - $this->set_vat_number( $value ); |
|
2724 | + public function set_customer_vat_number($value) { |
|
2725 | + $this->set_vat_number($value); |
|
2726 | 2726 | } |
2727 | 2727 | |
2728 | 2728 | /** |
@@ -2731,8 +2731,8 @@ discard block |
||
2731 | 2731 | * @since 1.0.19 |
2732 | 2732 | * @param string $value var rate. |
2733 | 2733 | */ |
2734 | - public function set_vat_rate( $value ) { |
|
2735 | - $this->set_prop( 'vat_rate', $value ); |
|
2734 | + public function set_vat_rate($value) { |
|
2735 | + $this->set_prop('vat_rate', $value); |
|
2736 | 2736 | } |
2737 | 2737 | |
2738 | 2738 | /** |
@@ -2741,8 +2741,8 @@ discard block |
||
2741 | 2741 | * @since 1.0.19 |
2742 | 2742 | * @param string $value var number. |
2743 | 2743 | */ |
2744 | - public function set_user_vat_rate( $value ) { |
|
2745 | - $this->set_vat_rate( $value ); |
|
2744 | + public function set_user_vat_rate($value) { |
|
2745 | + $this->set_vat_rate($value); |
|
2746 | 2746 | } |
2747 | 2747 | |
2748 | 2748 | /** |
@@ -2751,8 +2751,8 @@ discard block |
||
2751 | 2751 | * @since 1.0.19 |
2752 | 2752 | * @param string $value var number. |
2753 | 2753 | */ |
2754 | - public function set_customer_vat_rate( $value ) { |
|
2755 | - $this->set_vat_rate( $value ); |
|
2754 | + public function set_customer_vat_rate($value) { |
|
2755 | + $this->set_vat_rate($value); |
|
2756 | 2756 | } |
2757 | 2757 | |
2758 | 2758 | /** |
@@ -2761,8 +2761,8 @@ discard block |
||
2761 | 2761 | * @since 1.0.19 |
2762 | 2762 | * @param string $value address. |
2763 | 2763 | */ |
2764 | - public function set_address( $value ) { |
|
2765 | - $this->set_prop( 'address', $value ); |
|
2764 | + public function set_address($value) { |
|
2765 | + $this->set_prop('address', $value); |
|
2766 | 2766 | } |
2767 | 2767 | |
2768 | 2768 | /** |
@@ -2771,8 +2771,8 @@ discard block |
||
2771 | 2771 | * @since 1.0.19 |
2772 | 2772 | * @param string $value address. |
2773 | 2773 | */ |
2774 | - public function set_user_address( $value ) { |
|
2775 | - $this->set_address( $value ); |
|
2774 | + public function set_user_address($value) { |
|
2775 | + $this->set_address($value); |
|
2776 | 2776 | } |
2777 | 2777 | |
2778 | 2778 | /** |
@@ -2781,8 +2781,8 @@ discard block |
||
2781 | 2781 | * @since 1.0.19 |
2782 | 2782 | * @param string $value address. |
2783 | 2783 | */ |
2784 | - public function set_customer_address( $value ) { |
|
2785 | - $this->set_address( $value ); |
|
2784 | + public function set_customer_address($value) { |
|
2785 | + $this->set_address($value); |
|
2786 | 2786 | } |
2787 | 2787 | |
2788 | 2788 | /** |
@@ -2791,8 +2791,8 @@ discard block |
||
2791 | 2791 | * @since 1.0.19 |
2792 | 2792 | * @param int|bool $value confirmed. |
2793 | 2793 | */ |
2794 | - public function set_is_viewed( $value ) { |
|
2795 | - $this->set_prop( 'is_viewed', $value ); |
|
2794 | + public function set_is_viewed($value) { |
|
2795 | + $this->set_prop('is_viewed', $value); |
|
2796 | 2796 | } |
2797 | 2797 | |
2798 | 2798 | /** |
@@ -2801,8 +2801,8 @@ discard block |
||
2801 | 2801 | * @since 1.0.19 |
2802 | 2802 | * @param string $value email recipients. |
2803 | 2803 | */ |
2804 | - public function set_email_cc( $value ) { |
|
2805 | - $this->set_prop( 'email_cc', $value ); |
|
2804 | + public function set_email_cc($value) { |
|
2805 | + $this->set_prop('email_cc', $value); |
|
2806 | 2806 | } |
2807 | 2807 | |
2808 | 2808 | /** |
@@ -2811,9 +2811,9 @@ discard block |
||
2811 | 2811 | * @since 1.0.19 |
2812 | 2812 | * @param string $value template. |
2813 | 2813 | */ |
2814 | - public function set_template( $value ) { |
|
2815 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
2816 | - $this->set_prop( 'template', $value ); |
|
2814 | + public function set_template($value) { |
|
2815 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
2816 | + $this->set_prop('template', $value); |
|
2817 | 2817 | } |
2818 | 2818 | } |
2819 | 2819 | |
@@ -2824,8 +2824,8 @@ discard block |
||
2824 | 2824 | * @param string $value source. |
2825 | 2825 | * @deprecated |
2826 | 2826 | */ |
2827 | - public function created_via( $value ) { |
|
2828 | - $this->set_created_via( sanitize_text_field( $value ) ); |
|
2827 | + public function created_via($value) { |
|
2828 | + $this->set_created_via(sanitize_text_field($value)); |
|
2829 | 2829 | } |
2830 | 2830 | |
2831 | 2831 | /** |
@@ -2834,8 +2834,8 @@ discard block |
||
2834 | 2834 | * @since 1.0.19 |
2835 | 2835 | * @param string $value source. |
2836 | 2836 | */ |
2837 | - public function set_created_via( $value ) { |
|
2838 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
2837 | + public function set_created_via($value) { |
|
2838 | + $this->set_prop('created_via', sanitize_text_field($value)); |
|
2839 | 2839 | } |
2840 | 2840 | |
2841 | 2841 | /** |
@@ -2844,8 +2844,8 @@ discard block |
||
2844 | 2844 | * @since 1.0.19 |
2845 | 2845 | * @param int|bool $value confirmed. |
2846 | 2846 | */ |
2847 | - public function set_address_confirmed( $value ) { |
|
2848 | - $this->set_prop( 'address_confirmed', $value ); |
|
2847 | + public function set_address_confirmed($value) { |
|
2848 | + $this->set_prop('address_confirmed', $value); |
|
2849 | 2849 | } |
2850 | 2850 | |
2851 | 2851 | /** |
@@ -2854,8 +2854,8 @@ discard block |
||
2854 | 2854 | * @since 1.0.19 |
2855 | 2855 | * @param int|bool $value confirmed. |
2856 | 2856 | */ |
2857 | - public function set_user_address_confirmed( $value ) { |
|
2858 | - $this->set_address_confirmed( $value ); |
|
2857 | + public function set_user_address_confirmed($value) { |
|
2858 | + $this->set_address_confirmed($value); |
|
2859 | 2859 | } |
2860 | 2860 | |
2861 | 2861 | /** |
@@ -2864,8 +2864,8 @@ discard block |
||
2864 | 2864 | * @since 1.0.19 |
2865 | 2865 | * @param int|bool $value confirmed. |
2866 | 2866 | */ |
2867 | - public function set_customer_address_confirmed( $value ) { |
|
2868 | - $this->set_address_confirmed( $value ); |
|
2867 | + public function set_customer_address_confirmed($value) { |
|
2868 | + $this->set_address_confirmed($value); |
|
2869 | 2869 | } |
2870 | 2870 | |
2871 | 2871 | /** |
@@ -2874,13 +2874,13 @@ discard block |
||
2874 | 2874 | * @since 1.0.19 |
2875 | 2875 | * @param float $value shipping amount. |
2876 | 2876 | */ |
2877 | - public function set_shipping( $value ) { |
|
2877 | + public function set_shipping($value) { |
|
2878 | 2878 | |
2879 | - if ( ! is_numeric( $value ) ) { |
|
2880 | - return $this->set_prop( 'shipping', null ); |
|
2879 | + if (!is_numeric($value)) { |
|
2880 | + return $this->set_prop('shipping', null); |
|
2881 | 2881 | } |
2882 | 2882 | |
2883 | - $this->set_prop( 'shipping', max( 0, floatval( $value ) ) ); |
|
2883 | + $this->set_prop('shipping', max(0, floatval($value))); |
|
2884 | 2884 | } |
2885 | 2885 | |
2886 | 2886 | /** |
@@ -2889,8 +2889,8 @@ discard block |
||
2889 | 2889 | * @since 1.0.19 |
2890 | 2890 | * @param float $value sub total. |
2891 | 2891 | */ |
2892 | - public function set_subtotal( $value ) { |
|
2893 | - $this->set_prop( 'subtotal', max( 0, $value ) ); |
|
2892 | + public function set_subtotal($value) { |
|
2893 | + $this->set_prop('subtotal', max(0, $value)); |
|
2894 | 2894 | } |
2895 | 2895 | |
2896 | 2896 | /** |
@@ -2899,8 +2899,8 @@ discard block |
||
2899 | 2899 | * @since 1.0.19 |
2900 | 2900 | * @param float $value sub total. |
2901 | 2901 | */ |
2902 | - public function set_total( $value ) { |
|
2903 | - $this->set_prop( 'total', max( 0, $value ) ); |
|
2902 | + public function set_total($value) { |
|
2903 | + $this->set_prop('total', max(0, $value)); |
|
2904 | 2904 | } |
2905 | 2905 | |
2906 | 2906 | /** |
@@ -2909,8 +2909,8 @@ discard block |
||
2909 | 2909 | * @since 1.0.19 |
2910 | 2910 | * @param float $value discount total. |
2911 | 2911 | */ |
2912 | - public function set_total_discount( $value ) { |
|
2913 | - $this->set_prop( 'total_discount', max( 0, $value ) ); |
|
2912 | + public function set_total_discount($value) { |
|
2913 | + $this->set_prop('total_discount', max(0, $value)); |
|
2914 | 2914 | } |
2915 | 2915 | |
2916 | 2916 | /** |
@@ -2919,8 +2919,8 @@ discard block |
||
2919 | 2919 | * @since 1.0.19 |
2920 | 2920 | * @param float $value discount total. |
2921 | 2921 | */ |
2922 | - public function set_discount( $value ) { |
|
2923 | - $this->set_total_discount( $value ); |
|
2922 | + public function set_discount($value) { |
|
2923 | + $this->set_total_discount($value); |
|
2924 | 2924 | } |
2925 | 2925 | |
2926 | 2926 | /** |
@@ -2929,8 +2929,8 @@ discard block |
||
2929 | 2929 | * @since 1.0.19 |
2930 | 2930 | * @param float $value tax total. |
2931 | 2931 | */ |
2932 | - public function set_total_tax( $value ) { |
|
2933 | - $this->set_prop( 'total_tax', max( 0, $value ) ); |
|
2932 | + public function set_total_tax($value) { |
|
2933 | + $this->set_prop('total_tax', max(0, $value)); |
|
2934 | 2934 | } |
2935 | 2935 | |
2936 | 2936 | /** |
@@ -2939,8 +2939,8 @@ discard block |
||
2939 | 2939 | * @since 1.0.19 |
2940 | 2940 | * @param float $value tax total. |
2941 | 2941 | */ |
2942 | - public function set_tax_total( $value ) { |
|
2943 | - $this->set_total_tax( $value ); |
|
2942 | + public function set_tax_total($value) { |
|
2943 | + $this->set_total_tax($value); |
|
2944 | 2944 | } |
2945 | 2945 | |
2946 | 2946 | /** |
@@ -2949,8 +2949,8 @@ discard block |
||
2949 | 2949 | * @since 1.0.19 |
2950 | 2950 | * @param float $value fees total. |
2951 | 2951 | */ |
2952 | - public function set_total_fees( $value ) { |
|
2953 | - $this->set_prop( 'total_fees', max( 0, $value ) ); |
|
2952 | + public function set_total_fees($value) { |
|
2953 | + $this->set_prop('total_fees', max(0, $value)); |
|
2954 | 2954 | } |
2955 | 2955 | |
2956 | 2956 | /** |
@@ -2959,8 +2959,8 @@ discard block |
||
2959 | 2959 | * @since 1.0.19 |
2960 | 2960 | * @param float $value fees total. |
2961 | 2961 | */ |
2962 | - public function set_fees_total( $value ) { |
|
2963 | - $this->set_total_fees( $value ); |
|
2962 | + public function set_fees_total($value) { |
|
2963 | + $this->set_total_fees($value); |
|
2964 | 2964 | } |
2965 | 2965 | |
2966 | 2966 | /** |
@@ -2969,13 +2969,13 @@ discard block |
||
2969 | 2969 | * @since 1.0.19 |
2970 | 2970 | * @param array $value fees. |
2971 | 2971 | */ |
2972 | - public function set_fees( $value ) { |
|
2972 | + public function set_fees($value) { |
|
2973 | 2973 | |
2974 | - if ( ! is_array( $value ) ) { |
|
2974 | + if (!is_array($value)) { |
|
2975 | 2975 | $value = array(); |
2976 | 2976 | } |
2977 | 2977 | |
2978 | - $this->set_prop( 'fees', $value ); |
|
2978 | + $this->set_prop('fees', $value); |
|
2979 | 2979 | |
2980 | 2980 | } |
2981 | 2981 | |
@@ -2985,13 +2985,13 @@ discard block |
||
2985 | 2985 | * @since 1.0.19 |
2986 | 2986 | * @param array $value taxes. |
2987 | 2987 | */ |
2988 | - public function set_taxes( $value ) { |
|
2988 | + public function set_taxes($value) { |
|
2989 | 2989 | |
2990 | - if ( ! is_array( $value ) ) { |
|
2990 | + if (!is_array($value)) { |
|
2991 | 2991 | $value = array(); |
2992 | 2992 | } |
2993 | 2993 | |
2994 | - $this->set_prop( 'taxes', $value ); |
|
2994 | + $this->set_prop('taxes', $value); |
|
2995 | 2995 | |
2996 | 2996 | } |
2997 | 2997 | |
@@ -3001,13 +3001,13 @@ discard block |
||
3001 | 3001 | * @since 1.0.19 |
3002 | 3002 | * @param array $value discounts. |
3003 | 3003 | */ |
3004 | - public function set_discounts( $value ) { |
|
3004 | + public function set_discounts($value) { |
|
3005 | 3005 | |
3006 | - if ( ! is_array( $value ) ) { |
|
3006 | + if (!is_array($value)) { |
|
3007 | 3007 | $value = array(); |
3008 | 3008 | } |
3009 | 3009 | |
3010 | - $this->set_prop( 'discounts', $value ); |
|
3010 | + $this->set_prop('discounts', $value); |
|
3011 | 3011 | } |
3012 | 3012 | |
3013 | 3013 | /** |
@@ -3016,19 +3016,19 @@ discard block |
||
3016 | 3016 | * @since 1.0.19 |
3017 | 3017 | * @param GetPaid_Form_Item[] $value items. |
3018 | 3018 | */ |
3019 | - public function set_items( $value ) { |
|
3019 | + public function set_items($value) { |
|
3020 | 3020 | |
3021 | 3021 | // Remove existing items. |
3022 | - $this->set_prop( 'items', array() ); |
|
3022 | + $this->set_prop('items', array()); |
|
3023 | 3023 | $this->recurring_item = null; |
3024 | 3024 | |
3025 | 3025 | // Ensure that we have an array. |
3026 | - if ( ! is_array( $value ) ) { |
|
3026 | + if (!is_array($value)) { |
|
3027 | 3027 | return; |
3028 | 3028 | } |
3029 | 3029 | |
3030 | - foreach ( $value as $item ) { |
|
3031 | - $this->add_item( $item ); |
|
3030 | + foreach ($value as $item) { |
|
3031 | + $this->add_item($item); |
|
3032 | 3032 | } |
3033 | 3033 | |
3034 | 3034 | } |
@@ -3039,8 +3039,8 @@ discard block |
||
3039 | 3039 | * @since 1.0.19 |
3040 | 3040 | * @param int $value payment form. |
3041 | 3041 | */ |
3042 | - public function set_payment_form( $value ) { |
|
3043 | - $this->set_prop( 'payment_form', $value ); |
|
3042 | + public function set_payment_form($value) { |
|
3043 | + $this->set_prop('payment_form', $value); |
|
3044 | 3044 | } |
3045 | 3045 | |
3046 | 3046 | /** |
@@ -3049,8 +3049,8 @@ discard block |
||
3049 | 3049 | * @since 1.0.19 |
3050 | 3050 | * @param string $value submission id. |
3051 | 3051 | */ |
3052 | - public function set_submission_id( $value ) { |
|
3053 | - $this->set_prop( 'submission_id', $value ); |
|
3052 | + public function set_submission_id($value) { |
|
3053 | + $this->set_prop('submission_id', $value); |
|
3054 | 3054 | } |
3055 | 3055 | |
3056 | 3056 | /** |
@@ -3059,8 +3059,8 @@ discard block |
||
3059 | 3059 | * @since 1.0.19 |
3060 | 3060 | * @param string $value discount code. |
3061 | 3061 | */ |
3062 | - public function set_discount_code( $value ) { |
|
3063 | - $this->set_prop( 'discount_code', sanitize_text_field( $value ) ); |
|
3062 | + public function set_discount_code($value) { |
|
3063 | + $this->set_prop('discount_code', sanitize_text_field($value)); |
|
3064 | 3064 | } |
3065 | 3065 | |
3066 | 3066 | /** |
@@ -3069,8 +3069,8 @@ discard block |
||
3069 | 3069 | * @since 1.0.19 |
3070 | 3070 | * @param string $value gateway. |
3071 | 3071 | */ |
3072 | - public function set_gateway( $value ) { |
|
3073 | - $this->set_prop( 'gateway', $value ); |
|
3072 | + public function set_gateway($value) { |
|
3073 | + $this->set_prop('gateway', $value); |
|
3074 | 3074 | } |
3075 | 3075 | |
3076 | 3076 | /** |
@@ -3079,9 +3079,9 @@ discard block |
||
3079 | 3079 | * @since 1.0.19 |
3080 | 3080 | * @param string $value transaction id. |
3081 | 3081 | */ |
3082 | - public function set_transaction_id( $value ) { |
|
3083 | - if ( ! empty( $value ) ) { |
|
3084 | - $this->set_prop( 'transaction_id', $value ); |
|
3082 | + public function set_transaction_id($value) { |
|
3083 | + if (!empty($value)) { |
|
3084 | + $this->set_prop('transaction_id', $value); |
|
3085 | 3085 | } |
3086 | 3086 | } |
3087 | 3087 | |
@@ -3091,8 +3091,8 @@ discard block |
||
3091 | 3091 | * @since 1.0.19 |
3092 | 3092 | * @param string $value currency id. |
3093 | 3093 | */ |
3094 | - public function set_currency( $value ) { |
|
3095 | - $this->set_prop( 'currency', $value ); |
|
3094 | + public function set_currency($value) { |
|
3095 | + $this->set_prop('currency', $value); |
|
3096 | 3096 | } |
3097 | 3097 | |
3098 | 3098 | /** |
@@ -3101,8 +3101,8 @@ discard block |
||
3101 | 3101 | * @since 1.0.19 |
3102 | 3102 | * @param bool $value value. |
3103 | 3103 | */ |
3104 | - public function set_disable_taxes( $value ) { |
|
3105 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
3104 | + public function set_disable_taxes($value) { |
|
3105 | + $this->set_prop('disable_taxes', (bool) $value); |
|
3106 | 3106 | } |
3107 | 3107 | |
3108 | 3108 | /** |
@@ -3111,8 +3111,8 @@ discard block |
||
3111 | 3111 | * @since 1.0.19 |
3112 | 3112 | * @param string $value subscription id. |
3113 | 3113 | */ |
3114 | - public function set_subscription_id( $value ) { |
|
3115 | - $this->set_prop( 'subscription_id', $value ); |
|
3114 | + public function set_subscription_id($value) { |
|
3115 | + $this->set_prop('subscription_id', $value); |
|
3116 | 3116 | } |
3117 | 3117 | |
3118 | 3118 | /** |
@@ -3121,8 +3121,8 @@ discard block |
||
3121 | 3121 | * @since 1.0.19 |
3122 | 3122 | * @param string $value subscription id. |
3123 | 3123 | */ |
3124 | - public function set_remote_subscription_id( $value ) { |
|
3125 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
3124 | + public function set_remote_subscription_id($value) { |
|
3125 | + $this->set_prop('remote_subscription_id', $value); |
|
3126 | 3126 | } |
3127 | 3127 | |
3128 | 3128 | /* |
@@ -3139,28 +3139,28 @@ discard block |
||
3139 | 3139 | */ |
3140 | 3140 | public function is_parent() { |
3141 | 3141 | $parent = $this->get_parent_id(); |
3142 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
3142 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
3143 | 3143 | } |
3144 | 3144 | |
3145 | 3145 | /** |
3146 | 3146 | * Checks if this is a renewal invoice. |
3147 | 3147 | */ |
3148 | 3148 | public function is_renewal() { |
3149 | - return $this->is_recurring() && ! $this->is_parent(); |
|
3149 | + return $this->is_recurring() && !$this->is_parent(); |
|
3150 | 3150 | } |
3151 | 3151 | |
3152 | 3152 | /** |
3153 | 3153 | * Checks if this is a recurring invoice. |
3154 | 3154 | */ |
3155 | 3155 | public function is_recurring() { |
3156 | - return ! empty( $this->recurring_item ); |
|
3156 | + return !empty($this->recurring_item); |
|
3157 | 3157 | } |
3158 | 3158 | |
3159 | 3159 | /** |
3160 | 3160 | * Checks if this is a taxable invoice. |
3161 | 3161 | */ |
3162 | 3162 | public function is_taxable() { |
3163 | - return ! $this->get_disable_taxes(); |
|
3163 | + return !$this->get_disable_taxes(); |
|
3164 | 3164 | } |
3165 | 3165 | |
3166 | 3166 | /** |
@@ -3174,45 +3174,45 @@ discard block |
||
3174 | 3174 | * Checks to see if the invoice requires payment. |
3175 | 3175 | */ |
3176 | 3176 | public function is_free() { |
3177 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
3177 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
3178 | 3178 | |
3179 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
3179 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
3180 | 3180 | $is_free = false; |
3181 | 3181 | } |
3182 | 3182 | |
3183 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
3183 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
3184 | 3184 | } |
3185 | 3185 | |
3186 | 3186 | /** |
3187 | 3187 | * Checks if the invoice is paid. |
3188 | 3188 | */ |
3189 | 3189 | public function is_paid() { |
3190 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
3191 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
3190 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
3191 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
3192 | 3192 | } |
3193 | 3193 | |
3194 | 3194 | /** |
3195 | 3195 | * Checks if the invoice needs payment. |
3196 | 3196 | */ |
3197 | 3197 | public function needs_payment() { |
3198 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
3199 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
3198 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
3199 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
3200 | 3200 | } |
3201 | 3201 | |
3202 | 3202 | /** |
3203 | 3203 | * Checks if the invoice is refunded. |
3204 | 3204 | */ |
3205 | 3205 | public function is_refunded() { |
3206 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
3207 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
3206 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
3207 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
3208 | 3208 | } |
3209 | 3209 | |
3210 | 3210 | /** |
3211 | 3211 | * Checks if the invoice is held. |
3212 | 3212 | */ |
3213 | 3213 | public function is_held() { |
3214 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
3215 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
3214 | + $is_held = $this->has_status('wpi-onhold'); |
|
3215 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
3216 | 3216 | } |
3217 | 3217 | |
3218 | 3218 | /** |
@@ -3220,30 +3220,30 @@ discard block |
||
3220 | 3220 | */ |
3221 | 3221 | public function is_due() { |
3222 | 3222 | $due_date = $this->get_due_date(); |
3223 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
3223 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
3224 | 3224 | } |
3225 | 3225 | |
3226 | 3226 | /** |
3227 | 3227 | * Checks if the invoice is draft. |
3228 | 3228 | */ |
3229 | 3229 | public function is_draft() { |
3230 | - return $this->has_status( 'draft, auto-draft' ); |
|
3230 | + return $this->has_status('draft, auto-draft'); |
|
3231 | 3231 | } |
3232 | 3232 | |
3233 | 3233 | /** |
3234 | 3234 | * Checks if the invoice has a given status. |
3235 | 3235 | */ |
3236 | - public function has_status( $status ) { |
|
3237 | - $status = wpinv_parse_list( $status ); |
|
3238 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
3236 | + public function has_status($status) { |
|
3237 | + $status = wpinv_parse_list($status); |
|
3238 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
3239 | 3239 | } |
3240 | 3240 | |
3241 | 3241 | /** |
3242 | 3242 | * Checks if the invoice is of a given type. |
3243 | 3243 | */ |
3244 | - public function is_type( $type ) { |
|
3245 | - $type = wpinv_parse_list( $type ); |
|
3246 | - return in_array( $this->get_type(), $type ); |
|
3244 | + public function is_type($type) { |
|
3245 | + $type = wpinv_parse_list($type); |
|
3246 | + return in_array($this->get_type(), $type); |
|
3247 | 3247 | } |
3248 | 3248 | |
3249 | 3249 | /** |
@@ -3275,8 +3275,8 @@ discard block |
||
3275 | 3275 | * |
3276 | 3276 | */ |
3277 | 3277 | public function is_initial_free() { |
3278 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
3279 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
3278 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
3279 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
3280 | 3280 | } |
3281 | 3281 | |
3282 | 3282 | /** |
@@ -3286,11 +3286,11 @@ discard block |
||
3286 | 3286 | public function item_has_free_trial() { |
3287 | 3287 | |
3288 | 3288 | // Ensure we have a recurring item. |
3289 | - if ( ! $this->is_recurring() ) { |
|
3289 | + if (!$this->is_recurring()) { |
|
3290 | 3290 | return false; |
3291 | 3291 | } |
3292 | 3292 | |
3293 | - $item = $this->get_recurring( true ); |
|
3293 | + $item = $this->get_recurring(true); |
|
3294 | 3294 | return $item->has_free_trial(); |
3295 | 3295 | } |
3296 | 3296 | |
@@ -3298,7 +3298,7 @@ discard block |
||
3298 | 3298 | * Check if the free trial is a result of a discount. |
3299 | 3299 | */ |
3300 | 3300 | public function is_free_trial_from_discount() { |
3301 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
3301 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
3302 | 3302 | } |
3303 | 3303 | |
3304 | 3304 | /** |
@@ -3306,12 +3306,12 @@ discard block |
||
3306 | 3306 | */ |
3307 | 3307 | public function discount_first_payment_only() { |
3308 | 3308 | |
3309 | - $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
3310 | - if ( ! $discount->exists() || ! $this->is_recurring() ) { |
|
3309 | + $discount = wpinv_get_discount_obj($this->get_discount_code()); |
|
3310 | + if (!$discount->exists() || !$this->is_recurring()) { |
|
3311 | 3311 | return true; |
3312 | 3312 | } |
3313 | 3313 | |
3314 | - return ! $discount->get_is_recurring(); |
|
3314 | + return !$discount->get_is_recurring(); |
|
3315 | 3315 | } |
3316 | 3316 | |
3317 | 3317 | /* |
@@ -3329,23 +3329,23 @@ discard block |
||
3329 | 3329 | * @param GetPaid_Form_Item|array $item |
3330 | 3330 | * @return WP_Error|Bool |
3331 | 3331 | */ |
3332 | - public function add_item( $item ) { |
|
3332 | + public function add_item($item) { |
|
3333 | 3333 | |
3334 | - if ( is_array( $item ) ) { |
|
3335 | - $item = $this->process_array_item( $item ); |
|
3334 | + if (is_array($item)) { |
|
3335 | + $item = $this->process_array_item($item); |
|
3336 | 3336 | } |
3337 | 3337 | |
3338 | - if ( is_numeric( $item ) ) { |
|
3339 | - $item = new GetPaid_Form_Item( $item ); |
|
3338 | + if (is_numeric($item)) { |
|
3339 | + $item = new GetPaid_Form_Item($item); |
|
3340 | 3340 | } |
3341 | 3341 | |
3342 | 3342 | // Make sure that it is available for purchase. |
3343 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
3344 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
3343 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
3344 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
3345 | 3345 | } |
3346 | 3346 | |
3347 | 3347 | // Do we have a recurring item? |
3348 | - if ( $item->is_recurring() ) { |
|
3348 | + if ($item->is_recurring()) { |
|
3349 | 3349 | $this->recurring_item = $item->get_id(); |
3350 | 3350 | } |
3351 | 3351 | |
@@ -3353,9 +3353,9 @@ discard block |
||
3353 | 3353 | $item->invoice_id = (int) $this->get_id(); |
3354 | 3354 | |
3355 | 3355 | // Remove duplicates. |
3356 | - $this->remove_item( $item->get_id() ); |
|
3356 | + $this->remove_item($item->get_id()); |
|
3357 | 3357 | |
3358 | - if ( 0 == $item->get_quantity() ) { |
|
3358 | + if (0 == $item->get_quantity()) { |
|
3359 | 3359 | return; |
3360 | 3360 | } |
3361 | 3361 | |
@@ -3365,7 +3365,7 @@ discard block |
||
3365 | 3365 | // Add new item. |
3366 | 3366 | $items[] = $item; |
3367 | 3367 | |
3368 | - $this->set_prop( 'items', $items ); |
|
3368 | + $this->set_prop('items', $items); |
|
3369 | 3369 | |
3370 | 3370 | return true; |
3371 | 3371 | } |
@@ -3376,26 +3376,26 @@ discard block |
||
3376 | 3376 | * @since 1.0.19 |
3377 | 3377 | * @return GetPaid_Form_Item |
3378 | 3378 | */ |
3379 | - protected function process_array_item( $array ) { |
|
3379 | + protected function process_array_item($array) { |
|
3380 | 3380 | |
3381 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
3382 | - $item = new GetPaid_Form_Item( $item_id ); |
|
3381 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
3382 | + $item = new GetPaid_Form_Item($item_id); |
|
3383 | 3383 | |
3384 | 3384 | // Set item data. |
3385 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
3386 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
3385 | + foreach (array('name', 'price', 'description') as $key) { |
|
3386 | + if (isset($array["item_$key"])) { |
|
3387 | 3387 | $method = "set_$key"; |
3388 | - $item->$method( $array[ "item_$key" ] ); |
|
3388 | + $item->$method($array["item_$key"]); |
|
3389 | 3389 | } |
3390 | 3390 | } |
3391 | 3391 | |
3392 | - if ( isset( $array['quantity'] ) ) { |
|
3393 | - $item->set_quantity( $array['quantity'] ); |
|
3392 | + if (isset($array['quantity'])) { |
|
3393 | + $item->set_quantity($array['quantity']); |
|
3394 | 3394 | } |
3395 | 3395 | |
3396 | 3396 | // Set item meta. |
3397 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
3398 | - $item->set_item_meta( $array['meta'] ); |
|
3397 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
3398 | + $item->set_item_meta($array['meta']); |
|
3399 | 3399 | } |
3400 | 3400 | |
3401 | 3401 | return $item; |
@@ -3408,10 +3408,10 @@ discard block |
||
3408 | 3408 | * @since 1.0.19 |
3409 | 3409 | * @return GetPaid_Form_Item|null |
3410 | 3410 | */ |
3411 | - public function get_item( $item_id ) { |
|
3411 | + public function get_item($item_id) { |
|
3412 | 3412 | |
3413 | - foreach ( $this->get_items() as $item ) { |
|
3414 | - if ( (int) $item_id == $item->get_id() ) { |
|
3413 | + foreach ($this->get_items() as $item) { |
|
3414 | + if ((int) $item_id == $item->get_id()) { |
|
3415 | 3415 | return $item; |
3416 | 3416 | } |
3417 | 3417 | } |
@@ -3424,16 +3424,16 @@ discard block |
||
3424 | 3424 | * |
3425 | 3425 | * @since 1.0.19 |
3426 | 3426 | */ |
3427 | - public function remove_item( $item_id ) { |
|
3427 | + public function remove_item($item_id) { |
|
3428 | 3428 | $items = $this->get_items(); |
3429 | 3429 | $item_id = (int) $item_id; |
3430 | 3430 | |
3431 | - foreach ( $items as $index => $item ) { |
|
3432 | - if ( (int) $item_id == $item->get_id() ) { |
|
3433 | - unset( $items[ $index ] ); |
|
3434 | - $this->set_prop( 'items', $items ); |
|
3431 | + foreach ($items as $index => $item) { |
|
3432 | + if ((int) $item_id == $item->get_id()) { |
|
3433 | + unset($items[$index]); |
|
3434 | + $this->set_prop('items', $items); |
|
3435 | 3435 | |
3436 | - if ( $item_id == $this->recurring_item ) { |
|
3436 | + if ($item_id == $this->recurring_item) { |
|
3437 | 3437 | $this->recurring_item = null; |
3438 | 3438 | } |
3439 | 3439 | } |
@@ -3447,11 +3447,11 @@ discard block |
||
3447 | 3447 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
3448 | 3448 | * @since 1.0.19 |
3449 | 3449 | */ |
3450 | - public function add_fee( $fee ) { |
|
3450 | + public function add_fee($fee) { |
|
3451 | 3451 | |
3452 | 3452 | $fees = $this->get_fees(); |
3453 | - $fees[ $fee['name'] ] = $fee; |
|
3454 | - $this->set_prop( 'fees', $fees ); |
|
3453 | + $fees[$fee['name']] = $fee; |
|
3454 | + $this->set_prop('fees', $fees); |
|
3455 | 3455 | |
3456 | 3456 | } |
3457 | 3457 | |
@@ -3460,9 +3460,9 @@ discard block |
||
3460 | 3460 | * |
3461 | 3461 | * @since 1.0.19 |
3462 | 3462 | */ |
3463 | - public function get_fee( $fee ) { |
|
3463 | + public function get_fee($fee) { |
|
3464 | 3464 | $fees = $this->get_fees(); |
3465 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
3465 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
3466 | 3466 | } |
3467 | 3467 | |
3468 | 3468 | /** |
@@ -3470,11 +3470,11 @@ discard block |
||
3470 | 3470 | * |
3471 | 3471 | * @since 1.0.19 |
3472 | 3472 | */ |
3473 | - public function remove_fee( $fee ) { |
|
3473 | + public function remove_fee($fee) { |
|
3474 | 3474 | $fees = $this->get_fees(); |
3475 | - if ( isset( $fees[ $fee ] ) ) { |
|
3476 | - unset( $fees[ $fee ] ); |
|
3477 | - $this->set_prop( 'fees', $fees ); |
|
3475 | + if (isset($fees[$fee])) { |
|
3476 | + unset($fees[$fee]); |
|
3477 | + $this->set_prop('fees', $fees); |
|
3478 | 3478 | } |
3479 | 3479 | } |
3480 | 3480 | |
@@ -3484,11 +3484,11 @@ discard block |
||
3484 | 3484 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
3485 | 3485 | * @since 1.0.19 |
3486 | 3486 | */ |
3487 | - public function add_discount( $discount ) { |
|
3487 | + public function add_discount($discount) { |
|
3488 | 3488 | |
3489 | 3489 | $discounts = $this->get_discounts(); |
3490 | - $discounts[ $discount['name'] ] = $discount; |
|
3491 | - $this->set_prop( 'discounts', $discounts ); |
|
3490 | + $discounts[$discount['name']] = $discount; |
|
3491 | + $this->set_prop('discounts', $discounts); |
|
3492 | 3492 | |
3493 | 3493 | } |
3494 | 3494 | |
@@ -3498,15 +3498,15 @@ discard block |
||
3498 | 3498 | * @since 1.0.19 |
3499 | 3499 | * @return float |
3500 | 3500 | */ |
3501 | - public function get_discount( $discount = false ) { |
|
3501 | + public function get_discount($discount = false) { |
|
3502 | 3502 | |
3503 | 3503 | // Backwards compatibilty. |
3504 | - if ( empty( $discount ) ) { |
|
3504 | + if (empty($discount)) { |
|
3505 | 3505 | return $this->get_total_discount(); |
3506 | 3506 | } |
3507 | 3507 | |
3508 | 3508 | $discounts = $this->get_discounts(); |
3509 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
3509 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
3510 | 3510 | } |
3511 | 3511 | |
3512 | 3512 | /** |
@@ -3514,15 +3514,15 @@ discard block |
||
3514 | 3514 | * |
3515 | 3515 | * @since 1.0.19 |
3516 | 3516 | */ |
3517 | - public function remove_discount( $discount ) { |
|
3517 | + public function remove_discount($discount) { |
|
3518 | 3518 | $discounts = $this->get_discounts(); |
3519 | - if ( isset( $discounts[ $discount ] ) ) { |
|
3520 | - unset( $discounts[ $discount ] ); |
|
3521 | - $this->set_prop( 'discounts', $discounts ); |
|
3519 | + if (isset($discounts[$discount])) { |
|
3520 | + unset($discounts[$discount]); |
|
3521 | + $this->set_prop('discounts', $discounts); |
|
3522 | 3522 | } |
3523 | 3523 | |
3524 | - if ( 'discount_code' == $discount ) { |
|
3525 | - foreach ( $this->get_items() as $item ) { |
|
3524 | + if ('discount_code' == $discount) { |
|
3525 | + foreach ($this->get_items() as $item) { |
|
3526 | 3526 | $item->item_discount = 0; |
3527 | 3527 | $item->recurring_item_discount = 0; |
3528 | 3528 | } |
@@ -3535,12 +3535,12 @@ discard block |
||
3535 | 3535 | * |
3536 | 3536 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
3537 | 3537 | */ |
3538 | - public function add_tax( $tax ) { |
|
3539 | - if ( $this->is_taxable() ) { |
|
3538 | + public function add_tax($tax) { |
|
3539 | + if ($this->is_taxable()) { |
|
3540 | 3540 | |
3541 | - $taxes = $this->get_taxes(); |
|
3542 | - $taxes[ $tax['name'] ] = $tax; |
|
3543 | - $this->set_prop( 'taxes', $tax ); |
|
3541 | + $taxes = $this->get_taxes(); |
|
3542 | + $taxes[$tax['name']] = $tax; |
|
3543 | + $this->set_prop('taxes', $tax); |
|
3544 | 3544 | |
3545 | 3545 | } |
3546 | 3546 | } |
@@ -3550,15 +3550,15 @@ discard block |
||
3550 | 3550 | * |
3551 | 3551 | * @since 1.0.19 |
3552 | 3552 | */ |
3553 | - public function get_tax( $tax = null ) { |
|
3553 | + public function get_tax($tax = null) { |
|
3554 | 3554 | |
3555 | 3555 | // Backwards compatility. |
3556 | - if ( empty( $tax ) ) { |
|
3556 | + if (empty($tax)) { |
|
3557 | 3557 | return $this->get_total_tax(); |
3558 | 3558 | } |
3559 | 3559 | |
3560 | 3560 | $taxes = $this->get_taxes(); |
3561 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
3561 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
3562 | 3562 | } |
3563 | 3563 | |
3564 | 3564 | /** |
@@ -3566,11 +3566,11 @@ discard block |
||
3566 | 3566 | * |
3567 | 3567 | * @since 1.0.19 |
3568 | 3568 | */ |
3569 | - public function remove_tax( $tax ) { |
|
3569 | + public function remove_tax($tax) { |
|
3570 | 3570 | $taxes = $this->get_taxes(); |
3571 | - if ( isset( $taxes[ $tax ] ) ) { |
|
3572 | - unset( $taxes[ $tax ] ); |
|
3573 | - $this->set_prop( 'taxes', $taxes ); |
|
3571 | + if (isset($taxes[$tax])) { |
|
3572 | + unset($taxes[$tax]); |
|
3573 | + $this->set_prop('taxes', $taxes); |
|
3574 | 3574 | } |
3575 | 3575 | } |
3576 | 3576 | |
@@ -3581,22 +3581,22 @@ discard block |
||
3581 | 3581 | * @return float The recalculated subtotal |
3582 | 3582 | */ |
3583 | 3583 | public function recalculate_subtotal() { |
3584 | - $items = $this->get_items(); |
|
3584 | + $items = $this->get_items(); |
|
3585 | 3585 | $subtotal = 0; |
3586 | 3586 | $recurring = 0; |
3587 | 3587 | |
3588 | - foreach ( $items as $item ) { |
|
3589 | - $subtotal += $item->get_sub_total( 'edit' ); |
|
3590 | - $recurring += $item->get_recurring_sub_total( 'edit' ); |
|
3588 | + foreach ($items as $item) { |
|
3589 | + $subtotal += $item->get_sub_total('edit'); |
|
3590 | + $recurring += $item->get_recurring_sub_total('edit'); |
|
3591 | 3591 | } |
3592 | 3592 | |
3593 | - if ( wpinv_prices_include_tax() ) { |
|
3594 | - $subtotal = max( 0, $subtotal - $this->totals['tax']['initial'] ); |
|
3595 | - $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] ); |
|
3593 | + if (wpinv_prices_include_tax()) { |
|
3594 | + $subtotal = max(0, $subtotal - $this->totals['tax']['initial']); |
|
3595 | + $recurring = max(0, $recurring - $this->totals['tax']['recurring']); |
|
3596 | 3596 | } |
3597 | 3597 | |
3598 | 3598 | $current = $this->is_renewal() ? $recurring : $subtotal; |
3599 | - $this->set_subtotal( $current ); |
|
3599 | + $this->set_subtotal($current); |
|
3600 | 3600 | |
3601 | 3601 | $this->totals['subtotal'] = array( |
3602 | 3602 | 'initial' => $subtotal, |
@@ -3617,14 +3617,14 @@ discard block |
||
3617 | 3617 | $discount = 0; |
3618 | 3618 | $recurring = 0; |
3619 | 3619 | |
3620 | - foreach ( $discounts as $data ) { |
|
3621 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
3622 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
3620 | + foreach ($discounts as $data) { |
|
3621 | + $discount += wpinv_sanitize_amount($data['initial_discount']); |
|
3622 | + $recurring += wpinv_sanitize_amount($data['recurring_discount']); |
|
3623 | 3623 | } |
3624 | 3624 | |
3625 | 3625 | $current = $this->is_renewal() ? $recurring : $discount; |
3626 | 3626 | |
3627 | - $this->set_total_discount( $current ); |
|
3627 | + $this->set_total_discount($current); |
|
3628 | 3628 | |
3629 | 3629 | $this->totals['discount'] = array( |
3630 | 3630 | 'initial' => $discount, |
@@ -3645,13 +3645,13 @@ discard block |
||
3645 | 3645 | |
3646 | 3646 | // Maybe disable taxes. |
3647 | 3647 | $vat_number = $this->get_vat_number(); |
3648 | - $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number ); |
|
3648 | + $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number); |
|
3649 | 3649 | |
3650 | - if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
3650 | + if (wpinv_is_base_country($this->get_country()) && 'vat_too' === wpinv_get_option('vat_same_country_rule', 'vat_too')) { |
|
3651 | 3651 | $skip_tax = false; |
3652 | 3652 | } |
3653 | 3653 | |
3654 | - if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) { |
|
3654 | + if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) { |
|
3655 | 3655 | |
3656 | 3656 | $this->totals['tax'] = array( |
3657 | 3657 | 'initial' => 0, |
@@ -3660,37 +3660,37 @@ discard block |
||
3660 | 3660 | |
3661 | 3661 | $this->tax_rate = 0; |
3662 | 3662 | |
3663 | - $this->set_taxes( array() ); |
|
3663 | + $this->set_taxes(array()); |
|
3664 | 3664 | $current = 0; |
3665 | 3665 | } else { |
3666 | 3666 | |
3667 | 3667 | $item_taxes = array(); |
3668 | 3668 | |
3669 | - foreach ( $this->get_items() as $item ) { |
|
3670 | - $rates = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() ); |
|
3671 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
3672 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
3673 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
3674 | - foreach ( $taxes as $name => $amount ) { |
|
3675 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
3676 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
3677 | - |
|
3678 | - if ( ! isset( $item_taxes[ $name ] ) ) { |
|
3679 | - $item_taxes[ $name ] = $tax; |
|
3669 | + foreach ($this->get_items() as $item) { |
|
3670 | + $rates = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state()); |
|
3671 | + $rates = getpaid_filter_item_tax_rates($item, $rates); |
|
3672 | + $taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates); |
|
3673 | + $r_taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates); |
|
3674 | + foreach ($taxes as $name => $amount) { |
|
3675 | + $recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0; |
|
3676 | + $tax = getpaid_prepare_item_tax($item, $name, $amount, $recurring); |
|
3677 | + |
|
3678 | + if (!isset($item_taxes[$name])) { |
|
3679 | + $item_taxes[$name] = $tax; |
|
3680 | 3680 | continue; |
3681 | 3681 | } |
3682 | 3682 | |
3683 | - $item_taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
3684 | - $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
3683 | + $item_taxes[$name]['initial_tax'] += $tax['initial_tax']; |
|
3684 | + $item_taxes[$name]['recurring_tax'] += $tax['recurring_tax']; |
|
3685 | 3685 | |
3686 | 3686 | } |
3687 | 3687 | } |
3688 | 3688 | |
3689 | - $item_taxes = array_replace( $this->get_taxes(), $item_taxes ); |
|
3690 | - $this->set_taxes( $item_taxes ); |
|
3689 | + $item_taxes = array_replace($this->get_taxes(), $item_taxes); |
|
3690 | + $this->set_taxes($item_taxes); |
|
3691 | 3691 | |
3692 | - $initial_tax = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) ); |
|
3693 | - $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) ); |
|
3692 | + $initial_tax = array_sum(wp_list_pluck($item_taxes, 'initial_tax')); |
|
3693 | + $recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax')); |
|
3694 | 3694 | |
3695 | 3695 | $current = $this->is_renewal() ? $recurring_tax : $initial_tax; |
3696 | 3696 | |
@@ -3701,7 +3701,7 @@ discard block |
||
3701 | 3701 | |
3702 | 3702 | } |
3703 | 3703 | |
3704 | - $this->set_total_tax( $current ); |
|
3704 | + $this->set_total_tax($current); |
|
3705 | 3705 | |
3706 | 3706 | return $current; |
3707 | 3707 | |
@@ -3718,20 +3718,20 @@ discard block |
||
3718 | 3718 | $fee = 0; |
3719 | 3719 | $recurring = 0; |
3720 | 3720 | |
3721 | - foreach ( $fees as $data ) { |
|
3722 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
3723 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
3721 | + foreach ($fees as $data) { |
|
3722 | + $fee += wpinv_sanitize_amount($data['initial_fee']); |
|
3723 | + $recurring += wpinv_sanitize_amount($data['recurring_fee']); |
|
3724 | 3724 | } |
3725 | 3725 | |
3726 | 3726 | $current = $this->is_renewal() ? $recurring : $fee; |
3727 | - $this->set_total_fees( $current ); |
|
3727 | + $this->set_total_fees($current); |
|
3728 | 3728 | |
3729 | 3729 | $this->totals['fee'] = array( |
3730 | 3730 | 'initial' => $fee, |
3731 | 3731 | 'recurring' => $recurring, |
3732 | 3732 | ); |
3733 | 3733 | |
3734 | - $this->set_total_fees( $fee ); |
|
3734 | + $this->set_total_fees($fee); |
|
3735 | 3735 | return $current; |
3736 | 3736 | } |
3737 | 3737 | |
@@ -3746,7 +3746,7 @@ discard block |
||
3746 | 3746 | $this->recalculate_total_discount(); |
3747 | 3747 | $this->recalculate_total_tax(); |
3748 | 3748 | $this->recalculate_subtotal(); |
3749 | - $this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) ); |
|
3749 | + $this->set_total($this->get_total_tax('edit') + $this->get_total_fees('edit') + $this->get_subtotal('edit') - $this->get_total_discount('edit')); |
|
3750 | 3750 | return $this->get_total(); |
3751 | 3751 | } |
3752 | 3752 | |
@@ -3755,7 +3755,7 @@ discard block |
||
3755 | 3755 | */ |
3756 | 3756 | public function recalculate_totals() { |
3757 | 3757 | $this->recalculate_total(); |
3758 | - $this->save( true ); |
|
3758 | + $this->save(true); |
|
3759 | 3759 | return $this; |
3760 | 3760 | } |
3761 | 3761 | |
@@ -3773,8 +3773,8 @@ discard block |
||
3773 | 3773 | * @return int|false The new note's ID on success, false on failure. |
3774 | 3774 | * |
3775 | 3775 | */ |
3776 | - public function add_system_note( $note ) { |
|
3777 | - return $this->add_note( $note, false, false, true ); |
|
3776 | + public function add_system_note($note) { |
|
3777 | + return $this->add_note($note, false, false, true); |
|
3778 | 3778 | } |
3779 | 3779 | |
3780 | 3780 | /** |
@@ -3784,10 +3784,10 @@ discard block |
||
3784 | 3784 | * @return int|false The new note's ID on success, false on failure. |
3785 | 3785 | * |
3786 | 3786 | */ |
3787 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
3787 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
3788 | 3788 | |
3789 | 3789 | // Bail if no note specified or this invoice is not yet saved. |
3790 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
3790 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
3791 | 3791 | return false; |
3792 | 3792 | } |
3793 | 3793 | |
@@ -3795,23 +3795,23 @@ discard block |
||
3795 | 3795 | $author_email = '[email protected]'; |
3796 | 3796 | |
3797 | 3797 | // If this is an admin comment or it has been added by the user. |
3798 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
3799 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
3798 | + if (is_user_logged_in() && (!$system || $added_by_user)) { |
|
3799 | + $user = get_user_by('id', get_current_user_id()); |
|
3800 | 3800 | $author = $user->display_name; |
3801 | 3801 | $author_email = $user->user_email; |
3802 | 3802 | } |
3803 | 3803 | |
3804 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
3804 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
3805 | 3805 | |
3806 | 3806 | } |
3807 | 3807 | |
3808 | 3808 | /** |
3809 | 3809 | * Generates a unique key for the invoice. |
3810 | 3810 | */ |
3811 | - public function generate_key( $string = '' ) { |
|
3812 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
3811 | + public function generate_key($string = '') { |
|
3812 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
3813 | 3813 | return strtolower( |
3814 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
3814 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
3815 | 3815 | ); |
3816 | 3816 | } |
3817 | 3817 | |
@@ -3821,11 +3821,11 @@ discard block |
||
3821 | 3821 | public function generate_number() { |
3822 | 3822 | $number = $this->get_id(); |
3823 | 3823 | |
3824 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
3825 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
3824 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
3825 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
3826 | 3826 | } |
3827 | 3827 | |
3828 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
3828 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
3829 | 3829 | |
3830 | 3830 | } |
3831 | 3831 | |
@@ -3838,55 +3838,55 @@ discard block |
||
3838 | 3838 | // Reset status transition variable. |
3839 | 3839 | $this->status_transition = false; |
3840 | 3840 | |
3841 | - if ( $status_transition ) { |
|
3841 | + if ($status_transition) { |
|
3842 | 3842 | try { |
3843 | 3843 | |
3844 | 3844 | // Fire a hook for the status change. |
3845 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
3845 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
3846 | 3846 | |
3847 | 3847 | // @deprecated this is deprecated and will be removed in the future. |
3848 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3848 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3849 | 3849 | |
3850 | - if ( ! empty( $status_transition['from'] ) ) { |
|
3850 | + if (!empty($status_transition['from'])) { |
|
3851 | 3851 | |
3852 | 3852 | /* translators: 1: old invoice status 2: new invoice status */ |
3853 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
3853 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this)); |
|
3854 | 3854 | |
3855 | 3855 | // Fire another hook. |
3856 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
3857 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
3856 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
3857 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
3858 | 3858 | |
3859 | 3859 | // @deprecated this is deprecated and will be removed in the future. |
3860 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3860 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3861 | 3861 | |
3862 | 3862 | // Note the transition occurred. |
3863 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
3863 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']); |
|
3864 | 3864 | |
3865 | 3865 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
3866 | 3866 | if ( |
3867 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3868 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3867 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3868 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3869 | 3869 | ) { |
3870 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
3870 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
3871 | 3871 | } |
3872 | 3872 | |
3873 | 3873 | // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
3874 | 3874 | if ( |
3875 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3876 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3875 | + in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3876 | + && in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3877 | 3877 | ) { |
3878 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
3878 | + do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition); |
|
3879 | 3879 | } |
3880 | 3880 | } else { |
3881 | 3881 | /* translators: %s: new invoice status */ |
3882 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
3882 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this)); |
|
3883 | 3883 | |
3884 | 3884 | // Note the transition occurred. |
3885 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3885 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
3886 | 3886 | |
3887 | 3887 | } |
3888 | - } catch ( Exception $e ) { |
|
3889 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
3888 | + } catch (Exception $e) { |
|
3889 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
3890 | 3890 | } |
3891 | 3891 | } |
3892 | 3892 | } |
@@ -3894,13 +3894,13 @@ discard block |
||
3894 | 3894 | /** |
3895 | 3895 | * Updates an invoice status. |
3896 | 3896 | */ |
3897 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
3897 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
3898 | 3898 | |
3899 | 3899 | // Fires before updating a status. |
3900 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
3900 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
3901 | 3901 | |
3902 | 3902 | // Update the status. |
3903 | - $this->set_status( $new_status, $note, $manual ); |
|
3903 | + $this->set_status($new_status, $note, $manual); |
|
3904 | 3904 | |
3905 | 3905 | // Save the order. |
3906 | 3906 | return $this->save(); |
@@ -3911,18 +3911,18 @@ discard block |
||
3911 | 3911 | * @deprecated |
3912 | 3912 | */ |
3913 | 3913 | public function refresh_item_ids() { |
3914 | - $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) ); |
|
3915 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
3914 | + $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id'))); |
|
3915 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
3916 | 3916 | } |
3917 | 3917 | |
3918 | 3918 | /** |
3919 | 3919 | * @deprecated |
3920 | 3920 | */ |
3921 | - public function update_items( $temp = false ) { |
|
3921 | + public function update_items($temp = false) { |
|
3922 | 3922 | |
3923 | - $this->set_items( $this->get_items() ); |
|
3923 | + $this->set_items($this->get_items()); |
|
3924 | 3924 | |
3925 | - if ( ! $temp ) { |
|
3925 | + if (!$temp) { |
|
3926 | 3926 | $this->save(); |
3927 | 3927 | } |
3928 | 3928 | |
@@ -3936,11 +3936,11 @@ discard block |
||
3936 | 3936 | |
3937 | 3937 | $discount_code = $this->get_discount_code(); |
3938 | 3938 | |
3939 | - if ( empty( $discount_code ) ) { |
|
3939 | + if (empty($discount_code)) { |
|
3940 | 3940 | return false; |
3941 | 3941 | } |
3942 | 3942 | |
3943 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3943 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3944 | 3944 | |
3945 | 3945 | // Ensure it is active. |
3946 | 3946 | return $discount->exists(); |
@@ -3951,7 +3951,7 @@ discard block |
||
3951 | 3951 | * Refunds an invoice. |
3952 | 3952 | */ |
3953 | 3953 | public function refund() { |
3954 | - $this->set_status( 'wpi-refunded' ); |
|
3954 | + $this->set_status('wpi-refunded'); |
|
3955 | 3955 | $this->save(); |
3956 | 3956 | } |
3957 | 3957 | |
@@ -3960,53 +3960,53 @@ discard block |
||
3960 | 3960 | * |
3961 | 3961 | * @param string $transaction_id |
3962 | 3962 | */ |
3963 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
3963 | + public function mark_paid($transaction_id = null, $note = '') { |
|
3964 | 3964 | |
3965 | 3965 | // Set the transaction id. |
3966 | - if ( empty( $transaction_id ) ) { |
|
3967 | - $transaction_id = $this->generate_key( 'trans_' ); |
|
3966 | + if (empty($transaction_id)) { |
|
3967 | + $transaction_id = $this->generate_key('trans_'); |
|
3968 | 3968 | } |
3969 | 3969 | |
3970 | - if ( ! $this->get_transaction_id() ) { |
|
3971 | - $this->set_transaction_id( $transaction_id ); |
|
3970 | + if (!$this->get_transaction_id()) { |
|
3971 | + $this->set_transaction_id($transaction_id); |
|
3972 | 3972 | } |
3973 | 3973 | |
3974 | - if ( $this->is_paid() && 'wpi-processing' !== $this->get_status() ) { |
|
3974 | + if ($this->is_paid() && 'wpi-processing' !== $this->get_status()) { |
|
3975 | 3975 | return $this->save(); |
3976 | 3976 | } |
3977 | 3977 | |
3978 | 3978 | // Set the completed date. |
3979 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
3979 | + $this->set_date_completed(current_time('mysql')); |
|
3980 | 3980 | |
3981 | 3981 | // Set the new status. |
3982 | - $gateway = sanitize_text_field( $this->get_gateway_title() ); |
|
3983 | - if ( $this->is_renewal() || ! $this->is_parent() ) { |
|
3982 | + $gateway = sanitize_text_field($this->get_gateway_title()); |
|
3983 | + if ($this->is_renewal() || !$this->is_parent()) { |
|
3984 | 3984 | |
3985 | - $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway ); |
|
3986 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
3985 | + $_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway); |
|
3986 | + $_note = $_note . empty($note) ? '' : " ($note)"; |
|
3987 | 3987 | |
3988 | - if ( 'none' == $this->get_gateway() ) { |
|
3988 | + if ('none' == $this->get_gateway()) { |
|
3989 | 3989 | $_note = $note; |
3990 | 3990 | } |
3991 | 3991 | |
3992 | - $this->set_status( 'wpi-renewal', $_note ); |
|
3992 | + $this->set_status('wpi-renewal', $_note); |
|
3993 | 3993 | |
3994 | 3994 | } else { |
3995 | 3995 | |
3996 | - $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway ); |
|
3997 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
3996 | + $_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway); |
|
3997 | + $_note = $_note . empty($note) ? '' : " ($note)"; |
|
3998 | 3998 | |
3999 | - if ( 'none' == $this->get_gateway() ) { |
|
3999 | + if ('none' == $this->get_gateway()) { |
|
4000 | 4000 | $_note = $note; |
4001 | 4001 | } |
4002 | 4002 | |
4003 | - $this->set_status( 'publish', $_note ); |
|
4003 | + $this->set_status('publish', $_note); |
|
4004 | 4004 | |
4005 | 4005 | } |
4006 | 4006 | |
4007 | 4007 | // Set checkout mode. |
4008 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
4009 | - $this->set_mode( $mode ); |
|
4008 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
4009 | + $this->set_mode($mode); |
|
4010 | 4010 | |
4011 | 4011 | // Save the invoice. |
4012 | 4012 | $this->save(); |
@@ -4031,16 +4031,16 @@ discard block |
||
4031 | 4031 | * Clears the subscription's cache. |
4032 | 4032 | */ |
4033 | 4033 | public function clear_cache() { |
4034 | - if ( $this->get_key() ) { |
|
4035 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
4034 | + if ($this->get_key()) { |
|
4035 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
4036 | 4036 | } |
4037 | 4037 | |
4038 | - if ( $this->get_number() ) { |
|
4039 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
4038 | + if ($this->get_number()) { |
|
4039 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
4040 | 4040 | } |
4041 | 4041 | |
4042 | - if ( $this->get_transaction_id() ) { |
|
4043 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
4042 | + if ($this->get_transaction_id()) { |
|
4043 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
4044 | 4044 | } |
4045 | 4045 | } |
4046 | 4046 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains functions that display the subscriptions admin page. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Render the Subscriptions page |
@@ -17,23 +17,23 @@ discard block |
||
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
21 | 21 | <div class="bsui"> |
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | 25 | // Verify user permissions. |
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
27 | 27 | |
28 | 28 | aui()->alert( |
29 | 29 | array( |
30 | 30 | 'type' => 'danger', |
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
32 | 32 | ), |
33 | 33 | true |
34 | 34 | ); |
35 | 35 | |
36 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
36 | + } elseif (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
37 | 37 | |
38 | 38 | // Display a single subscription. |
39 | 39 | wpinv_recurring_subscription_details(); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | <?php $subscribers_table->views(); ?> |
68 | 68 | <form id="subscribers-filter" class="bsui" method="get"> |
69 | 69 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
70 | - <?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?> |
|
70 | + <?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?> |
|
71 | 71 | <?php $subscribers_table->display(); ?> |
72 | 72 | </form> |
73 | 73 | <?php |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | function wpinv_recurring_subscription_details() { |
84 | 84 | |
85 | 85 | // Fetch the subscription. |
86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
87 | - if ( ! $sub->exists() ) { |
|
86 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
87 | + if (!$sub->exists()) { |
|
88 | 88 | |
89 | 89 | aui()->alert( |
90 | 90 | array( |
91 | 91 | 'type' => 'danger', |
92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
92 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
93 | 93 | ), |
94 | 94 | true |
95 | 95 | ); |
@@ -98,32 +98,32 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | // Use metaboxes to display the subscription details. |
101 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
102 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
101 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
102 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
103 | 103 | |
104 | 104 | $subscription_id = $sub->get_id(); |
105 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
106 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
105 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
106 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
107 | 107 | |
108 | - if ( 1 < count( $subscription_groups ) ) { |
|
109 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
108 | + if (1 < count($subscription_groups)) { |
|
109 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
110 | 110 | } |
111 | 111 | |
112 | - if ( ! empty( $subscription_group ) ) { |
|
113 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
112 | + if (!empty($subscription_group)) { |
|
113 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
114 | 114 | } |
115 | 115 | |
116 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
116 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
117 | 117 | |
118 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
118 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
119 | 119 | |
120 | 120 | ?> |
121 | 121 | |
122 | - <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
|
122 | + <form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id()))); ?>"> |
|
123 | 123 | |
124 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
125 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
126 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
124 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
125 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
126 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
127 | 127 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
128 | 128 | <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
129 | 129 | |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
132 | 132 | |
133 | 133 | <div id="postbox-container-1" class="postbox-container"> |
134 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
134 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
135 | 135 | </div> |
136 | 136 | |
137 | 137 | <div id="postbox-container-2" class="postbox-container"> |
138 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
139 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
138 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
139 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
140 | 140 | </div> |
141 | 141 | |
142 | 142 | </div> |
@@ -155,48 +155,48 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @param WPInv_Subscription $sub |
157 | 157 | */ |
158 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
158 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
159 | 159 | |
160 | 160 | // Subscription items. |
161 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
162 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
161 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
162 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
163 | 163 | |
164 | 164 | // Prepare subscription detail columns. |
165 | 165 | $fields = apply_filters( |
166 | 166 | 'getpaid_subscription_admin_page_fields', |
167 | 167 | array( |
168 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
169 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
170 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
171 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
172 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
173 | - 'renewals' => __( 'Collected Payments', 'invoicing' ), |
|
174 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
177 | - 'status' => __( 'Status', 'invoicing' ), |
|
168 | + 'subscription' => __('Subscription', 'invoicing'), |
|
169 | + 'customer' => __('Customer', 'invoicing'), |
|
170 | + 'amount' => __('Amount', 'invoicing'), |
|
171 | + 'start_date' => __('Start Date', 'invoicing'), |
|
172 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
173 | + 'renewals' => __('Collected Payments', 'invoicing'), |
|
174 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
175 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
176 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
177 | + 'status' => __('Status', 'invoicing'), |
|
178 | 178 | ) |
179 | 179 | ); |
180 | 180 | |
181 | - if ( ! $sub->is_active() ) { |
|
181 | + if (!$sub->is_active()) { |
|
182 | 182 | |
183 | - if ( isset( $fields['renews_on'] ) ) { |
|
184 | - unset( $fields['renews_on'] ); |
|
183 | + if (isset($fields['renews_on'])) { |
|
184 | + unset($fields['renews_on']); |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( isset( $fields['gateway'] ) ) { |
|
188 | - unset( $fields['gateway'] ); |
|
187 | + if (isset($fields['gateway'])) { |
|
188 | + unset($fields['gateway']); |
|
189 | 189 | } |
190 | - } elseif ( $sub->is_last_renewal() ) { |
|
190 | + } elseif ($sub->is_last_renewal()) { |
|
191 | 191 | |
192 | - if ( isset( $fields['renews_on'] ) ) { |
|
193 | - $fields['renews_on'] = __( 'End Date', 'invoicing' ); |
|
192 | + if (isset($fields['renews_on'])) { |
|
193 | + $fields['renews_on'] = __('End Date', 'invoicing'); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | 197 | $profile_id = $sub->get_profile_id(); |
198 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
199 | - unset( $fields['profile_id'] ); |
|
198 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
199 | + unset($fields['profile_id']); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | ?> |
@@ -204,16 +204,16 @@ discard block |
||
204 | 204 | <table class="table table-borderless" style="font-size: 14px;"> |
205 | 205 | <tbody> |
206 | 206 | |
207 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
207 | + <?php foreach ($fields as $key => $label) : ?> |
|
208 | 208 | |
209 | - <tr class="getpaid-subscription-meta-<?php echo esc_attr( $key ); ?>"> |
|
209 | + <tr class="getpaid-subscription-meta-<?php echo esc_attr($key); ?>"> |
|
210 | 210 | |
211 | 211 | <th class="w-25" style="font-weight: 500;"> |
212 | - <?php echo esc_html( $label ); ?> |
|
212 | + <?php echo esc_html($label); ?> |
|
213 | 213 | </th> |
214 | 214 | |
215 | 215 | <td class="w-75 text-muted"> |
216 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?> |
|
216 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?> |
|
217 | 217 | </td> |
218 | 218 | |
219 | 219 | </tr> |
@@ -231,144 +231,144 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @param WPInv_Subscription $subscription |
233 | 233 | */ |
234 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
234 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
235 | 235 | |
236 | - $username = __( '(Missing User)', 'invoicing' ); |
|
236 | + $username = __('(Missing User)', 'invoicing'); |
|
237 | 237 | |
238 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
239 | - if ( $user ) { |
|
238 | + $user = get_userdata($subscription->get_customer_id()); |
|
239 | + if ($user) { |
|
240 | 240 | |
241 | 241 | $username = sprintf( |
242 | 242 | '<a href="user-edit.php?user_id=%s">%s</a>', |
243 | - absint( $user->ID ), |
|
244 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
243 | + absint($user->ID), |
|
244 | + !empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email) |
|
245 | 245 | ); |
246 | 246 | |
247 | 247 | } |
248 | 248 | |
249 | - echo wp_kses_post( $username ); |
|
249 | + echo wp_kses_post($username); |
|
250 | 250 | } |
251 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
251 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
252 | 252 | |
253 | 253 | /** |
254 | 254 | * Displays the subscription amount. |
255 | 255 | * |
256 | 256 | * @param WPInv_Subscription $subscription |
257 | 257 | */ |
258 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
259 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
260 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
258 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
259 | + $amount = getpaid_get_formatted_subscription_amount($subscription); |
|
260 | + echo wp_kses_post("<span>$amount</span>"); |
|
261 | 261 | } |
262 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
262 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
263 | 263 | |
264 | 264 | /** |
265 | 265 | * Displays the subscription id. |
266 | 266 | * |
267 | 267 | * @param WPInv_Subscription $subscription |
268 | 268 | */ |
269 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
269 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
270 | 270 | |
271 | 271 | printf( |
272 | 272 | '<a href="%s">#%s</a>', |
273 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
274 | - absint( $subscription->get_id() ) |
|
273 | + esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))), |
|
274 | + absint($subscription->get_id()) |
|
275 | 275 | ); |
276 | 276 | |
277 | 277 | } |
278 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
278 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
279 | 279 | |
280 | 280 | /** |
281 | 281 | * Displays the subscription renewal date. |
282 | 282 | * |
283 | 283 | * @param WPInv_Subscription $subscription |
284 | 284 | */ |
285 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
285 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
286 | 286 | |
287 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
287 | + if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) { |
|
288 | 288 | aui()->input( |
289 | 289 | array( |
290 | 290 | 'type' => 'text', |
291 | 291 | 'id' => 'wpinv_subscription_date_created', |
292 | 292 | 'name' => 'wpinv_subscription_date_created', |
293 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
293 | + 'label' => __('Start Date', 'invoicing'), |
|
294 | 294 | 'label_type' => 'hidden', |
295 | 295 | 'placeholder' => 'YYYY-MM-DD', |
296 | - 'value' => esc_attr( $subscription->get_date_created( 'edit' ) ), |
|
296 | + 'value' => esc_attr($subscription->get_date_created('edit')), |
|
297 | 297 | 'no_wrap' => true, |
298 | 298 | 'size' => 'sm', |
299 | 299 | ), |
300 | 300 | true |
301 | 301 | ); |
302 | 302 | } else { |
303 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
303 | + echo esc_html(getpaid_format_date_value($subscription->get_date_created())); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | } |
307 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
307 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
308 | 308 | |
309 | 309 | /** |
310 | 310 | * Displays the subscription renewal date. |
311 | 311 | * |
312 | 312 | * @param WPInv_Subscription $subscription |
313 | 313 | */ |
314 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
314 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
315 | 315 | |
316 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
316 | + if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) { |
|
317 | 317 | aui()->input( |
318 | 318 | array( |
319 | 319 | 'type' => 'text', |
320 | 320 | 'id' => 'wpinv_subscription_expiration', |
321 | 321 | 'name' => 'wpinv_subscription_expiration', |
322 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
322 | + 'label' => __('Renews On', 'invoicing'), |
|
323 | 323 | 'label_type' => 'hidden', |
324 | 324 | 'placeholder' => 'YYYY-MM-DD', |
325 | - 'value' => esc_attr( $subscription->get_expiration( 'edit' ) ), |
|
325 | + 'value' => esc_attr($subscription->get_expiration('edit')), |
|
326 | 326 | 'no_wrap' => true, |
327 | 327 | 'size' => 'sm', |
328 | 328 | ), |
329 | 329 | true |
330 | 330 | ); |
331 | 331 | } else { |
332 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
332 | + echo esc_html(getpaid_format_date_value($subscription->get_expiration())); |
|
333 | 333 | } |
334 | 334 | } |
335 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
335 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * Displays the subscription renewal count. |
339 | 339 | * |
340 | 340 | * @param WPInv_Subscription $subscription |
341 | 341 | */ |
342 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
342 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
343 | 343 | |
344 | 344 | $max_bills = $subscription->get_bill_times(); |
345 | 345 | $times_billed = (int) $subscription->get_times_billed(); |
346 | 346 | |
347 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) { |
|
347 | + if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_bill_times_change')) { |
|
348 | 348 | aui()->input( |
349 | 349 | array( |
350 | 350 | 'type' => 'number', |
351 | 351 | 'id' => 'wpinv_subscription_max_bill_times', |
352 | 352 | 'name' => 'wpinv_subscription_max_bill_times', |
353 | - 'label' => __( 'Maximum bill times', 'invoicing' ), |
|
353 | + 'label' => __('Maximum bill times', 'invoicing'), |
|
354 | 354 | 'label_type' => 'hidden', |
355 | - 'placeholder' => __( 'Unlimited', 'invoicing' ), |
|
356 | - 'value' => empty( $max_bills ) ? '' : (int) $max_bills, |
|
355 | + 'placeholder' => __('Unlimited', 'invoicing'), |
|
356 | + 'value' => empty($max_bills) ? '' : (int) $max_bills, |
|
357 | 357 | 'no_wrap' => true, |
358 | 358 | 'size' => 'sm', |
359 | 359 | 'input_group_left' => sprintf( |
360 | 360 | // translators: %d: Number of times billed |
361 | - __( '%d of', 'invoicing' ), |
|
361 | + __('%d of', 'invoicing'), |
|
362 | 362 | $times_billed |
363 | 363 | ), |
364 | 364 | ), |
365 | 365 | true |
366 | 366 | ); |
367 | 367 | } else { |
368 | - echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
368 | + echo esc_html($times_billed) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
369 | 369 | } |
370 | 370 | } |
371 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
371 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Displays the subscription item. |
@@ -376,53 +376,53 @@ discard block |
||
376 | 376 | * @param WPInv_Subscription $subscription |
377 | 377 | * @param false|array $subscription_group |
378 | 378 | */ |
379 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
379 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
380 | 380 | |
381 | - if ( empty( $subscription_group ) ) { |
|
382 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
381 | + if (empty($subscription_group)) { |
|
382 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id())); |
|
383 | 383 | return; |
384 | 384 | } |
385 | 385 | |
386 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
387 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
386 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
387 | + echo wp_kses_post(implode(' | ', $markup)); |
|
388 | 388 | |
389 | 389 | } |
390 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
390 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
391 | 391 | |
392 | 392 | /** |
393 | 393 | * Displays the subscription gateway. |
394 | 394 | * |
395 | 395 | * @param WPInv_Subscription $subscription |
396 | 396 | */ |
397 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
397 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
398 | 398 | |
399 | 399 | $gateway = $subscription->get_gateway(); |
400 | 400 | |
401 | - if ( ! empty( $gateway ) ) { |
|
402 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
401 | + if (!empty($gateway)) { |
|
402 | + echo esc_html(wpinv_get_gateway_admin_label($gateway)); |
|
403 | 403 | } else { |
404 | 404 | echo '—'; |
405 | 405 | } |
406 | 406 | |
407 | 407 | } |
408 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
408 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
409 | 409 | |
410 | 410 | /** |
411 | 411 | * Displays the subscription status. |
412 | 412 | * |
413 | 413 | * @param WPInv_Subscription $subscription |
414 | 414 | */ |
415 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
416 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
415 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
416 | + echo wp_kses_post($subscription->get_status_label_html()); |
|
417 | 417 | } |
418 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
418 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
419 | 419 | |
420 | 420 | /** |
421 | 421 | * Displays the subscription profile id. |
422 | 422 | * |
423 | 423 | * @param WPInv_Subscription $subscription |
424 | 424 | */ |
425 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
425 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
426 | 426 | |
427 | 427 | $profile_id = $subscription->get_profile_id(); |
428 | 428 | |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | 'type' => 'text', |
432 | 432 | 'id' => 'wpinv_subscription_profile_id', |
433 | 433 | 'name' => 'wpinv_subscription_profile_id', |
434 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
434 | + 'label' => __('Profile Id', 'invoicing'), |
|
435 | 435 | 'label_type' => 'hidden', |
436 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
437 | - 'value' => esc_attr( $profile_id ), |
|
436 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
437 | + 'value' => esc_attr($profile_id), |
|
438 | 438 | 'input_group_right' => '', |
439 | 439 | 'no_wrap' => true, |
440 | 440 | 'size' => 'sm', |
@@ -442,20 +442,20 @@ discard block |
||
442 | 442 | true |
443 | 443 | ); |
444 | 444 | |
445 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
446 | - if ( ! empty( $url ) ) { |
|
447 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
445 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
446 | + if (!empty($url)) { |
|
447 | + echo ' <a href="' . esc_url_raw($url) . '" title="' . esc_attr__('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | } |
451 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
451 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
452 | 452 | |
453 | 453 | /** |
454 | 454 | * Displays the subscriptions update metabox. |
455 | 455 | * |
456 | 456 | * @param WPInv_Subscription $subscription |
457 | 457 | */ |
458 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
458 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
459 | 459 | |
460 | 460 | ?> |
461 | 461 | <div class="mt-3"> |
@@ -468,10 +468,10 @@ discard block |
||
468 | 468 | 'id' => 'subscription_status_update_select', |
469 | 469 | 'required' => true, |
470 | 470 | 'no_wrap' => false, |
471 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
472 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
471 | + 'label' => __('Subscription Status', 'invoicing'), |
|
472 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
473 | 473 | 'select2' => true, |
474 | - 'value' => $subscription->get_status( 'edit' ), |
|
474 | + 'value' => $subscription->get_status('edit'), |
|
475 | 475 | ), |
476 | 476 | true |
477 | 477 | ); |
@@ -480,14 +480,14 @@ discard block |
||
480 | 480 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
481 | 481 | |
482 | 482 | <?php |
483 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
483 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
484 | 484 | |
485 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
486 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
487 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
485 | + $url = wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'); |
|
486 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
487 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
488 | 488 | |
489 | - if ( $subscription->is_active() ) { |
|
490 | - echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
489 | + if ($subscription->is_active()) { |
|
490 | + echo "<a href='" . esc_url($url) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr($title) . "\")'>" . esc_html($anchor) . "</a>"; |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | echo '</div></div>'; |
@@ -499,44 +499,44 @@ discard block |
||
499 | 499 | * @param WPInv_Subscription $subscription |
500 | 500 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
501 | 501 | */ |
502 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
502 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
503 | 503 | |
504 | 504 | $columns = apply_filters( |
505 | 505 | 'getpaid_subscription_related_invoices_columns', |
506 | 506 | array( |
507 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
508 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
509 | - 'date' => __( 'Date', 'invoicing' ), |
|
510 | - 'status' => __( 'Status', 'invoicing' ), |
|
511 | - 'total' => __( 'Total', 'invoicing' ), |
|
507 | + 'invoice' => __('Invoice', 'invoicing'), |
|
508 | + 'relationship' => __('Relationship', 'invoicing'), |
|
509 | + 'date' => __('Date', 'invoicing'), |
|
510 | + 'status' => __('Status', 'invoicing'), |
|
511 | + 'total' => __('Total', 'invoicing'), |
|
512 | 512 | ), |
513 | 513 | $subscription |
514 | 514 | ); |
515 | 515 | |
516 | 516 | // Prepare the invoices. |
517 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
517 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
518 | 518 | $parent = $subscription->get_parent_invoice(); |
519 | 519 | |
520 | - if ( $parent->exists() ) { |
|
521 | - $payments = array_merge( array( $parent ), $payments ); |
|
520 | + if ($parent->exists()) { |
|
521 | + $payments = array_merge(array($parent), $payments); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | $table_class = 'w-100 bg-white'; |
525 | 525 | |
526 | - if ( ! is_admin() ) { |
|
526 | + if (!is_admin()) { |
|
527 | 527 | $table_class = 'table table-bordered'; |
528 | 528 | } |
529 | 529 | |
530 | 530 | ?> |
531 | 531 | <div class="m-0" style="overflow: auto;"> |
532 | 532 | |
533 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
533 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
534 | 534 | |
535 | 535 | <thead> |
536 | 536 | <tr> |
537 | 537 | <?php |
538 | - foreach ( $columns as $key => $label ) { |
|
539 | - echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
538 | + foreach ($columns as $key => $label) { |
|
539 | + echo "<th class='subscription-invoice-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
540 | 540 | } |
541 | 541 | ?> |
542 | 542 | </tr> |
@@ -544,71 +544,71 @@ discard block |
||
544 | 544 | |
545 | 545 | <tbody> |
546 | 546 | |
547 | - <?php if ( empty( $payments ) ) : ?> |
|
547 | + <?php if (empty($payments)) : ?> |
|
548 | 548 | <tr> |
549 | - <td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted"> |
|
550 | - <?php esc_html_e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
549 | + <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
|
550 | + <?php esc_html_e('This subscription has no invoices.', 'invoicing'); ?> |
|
551 | 551 | </td> |
552 | 552 | </tr> |
553 | 553 | <?php endif; ?> |
554 | 554 | |
555 | 555 | <?php |
556 | 556 | |
557 | - foreach ( $payments as $payment ) : |
|
557 | + foreach ($payments as $payment) : |
|
558 | 558 | |
559 | 559 | // Ensure that we have an invoice. |
560 | - $payment = new WPInv_Invoice( $payment ); |
|
560 | + $payment = new WPInv_Invoice($payment); |
|
561 | 561 | |
562 | 562 | // Abort if the invoice is invalid... |
563 | - if ( ! $payment->exists() ) { |
|
563 | + if (!$payment->exists()) { |
|
564 | 564 | continue; |
565 | 565 | } |
566 | 566 | |
567 | 567 | // ... or belongs to a different subscription. |
568 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
568 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
569 | 569 | continue; |
570 | 570 | } |
571 | 571 | |
572 | 572 | echo '<tr>'; |
573 | 573 | |
574 | - foreach ( array_keys( $columns ) as $key ) { |
|
574 | + foreach (array_keys($columns) as $key) { |
|
575 | 575 | |
576 | 576 | echo "<td class='p-2 text-left'>"; |
577 | 577 | |
578 | - switch ( $key ) { |
|
578 | + switch ($key) { |
|
579 | 579 | |
580 | 580 | case 'total': |
581 | 581 | echo '<strong>'; |
582 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
582 | + wpinv_the_price($payment->get_total(), $payment->get_currency()); |
|
583 | 583 | echo '</strong>'; |
584 | 584 | break; |
585 | 585 | |
586 | 586 | case 'relationship': |
587 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
587 | + echo $payment->is_renewal() ? esc_html__('Renewal Invoice', 'invoicing') : esc_html__('Initial Invoice', 'invoicing'); |
|
588 | 588 | break; |
589 | 589 | |
590 | 590 | case 'date': |
591 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
591 | + echo esc_html(getpaid_format_date_value($payment->get_date_created())); |
|
592 | 592 | break; |
593 | 593 | |
594 | 594 | case 'status': |
595 | 595 | $status = $payment->get_status_nicename(); |
596 | - if ( is_admin() ) { |
|
596 | + if (is_admin()) { |
|
597 | 597 | $status = $payment->get_status_label_html(); |
598 | 598 | } |
599 | 599 | |
600 | - echo wp_kses_post( $status ); |
|
600 | + echo wp_kses_post($status); |
|
601 | 601 | break; |
602 | 602 | |
603 | 603 | case 'invoice': |
604 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
604 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
605 | 605 | |
606 | - if ( ! is_admin() ) { |
|
607 | - $link = esc_url( $payment->get_view_url() ); |
|
606 | + if (!is_admin()) { |
|
607 | + $link = esc_url($payment->get_view_url()); |
|
608 | 608 | } |
609 | 609 | |
610 | - $invoice = esc_html( $payment->get_number() ); |
|
611 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
610 | + $invoice = esc_html($payment->get_number()); |
|
611 | + echo wp_kses_post("<a href='$link'>$invoice</a>"); |
|
612 | 612 | break; |
613 | 613 | } |
614 | 614 | |
@@ -635,12 +635,12 @@ discard block |
||
635 | 635 | * |
636 | 636 | * @param WPInv_Subscription $subscription |
637 | 637 | */ |
638 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
638 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
639 | 639 | |
640 | 640 | // Fetch the subscription group. |
641 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
641 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
642 | 642 | |
643 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
643 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
644 | 644 | return; |
645 | 645 | } |
646 | 646 | |
@@ -648,12 +648,12 @@ discard block |
||
648 | 648 | $columns = apply_filters( |
649 | 649 | 'getpaid_subscription_item_details_columns', |
650 | 650 | array( |
651 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
652 | - 'price' => __( 'Price', 'invoicing' ), |
|
653 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
654 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
651 | + 'item_name' => __('Item', 'invoicing'), |
|
652 | + 'price' => __('Price', 'invoicing'), |
|
653 | + 'tax' => __('Tax', 'invoicing'), |
|
654 | + 'discount' => __('Discount', 'invoicing'), |
|
655 | 655 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
656 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
656 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
657 | 657 | ), |
658 | 658 | $subscription |
659 | 659 | ); |
@@ -662,27 +662,27 @@ discard block |
||
662 | 662 | |
663 | 663 | $invoice = $subscription->get_parent_invoice(); |
664 | 664 | |
665 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
666 | - unset( $columns['tax'] ); |
|
665 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
666 | + unset($columns['tax']); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | $table_class = 'w-100 bg-white'; |
670 | 670 | |
671 | - if ( ! is_admin() ) { |
|
671 | + if (!is_admin()) { |
|
672 | 672 | $table_class = 'table table-bordered'; |
673 | 673 | } |
674 | 674 | |
675 | 675 | ?> |
676 | 676 | <div class="m-0" style="overflow: auto;"> |
677 | 677 | |
678 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
678 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
679 | 679 | |
680 | 680 | <thead> |
681 | 681 | <tr> |
682 | 682 | <?php |
683 | 683 | |
684 | - foreach ( $columns as $key => $label ) { |
|
685 | - echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
684 | + foreach ($columns as $key => $label) { |
|
685 | + echo "<th class='subscription-item-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
686 | 686 | } |
687 | 687 | ?> |
688 | 688 | </tr> |
@@ -692,48 +692,48 @@ discard block |
||
692 | 692 | |
693 | 693 | <?php |
694 | 694 | |
695 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
695 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
696 | 696 | |
697 | 697 | echo '<tr>'; |
698 | 698 | |
699 | - foreach ( array_keys( $columns ) as $key ) { |
|
699 | + foreach (array_keys($columns) as $key) { |
|
700 | 700 | |
701 | 701 | $class = 'text-left'; |
702 | 702 | |
703 | 703 | echo "<td class='p-2 text-left'>"; |
704 | 704 | |
705 | - switch ( $key ) { |
|
705 | + switch ($key) { |
|
706 | 706 | |
707 | 707 | case 'item_name': |
708 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
709 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
708 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
709 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
710 | 710 | |
711 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
712 | - echo esc_html( $item_name ); |
|
711 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
712 | + echo esc_html($item_name); |
|
713 | 713 | } else { |
714 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
714 | + printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | break; |
718 | 718 | |
719 | 719 | case 'price': |
720 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
720 | + wpinv_the_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
721 | 721 | break; |
722 | 722 | |
723 | 723 | case 'tax': |
724 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
724 | + wpinv_the_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
725 | 725 | break; |
726 | 726 | |
727 | 727 | case 'discount': |
728 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
728 | + wpinv_the_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
729 | 729 | break; |
730 | 730 | |
731 | 731 | case 'initial': |
732 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
732 | + wpinv_the_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
733 | 733 | break; |
734 | 734 | |
735 | 735 | case 'recurring': |
736 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
736 | + echo wp_kses_post('<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'); |
|
737 | 737 | break; |
738 | 738 | |
739 | 739 | } |
@@ -746,24 +746,24 @@ discard block |
||
746 | 746 | |
747 | 747 | endforeach; |
748 | 748 | |
749 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
749 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
750 | 750 | |
751 | 751 | echo '<tr>'; |
752 | 752 | |
753 | - foreach ( array_keys( $columns ) as $key ) { |
|
753 | + foreach (array_keys($columns) as $key) { |
|
754 | 754 | |
755 | 755 | $class = 'text-left'; |
756 | 756 | |
757 | 757 | echo "<td class='p-2 text-left'>"; |
758 | 758 | |
759 | - switch ( $key ) { |
|
759 | + switch ($key) { |
|
760 | 760 | |
761 | 761 | case 'item_name': |
762 | - echo esc_html( $subscription_group_fee['name'] ); |
|
762 | + echo esc_html($subscription_group_fee['name']); |
|
763 | 763 | break; |
764 | 764 | |
765 | 765 | case 'price': |
766 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
766 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
767 | 767 | break; |
768 | 768 | |
769 | 769 | case 'tax': |
@@ -775,11 +775,11 @@ discard block |
||
775 | 775 | break; |
776 | 776 | |
777 | 777 | case 'initial': |
778 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
778 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
779 | 779 | break; |
780 | 780 | |
781 | 781 | case 'recurring': |
782 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
782 | + echo wp_kses_post('<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'); |
|
783 | 783 | break; |
784 | 784 | |
785 | 785 | } |
@@ -808,12 +808,12 @@ discard block |
||
808 | 808 | * @param WPInv_Subscription $subscription |
809 | 809 | * @param bool $skip_current |
810 | 810 | */ |
811 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
811 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
812 | 812 | |
813 | 813 | // Fetch the subscription groups. |
814 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
814 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
815 | 815 | |
816 | - if ( empty( $subscription_groups ) ) { |
|
816 | + if (empty($subscription_groups)) { |
|
817 | 817 | return; |
818 | 818 | } |
819 | 819 | |
@@ -821,37 +821,37 @@ discard block |
||
821 | 821 | $columns = apply_filters( |
822 | 822 | 'getpaid_subscription_related_subscriptions_columns', |
823 | 823 | array( |
824 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
825 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
826 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
827 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
828 | - 'item' => __( 'Items', 'invoicing' ), |
|
829 | - 'status' => __( 'Status', 'invoicing' ), |
|
824 | + 'subscription' => __('Subscription', 'invoicing'), |
|
825 | + 'start_date' => __('Start Date', 'invoicing'), |
|
826 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
827 | + 'renewals' => __('Payments', 'invoicing'), |
|
828 | + 'item' => __('Items', 'invoicing'), |
|
829 | + 'status' => __('Status', 'invoicing'), |
|
830 | 830 | ), |
831 | 831 | $subscription |
832 | 832 | ); |
833 | 833 | |
834 | - if ( $subscription->get_status() == 'pending' ) { |
|
835 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
834 | + if ($subscription->get_status() == 'pending') { |
|
835 | + unset($columns['start_date'], $columns['renewal_date']); |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | $table_class = 'w-100 bg-white'; |
839 | 839 | |
840 | - if ( ! is_admin() ) { |
|
840 | + if (!is_admin()) { |
|
841 | 841 | $table_class = 'table table-bordered'; |
842 | 842 | } |
843 | 843 | |
844 | 844 | ?> |
845 | 845 | <div class="m-0" style="overflow: auto;"> |
846 | 846 | |
847 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
847 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
848 | 848 | |
849 | 849 | <thead> |
850 | 850 | <tr> |
851 | 851 | <?php |
852 | 852 | |
853 | - foreach ( $columns as $key => $label ) { |
|
854 | - echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
853 | + foreach ($columns as $key => $label) { |
|
854 | + echo "<th class='related-subscription-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
855 | 855 | } |
856 | 856 | ?> |
857 | 857 | </tr> |
@@ -861,62 +861,62 @@ discard block |
||
861 | 861 | |
862 | 862 | <?php |
863 | 863 | |
864 | - foreach ( $subscription_groups as $subscription_group ) : |
|
864 | + foreach ($subscription_groups as $subscription_group) : |
|
865 | 865 | |
866 | 866 | // Do not list current subscription. |
867 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
867 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
868 | 868 | continue; |
869 | 869 | } |
870 | 870 | |
871 | 871 | // Ensure the subscription exists. |
872 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
872 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
873 | 873 | |
874 | - if ( ! $_suscription->exists() ) { |
|
874 | + if (!$_suscription->exists()) { |
|
875 | 875 | continue; |
876 | 876 | } |
877 | 877 | |
878 | 878 | echo '<tr>'; |
879 | 879 | |
880 | - foreach ( array_keys( $columns ) as $key ) { |
|
880 | + foreach (array_keys($columns) as $key) { |
|
881 | 881 | |
882 | 882 | $class = 'text-left'; |
883 | 883 | |
884 | 884 | echo "<td class='p-2 text-left'>"; |
885 | 885 | |
886 | - switch ( $key ) { |
|
886 | + switch ($key) { |
|
887 | 887 | |
888 | 888 | case 'status': |
889 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
889 | + echo wp_kses_post($_suscription->get_status_label_html()); |
|
890 | 890 | break; |
891 | 891 | |
892 | 892 | case 'item': |
893 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
894 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
893 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
894 | + echo wp_kses_post(implode(' | ', $markup)); |
|
895 | 895 | break; |
896 | 896 | |
897 | 897 | case 'renewals': |
898 | 898 | $max_bills = $_suscription->get_bill_times(); |
899 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
899 | + echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
900 | 900 | break; |
901 | 901 | |
902 | 902 | case 'renewal_date': |
903 | - echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
903 | + echo $_suscription->is_active() ? esc_html(getpaid_format_date_value($_suscription->get_expiration())) : '—'; |
|
904 | 904 | break; |
905 | 905 | |
906 | 906 | case 'start_date': |
907 | - echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
907 | + echo 'pending' == $_suscription->get_status() ? '—' : esc_html(getpaid_format_date_value($_suscription->get_date_created())); |
|
908 | 908 | break; |
909 | 909 | |
910 | 910 | case 'subscription': |
911 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
911 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
912 | 912 | printf( |
913 | 913 | '%1$s#%2$s%3$s', |
914 | - '<a href="' . esc_url( $url ) . '">', |
|
915 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
914 | + '<a href="' . esc_url($url) . '">', |
|
915 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
916 | 916 | '</a>' |
917 | 917 | ); |
918 | 918 | |
919 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
919 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::column_amount($_suscription)); |
|
920 | 920 | break; |
921 | 921 | |
922 | 922 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Manual Payment Gateway class. |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | public function __construct() { |
47 | 47 | parent::__construct(); |
48 | 48 | |
49 | - $this->title = __( 'Test Gateway', 'invoicing' ); |
|
50 | - $this->method_title = __( 'Test Gateway', 'invoicing' ); |
|
49 | + $this->title = __('Test Gateway', 'invoicing'); |
|
50 | + $this->method_title = __('Test Gateway', 'invoicing'); |
|
51 | 51 | |
52 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) ); |
|
52 | + add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription')); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -61,32 +61,32 @@ discard block |
||
61 | 61 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
62 | 62 | * @return array |
63 | 63 | */ |
64 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
64 | + public function process_payment($invoice, $submission_data, $submission) { |
|
65 | 65 | |
66 | 66 | // Mark it as paid. |
67 | 67 | $invoice->mark_paid(); |
68 | 68 | |
69 | 69 | // (Maybe) activate subscriptions. |
70 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
70 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
71 | 71 | |
72 | - if ( ! empty( $subscriptions ) ) { |
|
73 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
72 | + if (!empty($subscriptions)) { |
|
73 | + $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions); |
|
74 | 74 | |
75 | - foreach ( $subscriptions as $subscription ) { |
|
76 | - if ( $subscription->exists() ) { |
|
77 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
78 | - $expiry = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
75 | + foreach ($subscriptions as $subscription) { |
|
76 | + if ($subscription->exists()) { |
|
77 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
78 | + $expiry = gmdate('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
79 | 79 | |
80 | - $subscription->set_next_renewal_date( $expiry ); |
|
81 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
82 | - $subscription->set_profile_id( $invoice->generate_key( 'manual_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) ); |
|
80 | + $subscription->set_next_renewal_date($expiry); |
|
81 | + $subscription->set_date_created(current_time('mysql')); |
|
82 | + $subscription->set_profile_id($invoice->generate_key('manual_sub_' . $invoice->get_id() . '_' . $subscription->get_id())); |
|
83 | 83 | $subscription->activate(); |
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | 88 | // Send to the success page. |
89 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
89 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
90 | 90 | |
91 | 91 | } |
92 | 92 | |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param WPInv_Subscription $subscription |
98 | 98 | */ |
99 | - public function maybe_renew_subscription( $subscription ) { |
|
99 | + public function maybe_renew_subscription($subscription) { |
|
100 | 100 | |
101 | 101 | // Ensure its our subscription && it's active. |
102 | - if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
|
102 | + if ($this->id === $subscription->get_gateway() && $subscription->has_status('active trialling')) { |
|
103 | 103 | |
104 | 104 | // Renew the subscription. |
105 | 105 | $subscription->add_payment( |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | * @param GetPaid_Form_Item[] $items |
123 | 123 | * @return WPInv_Invoice |
124 | 124 | */ |
125 | - public function process_addons( $invoice, $items ) { |
|
125 | + public function process_addons($invoice, $items) { |
|
126 | 126 | |
127 | - foreach ( $items as $item ) { |
|
128 | - $invoice->add_item( $item ); |
|
127 | + foreach ($items as $item) { |
|
128 | + $invoice->add_item($item); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | $invoice->recalculate_total(); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Bank transfer Payment Gateway class. |
@@ -56,17 +56,17 @@ discard block |
||
56 | 56 | public function __construct() { |
57 | 57 | parent::__construct(); |
58 | 58 | |
59 | - $this->title = __( 'Direct bank transfer', 'invoicing' ); |
|
60 | - $this->method_title = __( 'Bank transfer', 'invoicing' ); |
|
61 | - $this->checkout_button_text = __( 'Proceed', 'invoicing' ); |
|
62 | - $this->instructions = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) ); |
|
59 | + $this->title = __('Direct bank transfer', 'invoicing'); |
|
60 | + $this->method_title = __('Bank transfer', 'invoicing'); |
|
61 | + $this->checkout_button_text = __('Proceed', 'invoicing'); |
|
62 | + $this->instructions = apply_filters('wpinv_bank_instructions', $this->get_option('info')); |
|
63 | 63 | |
64 | - add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) ); |
|
65 | - add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 ); |
|
66 | - add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 ); |
|
67 | - add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 ); |
|
68 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) ); |
|
69 | - add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 ); |
|
64 | + add_action('wpinv_receipt_end', array($this, 'thankyou_page')); |
|
65 | + add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40); |
|
66 | + add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11); |
|
67 | + add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3); |
|
68 | + add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription')); |
|
69 | + add_action('getpaid_invoice_status_publish', array($this, 'invoice_paid'), 20); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
@@ -78,23 +78,23 @@ discard block |
||
78 | 78 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
79 | 79 | * @return array |
80 | 80 | */ |
81 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
81 | + public function process_payment($invoice, $submission_data, $submission) { |
|
82 | 82 | |
83 | 83 | // Add a transaction id. |
84 | - $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) ); |
|
84 | + $invoice->set_transaction_id($invoice->generate_key('bt_')); |
|
85 | 85 | |
86 | 86 | // Set it as pending payment. |
87 | - if ( ! $invoice->needs_payment() ) { |
|
87 | + if (!$invoice->needs_payment()) { |
|
88 | 88 | $invoice->mark_paid(); |
89 | - } elseif ( ! $invoice->is_paid() ) { |
|
90 | - $invoice->set_status( 'wpi-onhold' ); |
|
89 | + } elseif (!$invoice->is_paid()) { |
|
90 | + $invoice->set_status('wpi-onhold'); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Save it. |
94 | 94 | $invoice->save(); |
95 | 95 | |
96 | 96 | // Send to the success page. |
97 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
97 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
98 | 98 | |
99 | 99 | } |
100 | 100 | |
@@ -103,17 +103,17 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @param WPInv_Invoice $invoice Invoice. |
105 | 105 | */ |
106 | - public function thankyou_page( $invoice ) { |
|
106 | + public function thankyou_page($invoice) { |
|
107 | 107 | |
108 | - if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
108 | + if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) { |
|
109 | 109 | |
110 | 110 | echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL; |
111 | 111 | |
112 | - if ( ! empty( $this->instructions ) ) { |
|
113 | - echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) ); |
|
112 | + if (!empty($this->instructions)) { |
|
113 | + echo wp_kses_post(wpautop(wptexturize($this->instructions))); |
|
114 | 114 | } |
115 | 115 | |
116 | - $this->bank_details( $invoice ); |
|
116 | + $this->bank_details($invoice); |
|
117 | 117 | |
118 | 118 | echo '</div>'; |
119 | 119 | |
@@ -128,17 +128,17 @@ discard block |
||
128 | 128 | * @param string $email_type Email format: plain text or HTML. |
129 | 129 | * @param bool $sent_to_admin Sent to admin. |
130 | 130 | */ |
131 | - public function email_instructions( $invoice, $email_type, $sent_to_admin ) { |
|
131 | + public function email_instructions($invoice, $email_type, $sent_to_admin) { |
|
132 | 132 | |
133 | - if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
133 | + if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) { |
|
134 | 134 | |
135 | 135 | echo '<div class="wpi-email-row getpaid-bank-transfer-details">'; |
136 | 136 | |
137 | - if ( $this->instructions ) { |
|
138 | - echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); |
|
137 | + if ($this->instructions) { |
|
138 | + echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL); |
|
139 | 139 | } |
140 | 140 | |
141 | - $this->bank_details( $invoice ); |
|
141 | + $this->bank_details($invoice); |
|
142 | 142 | |
143 | 143 | echo '</div>'; |
144 | 144 | |
@@ -151,50 +151,50 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @param WPInv_Invoice $invoice Invoice. |
153 | 153 | */ |
154 | - protected function bank_details( $invoice ) { |
|
154 | + protected function bank_details($invoice) { |
|
155 | 155 | |
156 | 156 | // Get the invoice country and country $locale. |
157 | 157 | $country = $invoice->get_country(); |
158 | 158 | $locale = $this->get_country_locale(); |
159 | 159 | |
160 | 160 | // Get sortcode label in the $locale array and use appropriate one. |
161 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
161 | + $sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing'); |
|
162 | 162 | |
163 | 163 | $bank_fields = array( |
164 | - 'ac_name' => __( 'Account Name', 'invoicing' ), |
|
165 | - 'ac_no' => __( 'Account Number', 'invoicing' ), |
|
166 | - 'bank_name' => __( 'Bank Name', 'invoicing' ), |
|
167 | - 'ifsc' => __( 'IFSC code', 'invoicing' ), |
|
168 | - 'iban' => __( 'IBAN', 'invoicing' ), |
|
169 | - 'bic' => __( 'BIC/Swift code', 'invoicing' ), |
|
164 | + 'ac_name' => __('Account Name', 'invoicing'), |
|
165 | + 'ac_no' => __('Account Number', 'invoicing'), |
|
166 | + 'bank_name' => __('Bank Name', 'invoicing'), |
|
167 | + 'ifsc' => __('IFSC code', 'invoicing'), |
|
168 | + 'iban' => __('IBAN', 'invoicing'), |
|
169 | + 'bic' => __('BIC/Swift code', 'invoicing'), |
|
170 | 170 | 'sort_code' => $sortcode, |
171 | 171 | ); |
172 | 172 | |
173 | 173 | $bank_info = array(); |
174 | 174 | |
175 | - foreach ( $bank_fields as $field => $label ) { |
|
176 | - $value = $this->get_option( $field ); |
|
175 | + foreach ($bank_fields as $field => $label) { |
|
176 | + $value = $this->get_option($field); |
|
177 | 177 | |
178 | - if ( ! empty( $value ) ) { |
|
179 | - $bank_info[ $field ] = array( |
|
178 | + if (!empty($value)) { |
|
179 | + $bank_info[$field] = array( |
|
180 | 180 | 'label' => $label, |
181 | 181 | 'value' => $value, |
182 | 182 | ); |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice ); |
|
186 | + $bank_info = apply_filters('wpinv_bank_info', $bank_info, $invoice); |
|
187 | 187 | |
188 | - if ( empty( $bank_info ) ) { |
|
188 | + if (empty($bank_info)) { |
|
189 | 189 | return; |
190 | 190 | } |
191 | 191 | |
192 | - echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL; |
|
192 | + echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html(apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing'), $invoice)) . '</h3>' . PHP_EOL; |
|
193 | 193 | |
194 | 194 | echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL; |
195 | 195 | |
196 | - foreach ( $bank_info as $key => $data ) { |
|
197 | - echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL; |
|
196 | + foreach ($bank_info as $key => $data) { |
|
197 | + echo "<tr class='getpaid-bank-transfer-" . esc_attr($key) . "'><th class='font-weight-bold'>" . wp_kses_post($data['label']) . "</th><td class='w-75'>" . wp_kses_post(wptexturize($data['value'])) . '</td></tr>' . PHP_EOL; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | echo '</table>'; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function get_country_locale() { |
210 | 210 | |
211 | - if ( empty( $this->locale ) ) { |
|
211 | + if (empty($this->locale)) { |
|
212 | 212 | |
213 | 213 | // Locale information to be used - only those that are not 'Sort Code'. |
214 | 214 | $this->locale = apply_filters( |
@@ -216,42 +216,42 @@ discard block |
||
216 | 216 | array( |
217 | 217 | 'AU' => array( |
218 | 218 | 'sortcode' => array( |
219 | - 'label' => __( 'BSB', 'invoicing' ), |
|
219 | + 'label' => __('BSB', 'invoicing'), |
|
220 | 220 | ), |
221 | 221 | ), |
222 | 222 | 'CA' => array( |
223 | 223 | 'sortcode' => array( |
224 | - 'label' => __( 'Bank transit number', 'invoicing' ), |
|
224 | + 'label' => __('Bank transit number', 'invoicing'), |
|
225 | 225 | ), |
226 | 226 | ), |
227 | 227 | 'IN' => array( |
228 | 228 | 'sortcode' => array( |
229 | - 'label' => __( 'IFSC', 'invoicing' ), |
|
229 | + 'label' => __('IFSC', 'invoicing'), |
|
230 | 230 | ), |
231 | 231 | ), |
232 | 232 | 'IT' => array( |
233 | 233 | 'sortcode' => array( |
234 | - 'label' => __( 'Branch sort', 'invoicing' ), |
|
234 | + 'label' => __('Branch sort', 'invoicing'), |
|
235 | 235 | ), |
236 | 236 | ), |
237 | 237 | 'NZ' => array( |
238 | 238 | 'sortcode' => array( |
239 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
239 | + 'label' => __('Bank code', 'invoicing'), |
|
240 | 240 | ), |
241 | 241 | ), |
242 | 242 | 'SE' => array( |
243 | 243 | 'sortcode' => array( |
244 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
244 | + 'label' => __('Bank code', 'invoicing'), |
|
245 | 245 | ), |
246 | 246 | ), |
247 | 247 | 'US' => array( |
248 | 248 | 'sortcode' => array( |
249 | - 'label' => __( 'Routing number', 'invoicing' ), |
|
249 | + 'label' => __('Routing number', 'invoicing'), |
|
250 | 250 | ), |
251 | 251 | ), |
252 | 252 | 'ZA' => array( |
253 | 253 | 'sortcode' => array( |
254 | - 'label' => __( 'Branch code', 'invoicing' ), |
|
254 | + 'label' => __('Branch code', 'invoicing'), |
|
255 | 255 | ), |
256 | 256 | ), |
257 | 257 | ) |
@@ -268,51 +268,51 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @param array $admin_settings |
270 | 270 | */ |
271 | - public function admin_settings( $admin_settings ) { |
|
271 | + public function admin_settings($admin_settings) { |
|
272 | 272 | |
273 | - $admin_settings['bank_transfer_desc']['std'] = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ); |
|
274 | - $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' ); |
|
273 | + $admin_settings['bank_transfer_desc']['std'] = __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'); |
|
274 | + $admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing'); |
|
275 | 275 | |
276 | - $locale = $this->get_country_locale(); |
|
276 | + $locale = $this->get_country_locale(); |
|
277 | 277 | |
278 | 278 | // Get sortcode label in the $locale array and use appropriate one. |
279 | 279 | $country = wpinv_default_billing_country(); |
280 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
280 | + $sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing'); |
|
281 | 281 | |
282 | 282 | $admin_settings['bank_transfer_ac_name'] = array( |
283 | 283 | 'type' => 'text', |
284 | 284 | 'id' => 'bank_transfer_ac_name', |
285 | - 'name' => __( 'Account Name', 'invoicing' ), |
|
285 | + 'name' => __('Account Name', 'invoicing'), |
|
286 | 286 | ); |
287 | 287 | |
288 | 288 | $admin_settings['bank_transfer_ac_no'] = array( |
289 | 289 | 'type' => 'text', |
290 | 290 | 'id' => 'bank_transfer_ac_no', |
291 | - 'name' => __( 'Account Number', 'invoicing' ), |
|
291 | + 'name' => __('Account Number', 'invoicing'), |
|
292 | 292 | ); |
293 | 293 | |
294 | 294 | $admin_settings['bank_transfer_bank_name'] = array( |
295 | 295 | 'type' => 'text', |
296 | 296 | 'id' => 'bank_transfer_bank_name', |
297 | - 'name' => __( 'Bank Name', 'invoicing' ), |
|
297 | + 'name' => __('Bank Name', 'invoicing'), |
|
298 | 298 | ); |
299 | 299 | |
300 | 300 | $admin_settings['bank_transfer_ifsc'] = array( |
301 | 301 | 'type' => 'text', |
302 | 302 | 'id' => 'bank_transfer_ifsc', |
303 | - 'name' => __( 'IFSC Code', 'invoicing' ), |
|
303 | + 'name' => __('IFSC Code', 'invoicing'), |
|
304 | 304 | ); |
305 | 305 | |
306 | 306 | $admin_settings['bank_transfer_iban'] = array( |
307 | 307 | 'type' => 'text', |
308 | 308 | 'id' => 'bank_transfer_iban', |
309 | - 'name' => __( 'IBAN', 'invoicing' ), |
|
309 | + 'name' => __('IBAN', 'invoicing'), |
|
310 | 310 | ); |
311 | 311 | |
312 | 312 | $admin_settings['bank_transfer_bic'] = array( |
313 | 313 | 'type' => 'text', |
314 | 314 | 'id' => 'bank_transfer_bic', |
315 | - 'name' => __( 'BIC/Swift Code', 'invoicing' ), |
|
315 | + 'name' => __('BIC/Swift Code', 'invoicing'), |
|
316 | 316 | ); |
317 | 317 | |
318 | 318 | $admin_settings['bank_transfer_sort_code'] = array( |
@@ -323,10 +323,10 @@ discard block |
||
323 | 323 | |
324 | 324 | $admin_settings['bank_transfer_info'] = array( |
325 | 325 | 'id' => 'bank_transfer_info', |
326 | - 'name' => __( 'Instructions', 'invoicing' ), |
|
327 | - 'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ), |
|
326 | + 'name' => __('Instructions', 'invoicing'), |
|
327 | + 'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'), |
|
328 | 328 | 'type' => 'textarea', |
329 | - 'std' => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ), |
|
329 | + 'std' => __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'), |
|
330 | 330 | 'cols' => 50, |
331 | 331 | 'rows' => 5, |
332 | 332 | ); |
@@ -341,10 +341,10 @@ discard block |
||
341 | 341 | * @param GetPaid_Form_Item[] $items |
342 | 342 | * @return WPInv_Invoice |
343 | 343 | */ |
344 | - public function process_addons( $invoice, $items ) { |
|
344 | + public function process_addons($invoice, $items) { |
|
345 | 345 | |
346 | - foreach ( $items as $item ) { |
|
347 | - $invoice->add_item( $item ); |
|
346 | + foreach ($items as $item) { |
|
347 | + $invoice->add_item($item); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | $invoice->recalculate_total(); |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | * |
358 | 358 | * @param WPInv_Subscription $subscription |
359 | 359 | */ |
360 | - public function maybe_renew_subscription( $subscription ) { |
|
360 | + public function maybe_renew_subscription($subscription) { |
|
361 | 361 | |
362 | 362 | // Ensure its our subscription && it's active. |
363 | - if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
|
363 | + if ($this->id === $subscription->get_gateway() && $subscription->has_status('active trialling')) { |
|
364 | 364 | $subscription->create_payment(); |
365 | 365 | } |
366 | 366 | |
@@ -372,42 +372,42 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @param WPInv_Invoice $invoice |
374 | 374 | */ |
375 | - public function invoice_paid( $invoice ) { |
|
375 | + public function invoice_paid($invoice) { |
|
376 | 376 | |
377 | 377 | // Abort if not paid by bank transfer. |
378 | - if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) { |
|
378 | + if ($this->id !== $invoice->get_gateway() || !$invoice->is_recurring()) { |
|
379 | 379 | return; |
380 | 380 | } |
381 | 381 | |
382 | 382 | // Is it a parent payment? |
383 | - if ( 0 == $invoice->get_parent_id() ) { |
|
383 | + if (0 == $invoice->get_parent_id()) { |
|
384 | 384 | |
385 | 385 | // (Maybe) activate subscriptions. |
386 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
386 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
387 | 387 | |
388 | - if ( ! empty( $subscriptions ) ) { |
|
389 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
388 | + if (!empty($subscriptions)) { |
|
389 | + $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions); |
|
390 | 390 | |
391 | - foreach ( $subscriptions as $subscription ) { |
|
392 | - if ( $subscription->exists() ) { |
|
393 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
394 | - $expiry = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
391 | + foreach ($subscriptions as $subscription) { |
|
392 | + if ($subscription->exists()) { |
|
393 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
394 | + $expiry = gmdate('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
395 | 395 | |
396 | - $subscription->set_next_renewal_date( $expiry ); |
|
397 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
398 | - $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ); |
|
396 | + $subscription->set_next_renewal_date($expiry); |
|
397 | + $subscription->set_date_created(current_time('mysql')); |
|
398 | + $subscription->set_profile_id('bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id()); |
|
399 | 399 | $subscription->activate(); |
400 | 400 | } |
401 | 401 | } |
402 | 402 | } |
403 | 403 | } else { |
404 | 404 | |
405 | - $subscription = getpaid_get_subscription( $invoice->get_subscription_id() ); |
|
405 | + $subscription = getpaid_get_subscription($invoice->get_subscription_id()); |
|
406 | 406 | |
407 | 407 | // Renew the subscription. |
408 | - if ( $subscription && $subscription->exists() ) { |
|
409 | - $subscription->add_payment( array(), $invoice ); |
|
410 | - $subscription->renew( strtotime( $invoice->get_date_created() ) ); |
|
408 | + if ($subscription && $subscription->exists()) { |
|
409 | + $subscription->add_payment(array(), $invoice); |
|
410 | + $subscription->renew(strtotime($invoice->get_date_created())); |
|
411 | 411 | } |
412 | 412 | } |
413 | 413 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Authorize.net Payment Gateway class. |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @var array |
63 | 63 | */ |
64 | - public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
64 | + public $currencies = array('USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD'); |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * URL to view a transaction. |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function __construct() { |
77 | 77 | |
78 | - $this->title = __( 'Credit Card / Debit Card', 'invoicing' ); |
|
79 | - $this->method_title = __( 'Authorize.Net', 'invoicing' ); |
|
80 | - $this->notify_url = getpaid_get_non_query_string_ipn_url( $this->id ); |
|
78 | + $this->title = __('Credit Card / Debit Card', 'invoicing'); |
|
79 | + $this->method_title = __('Authorize.Net', 'invoicing'); |
|
80 | + $this->notify_url = getpaid_get_non_query_string_ipn_url($this->id); |
|
81 | 81 | |
82 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) ); |
|
83 | - add_filter( 'getpaid_authorizenet_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
|
82 | + add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription')); |
|
83 | + add_filter('getpaid_authorizenet_sandbox_notice', array($this, 'sandbox_notice')); |
|
84 | 84 | parent::__construct(); |
85 | 85 | } |
86 | 86 | |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | * @param int $invoice_id 0 or invoice id. |
91 | 91 | * @param GetPaid_Payment_Form $form Current payment form. |
92 | 92 | */ |
93 | - public function payment_fields( $invoice_id, $form ) { |
|
93 | + public function payment_fields($invoice_id, $form) { |
|
94 | 94 | |
95 | 95 | // Let the user select a payment method. |
96 | 96 | $this->saved_payment_methods(); |
97 | 97 | |
98 | 98 | // Show the credit card entry form. |
99 | - $this->new_payment_method_entry( $this->get_cc_form( true ) ); |
|
99 | + $this->new_payment_method_entry($this->get_cc_form(true)); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -109,79 +109,79 @@ discard block |
||
109 | 109 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
110 | 110 | * @return string|WP_Error Payment profile id. |
111 | 111 | */ |
112 | - public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
112 | + public function create_customer_profile($invoice, $submission_data, $save = true) { |
|
113 | 113 | |
114 | 114 | // Remove non-digits from the number |
115 | - $submission_data['authorizenet']['cc_number'] = preg_replace( '/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
115 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
116 | 116 | |
117 | 117 | // Generate args. |
118 | 118 | $args = array( |
119 | 119 | 'createCustomerProfileRequest' => array( |
120 | 120 | 'merchantAuthentication' => $this->get_auth_params(), |
121 | 121 | 'profile' => array( |
122 | - 'merchantCustomerId' => getpaid_limit_length( $invoice->get_user_id(), 20 ), |
|
123 | - 'description' => getpaid_limit_length( $invoice->get_full_name(), 255 ), |
|
124 | - 'email' => getpaid_limit_length( $invoice->get_email(), 255 ), |
|
122 | + 'merchantCustomerId' => getpaid_limit_length($invoice->get_user_id(), 20), |
|
123 | + 'description' => getpaid_limit_length($invoice->get_full_name(), 255), |
|
124 | + 'email' => getpaid_limit_length($invoice->get_email(), 255), |
|
125 | 125 | 'paymentProfiles' => array( |
126 | 126 | 'customerType' => 'individual', |
127 | 127 | |
128 | 128 | // Billing information. |
129 | 129 | 'billTo' => array( |
130 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
131 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
132 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
133 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
134 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
135 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
136 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
130 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
131 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
132 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
133 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
134 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
135 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
136 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
137 | 137 | ), |
138 | 138 | |
139 | 139 | // Payment information. |
140 | - 'payment' => $this->get_payment_information( $submission_data['authorizenet'] ), |
|
140 | + 'payment' => $this->get_payment_information($submission_data['authorizenet']), |
|
141 | 141 | ), |
142 | 142 | ), |
143 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
143 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
144 | 144 | ), |
145 | 145 | ); |
146 | 146 | |
147 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_customer_profile_args', $args, $invoice ), $invoice ); |
|
147 | + $response = $this->post(apply_filters('getpaid_authorizenet_customer_profile_args', $args, $invoice), $invoice); |
|
148 | 148 | |
149 | - if ( is_wp_error( $response ) ) { |
|
149 | + if (is_wp_error($response)) { |
|
150 | 150 | |
151 | 151 | // In case the payment profile already exists remotely. |
152 | - if ( 'dup_payment_profile' === $response->get_error_code() ) { |
|
153 | - $customer_profile_id = strtok( $response->get_error_message(), '.' ); |
|
154 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile_id ); |
|
155 | - return strtok( '.' ); |
|
152 | + if ('dup_payment_profile' === $response->get_error_code()) { |
|
153 | + $customer_profile_id = strtok($response->get_error_message(), '.'); |
|
154 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile_id); |
|
155 | + return strtok('.'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // In case the customer profile already exists remotely. |
159 | - if ( 'E00039' === $response->get_error_code() ) { |
|
160 | - $customer_profile_id = str_replace( 'A duplicate record with ID ', '', $response->get_error_message() ); |
|
161 | - $customer_profile_id = str_replace( ' already exists.', '', $customer_profile_id ); |
|
162 | - return $this->create_customer_payment_profile( trim( $customer_profile_id ), $invoice, $submission_data, $save ); |
|
159 | + if ('E00039' === $response->get_error_code()) { |
|
160 | + $customer_profile_id = str_replace('A duplicate record with ID ', '', $response->get_error_message()); |
|
161 | + $customer_profile_id = str_replace(' already exists.', '', $customer_profile_id); |
|
162 | + return $this->create_customer_payment_profile(trim($customer_profile_id), $invoice, $submission_data, $save); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | return $response; |
166 | 166 | } |
167 | 167 | |
168 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId ); |
|
168 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId); |
|
169 | 169 | |
170 | 170 | // Save the payment token. |
171 | - if ( $save ) { |
|
171 | + if ($save) { |
|
172 | 172 | $this->save_token( |
173 | 173 | array( |
174 | 174 | 'id' => $response->customerPaymentProfileIdList[0], |
175 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . '····' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
175 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . '····' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
176 | 176 | 'default' => true, |
177 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
177 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
178 | 178 | ) |
179 | 179 | ); |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Add a note about the validation response. |
183 | 183 | $invoice->add_note( |
184 | - sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ), |
|
184 | + sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]), |
|
185 | 185 | false, |
186 | 186 | false, |
187 | 187 | true |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @return string|WP_Error Profile id. |
199 | 199 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile |
200 | 200 | */ |
201 | - public function get_customer_profile( $profile_id ) { |
|
201 | + public function get_customer_profile($profile_id) { |
|
202 | 202 | |
203 | 203 | // Generate args. |
204 | 204 | $args = array( |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | ), |
209 | 209 | ); |
210 | 210 | |
211 | - return $this->post( $args, false ); |
|
211 | + return $this->post($args, false); |
|
212 | 212 | |
213 | 213 | } |
214 | 214 | |
@@ -223,18 +223,18 @@ discard block |
||
223 | 223 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
224 | 224 | * @return string|WP_Error Profile id. |
225 | 225 | */ |
226 | - public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
226 | + public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) { |
|
227 | 227 | |
228 | 228 | // Remove non-digits from the number |
229 | - $submission_data['authorizenet']['cc_number'] = preg_replace( '/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
229 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
230 | 230 | |
231 | 231 | // Prepare card details. |
232 | - $payment_information = $this->get_payment_information( $submission_data['authorizenet'] ); |
|
232 | + $payment_information = $this->get_payment_information($submission_data['authorizenet']); |
|
233 | 233 | |
234 | 234 | // Authorize.NET does not support saving the same card twice. |
235 | - $cached_information = $this->retrieve_payment_profile_from_cache( $payment_information, $customer_profile, $invoice ); |
|
235 | + $cached_information = $this->retrieve_payment_profile_from_cache($payment_information, $customer_profile, $invoice); |
|
236 | 236 | |
237 | - if ( $cached_information ) { |
|
237 | + if ($cached_information) { |
|
238 | 238 | return $cached_information; |
239 | 239 | } |
240 | 240 | |
@@ -247,34 +247,34 @@ discard block |
||
247 | 247 | |
248 | 248 | // Billing information. |
249 | 249 | 'billTo' => array( |
250 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
251 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
252 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
253 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
254 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
255 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
256 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
250 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
251 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
252 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
253 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
254 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
255 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
256 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
257 | 257 | ), |
258 | 258 | |
259 | 259 | // Payment information. |
260 | 260 | 'payment' => $payment_information, |
261 | 261 | ), |
262 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
262 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
263 | 263 | ), |
264 | 264 | ); |
265 | 265 | |
266 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
266 | + $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice); |
|
267 | 267 | |
268 | - if ( is_wp_error( $response ) ) { |
|
268 | + if (is_wp_error($response)) { |
|
269 | 269 | |
270 | 270 | // In case the payment profile already exists remotely. |
271 | - if ( 'dup_payment_profile' == $response->get_error_code() ) { |
|
272 | - $customer_profile_id = strtok( $response->get_error_message(), '.' ); |
|
273 | - $payment_profile_id = strtok( '.' ); |
|
274 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile_id ); |
|
271 | + if ('dup_payment_profile' == $response->get_error_code()) { |
|
272 | + $customer_profile_id = strtok($response->get_error_message(), '.'); |
|
273 | + $payment_profile_id = strtok('.'); |
|
274 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile_id); |
|
275 | 275 | |
276 | 276 | // Cache payment profile id. |
277 | - $this->add_payment_profile_to_cache( $payment_information, $payment_profile_id ); |
|
277 | + $this->add_payment_profile_to_cache($payment_information, $payment_profile_id); |
|
278 | 278 | |
279 | 279 | return $payment_profile_id; |
280 | 280 | } |
@@ -283,29 +283,29 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | // Save the payment token. |
286 | - if ( $save ) { |
|
286 | + if ($save) { |
|
287 | 287 | $this->save_token( |
288 | 288 | array( |
289 | 289 | 'id' => $response->customerPaymentProfileId, |
290 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' ···· ' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
290 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . ' ···· ' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
291 | 291 | 'default' => true, |
292 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
292 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
293 | 293 | ) |
294 | 294 | ); |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Cache payment profile id. |
298 | - $this->add_payment_profile_to_cache( $payment_information, $response->customerPaymentProfileId ); |
|
298 | + $this->add_payment_profile_to_cache($payment_information, $response->customerPaymentProfileId); |
|
299 | 299 | |
300 | 300 | // Add a note about the validation response. |
301 | 301 | $invoice->add_note( |
302 | - sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ), |
|
302 | + sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse), |
|
303 | 303 | false, |
304 | 304 | false, |
305 | 305 | true |
306 | 306 | ); |
307 | 307 | |
308 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile ); |
|
308 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile); |
|
309 | 309 | |
310 | 310 | return $response->customerPaymentProfileId; |
311 | 311 | } |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | * @param array $payment_details. |
318 | 318 | * @return array|false Profile id. |
319 | 319 | */ |
320 | - public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) { |
|
320 | + public function retrieve_payment_profile_from_cache($payment_details, $customer_profile, $invoice) { |
|
321 | 321 | |
322 | - $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
|
323 | - $payment_details = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY ); |
|
322 | + $cached_information = get_option('getpaid_authorize_net_cached_profiles', array()); |
|
323 | + $payment_details = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY); |
|
324 | 324 | |
325 | - if ( ! is_array( $cached_information ) || ! array_key_exists( $payment_details, $cached_information ) ) { |
|
325 | + if (!is_array($cached_information) || !array_key_exists($payment_details, $cached_information)) { |
|
326 | 326 | return false; |
327 | 327 | } |
328 | 328 | |
@@ -331,13 +331,13 @@ discard block |
||
331 | 331 | 'getCustomerPaymentProfileRequest' => array( |
332 | 332 | 'merchantAuthentication' => $this->get_auth_params(), |
333 | 333 | 'customerProfileId' => $customer_profile, |
334 | - 'customerPaymentProfileId' => $cached_information[ $payment_details ], |
|
334 | + 'customerPaymentProfileId' => $cached_information[$payment_details], |
|
335 | 335 | ), |
336 | 336 | ); |
337 | 337 | |
338 | - $response = $this->post( $args, $invoice ); |
|
338 | + $response = $this->post($args, $invoice); |
|
339 | 339 | |
340 | - return is_wp_error( $response ) ? false : $cached_information[ $payment_details ]; |
|
340 | + return is_wp_error($response) ? false : $cached_information[$payment_details]; |
|
341 | 341 | |
342 | 342 | } |
343 | 343 | |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | * @param array $payment_details. |
349 | 349 | * @param string $payment_profile_id. |
350 | 350 | */ |
351 | - public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) { |
|
351 | + public function add_payment_profile_to_cache($payment_details, $payment_profile_id) { |
|
352 | 352 | |
353 | - $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
|
354 | - $cached_information = is_array( $cached_information ) ? $cached_information : array(); |
|
355 | - $payment_details = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY ); |
|
353 | + $cached_information = get_option('getpaid_authorize_net_cached_profiles', array()); |
|
354 | + $cached_information = is_array($cached_information) ? $cached_information : array(); |
|
355 | + $payment_details = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY); |
|
356 | 356 | |
357 | - $cached_information[ $payment_details ] = $payment_profile_id; |
|
358 | - update_option( 'getpaid_authorize_net_cached_profiles', $cached_information ); |
|
357 | + $cached_information[$payment_details] = $payment_profile_id; |
|
358 | + update_option('getpaid_authorize_net_cached_profiles', $cached_information); |
|
359 | 359 | |
360 | 360 | } |
361 | 361 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @return string|WP_Error Profile id. |
369 | 369 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile |
370 | 370 | */ |
371 | - public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
371 | + public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) { |
|
372 | 372 | |
373 | 373 | // Generate args. |
374 | 374 | $args = array( |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | ), |
380 | 380 | ); |
381 | 381 | |
382 | - return $this->post( $args, false ); |
|
382 | + return $this->post($args, false); |
|
383 | 383 | |
384 | 384 | } |
385 | 385 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile |
393 | 393 | * @return WP_Error|object |
394 | 394 | */ |
395 | - public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
395 | + public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) { |
|
396 | 396 | |
397 | 397 | // Generate args. |
398 | 398 | $args = array( |
@@ -412,28 +412,28 @@ discard block |
||
412 | 412 | ), |
413 | 413 | ), |
414 | 414 | 'order' => array( |
415 | - 'invoiceNumber' => getpaid_limit_length( $invoice->get_number(), 20 ), |
|
415 | + 'invoiceNumber' => getpaid_limit_length($invoice->get_number(), 20), |
|
416 | 416 | ), |
417 | - 'lineItems' => array( 'lineItem' => $this->get_line_items( $invoice ) ), |
|
417 | + 'lineItems' => array('lineItem' => $this->get_line_items($invoice)), |
|
418 | 418 | 'tax' => array( |
419 | 419 | 'amount' => $invoice->get_total_tax(), |
420 | - 'name' => __( 'TAX', 'invoicing' ), |
|
420 | + 'name' => __('TAX', 'invoicing'), |
|
421 | 421 | ), |
422 | - 'poNumber' => getpaid_limit_length( $invoice->get_number(), 25 ), |
|
422 | + 'poNumber' => getpaid_limit_length($invoice->get_number(), 25), |
|
423 | 423 | 'customer' => array( |
424 | - 'id' => getpaid_limit_length( $invoice->get_user_id(), 25 ), |
|
425 | - 'email' => getpaid_limit_length( $invoice->get_email(), 25 ), |
|
424 | + 'id' => getpaid_limit_length($invoice->get_user_id(), 25), |
|
425 | + 'email' => getpaid_limit_length($invoice->get_email(), 25), |
|
426 | 426 | ), |
427 | 427 | 'customerIP' => $invoice->get_ip(), |
428 | 428 | ), |
429 | 429 | ), |
430 | 430 | ); |
431 | 431 | |
432 | - if ( 0 == $invoice->get_total_tax() ) { |
|
433 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
432 | + if (0 == $invoice->get_total_tax()) { |
|
433 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
434 | 434 | } |
435 | 435 | |
436 | - return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
436 | + return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | |
@@ -443,29 +443,29 @@ discard block |
||
443 | 443 | * @param stdClass $result Api response. |
444 | 444 | * @param WPInv_Invoice $invoice Invoice. |
445 | 445 | */ |
446 | - public function process_charge_response( $result, $invoice ) { |
|
446 | + public function process_charge_response($result, $invoice) { |
|
447 | 447 | |
448 | 448 | wpinv_clear_errors(); |
449 | 449 | $response_code = (int) $result->transactionResponse->responseCode; |
450 | 450 | |
451 | 451 | // Succeeded. |
452 | - if ( 1 == $response_code || 4 == $response_code ) { |
|
452 | + if (1 == $response_code || 4 == $response_code) { |
|
453 | 453 | |
454 | 454 | // Maybe set a transaction id. |
455 | - if ( ! empty( $result->transactionResponse->transId ) ) { |
|
456 | - $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
455 | + if (!empty($result->transactionResponse->transId)) { |
|
456 | + $invoice->set_transaction_id($result->transactionResponse->transId); |
|
457 | 457 | } |
458 | 458 | |
459 | - $invoice->add_note( sprintf( __( 'Authentication code: %1$s (%2$s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
459 | + $invoice->add_note(sprintf(__('Authentication code: %1$s (%2$s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true); |
|
460 | 460 | |
461 | - if ( 1 == $response_code ) { |
|
461 | + if (1 == $response_code) { |
|
462 | 462 | return $invoice->mark_paid(); |
463 | 463 | } |
464 | 464 | |
465 | - $invoice->set_status( 'wpi-onhold' ); |
|
465 | + $invoice->set_status('wpi-onhold'); |
|
466 | 466 | $invoice->add_note( |
467 | 467 | sprintf( |
468 | - __( 'Held for review: %s', 'invoicing' ), |
|
468 | + __('Held for review: %s', 'invoicing'), |
|
469 | 469 | $result->transactionResponse->messages->message[0]->description |
470 | 470 | ) |
471 | 471 | ); |
@@ -474,11 +474,11 @@ discard block |
||
474 | 474 | |
475 | 475 | } |
476 | 476 | |
477 | - wpinv_set_error( 'card_declined' ); |
|
477 | + wpinv_set_error('card_declined'); |
|
478 | 478 | |
479 | - if ( ! empty( $result->transactionResponse->errors ) ) { |
|
479 | + if (!empty($result->transactionResponse->errors)) { |
|
480 | 480 | $errors = (object) $result->transactionResponse->errors; |
481 | - wpinv_set_error( $errors->error[0]->errorCode, esc_html( $errors->error[0]->errorText ) ); |
|
481 | + wpinv_set_error($errors->error[0]->errorCode, esc_html($errors->error[0]->errorText)); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | } |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | * @param array $card Card details. |
491 | 491 | * @return array |
492 | 492 | */ |
493 | - public function get_payment_information( $card ) { |
|
493 | + public function get_payment_information($card) { |
|
494 | 494 | return array( |
495 | 495 | |
496 | 496 | 'creditCard' => array( |
@@ -509,8 +509,8 @@ discard block |
||
509 | 509 | * @param WPInv_Invoice $invoice Invoice. |
510 | 510 | * @return string |
511 | 511 | */ |
512 | - public function get_customer_profile_meta_name( $invoice ) { |
|
513 | - return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
512 | + public function get_customer_profile_meta_name($invoice) { |
|
513 | + return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -521,34 +521,34 @@ discard block |
||
521 | 521 | * @param WPInv_Invoice $invoice |
522 | 522 | * @return WP_Error|string The payment profile id |
523 | 523 | */ |
524 | - public function validate_submission_data( $submission_data, $invoice ) { |
|
524 | + public function validate_submission_data($submission_data, $invoice) { |
|
525 | 525 | |
526 | 526 | // Validate authentication details. |
527 | 527 | $auth = $this->get_auth_params(); |
528 | 528 | |
529 | - if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) { |
|
530 | - return new WP_Error( 'invalid_settings', __( 'Please set-up your login id and transaction key before using this gateway.', 'invoicing' ) ); |
|
529 | + if (empty($auth['name']) || empty($auth['transactionKey'])) { |
|
530 | + return new WP_Error('invalid_settings', __('Please set-up your login id and transaction key before using this gateway.', 'invoicing')); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | // Validate the payment method. |
534 | - if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) { |
|
535 | - return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing' ) ); |
|
534 | + if (empty($submission_data['getpaid-authorizenet-payment-method'])) { |
|
535 | + return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing')); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | // Are we adding a new payment method? |
539 | - if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) { |
|
539 | + if ('new' != $submission_data['getpaid-authorizenet-payment-method']) { |
|
540 | 540 | return $submission_data['getpaid-authorizenet-payment-method']; |
541 | 541 | } |
542 | 542 | |
543 | 543 | // Retrieve the customer profile id. |
544 | - $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
544 | + $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
545 | 545 | |
546 | 546 | // Create payment method. |
547 | - if ( empty( $profile_id ) ) { |
|
548 | - return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
547 | + if (empty($profile_id)) { |
|
548 | + return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
549 | 549 | } |
550 | 550 | |
551 | - return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
551 | + return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
552 | 552 | |
553 | 553 | } |
554 | 554 | |
@@ -559,32 +559,32 @@ discard block |
||
559 | 559 | * @param WPInv_Invoice $invoice Invoice. |
560 | 560 | * @return array |
561 | 561 | */ |
562 | - public function get_line_items( $invoice ) { |
|
562 | + public function get_line_items($invoice) { |
|
563 | 563 | $items = array(); |
564 | 564 | |
565 | - foreach ( $invoice->get_items() as $item ) { |
|
565 | + foreach ($invoice->get_items() as $item) { |
|
566 | 566 | |
567 | 567 | $amount = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
568 | 568 | $items[] = array( |
569 | - 'itemId' => getpaid_limit_length( $item->get_id(), 31 ), |
|
570 | - 'name' => getpaid_limit_length( $item->get_raw_name(), 31 ), |
|
571 | - 'description' => getpaid_limit_length( $item->get_description(), 255 ), |
|
572 | - 'quantity' => (string) ( $invoice->get_template() == 'amount' ? 1 : $item->get_quantity() ), |
|
569 | + 'itemId' => getpaid_limit_length($item->get_id(), 31), |
|
570 | + 'name' => getpaid_limit_length($item->get_raw_name(), 31), |
|
571 | + 'description' => getpaid_limit_length($item->get_description(), 255), |
|
572 | + 'quantity' => (string) ($invoice->get_template() == 'amount' ? 1 : $item->get_quantity()), |
|
573 | 573 | 'unitPrice' => (float) $amount, |
574 | 574 | 'taxable' => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(), |
575 | 575 | ); |
576 | 576 | |
577 | 577 | } |
578 | 578 | |
579 | - foreach ( $invoice->get_fees() as $fee_name => $fee ) { |
|
579 | + foreach ($invoice->get_fees() as $fee_name => $fee) { |
|
580 | 580 | |
581 | - $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
581 | + $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
582 | 582 | |
583 | - if ( $amount > 0 ) { |
|
583 | + if ($amount > 0) { |
|
584 | 584 | $items[] = array( |
585 | - 'itemId' => getpaid_limit_length( $fee_name, 31 ), |
|
586 | - 'name' => getpaid_limit_length( $fee_name, 31 ), |
|
587 | - 'description' => getpaid_limit_length( $fee_name, 255 ), |
|
585 | + 'itemId' => getpaid_limit_length($fee_name, 31), |
|
586 | + 'name' => getpaid_limit_length($fee_name, 31), |
|
587 | + 'description' => getpaid_limit_length($fee_name, 255), |
|
588 | 588 | 'quantity' => '1', |
589 | 589 | 'unitPrice' => (float) $amount, |
590 | 590 | 'taxable' => false, |
@@ -604,36 +604,36 @@ discard block |
||
604 | 604 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
605 | 605 | * @return array |
606 | 606 | */ |
607 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
607 | + public function process_payment($invoice, $submission_data, $submission) { |
|
608 | 608 | |
609 | 609 | // Validate the submitted data. |
610 | - $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice ); |
|
610 | + $payment_profile_id = $this->validate_submission_data($submission_data, $invoice); |
|
611 | 611 | |
612 | 612 | // Do we have an error? |
613 | - if ( is_wp_error( $payment_profile_id ) ) { |
|
614 | - wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() ); |
|
615 | - wpinv_send_back_to_checkout( $invoice ); |
|
613 | + if (is_wp_error($payment_profile_id)) { |
|
614 | + wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message()); |
|
615 | + wpinv_send_back_to_checkout($invoice); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | // Save the payment method to the order. |
619 | - update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id ); |
|
619 | + update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id); |
|
620 | 620 | |
621 | 621 | // Check if this is a subscription or not. |
622 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
623 | - if ( ! empty( $subscriptions ) ) { |
|
624 | - $this->process_subscription( $invoice, $subscriptions ); |
|
622 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
623 | + if (!empty($subscriptions)) { |
|
624 | + $this->process_subscription($invoice, $subscriptions); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | // If it is free, send to the success page. |
628 | - if ( ! $invoice->needs_payment() ) { |
|
628 | + if (!$invoice->needs_payment()) { |
|
629 | 629 | $invoice->mark_paid(); |
630 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
630 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | // Charge the payment profile. |
634 | - $this->process_initial_payment( $invoice ); |
|
634 | + $this->process_initial_payment($invoice); |
|
635 | 635 | |
636 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
636 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
637 | 637 | |
638 | 638 | exit; |
639 | 639 | |
@@ -644,23 +644,23 @@ discard block |
||
644 | 644 | * |
645 | 645 | * @param WPInv_Invoice $invoice Invoice. |
646 | 646 | */ |
647 | - protected function process_initial_payment( $invoice ) { |
|
647 | + protected function process_initial_payment($invoice) { |
|
648 | 648 | |
649 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
650 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
651 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
649 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
650 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
651 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
652 | 652 | |
653 | 653 | // Do we have an error? |
654 | - if ( is_wp_error( $result ) ) { |
|
655 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
656 | - wpinv_send_back_to_checkout( $invoice ); |
|
654 | + if (is_wp_error($result)) { |
|
655 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
656 | + wpinv_send_back_to_checkout($invoice); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | // Process the response. |
660 | - $this->process_charge_response( $result, $invoice ); |
|
660 | + $this->process_charge_response($result, $invoice); |
|
661 | 661 | |
662 | - if ( wpinv_get_errors() ) { |
|
663 | - wpinv_send_back_to_checkout( $invoice ); |
|
662 | + if (wpinv_get_errors()) { |
|
663 | + wpinv_send_back_to_checkout($invoice); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | } |
@@ -671,30 +671,30 @@ discard block |
||
671 | 671 | * @param WPInv_Invoice $invoice Invoice. |
672 | 672 | * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions. |
673 | 673 | */ |
674 | - public function process_subscription( $invoice, $subscriptions ) { |
|
674 | + public function process_subscription($invoice, $subscriptions) { |
|
675 | 675 | |
676 | 676 | // Check if there is an initial amount to charge. |
677 | - if ( (float) $invoice->get_total() > 0 ) { |
|
678 | - $this->process_initial_payment( $invoice ); |
|
677 | + if ((float) $invoice->get_total() > 0) { |
|
678 | + $this->process_initial_payment($invoice); |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | // Activate the subscriptions. |
682 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
682 | + $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions); |
|
683 | 683 | |
684 | - foreach ( $subscriptions as $subscription ) { |
|
685 | - if ( $subscription->exists() ) { |
|
686 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
687 | - $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
684 | + foreach ($subscriptions as $subscription) { |
|
685 | + if ($subscription->exists()) { |
|
686 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
687 | + $expiry = date('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
688 | 688 | |
689 | - $subscription->set_next_renewal_date( $expiry ); |
|
690 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
691 | - $subscription->set_profile_id( $invoice->generate_key( 'authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) ); |
|
689 | + $subscription->set_next_renewal_date($expiry); |
|
690 | + $subscription->set_date_created(current_time('mysql')); |
|
691 | + $subscription->set_profile_id($invoice->generate_key('authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id())); |
|
692 | 692 | $subscription->activate(); |
693 | 693 | } |
694 | 694 | } |
695 | 695 | |
696 | 696 | // Redirect to the success page. |
697 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
697 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
698 | 698 | |
699 | 699 | } |
700 | 700 | |
@@ -704,11 +704,11 @@ discard block |
||
704 | 704 | * |
705 | 705 | * @param WPInv_Subscription $subscription |
706 | 706 | */ |
707 | - public function maybe_renew_subscription( $subscription ) { |
|
707 | + public function maybe_renew_subscription($subscription) { |
|
708 | 708 | |
709 | 709 | // Ensure its our subscription && it's active. |
710 | - if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
|
711 | - $this->renew_subscription( $subscription ); |
|
710 | + if ($this->id === $subscription->get_gateway() && $subscription->has_status('active trialling')) { |
|
711 | + $this->renew_subscription($subscription); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | } |
@@ -718,28 +718,28 @@ discard block |
||
718 | 718 | * |
719 | 719 | * @param WPInv_Subscription $subscription |
720 | 720 | */ |
721 | - public function renew_subscription( $subscription ) { |
|
721 | + public function renew_subscription($subscription) { |
|
722 | 722 | |
723 | 723 | // Generate the renewal invoice. |
724 | 724 | $new_invoice = $subscription->create_payment(); |
725 | 725 | $old_invoice = $subscription->get_parent_payment(); |
726 | 726 | |
727 | - if ( empty( $new_invoice ) ) { |
|
728 | - $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false ); |
|
727 | + if (empty($new_invoice)) { |
|
728 | + $old_invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false); |
|
729 | 729 | $subscription->failing(); |
730 | 730 | return; |
731 | 731 | } |
732 | 732 | |
733 | 733 | // Charge the payment method. |
734 | - $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
735 | - $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
736 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
734 | + $payment_profile_id = get_post_meta($old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
735 | + $customer_profile = get_user_meta($old_invoice->get_user_id(), $this->get_customer_profile_meta_name($old_invoice), true); |
|
736 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice); |
|
737 | 737 | |
738 | 738 | // Do we have an error? |
739 | - if ( is_wp_error( $result ) ) { |
|
739 | + if (is_wp_error($result)) { |
|
740 | 740 | |
741 | 741 | $old_invoice->add_note( |
742 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
742 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()), |
|
743 | 743 | true, |
744 | 744 | false, |
745 | 745 | true |
@@ -750,12 +750,12 @@ discard block |
||
750 | 750 | } |
751 | 751 | |
752 | 752 | // Process the response. |
753 | - $this->process_charge_response( $result, $new_invoice ); |
|
753 | + $this->process_charge_response($result, $new_invoice); |
|
754 | 754 | |
755 | - if ( wpinv_get_errors() ) { |
|
755 | + if (wpinv_get_errors()) { |
|
756 | 756 | |
757 | 757 | $old_invoice->add_note( |
758 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
758 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()), |
|
759 | 759 | true, |
760 | 760 | false, |
761 | 761 | true |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | |
766 | 766 | } |
767 | 767 | |
768 | - $subscription->add_payment( array(), $new_invoice ); |
|
768 | + $subscription->add_payment(array(), $new_invoice); |
|
769 | 769 | $subscription->renew(); |
770 | 770 | } |
771 | 771 | |
@@ -776,33 +776,33 @@ discard block |
||
776 | 776 | * @param GetPaid_Form_Item[] $items |
777 | 777 | * @return WPInv_Invoice |
778 | 778 | */ |
779 | - public function process_addons( $invoice, $items ) { |
|
779 | + public function process_addons($invoice, $items) { |
|
780 | 780 | |
781 | 781 | global $getpaid_authorize_addons; |
782 | 782 | |
783 | 783 | $getpaid_authorize_addons = array(); |
784 | - foreach ( $items as $item ) { |
|
784 | + foreach ($items as $item) { |
|
785 | 785 | |
786 | - if ( is_null( $invoice->get_item( $item->get_id() ) ) && ! is_wp_error( $invoice->add_item( $item ) ) ) { |
|
786 | + if (is_null($invoice->get_item($item->get_id())) && !is_wp_error($invoice->add_item($item))) { |
|
787 | 787 | $getpaid_authorize_addons[] = $item; |
788 | 788 | } |
789 | 789 | } |
790 | 790 | |
791 | - if ( empty( $getpaid_authorize_addons ) ) { |
|
791 | + if (empty($getpaid_authorize_addons)) { |
|
792 | 792 | return; |
793 | 793 | } |
794 | 794 | |
795 | 795 | $invoice->recalculate_total(); |
796 | 796 | |
797 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
798 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
797 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
798 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
799 | 799 | |
800 | - add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 ); |
|
801 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
802 | - remove_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ) ); |
|
800 | + add_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'), 10, 2); |
|
801 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
802 | + remove_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request')); |
|
803 | 803 | |
804 | - if ( is_wp_error( $result ) ) { |
|
805 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
804 | + if (is_wp_error($result)) { |
|
805 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
806 | 806 | return; |
807 | 807 | } |
808 | 808 | |
@@ -815,19 +815,19 @@ discard block |
||
815 | 815 | * @param array $args |
816 | 816 | * @return array |
817 | 817 | */ |
818 | - public function filter_addons_request( $args ) { |
|
818 | + public function filter_addons_request($args) { |
|
819 | 819 | |
820 | 820 | global $getpaid_authorize_addons; |
821 | 821 | $total = 0; |
822 | 822 | |
823 | - foreach ( $getpaid_authorize_addons as $addon ) { |
|
823 | + foreach ($getpaid_authorize_addons as $addon) { |
|
824 | 824 | $total += $addon->get_sub_total(); |
825 | 825 | } |
826 | 826 | |
827 | 827 | $args['createTransactionRequest']['transactionRequest']['amount'] = $total; |
828 | 828 | |
829 | - if ( isset( $args['createTransactionRequest']['transactionRequest']['tax'] ) ) { |
|
830 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
829 | + if (isset($args['createTransactionRequest']['transactionRequest']['tax'])) { |
|
830 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
831 | 831 | } |
832 | 832 | |
833 | 833 | return $args; |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | public function sandbox_notice() { |
841 | 841 | |
842 | 842 | return sprintf( |
843 | - __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %1$sAuthorize.NET Sandbox Testing Guide%2$s for more details.', 'invoicing' ), |
|
843 | + __('SANDBOX ENABLED. You can use sandbox testing details only. See the %1$sAuthorize.NET Sandbox Testing Guide%2$s for more details.', 'invoicing'), |
|
844 | 844 | '<a href="https://developer.authorize.net/hello_world/testing_guide.html">', |
845 | 845 | '</a>' |
846 | 846 | ); |
@@ -852,42 +852,42 @@ discard block |
||
852 | 852 | * |
853 | 853 | * @param array $admin_settings |
854 | 854 | */ |
855 | - public function admin_settings( $admin_settings ) { |
|
855 | + public function admin_settings($admin_settings) { |
|
856 | 856 | |
857 | 857 | $currencies = sprintf( |
858 | - __( 'Supported Currencies: %s', 'invoicing' ), |
|
859 | - implode( ', ', $this->currencies ) |
|
858 | + __('Supported Currencies: %s', 'invoicing'), |
|
859 | + implode(', ', $this->currencies) |
|
860 | 860 | ); |
861 | 861 | |
862 | 862 | $admin_settings['authorizenet_active']['desc'] .= " ($currencies)"; |
863 | - $admin_settings['authorizenet_desc']['std'] = __( 'Pay securely using your credit or debit card.', 'invoicing' ); |
|
863 | + $admin_settings['authorizenet_desc']['std'] = __('Pay securely using your credit or debit card.', 'invoicing'); |
|
864 | 864 | |
865 | 865 | $admin_settings['authorizenet_login_id'] = array( |
866 | 866 | 'type' => 'text', |
867 | 867 | 'id' => 'authorizenet_login_id', |
868 | - 'name' => __( 'API Login ID', 'invoicing' ), |
|
869 | - 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __( 'How do I obtain my API Login ID and Transaction Key?', 'invoicing' ) . '</em></a>', |
|
868 | + 'name' => __('API Login ID', 'invoicing'), |
|
869 | + 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __('How do I obtain my API Login ID and Transaction Key?', 'invoicing') . '</em></a>', |
|
870 | 870 | ); |
871 | 871 | |
872 | 872 | $admin_settings['authorizenet_transaction_key'] = array( |
873 | 873 | 'type' => 'text', |
874 | 874 | 'id' => 'authorizenet_transaction_key', |
875 | - 'name' => __( 'Transaction Key', 'invoicing' ), |
|
875 | + 'name' => __('Transaction Key', 'invoicing'), |
|
876 | 876 | ); |
877 | 877 | |
878 | 878 | $admin_settings['authorizenet_signature_key'] = array( |
879 | 879 | 'type' => 'text', |
880 | 880 | 'id' => 'authorizenet_signature_key', |
881 | - 'name' => __( 'Signature Key', 'invoicing' ), |
|
882 | - 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
881 | + 'name' => __('Signature Key', 'invoicing'), |
|
882 | + 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
883 | 883 | ); |
884 | 884 | |
885 | 885 | $admin_settings['authorizenet_ipn_url'] = array( |
886 | 886 | 'type' => 'ipn_url', |
887 | 887 | 'id' => 'authorizenet_ipn_url', |
888 | - 'name' => __( 'Webhook URL', 'invoicing' ), |
|
888 | + 'name' => __('Webhook URL', 'invoicing'), |
|
889 | 889 | 'std' => $this->notify_url, |
890 | - 'desc' => __( 'Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing' ) . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
890 | + 'desc' => __('Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing') . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
891 | 891 | 'custom' => 'authorizenet', |
892 | 892 | 'readonly' => true, |
893 | 893 | ); |