@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @deprecated |
@@ -19,48 +19,48 @@ discard block |
||
19 | 19 | * @deprecated |
20 | 20 | */ |
21 | 21 | function wpinv_get_invoice_cart() { |
22 | - return wpinv_get_invoice( getpaid_get_current_invoice_id() ); |
|
22 | + return wpinv_get_invoice(getpaid_get_current_invoice_id()); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @deprecated |
27 | 27 | */ |
28 | -function wpinv_get_invoice_description( $invoice ) { |
|
29 | - $invoice = new WPInv_Invoice( $invoice ); |
|
28 | +function wpinv_get_invoice_description($invoice) { |
|
29 | + $invoice = new WPInv_Invoice($invoice); |
|
30 | 30 | return $invoice->get_description(); |
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @deprecated |
35 | 35 | */ |
36 | -function wpinv_get_invoice_currency_code( $invoice ) { |
|
37 | - $invoice = new WPInv_Invoice( $invoice ); |
|
36 | +function wpinv_get_invoice_currency_code($invoice) { |
|
37 | + $invoice = new WPInv_Invoice($invoice); |
|
38 | 38 | return $invoice->get_currency(); |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @deprecated |
43 | 43 | */ |
44 | -function wpinv_get_payment_user_email( $invoice ) { |
|
45 | - $invoice = new WPInv_Invoice( $invoice ); |
|
44 | +function wpinv_get_payment_user_email($invoice) { |
|
45 | + $invoice = new WPInv_Invoice($invoice); |
|
46 | 46 | return $invoice->get_email(); |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @deprecated |
51 | 51 | */ |
52 | -function wpinv_get_user_id( $invoice ) { |
|
53 | - $invoice = new WPInv_Invoice( $invoice ); |
|
52 | +function wpinv_get_user_id($invoice) { |
|
53 | + $invoice = new WPInv_Invoice($invoice); |
|
54 | 54 | return $invoice->get_user_id(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @deprecated |
59 | 59 | */ |
60 | -function wpinv_get_invoice_status( $invoice, $return_label = false ) { |
|
61 | - $invoice = new WPInv_Invoice( $invoice ); |
|
60 | +function wpinv_get_invoice_status($invoice, $return_label = false) { |
|
61 | + $invoice = new WPInv_Invoice($invoice); |
|
62 | 62 | |
63 | - if ( $return_label ) { |
|
63 | + if ($return_label) { |
|
64 | 64 | return $invoice->get_status_nicename(); |
65 | 65 | } |
66 | 66 | |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * @deprecated |
72 | 72 | */ |
73 | -function wpinv_get_payment_gateway( $invoice, $return_label = false ) { |
|
74 | - $invoice = new WPInv_Invoice( $invoice ); |
|
73 | +function wpinv_get_payment_gateway($invoice, $return_label = false) { |
|
74 | + $invoice = new WPInv_Invoice($invoice); |
|
75 | 75 | |
76 | - if ( $return_label ) { |
|
76 | + if ($return_label) { |
|
77 | 77 | return $invoice->get_gateway_title(); |
78 | 78 | } |
79 | 79 | |
@@ -83,75 +83,75 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @deprecated |
85 | 85 | */ |
86 | -function wpinv_get_payment_gateway_name( $invoice ) { |
|
87 | - return wpinv_get_payment_gateway( $invoice, true ); |
|
86 | +function wpinv_get_payment_gateway_name($invoice) { |
|
87 | + return wpinv_get_payment_gateway($invoice, true); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @deprecated |
92 | 92 | */ |
93 | -function wpinv_get_payment_transaction_id( $invoice ) { |
|
94 | - $invoice = new WPInv_Invoice( $invoice ); |
|
93 | +function wpinv_get_payment_transaction_id($invoice) { |
|
94 | + $invoice = new WPInv_Invoice($invoice); |
|
95 | 95 | return $invoice->get_transaction_id(); |
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * @deprecated |
100 | 100 | */ |
101 | -function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
102 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
103 | - return $invoice->get_meta( $meta_key, $single ); |
|
101 | +function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) { |
|
102 | + $invoice = new WPInv_Invoice($invoice_id); |
|
103 | + return $invoice->get_meta($meta_key, $single); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @deprecated |
108 | 108 | */ |
109 | -function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '' ) { |
|
110 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
111 | - return $invoice->update_meta_data( $meta_key, $meta_value ); |
|
109 | +function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '') { |
|
110 | + $invoice = new WPInv_Invoice($invoice_id); |
|
111 | + return $invoice->update_meta_data($meta_key, $meta_value); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @deprecated |
116 | 116 | */ |
117 | -function wpinv_get_items( $invoice = 0 ) { |
|
118 | - $invoice = new WPInv_Invoice( $invoice ); |
|
117 | +function wpinv_get_items($invoice = 0) { |
|
118 | + $invoice = new WPInv_Invoice($invoice); |
|
119 | 119 | return $invoice->get_items(); |
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * @deprecated |
124 | 124 | */ |
125 | -function wpinv_get_fees( $invoice = 0 ) { |
|
126 | - $invoice = new WPInv_Invoice( $invoice ); |
|
125 | +function wpinv_get_fees($invoice = 0) { |
|
126 | + $invoice = new WPInv_Invoice($invoice); |
|
127 | 127 | return $invoice->get_fees(); |
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | 131 | * @deprecated |
132 | 132 | */ |
133 | -function wpinv_get_invoice_ip( $invoice ) { |
|
134 | - $invoice = new WPInv_Invoice( $invoice ); |
|
133 | +function wpinv_get_invoice_ip($invoice) { |
|
134 | + $invoice = new WPInv_Invoice($invoice); |
|
135 | 135 | return $invoice->get_ip(); |
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | 139 | * @deprecated |
140 | 140 | */ |
141 | -function wpinv_get_invoice_user_info( $invoice ) { |
|
142 | - $invoice = new WPInv_Invoice( $invoice ); |
|
141 | +function wpinv_get_invoice_user_info($invoice) { |
|
142 | + $invoice = new WPInv_Invoice($invoice); |
|
143 | 143 | return $invoice->get_user_info(); |
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | 147 | * @deprecated |
148 | 148 | */ |
149 | -function wpinv_subtotal( $invoice = 0, $currency = false ) { |
|
150 | - $invoice = new WPInv_Invoice( $invoice ); |
|
149 | +function wpinv_subtotal($invoice = 0, $currency = false) { |
|
150 | + $invoice = new WPInv_Invoice($invoice); |
|
151 | 151 | $subtotal = $invoice->get_subtotal(); |
152 | 152 | |
153 | - if ( $currency ) { |
|
154 | - return wpinv_price( $subtotal, $invoice->get_currency() ); |
|
153 | + if ($currency) { |
|
154 | + return wpinv_price($subtotal, $invoice->get_currency()); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $subtotal; |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | /** |
161 | 161 | * @deprecated |
162 | 162 | */ |
163 | -function wpinv_tax( $invoice = 0, $currency = false ) { |
|
164 | - $invoice = new WPInv_Invoice( $invoice ); |
|
163 | +function wpinv_tax($invoice = 0, $currency = false) { |
|
164 | + $invoice = new WPInv_Invoice($invoice); |
|
165 | 165 | $tax = $invoice->get_total_tax(); |
166 | 166 | |
167 | - if ( $currency ) { |
|
168 | - return wpinv_price( $tax, $invoice->get_currency() ); |
|
167 | + if ($currency) { |
|
168 | + return wpinv_price($tax, $invoice->get_currency()); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | return $tax; |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * @deprecated |
176 | 176 | */ |
177 | -function wpinv_discount( $invoice = 0, $currency = false ) { |
|
178 | - $invoice = new WPInv_Invoice( $invoice ); |
|
177 | +function wpinv_discount($invoice = 0, $currency = false) { |
|
178 | + $invoice = new WPInv_Invoice($invoice); |
|
179 | 179 | $discount = $invoice->get_total_discount(); |
180 | 180 | |
181 | - if ( $currency ) { |
|
182 | - return wpinv_price( $discount, $invoice->get_currency() ); |
|
181 | + if ($currency) { |
|
182 | + return wpinv_price($discount, $invoice->get_currency()); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | return $discount; |
@@ -188,20 +188,20 @@ discard block |
||
188 | 188 | /** |
189 | 189 | * @deprecated |
190 | 190 | */ |
191 | -function wpinv_discount_code( $invoice = 0 ) { |
|
192 | - $invoice = new WPInv_Invoice( $invoice ); |
|
191 | +function wpinv_discount_code($invoice = 0) { |
|
192 | + $invoice = new WPInv_Invoice($invoice); |
|
193 | 193 | return $invoice->get_discount_code(); |
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
197 | 197 | * @deprecated |
198 | 198 | */ |
199 | -function wpinv_payment_total( $invoice = 0, $currency = false ) { |
|
200 | - $invoice = new WPInv_Invoice( $invoice ); |
|
199 | +function wpinv_payment_total($invoice = 0, $currency = false) { |
|
200 | + $invoice = new WPInv_Invoice($invoice); |
|
201 | 201 | $total = $invoice->get_total(); |
202 | 202 | |
203 | - if ( $currency ) { |
|
204 | - return wpinv_price( $total, $invoice->get_currency() ); |
|
203 | + if ($currency) { |
|
204 | + return wpinv_price($total, $invoice->get_currency()); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | return $total; |
@@ -210,51 +210,51 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * @deprecated |
212 | 212 | */ |
213 | -function wpinv_get_date_created( $invoice = 0, $format = '' ) { |
|
214 | - $invoice = new WPInv_Invoice( $invoice ); |
|
213 | +function wpinv_get_date_created($invoice = 0, $format = '') { |
|
214 | + $invoice = new WPInv_Invoice($invoice); |
|
215 | 215 | |
216 | - $format = ! empty( $format ) ? $format : get_option( 'date_format' ); |
|
216 | + $format = !empty($format) ? $format : get_option('date_format'); |
|
217 | 217 | $date_created = $invoice->get_created_date(); |
218 | 218 | |
219 | - return empty( $date_created ) ? date_i18n( $format, strtotime( $date_created ) ) : ''; |
|
219 | + return empty($date_created) ? date_i18n($format, strtotime($date_created)) : ''; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | 223 | * @deprecated |
224 | 224 | */ |
225 | -function wpinv_get_invoice_date( $invoice = 0, $format = '' ) { |
|
226 | - wpinv_get_date_created( $invoice, $format ); |
|
225 | +function wpinv_get_invoice_date($invoice = 0, $format = '') { |
|
226 | + wpinv_get_date_created($invoice, $format); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
230 | 230 | * @deprecated |
231 | 231 | */ |
232 | -function wpinv_get_invoice_vat_number( $invoice = 0 ) { |
|
233 | - $invoice = new WPInv_Invoice( $invoice ); |
|
232 | +function wpinv_get_invoice_vat_number($invoice = 0) { |
|
233 | + $invoice = new WPInv_Invoice($invoice); |
|
234 | 234 | return $invoice->get_vat_number(); |
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
238 | 238 | * @deprecated |
239 | 239 | */ |
240 | -function wpinv_insert_payment_note( $invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false ) { |
|
241 | - $invoice = new WPInv_Invoice( $invoice ); |
|
242 | - return $invoice->add_note( $note, $user_type, $added_by_user, $system ); |
|
240 | +function wpinv_insert_payment_note($invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false) { |
|
241 | + $invoice = new WPInv_Invoice($invoice); |
|
242 | + return $invoice->add_note($note, $user_type, $added_by_user, $system); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | 246 | * @deprecated |
247 | 247 | */ |
248 | -function wpinv_get_payment_key( $invoice = 0 ) { |
|
249 | - $invoice = new WPInv_Invoice( $invoice ); |
|
248 | +function wpinv_get_payment_key($invoice = 0) { |
|
249 | + $invoice = new WPInv_Invoice($invoice); |
|
250 | 250 | return $invoice->get_key(); |
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
254 | 254 | * @deprecated |
255 | 255 | */ |
256 | -function wpinv_get_invoice_number( $invoice = 0 ) { |
|
257 | - $invoice = new WPInv_Invoice( $invoice ); |
|
256 | +function wpinv_get_invoice_number($invoice = 0) { |
|
257 | + $invoice = new WPInv_Invoice($invoice); |
|
258 | 258 | return $invoice->get_number(); |
259 | 259 | } |
260 | 260 | |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | /** |
402 | 402 | * @deprecated |
403 | 403 | */ |
404 | -function wpinv_update_payment_status( $invoice, $new_status = 'publish' ) { |
|
405 | - $invoice = new WPInv_Invoice( $invoice ); |
|
406 | - return $invoice->update_status( $new_status ); |
|
404 | +function wpinv_update_payment_status($invoice, $new_status = 'publish') { |
|
405 | + $invoice = new WPInv_Invoice($invoice); |
|
406 | + return $invoice->update_status($new_status); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -456,22 +456,22 @@ discard block |
||
456 | 456 | /** |
457 | 457 | * @deprecated |
458 | 458 | */ |
459 | -function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) { |
|
459 | +function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') { |
|
460 | 460 | |
461 | 461 | // Fetch the invoice. |
462 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
462 | + $invoice = new WPInv_Invoice($invoice_id); |
|
463 | 463 | |
464 | - if ( 0 == $invoice->get_id() ) { |
|
464 | + if (0 == $invoice->get_id()) { |
|
465 | 465 | return false; |
466 | 466 | } |
467 | 467 | |
468 | 468 | // Prepare the transaction id. |
469 | - if ( empty( $transaction_id ) ) { |
|
469 | + if (empty($transaction_id)) { |
|
470 | 470 | $transaction_id = $invoice_id; |
471 | 471 | } |
472 | 472 | |
473 | 473 | // Set the transaction id; |
474 | - $invoice->set_transaction_id( apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice ) ); |
|
474 | + $invoice->set_transaction_id(apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice)); |
|
475 | 475 | |
476 | 476 | // Save the invoice. |
477 | 477 | return $invoice->save(); |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | * @param WPInv_Invoice $invoice |
485 | 485 | * @param string $gateway |
486 | 486 | */ |
487 | -function wpinv_send_to_gateway( $gateway, $invoice ) { |
|
487 | +function wpinv_send_to_gateway($gateway, $invoice) { |
|
488 | 488 | |
489 | 489 | $payment_data = array( |
490 | 490 | 'invoice_id' => $invoice->get_id(), |
491 | 491 | 'items' => $invoice->get_cart_details(), |
492 | - 'cart_discounts' => array( $invoice->get_discount_code() ), |
|
492 | + 'cart_discounts' => array($invoice->get_discount_code()), |
|
493 | 493 | 'fees' => $invoice->get_total_fees(), |
494 | 494 | 'subtotal' => $invoice->get_subtotal(), |
495 | 495 | 'discount' => $invoice->get_total_discount(), |
@@ -497,16 +497,16 @@ discard block |
||
497 | 497 | 'price' => $invoice->get_total(), |
498 | 498 | 'invoice_key' => $invoice->get_key(), |
499 | 499 | 'user_email' => $invoice->get_email(), |
500 | - 'date' => gmdate( 'Y-m-d H:i:s', time() ), |
|
500 | + 'date' => gmdate('Y-m-d H:i:s', time()), |
|
501 | 501 | 'user_info' => $invoice->get_user_info(), |
502 | - 'post_data' => wp_kses_post_deep( wp_unslash( $_POST ) ), |
|
502 | + 'post_data' => wp_kses_post_deep(wp_unslash($_POST)), |
|
503 | 503 | 'cart_details' => $invoice->get_cart_details(), |
504 | 504 | 'gateway' => $gateway, |
505 | 505 | 'card_info' => array(), |
506 | - 'gateway_nonce' => wp_create_nonce( 'wpi-gateway' ), |
|
506 | + 'gateway_nonce' => wp_create_nonce('wpi-gateway'), |
|
507 | 507 | ); |
508 | 508 | |
509 | - do_action( 'wpinv_gateway_' . $gateway, $payment_data ); |
|
509 | + do_action('wpinv_gateway_' . $gateway, $payment_data); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | /** |
520 | 520 | * @deprecated |
521 | 521 | */ |
522 | -function wpinv_die( $message = '', $title = '', $status = 400 ) { |
|
523 | - add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 ); |
|
524 | - add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 ); |
|
525 | - wp_die( esc_html( $message ), esc_html( $title ), array( 'response' => (int) $status ) ); |
|
522 | +function wpinv_die($message = '', $title = '', $status = 400) { |
|
523 | + add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3); |
|
524 | + add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3); |
|
525 | + wp_die(esc_html($message), esc_html($title), array('response' => (int) $status)); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -640,14 +640,14 @@ discard block |
||
640 | 640 | /** |
641 | 641 | * @deprecated |
642 | 642 | */ |
643 | -function wpinv_invoice_status_label( $status, $status_display = '' ) { |
|
644 | - return empty( $status_display ) ? sanitize_text_field( $status ) : sanitize_text_field( $status_display ); |
|
643 | +function wpinv_invoice_status_label($status, $status_display = '') { |
|
644 | + return empty($status_display) ? sanitize_text_field($status) : sanitize_text_field($status_display); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
648 | 648 | * @deprecated |
649 | 649 | */ |
650 | -function wpinv_clean_invoice_number( $number ) { |
|
650 | +function wpinv_clean_invoice_number($number) { |
|
651 | 651 | return $number; |
652 | 652 | } |
653 | 653 | |
@@ -852,12 +852,12 @@ discard block |
||
852 | 852 | /** |
853 | 853 | * @deprecated |
854 | 854 | */ |
855 | -function wpinv_item_show_price( $item_id = 0, $echo = true ) { |
|
855 | +function wpinv_item_show_price($item_id = 0, $echo = true) { |
|
856 | 856 | |
857 | - if ( $echo ) { |
|
858 | - echo wp_kses_post( wpinv_item_price( $item_id ) ); |
|
857 | + if ($echo) { |
|
858 | + echo wp_kses_post(wpinv_item_price($item_id)); |
|
859 | 859 | } else { |
860 | - return wpinv_item_price( $item_id ); |
|
860 | + return wpinv_item_price($item_id); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | } |
@@ -1272,6 +1272,6 @@ discard block |
||
1272 | 1272 | * @return WPInv_Subscription|bool |
1273 | 1273 | * @deprecated |
1274 | 1274 | */ |
1275 | -function wpinv_get_subscription( $invoice ) { |
|
1276 | - return wpinv_get_invoice_subscription( $invoice ); |
|
1275 | +function wpinv_get_subscription($invoice) { |
|
1276 | + return wpinv_get_invoice_subscription($invoice); |
|
1277 | 1277 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains gateway functions. |
4 | 4 | * |
5 | 5 | */ |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Returns an array of payment gateways. |
@@ -11,30 +11,30 @@ discard block |
||
11 | 11 | * @return array |
12 | 12 | */ |
13 | 13 | function wpinv_get_payment_gateways() { |
14 | - return apply_filters( 'wpinv_payment_gateways', array() ); |
|
14 | + return apply_filters('wpinv_payment_gateways', array()); |
|
15 | 15 | } |
16 | 16 | |
17 | -function wpinv_payment_gateway_titles( $all_gateways ) { |
|
17 | +function wpinv_payment_gateway_titles($all_gateways) { |
|
18 | 18 | |
19 | 19 | $options = wpinv_get_options(); |
20 | 20 | $gateways = array(); |
21 | - foreach ( $all_gateways as $key => $gateway ) { |
|
22 | - if ( ! empty( $options[ $key . '_title' ] ) ) { |
|
23 | - $all_gateways[ $key ]['checkout_label'] = __( $options[ $key . '_title' ], 'invoicing' ); |
|
21 | + foreach ($all_gateways as $key => $gateway) { |
|
22 | + if (!empty($options[$key . '_title'])) { |
|
23 | + $all_gateways[$key]['checkout_label'] = __($options[$key . '_title'], 'invoicing'); |
|
24 | 24 | } |
25 | 25 | |
26 | - $gateways[ $key ] = isset( $options[ $key . '_ordering' ] ) ? $options[ $key . '_ordering' ] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' ); |
|
26 | + $gateways[$key] = isset($options[$key . '_ordering']) ? $options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : ''); |
|
27 | 27 | } |
28 | 28 | |
29 | - asort( $gateways ); |
|
29 | + asort($gateways); |
|
30 | 30 | |
31 | - foreach ( $gateways as $gateway => $key ) { |
|
32 | - $gateways[ $gateway ] = $all_gateways[ $gateway ]; |
|
31 | + foreach ($gateways as $gateway => $key) { |
|
32 | + $gateways[$gateway] = $all_gateways[$gateway]; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | return $gateways; |
36 | 36 | } |
37 | -add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 ); |
|
37 | +add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Returns an array of enabled gateways. |
@@ -42,36 +42,36 @@ discard block |
||
42 | 42 | * @param bool $sort |
43 | 43 | * @return array |
44 | 44 | */ |
45 | -function wpinv_get_enabled_payment_gateways( $sort = false ) { |
|
45 | +function wpinv_get_enabled_payment_gateways($sort = false) { |
|
46 | 46 | |
47 | 47 | $enabled = array(); |
48 | 48 | |
49 | - foreach ( wpinv_get_payment_gateways() as $gateway => $data ) { |
|
49 | + foreach (wpinv_get_payment_gateways() as $gateway => $data) { |
|
50 | 50 | |
51 | - if ( (int) wpinv_get_option( "{$gateway}_active", $gateway === 'manual' ) === 1 ) { |
|
52 | - $enabled[ $gateway ] = $data; |
|
51 | + if ((int) wpinv_get_option("{$gateway}_active", $gateway === 'manual') === 1) { |
|
52 | + $enabled[$gateway] = $data; |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | - if ( true === $sort ) { |
|
57 | - uasort( $enabled, 'wpinv_sort_gateway_order' ); |
|
56 | + if (true === $sort) { |
|
57 | + uasort($enabled, 'wpinv_sort_gateway_order'); |
|
58 | 58 | |
59 | 59 | // Reorder our gateways so the default is first |
60 | 60 | $default_gateway_id = wpinv_get_default_gateway(); |
61 | - if ( isset( $enabled[ $default_gateway_id ] ) ) { |
|
61 | + if (isset($enabled[$default_gateway_id])) { |
|
62 | 62 | $default_gateway = array( |
63 | - $default_gateway_id => $enabled[ $default_gateway_id ], |
|
63 | + $default_gateway_id => $enabled[$default_gateway_id], |
|
64 | 64 | ); |
65 | 65 | |
66 | - unset( $enabled[ $default_gateway_id ] ); |
|
67 | - $enabled = array_merge( $default_gateway, $enabled ); |
|
66 | + unset($enabled[$default_gateway_id]); |
|
67 | + $enabled = array_merge($default_gateway, $enabled); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - return apply_filters( 'wpinv_enabled_payment_gateways', $enabled ); |
|
71 | + return apply_filters('wpinv_enabled_payment_gateways', $enabled); |
|
72 | 72 | } |
73 | 73 | |
74 | -function wpinv_sort_gateway_order( $a, $b ) { |
|
74 | +function wpinv_sort_gateway_order($a, $b) { |
|
75 | 75 | return $a['ordering'] - $b['ordering']; |
76 | 76 | } |
77 | 77 | |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | * @param string $gateway |
82 | 82 | * @return bool |
83 | 83 | */ |
84 | -function wpinv_is_gateway_active( $gateway ) { |
|
85 | - $is_active = (int) wpinv_get_option( "{$gateway}_active", $gateway === 'manual' ) === 1; |
|
86 | - return apply_filters( 'wpinv_is_gateway_active', $is_active, $gateway ); |
|
84 | +function wpinv_is_gateway_active($gateway) { |
|
85 | + $is_active = (int) wpinv_get_option("{$gateway}_active", $gateway === 'manual') === 1; |
|
86 | + return apply_filters('wpinv_is_gateway_active', $is_active, $gateway); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | * @return string|false |
93 | 93 | */ |
94 | 94 | function wpinv_get_default_gateway() { |
95 | - $default = wpinv_get_option( 'default_gateway' ); |
|
95 | + $default = wpinv_get_option('default_gateway'); |
|
96 | 96 | $gateways = wpinv_get_enabled_payment_gateways(); |
97 | - $default = ! empty( $default ) && isset( $gateways[ $default ] ) ? $default : false; |
|
97 | + $default = !empty($default) && isset($gateways[$default]) ? $default : false; |
|
98 | 98 | |
99 | - return apply_filters( 'wpinv_default_gateway', $default ); |
|
99 | + return apply_filters('wpinv_default_gateway', $default); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -105,17 +105,17 @@ discard block |
||
105 | 105 | * @param string $gateway The gateway to key. |
106 | 106 | * @return string |
107 | 107 | */ |
108 | -function wpinv_get_gateway_admin_label( $gateway ) { |
|
108 | +function wpinv_get_gateway_admin_label($gateway) { |
|
109 | 109 | |
110 | - if ( empty( $gateway ) || 'none' == $gateway ) { |
|
111 | - return esc_html__( 'No Gateway', 'invoicing' ); |
|
110 | + if (empty($gateway) || 'none' == $gateway) { |
|
111 | + return esc_html__('No Gateway', 'invoicing'); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | $gateways = wpinv_get_payment_gateways(); |
115 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
116 | - $gateway = apply_filters( 'wpinv_gateway_admin_label', $label, $gateway ); |
|
115 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
116 | + $gateway = apply_filters('wpinv_gateway_admin_label', $label, $gateway); |
|
117 | 117 | |
118 | - return wpinv_clean( $gateway ); |
|
118 | + return wpinv_clean($gateway); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -123,48 +123,48 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @param string $gateway |
125 | 125 | */ |
126 | -function wpinv_get_gateway_description( $gateway ) { |
|
126 | +function wpinv_get_gateway_description($gateway) { |
|
127 | 127 | |
128 | 128 | $options = wpinv_get_options(); |
129 | - $description = ! empty( $options[ $gateway . '_desc' ] ) ? $options[ $gateway . '_desc' ] : ''; |
|
129 | + $description = !empty($options[$gateway . '_desc']) ? $options[$gateway . '_desc'] : ''; |
|
130 | 130 | |
131 | - return apply_filters( 'wpinv_gateway_description', $description, $gateway ); |
|
131 | + return apply_filters('wpinv_gateway_description', $description, $gateway); |
|
132 | 132 | } |
133 | 133 | |
134 | -function wpinv_get_gateway_button_label( $gateway ) { |
|
135 | - return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' ); |
|
134 | +function wpinv_get_gateway_button_label($gateway) { |
|
135 | + return apply_filters('wpinv_gateway_' . $gateway . '_button_label', ''); |
|
136 | 136 | } |
137 | 137 | |
138 | -function wpinv_get_gateway_checkout_label( $gateway ) { |
|
138 | +function wpinv_get_gateway_checkout_label($gateway) { |
|
139 | 139 | $gateways = wpinv_get_payment_gateways(); |
140 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
140 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
141 | 141 | |
142 | - if ( $gateway == 'none' ) { |
|
143 | - $label = __( 'None', 'invoicing' ); |
|
142 | + if ($gateway == 'none') { |
|
143 | + $label = __('None', 'invoicing'); |
|
144 | 144 | } |
145 | 145 | |
146 | - return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway ); |
|
146 | + return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway); |
|
147 | 147 | } |
148 | 148 | |
149 | -function wpinv_settings_sections_gateways( $settings ) { |
|
149 | +function wpinv_settings_sections_gateways($settings) { |
|
150 | 150 | $gateways = wpinv_get_payment_gateways(); |
151 | - ksort( $gateways ); |
|
151 | + ksort($gateways); |
|
152 | 152 | |
153 | - foreach ( $gateways as $key => $gateway ) { |
|
154 | - $settings[ $key ] = $gateway['admin_label']; |
|
153 | + foreach ($gateways as $key => $gateway) { |
|
154 | + $settings[$key] = $gateway['admin_label']; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $settings; |
158 | 158 | } |
159 | -add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 ); |
|
159 | +add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1); |
|
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Adds GateWay settings. |
163 | 163 | */ |
164 | -function wpinv_settings_gateways( $settings ) { |
|
164 | +function wpinv_settings_gateways($settings) { |
|
165 | 165 | |
166 | 166 | // Loop through each gateway. |
167 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
167 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
168 | 168 | |
169 | 169 | $gateway_settings = array( |
170 | 170 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | "{$key}_header" => array( |
173 | 173 | |
174 | 174 | 'id' => "{$key}_gateway_header", |
175 | - 'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>', |
|
175 | + 'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>', |
|
176 | 176 | 'custom' => $key, |
177 | 177 | 'type' => 'gateway_header', |
178 | 178 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | // Activate/Deactivate a gateway. |
182 | 182 | "{$key}_active" => array( |
183 | 183 | 'id' => $key . '_active', |
184 | - 'name' => __( 'Activate', 'invoicing' ), |
|
185 | - 'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ), |
|
184 | + 'name' => __('Activate', 'invoicing'), |
|
185 | + 'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']), |
|
186 | 186 | 'type' => 'checkbox', |
187 | 187 | 'std' => $key === 'manual' ? '1' : '0', |
188 | 188 | ), |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | // Activate/Deactivate sandbox. |
191 | 191 | "{$key}_sandbox" => array( |
192 | 192 | 'id' => $key . '_sandbox', |
193 | - 'name' => __( 'Sandbox', 'invoicing' ), |
|
194 | - 'desc' => __( 'Enable sandbox to test payments', 'invoicing' ), |
|
193 | + 'name' => __('Sandbox', 'invoicing'), |
|
194 | + 'desc' => __('Enable sandbox to test payments', 'invoicing'), |
|
195 | 195 | 'type' => 'checkbox', |
196 | 196 | 'std' => '1', |
197 | 197 | ), |
@@ -199,52 +199,52 @@ discard block |
||
199 | 199 | // Checkout title. |
200 | 200 | "{$key}_title" => array( |
201 | 201 | 'id' => $key . '_title', |
202 | - 'name' => __( 'Checkout Title', 'invoicing' ), |
|
203 | - 'std' => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '', |
|
202 | + 'name' => __('Checkout Title', 'invoicing'), |
|
203 | + 'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '', |
|
204 | 204 | 'type' => 'text', |
205 | 205 | ), |
206 | 206 | |
207 | 207 | // Checkout description. |
208 | 208 | "{$key}_desc" => array( |
209 | 209 | 'id' => $key . '_desc', |
210 | - 'name' => __( 'Checkout Description', 'invoicing' ), |
|
211 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
210 | + 'name' => __('Checkout Description', 'invoicing'), |
|
211 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
212 | 212 | 'type' => 'text', |
213 | 213 | ), |
214 | 214 | |
215 | 215 | // Checkout order. |
216 | 216 | "{$key}_ordering" => array( |
217 | 217 | 'id' => $key . '_ordering', |
218 | - 'name' => __( 'Priority', 'invoicing' ), |
|
219 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
218 | + 'name' => __('Priority', 'invoicing'), |
|
219 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
220 | 220 | 'type' => 'number', |
221 | 221 | 'step' => '1', |
222 | 222 | 'min' => '0', |
223 | 223 | 'max' => '100000', |
224 | - 'std' => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10', |
|
224 | + 'std' => isset($gateway['ordering']) ? $gateway['ordering'] : '10', |
|
225 | 225 | ), |
226 | 226 | |
227 | 227 | ); |
228 | 228 | |
229 | 229 | // Maybe remove the sandbox. |
230 | - if ( ! getpaid_payment_gateway_supports( $key, 'sandbox' ) ) { |
|
231 | - unset( $gateway_settings[ "{$key}_sandbox" ] ); |
|
230 | + if (!getpaid_payment_gateway_supports($key, 'sandbox')) { |
|
231 | + unset($gateway_settings["{$key}_sandbox"]); |
|
232 | 232 | } |
233 | 233 | |
234 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway ); |
|
235 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway ); |
|
234 | + $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway); |
|
235 | + $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway); |
|
236 | 236 | |
237 | - $settings[ $key ] = $gateway_settings; |
|
237 | + $settings[$key] = $gateway_settings; |
|
238 | 238 | } |
239 | 239 | |
240 | - do_action( 'getpaid_after_gateway_settings', $settings ); |
|
240 | + do_action('getpaid_after_gateway_settings', $settings); |
|
241 | 241 | return $settings; |
242 | 242 | |
243 | 243 | } |
244 | -add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 ); |
|
244 | +add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1); |
|
245 | 245 | |
246 | -function wpinv_gateway_header_callback( $args ) { |
|
247 | - echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />'; |
|
246 | +function wpinv_gateway_header_callback($args) { |
|
247 | + echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />'; |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -255,60 +255,60 @@ discard block |
||
255 | 255 | * @return bool |
256 | 256 | * @since 2.3.0 |
257 | 257 | */ |
258 | -function getpaid_payment_gateway_supports( $gateway, $feature ) { |
|
258 | +function getpaid_payment_gateway_supports($gateway, $feature) { |
|
259 | 259 | |
260 | 260 | $supports = false; |
261 | 261 | |
262 | - $supports = apply_filters( "getpaid_{$gateway}_supports_{$feature}", false ); |
|
262 | + $supports = apply_filters("getpaid_{$gateway}_supports_{$feature}", false); |
|
263 | 263 | |
264 | 264 | // Backwards compatibility. |
265 | - $supports = apply_filters( "wpinv_{$gateway}_supports_{$feature}", $supports ); |
|
266 | - $supports = apply_filters( "wpinv_{$gateway}_support_{$feature}", $supports ); |
|
265 | + $supports = apply_filters("wpinv_{$gateway}_supports_{$feature}", $supports); |
|
266 | + $supports = apply_filters("wpinv_{$gateway}_support_{$feature}", $supports); |
|
267 | 267 | |
268 | - $supports = apply_filters( "getpaid_gateway_supports_{$feature}", $supports, $gateway ); |
|
269 | - $supports = apply_filters( 'getpaid_payment_gateway_supports', $supports, $feature, $gateway ); |
|
268 | + $supports = apply_filters("getpaid_gateway_supports_{$feature}", $supports, $gateway); |
|
269 | + $supports = apply_filters('getpaid_payment_gateway_supports', $supports, $feature, $gateway); |
|
270 | 270 | |
271 | 271 | return $supports; |
272 | 272 | } |
273 | 273 | |
274 | -function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
|
275 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
274 | +function wpinv_get_chosen_gateway($invoice_id = 0) { |
|
275 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
276 | 276 | |
277 | 277 | $chosen = false; |
278 | - if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
278 | + if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) { |
|
279 | 279 | $chosen = $invoice->get_gateway(); |
280 | 280 | } |
281 | 281 | |
282 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
282 | + $chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen; |
|
283 | 283 | |
284 | - if ( false !== $chosen ) { |
|
285 | - $chosen = preg_replace( '/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
284 | + if (false !== $chosen) { |
|
285 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen); |
|
286 | 286 | } |
287 | 287 | |
288 | - if ( ! empty( $chosen ) ) { |
|
289 | - $enabled_gateway = urldecode( $chosen ); |
|
290 | - } elseif ( ! empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
288 | + if (!empty($chosen)) { |
|
289 | + $enabled_gateway = urldecode($chosen); |
|
290 | + } elseif (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) { |
|
291 | 291 | $enabled_gateway = 'manual'; |
292 | 292 | } else { |
293 | 293 | $enabled_gateway = wpinv_get_default_gateway(); |
294 | 294 | } |
295 | 295 | |
296 | - if ( ! wpinv_is_gateway_active( $enabled_gateway ) && ! empty( $gateways ) ) { |
|
297 | - if ( wpinv_is_gateway_active( wpinv_get_default_gateway() ) ) { |
|
296 | + if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) { |
|
297 | + if (wpinv_is_gateway_active(wpinv_get_default_gateway())) { |
|
298 | 298 | $enabled_gateway = wpinv_get_default_gateway(); |
299 | 299 | } else { |
300 | 300 | $enabled_gateway = $gateways[0]; |
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
304 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
304 | + return apply_filters('wpinv_chosen_gateway', $enabled_gateway); |
|
305 | 305 | } |
306 | 306 | |
307 | -function wpinv_record_gateway_error( $title = '', $message = '' ) { |
|
308 | - return wpinv_error_log( $message, $title ); |
|
307 | +function wpinv_record_gateway_error($title = '', $message = '') { |
|
308 | + return wpinv_error_log($message, $title); |
|
309 | 309 | } |
310 | 310 | |
311 | -function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
311 | +function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
312 | 312 | $ret = 0; |
313 | 313 | $args = array( |
314 | 314 | 'meta_key' => '_wpinv_gateway', |
@@ -319,9 +319,9 @@ discard block |
||
319 | 319 | 'fields' => 'ids', |
320 | 320 | ); |
321 | 321 | |
322 | - $payments = new WP_Query( $args ); |
|
322 | + $payments = new WP_Query($args); |
|
323 | 323 | |
324 | - if ( $payments ) { |
|
324 | + if ($payments) { |
|
325 | 325 | $ret = $payments->post_count; |
326 | 326 | } |
327 | 327 | return $ret; |
@@ -330,11 +330,11 @@ discard block |
||
330 | 330 | /** |
331 | 331 | * Displays the ipn url field. |
332 | 332 | */ |
333 | -function wpinv_ipn_url_callback( $args ) { |
|
334 | - $sanitize_id = esc_attr( wpinv_sanitize_key( $args['id'] ) ); |
|
333 | +function wpinv_ipn_url_callback($args) { |
|
334 | + $sanitize_id = esc_attr(wpinv_sanitize_key($args['id'])); |
|
335 | 335 | |
336 | - echo '<input class="regular-text" type="text" ' . ( $args['readonly'] ? ' readonly' : '' ) . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" onClick="this.select()">'; |
|
337 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']">' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
336 | + echo '<input class="regular-text" type="text" ' . ($args['readonly'] ? ' readonly' : '') . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . esc_attr($sanitize_id) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" onClick="this.select()">'; |
|
337 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']">' . wp_kses_post($args['desc']) . '</label>'; |
|
338 | 338 | |
339 | 339 | } |
340 | 340 | |
@@ -345,10 +345,10 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return bool |
347 | 347 | */ |
348 | -function wpinv_is_test_mode( $gateway = '' ) { |
|
349 | - $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", true ); |
|
350 | - $supports = getpaid_payment_gateway_supports( $gateway, 'sandbox' ); |
|
351 | - return apply_filters( 'wpinv_is_test_mode', $sandbox && $supports, $gateway ); |
|
348 | +function wpinv_is_test_mode($gateway = '') { |
|
349 | + $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", true); |
|
350 | + $supports = getpaid_payment_gateway_supports($gateway, 'sandbox'); |
|
351 | + return apply_filters('wpinv_is_test_mode', $sandbox && $supports, $gateway); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * |
360 | 360 | * @return string |
361 | 361 | */ |
362 | -function wpinv_get_ipn_url( $gateway = false, $args = array() ) { |
|
362 | +function wpinv_get_ipn_url($gateway = false, $args = array()) { |
|
363 | 363 | $args = wp_parse_args( |
364 | 364 | array( |
365 | 365 | 'wpi-listener' => 'IPN', |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | $args |
369 | 369 | ); |
370 | 370 | |
371 | - return apply_filters( 'wpinv_ipn_url', add_query_arg( $args, home_url( 'index.php' ) ), $gateway, $args ); |
|
371 | + return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args); |
|
372 | 372 | |
373 | 373 | } |
374 | 374 | |
@@ -379,34 +379,34 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @return string |
381 | 381 | */ |
382 | -function getpaid_get_non_query_string_ipn_url( $gateway ) { |
|
383 | - $gateway = wpinv_sanitize_key( $gateway ); |
|
384 | - return home_url( "getpaid-ipn/$gateway" ); |
|
382 | +function getpaid_get_non_query_string_ipn_url($gateway) { |
|
383 | + $gateway = wpinv_sanitize_key($gateway); |
|
384 | + return home_url("getpaid-ipn/$gateway"); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | |
388 | 388 | /** |
389 | 389 | * Retrieves request data with slashes removed slashes. |
390 | 390 | */ |
391 | -function wpinv_get_post_data( $method = 'request' ) { |
|
391 | +function wpinv_get_post_data($method = 'request') { |
|
392 | 392 | |
393 | - if ( $method == 'post' ) { |
|
394 | - return wp_kses_post_deep( wp_unslash( $_POST ) ); |
|
393 | + if ($method == 'post') { |
|
394 | + return wp_kses_post_deep(wp_unslash($_POST)); |
|
395 | 395 | } |
396 | 396 | |
397 | - if ( $method == 'get' ) { |
|
398 | - return wp_kses_post_deep( wp_unslash( $_GET ) ); |
|
397 | + if ($method == 'get') { |
|
398 | + return wp_kses_post_deep(wp_unslash($_GET)); |
|
399 | 399 | } |
400 | 400 | |
401 | - return wp_kses_post_deep( wp_unslash( $_REQUEST ) ); |
|
401 | + return wp_kses_post_deep(wp_unslash($_REQUEST)); |
|
402 | 402 | |
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
406 | 406 | * Checks if a given gateway supports subscription payments. |
407 | 407 | */ |
408 | -function wpinv_gateway_support_subscription( $gateway ) { |
|
409 | - return getpaid_payment_gateway_supports( $gateway, 'subscription' ); |
|
408 | +function wpinv_gateway_support_subscription($gateway) { |
|
409 | + return getpaid_payment_gateway_supports($gateway, 'subscription'); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | /** |
@@ -415,18 +415,18 @@ discard block |
||
415 | 415 | * @param array $gateways an array of gateways. |
416 | 416 | * @param GetPaid_Payment_Form $form payment form. |
417 | 417 | */ |
418 | -function wpinv_payment_gateways_on_cart( $gateways, $form ) { |
|
418 | +function wpinv_payment_gateways_on_cart($gateways, $form) { |
|
419 | 419 | |
420 | - if ( $form->is_recurring() ) { |
|
420 | + if ($form->is_recurring()) { |
|
421 | 421 | |
422 | - foreach ( array_keys( $gateways ) as $gateway ) { |
|
422 | + foreach (array_keys($gateways) as $gateway) { |
|
423 | 423 | |
424 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
425 | - unset( $gateways[ $gateway ] ); |
|
424 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
425 | + unset($gateways[$gateway]); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
430 | 430 | return $gateways; |
431 | 431 | } |
432 | -add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 ); |
|
432 | +add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2); |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Current page. |
13 | -$current_page = empty( $_GET['page'] ) ? 1 : absint( $_GET['page'] ); |
|
13 | +$current_page = empty($_GET['page']) ? 1 : absint($_GET['page']); |
|
14 | 14 | |
15 | 15 | // Fires before displaying user invoices. |
16 | -do_action( 'wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type ); |
|
16 | +do_action('wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type); |
|
17 | 17 | |
18 | 18 | wpinv_print_errors(); |
19 | 19 | |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | |
22 | 22 | |
23 | 23 | <div class="table-responsive"> |
24 | - <table class="table table-bordered table-hover getpaid-user-invoices <?php echo esc_attr( $post_type ); ?>"> |
|
24 | + <table class="table table-bordered table-hover getpaid-user-invoices <?php echo esc_attr($post_type); ?>"> |
|
25 | 25 | |
26 | 26 | |
27 | 27 | <thead> |
28 | 28 | <tr> |
29 | 29 | |
30 | - <?php foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : ?> |
|
31 | - <th class="<?php echo esc_attr( $column_id ); ?> <?php echo ( ! empty( $column_name['class'] ) ? sanitize_html_class( $column_name['class'] ) : ''); ?> border-bottom-0"> |
|
32 | - <span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span> |
|
30 | + <?php foreach (wpinv_get_user_invoices_columns($post_type) as $column_id => $column_name) : ?> |
|
31 | + <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? sanitize_html_class($column_name['class']) : ''); ?> border-bottom-0"> |
|
32 | + <span class="nobr"><?php echo esc_html($column_name['title']); ?></span> |
|
33 | 33 | </th> |
34 | 34 | <?php endforeach; ?> |
35 | 35 | |
@@ -39,43 +39,43 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | <tbody> |
42 | - <?php foreach ( $invoices->invoices as $invoice ) : ?> |
|
42 | + <?php foreach ($invoices->invoices as $invoice) : ?> |
|
43 | 43 | |
44 | - <tr class="wpinv-item wpinv-item-<?php echo esc_attr( $invoice->get_status() ); ?>"> |
|
44 | + <tr class="wpinv-item wpinv-item-<?php echo esc_attr($invoice->get_status()); ?>"> |
|
45 | 45 | <?php |
46 | 46 | |
47 | - foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : |
|
47 | + foreach (wpinv_get_user_invoices_columns($post_type) as $column_id => $column_name) : |
|
48 | 48 | |
49 | - $column_id = sanitize_html_class( $column_id ); |
|
50 | - $class = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] ); |
|
49 | + $column_id = sanitize_html_class($column_id); |
|
50 | + $class = empty($column_name['class']) ? '' : sanitize_html_class($column_name['class']); |
|
51 | 51 | |
52 | - echo "<td class='" . esc_attr( $column_id . ' ' . $class ) . "'>"; |
|
53 | - switch ( $column_id ) { |
|
52 | + echo "<td class='" . esc_attr($column_id . ' ' . $class) . "'>"; |
|
53 | + switch ($column_id) { |
|
54 | 54 | |
55 | 55 | case 'invoice-number': |
56 | - echo wp_kses_post( wpinv_invoice_link( $invoice ) ); |
|
56 | + echo wp_kses_post(wpinv_invoice_link($invoice)); |
|
57 | 57 | break; |
58 | 58 | |
59 | 59 | case 'created-date': |
60 | - echo esc_html( getpaid_format_date_value( $invoice->get_date_created() ) ); |
|
60 | + echo esc_html(getpaid_format_date_value($invoice->get_date_created())); |
|
61 | 61 | break; |
62 | 62 | |
63 | 63 | case 'payment-date': |
64 | - if ( $invoice->needs_payment() ) { |
|
64 | + if ($invoice->needs_payment()) { |
|
65 | 65 | echo '—'; |
66 | 66 | } else { |
67 | - echo esc_html( getpaid_format_date_value( $invoice->get_date_completed() ) ); |
|
67 | + echo esc_html(getpaid_format_date_value($invoice->get_date_completed())); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | break; |
71 | 71 | |
72 | 72 | case 'invoice-status': |
73 | - echo wp_kses_post( $invoice->get_status_label_html() ); |
|
73 | + echo wp_kses_post($invoice->get_status_label_html()); |
|
74 | 74 | |
75 | 75 | break; |
76 | 76 | |
77 | 77 | case 'invoice-total': |
78 | - wpinv_the_price( $invoice->get_total(), $invoice->get_currency() ); |
|
78 | + wpinv_the_price($invoice->get_total(), $invoice->get_currency()); |
|
79 | 79 | |
80 | 80 | break; |
81 | 81 | |
@@ -84,47 +84,47 @@ discard block |
||
84 | 84 | |
85 | 85 | 'pay' => array( |
86 | 86 | 'url' => $invoice->get_checkout_payment_url(), |
87 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
87 | + 'name' => __('Pay Now', 'invoicing'), |
|
88 | 88 | 'class' => 'btn-success', |
89 | 89 | ), |
90 | 90 | |
91 | 91 | 'print' => array( |
92 | 92 | 'url' => $invoice->get_view_url(), |
93 | - 'name' => __( 'View', 'invoicing' ), |
|
93 | + 'name' => __('View', 'invoicing'), |
|
94 | 94 | 'class' => 'btn-secondary', |
95 | 95 | 'attrs' => 'target="_blank"', |
96 | 96 | ), |
97 | 97 | ); |
98 | 98 | |
99 | - if ( ! $invoice->needs_payment() ) { |
|
100 | - unset( $actions['pay'] ); |
|
99 | + if (!$invoice->needs_payment()) { |
|
100 | + unset($actions['pay']); |
|
101 | 101 | } |
102 | 102 | |
103 | - if ( $invoice->needs_payment() ) { |
|
103 | + if ($invoice->needs_payment()) { |
|
104 | 104 | $actions['delete'] = array( |
105 | - 'url' => getpaid_get_authenticated_action_url( 'delete_invoice', add_query_arg( 'invoice_id', $invoice->get_id() ) ), |
|
106 | - 'name' => __( 'Delete', 'invoicing' ), |
|
105 | + 'url' => getpaid_get_authenticated_action_url('delete_invoice', add_query_arg('invoice_id', $invoice->get_id())), |
|
106 | + 'name' => __('Delete', 'invoicing'), |
|
107 | 107 | 'class' => 'btn-danger', |
108 | 108 | ); |
109 | 109 | } |
110 | 110 | |
111 | - $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type ); |
|
111 | + $actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice, $post_type); |
|
112 | 112 | |
113 | - foreach ( $actions as $key => $action ) { |
|
114 | - $class = ! empty( $action['class'] ) ? sanitize_html_class( $action['class'] ) : ''; |
|
115 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . esc_attr( $class . ' ' . sanitize_html_class( $key ) ) . '" ' . ( ! empty( $action['attrs'] ) ? esc_html( $action['attrs'] ) : '' ) . '>' . esc_attr( $action['name'] ) . '</a>'; |
|
113 | + foreach ($actions as $key => $action) { |
|
114 | + $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
115 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm btn-block ' . esc_attr($class . ' ' . sanitize_html_class($key)) . '" ' . (!empty($action['attrs']) ? esc_html($action['attrs']) : '') . '>' . esc_attr($action['name']) . '</a>'; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | break; |
119 | 119 | |
120 | 120 | default: |
121 | - do_action( "wpinv_user_invoices_column_$column_id", $invoice ); |
|
121 | + do_action("wpinv_user_invoices_column_$column_id", $invoice); |
|
122 | 122 | break; |
123 | 123 | |
124 | 124 | |
125 | 125 | } |
126 | 126 | |
127 | - do_action( "wpinv_user_invoices_column_after_$column_id", $invoice ); |
|
127 | + do_action("wpinv_user_invoices_column_after_$column_id", $invoice); |
|
128 | 128 | |
129 | 129 | echo '</td>'; |
130 | 130 | |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | </table> |
139 | 139 | </div> |
140 | 140 | |
141 | - <?php do_action( 'wpinv_before_user_invoices_pagination' ); ?> |
|
141 | + <?php do_action('wpinv_before_user_invoices_pagination'); ?> |
|
142 | 142 | |
143 | - <?php if ( 1 < $invoices->max_num_pages ) : ?> |
|
143 | + <?php if (1 < $invoices->max_num_pages) : ?> |
|
144 | 144 | <div class="invoicing-Pagination"> |
145 | 145 | <?php |
146 | 146 | $big = 999999; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | echo wp_kses_post( |
149 | 149 | paginate_links( |
150 | 150 | array( |
151 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
151 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
152 | 152 | 'format' => '?paged=%#%', |
153 | 153 | 'total' => $invoices->max_num_pages, |
154 | 154 | ) |
@@ -158,4 +158,4 @@ discard block |
||
158 | 158 | </div> |
159 | 159 | <?php endif; ?> |
160 | 160 | |
161 | -<?php do_action( 'wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type ); ?> |
|
161 | +<?php do_action('wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type); ?> |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Session handler class. |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function old__construct() { |
56 | 56 | |
57 | - $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH ); |
|
58 | - add_action( 'init', array( $this, 'init' ), -1 ); |
|
59 | - add_action( 'wp_logout', array( $this, 'destroy_session' ) ); |
|
60 | - add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 ); |
|
61 | - add_action( 'shutdown', array( $this, 'save_data' ), 20 ); |
|
57 | + $this->_cookie = apply_filters('wpinv_cookie', 'wpinv_session_' . COOKIEHASH); |
|
58 | + add_action('init', array($this, 'init'), -1); |
|
59 | + add_action('wp_logout', array($this, 'destroy_session')); |
|
60 | + add_action('wp', array($this, 'set_customer_session_cookie'), 10); |
|
61 | + add_action('shutdown', array($this, 'save_data'), 20); |
|
62 | 62 | |
63 | 63 | } |
64 | 64 | |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | public function init() { |
71 | 71 | $this->init_session_cookie(); |
72 | 72 | |
73 | - if ( ! is_user_logged_in() ) { |
|
74 | - add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ), 10, 2 ); |
|
73 | + if (!is_user_logged_in()) { |
|
74 | + add_filter('nonce_user_logged_out', array($this, 'nonce_user_logged_out'), 10, 2); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | public function init_session_cookie() { |
84 | 84 | $cookie = $this->get_session_cookie(); |
85 | 85 | |
86 | - if ( $cookie ) { |
|
86 | + if ($cookie) { |
|
87 | 87 | $this->_customer_id = $cookie[0]; |
88 | 88 | $this->_session_expiration = $cookie[1]; |
89 | 89 | $this->_session_expiring = $cookie[2]; |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | $this->_data = $this->get_session_data(); |
92 | 92 | |
93 | 93 | // If the user logs in, update session. |
94 | - if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) { |
|
94 | + if (is_user_logged_in() && get_current_user_id() != $this->_customer_id) { |
|
95 | 95 | $this->_customer_id = get_current_user_id(); |
96 | 96 | $this->_dirty = true; |
97 | 97 | $this->save_data(); |
98 | - $this->set_customer_session_cookie( true ); |
|
98 | + $this->set_customer_session_cookie(true); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | // Update session if its close to expiring. |
102 | - if ( time() > $this->_session_expiring ) { |
|
102 | + if (time() > $this->_session_expiring) { |
|
103 | 103 | $this->set_session_expiration(); |
104 | - $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration ); |
|
104 | + $this->update_session_timestamp($this->_customer_id, $this->_session_expiration); |
|
105 | 105 | } |
106 | 106 | } else { |
107 | 107 | $this->set_session_expiration(); |
@@ -119,25 +119,25 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @param bool $set Should the session cookie be set. |
121 | 121 | */ |
122 | - public function set_customer_session_cookie( $set ) { |
|
123 | - if ( $set ) { |
|
122 | + public function set_customer_session_cookie($set) { |
|
123 | + if ($set) { |
|
124 | 124 | $to_hash = $this->_customer_id . '|' . $this->_session_expiration; |
125 | - $cookie_hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
125 | + $cookie_hash = hash_hmac('md5', $to_hash, wp_hash($to_hash)); |
|
126 | 126 | $cookie_value = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash; |
127 | 127 | $this->_has_cookie = true; |
128 | 128 | |
129 | - if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) { |
|
130 | - $this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true ); |
|
129 | + if (!isset($_COOKIE[$this->_cookie]) || $_COOKIE[$this->_cookie] !== $cookie_value) { |
|
130 | + $this->setcookie($this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | - public function setcookie( $name, $value, $expire = 0, $secure = false, $httponly = false ) { |
|
136 | - if ( ! headers_sent() ) { |
|
137 | - setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) ); |
|
138 | - } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
139 | - headers_sent( $file, $line ); |
|
140 | - trigger_error( "{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE ); // @codingStandardsIgnoreLine |
|
135 | + public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false) { |
|
136 | + if (!headers_sent()) { |
|
137 | + setcookie($name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters('wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure)); |
|
138 | + } elseif (defined('WP_DEBUG') && WP_DEBUG) { |
|
139 | + headers_sent($file, $line); |
|
140 | + trigger_error("{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE); // @codingStandardsIgnoreLine |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | * @return bool |
149 | 149 | */ |
150 | 150 | protected function use_secure_cookie() { |
151 | - $is_https = false !== strstr( get_option( 'home' ), 'https:' ); |
|
152 | - return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() ); |
|
151 | + $is_https = false !== strstr(get_option('home'), 'https:'); |
|
152 | + return apply_filters('wpinv_session_use_secure_cookie', $is_https && is_ssl()); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,15 +158,15 @@ discard block |
||
158 | 158 | * @return bool |
159 | 159 | */ |
160 | 160 | public function has_session() { |
161 | - return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine. |
|
161 | + return isset($_COOKIE[$this->_cookie]) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine. |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * Set session expiration. |
166 | 166 | */ |
167 | 167 | public function set_session_expiration() { |
168 | - $this->_session_expiring = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours. |
|
169 | - $this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours. |
|
168 | + $this->_session_expiring = time() + intval(apply_filters('wpinv_session_expiring', 60 * 60 * 47)); // 47 Hours. |
|
169 | + $this->_session_expiration = time() + intval(apply_filters('wpinv_session_expiration', 60 * 60 * 48)); // 48 Hours. |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function generate_customer_id() { |
178 | 178 | require_once ABSPATH . 'wp-includes/class-phpass.php'; |
179 | - $hasher = new PasswordHash( 8, false ); |
|
180 | - return md5( $hasher->get_random_bytes( 32 ) ); |
|
179 | + $hasher = new PasswordHash(8, false); |
|
180 | + return md5($hasher->get_random_bytes(32)); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -188,27 +188,27 @@ discard block |
||
188 | 188 | * @return bool|array |
189 | 189 | */ |
190 | 190 | public function get_session_cookie() { |
191 | - $cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine. |
|
191 | + $cookie_value = isset($_COOKIE[$this->_cookie]) ? wp_unslash($_COOKIE[$this->_cookie]) : false; // @codingStandardsIgnoreLine. |
|
192 | 192 | |
193 | - if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) { |
|
193 | + if (empty($cookie_value) || !is_string($cookie_value)) { |
|
194 | 194 | return false; |
195 | 195 | } |
196 | 196 | |
197 | - list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value ); |
|
197 | + list($customer_id, $session_expiration, $session_expiring, $cookie_hash) = explode('||', $cookie_value); |
|
198 | 198 | |
199 | - if ( empty( $customer_id ) ) { |
|
199 | + if (empty($customer_id)) { |
|
200 | 200 | return false; |
201 | 201 | } |
202 | 202 | |
203 | 203 | // Validate hash. |
204 | 204 | $to_hash = $customer_id . '|' . $session_expiration; |
205 | - $hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
205 | + $hash = hash_hmac('md5', $to_hash, wp_hash($to_hash)); |
|
206 | 206 | |
207 | - if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) { |
|
207 | + if (empty($cookie_hash) || !hash_equals($hash, $cookie_hash)) { |
|
208 | 208 | return false; |
209 | 209 | } |
210 | 210 | |
211 | - return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash ); |
|
211 | + return array($customer_id, $session_expiration, $session_expiring, $cookie_hash); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | * @return array |
218 | 218 | */ |
219 | 219 | public function get_session_data() { |
220 | - return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array(); |
|
220 | + return $this->has_session() ? (array) $this->get_session($this->_customer_id) : array(); |
|
221 | 221 | } |
222 | 222 | |
223 | - public function generate_key( $customer_id ) { |
|
224 | - if ( ! $customer_id ) { |
|
223 | + public function generate_key($customer_id) { |
|
224 | + if (!$customer_id) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function save_data() { |
235 | 235 | // Dirty if something changed - prevents saving nothing new. |
236 | - if ( $this->_dirty && $this->has_session() ) { |
|
236 | + if ($this->_dirty && $this->has_session()) { |
|
237 | 237 | |
238 | - set_transient( $this->generate_key( $this->_customer_id ), $this->_data, $this->_session_expiration ); |
|
238 | + set_transient($this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration); |
|
239 | 239 | |
240 | 240 | $this->_dirty = false; |
241 | 241 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * Destroy all session data. |
246 | 246 | */ |
247 | 247 | public function destroy_session() { |
248 | - $this->delete_session( $this->_customer_id ); |
|
248 | + $this->delete_session($this->_customer_id); |
|
249 | 249 | $this->forget_session(); |
250 | 250 | } |
251 | 251 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * Forget all session data without destroying it. |
254 | 254 | */ |
255 | 255 | public function forget_session() { |
256 | - $this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true ); |
|
256 | + $this->setcookie($this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true); |
|
257 | 257 | |
258 | 258 | wpinv_empty_cart(); |
259 | 259 | |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | * @param int $uid User ID. |
269 | 269 | * @return string |
270 | 270 | */ |
271 | - public function nonce_user_logged_out( $uid ) { |
|
271 | + public function nonce_user_logged_out($uid) { |
|
272 | 272 | |
273 | 273 | // Check if one of our nonces. |
274 | - if ( substr( $uid, 0, 5 ) === 'wpinv' || substr( $uid, 0, 7 ) === 'getpaid' ) { |
|
274 | + if (substr($uid, 0, 5) === 'wpinv' || substr($uid, 0, 7) === 'getpaid') { |
|
275 | 275 | return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid; |
276 | 276 | } |
277 | 277 | |
@@ -285,20 +285,20 @@ discard block |
||
285 | 285 | * @param mixed $default Default session value. |
286 | 286 | * @return string|array |
287 | 287 | */ |
288 | - public function get_session( $customer_id, $default = false ) { |
|
288 | + public function get_session($customer_id, $default = false) { |
|
289 | 289 | |
290 | - if ( defined( 'WP_SETUP_CONFIG' ) ) { |
|
290 | + if (defined('WP_SETUP_CONFIG')) { |
|
291 | 291 | return array(); |
292 | 292 | } |
293 | 293 | |
294 | - $key = $this->generate_key( $customer_id ); |
|
295 | - $value = get_transient( $key ); |
|
294 | + $key = $this->generate_key($customer_id); |
|
295 | + $value = get_transient($key); |
|
296 | 296 | |
297 | - if ( ! $value ) { |
|
297 | + if (!$value) { |
|
298 | 298 | $value = $default; |
299 | 299 | } |
300 | 300 | |
301 | - return maybe_unserialize( $value ); |
|
301 | + return maybe_unserialize($value); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -306,11 +306,11 @@ discard block |
||
306 | 306 | * |
307 | 307 | * @param int $customer_id Customer ID. |
308 | 308 | */ |
309 | - public function delete_session( $customer_id ) { |
|
309 | + public function delete_session($customer_id) { |
|
310 | 310 | |
311 | - $key = $this->generate_key( $customer_id ); |
|
311 | + $key = $this->generate_key($customer_id); |
|
312 | 312 | |
313 | - delete_transient( $key ); |
|
313 | + delete_transient($key); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -319,9 +319,9 @@ discard block |
||
319 | 319 | * @param string $customer_id Customer ID. |
320 | 320 | * @param int $timestamp Timestamp to expire the cookie. |
321 | 321 | */ |
322 | - public function update_session_timestamp( $customer_id, $timestamp ) { |
|
322 | + public function update_session_timestamp($customer_id, $timestamp) { |
|
323 | 323 | |
324 | - set_transient( $this->generate_key( $customer_id ), maybe_serialize( $this->_data ), $timestamp ); |
|
324 | + set_transient($this->generate_key($customer_id), maybe_serialize($this->_data), $timestamp); |
|
325 | 325 | |
326 | 326 | } |
327 | 327 | } |
@@ -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 | * Metaboxes Admin Class |
@@ -25,35 +25,35 @@ discard block |
||
25 | 25 | public static function init() { |
26 | 26 | |
27 | 27 | // Register metaboxes. |
28 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 50, 2 ); |
|
28 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 50, 2); |
|
29 | 29 | |
30 | 30 | // Remove metaboxes. |
31 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
31 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30); |
|
32 | 32 | |
33 | 33 | // Rename metaboxes. |
34 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
34 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45); |
|
35 | 35 | |
36 | 36 | // Save metaboxes. |
37 | - add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
37 | + add_action('save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Register core metaboxes. |
42 | 42 | */ |
43 | - public static function add_meta_boxes( $post_type, $post ) { |
|
43 | + public static function add_meta_boxes($post_type, $post) { |
|
44 | 44 | |
45 | 45 | // For invoices. |
46 | - self::add_invoice_meta_boxes( $post_type, $post ); |
|
46 | + self::add_invoice_meta_boxes($post_type, $post); |
|
47 | 47 | |
48 | 48 | // For payment forms. |
49 | - self::add_payment_form_meta_boxes( $post_type, $post ); |
|
49 | + self::add_payment_form_meta_boxes($post_type, $post); |
|
50 | 50 | |
51 | 51 | // For invoice items. |
52 | - self::add_item_meta_boxes( $post_type ); |
|
52 | + self::add_item_meta_boxes($post_type); |
|
53 | 53 | |
54 | 54 | // For invoice discounts. |
55 | - if ( 'wpi_discount' === $post_type ) { |
|
56 | - add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
|
55 | + if ('wpi_discount' === $post_type) { |
|
56 | + add_meta_box('wpinv_discount_details', __('Discount Details', 'invoicing'), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | } |
@@ -61,17 +61,17 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * Register core metaboxes. |
63 | 63 | */ |
64 | - protected static function add_payment_form_meta_boxes( $post_type, $post ) { |
|
64 | + protected static function add_payment_form_meta_boxes($post_type, $post) { |
|
65 | 65 | |
66 | 66 | // For payment forms. |
67 | - if ( 'wpi_payment_form' === $post_type ) { |
|
67 | + if ('wpi_payment_form' === $post_type) { |
|
68 | 68 | |
69 | 69 | // Design payment form. |
70 | - add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
70 | + add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal'); |
|
71 | 71 | |
72 | 72 | // Payment form information. |
73 | - if ( wpinv_get_default_payment_form() !== $post->ID ) { |
|
74 | - add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
73 | + if (wpinv_get_default_payment_form() !== $post->ID) { |
|
74 | + add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side'); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -80,23 +80,23 @@ discard block |
||
80 | 80 | /** |
81 | 81 | * Register core metaboxes. |
82 | 82 | */ |
83 | - protected static function add_item_meta_boxes( $post_type ) { |
|
83 | + protected static function add_item_meta_boxes($post_type) { |
|
84 | 84 | |
85 | - if ( 'wpi_item' === $post_type ) { |
|
85 | + if ('wpi_item' === $post_type) { |
|
86 | 86 | |
87 | 87 | // Item details. |
88 | - add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
88 | + add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high'); |
|
89 | 89 | |
90 | 90 | // If taxes are enabled, register the tax metabox. |
91 | - if ( wpinv_use_taxes() ) { |
|
92 | - add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
91 | + if (wpinv_use_taxes()) { |
|
92 | + add_meta_box('wpinv_item_vat', __('Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high'); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // Item info. |
96 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
96 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core'); |
|
97 | 97 | |
98 | 98 | // Item description. |
99 | - add_meta_box( 'postexcerpt', __( 'Item Description', 'invoicing' ), 'GetPaid_Meta_Box_Description::output', 'wpi_item', 'normal' ); |
|
99 | + add_meta_box('postexcerpt', __('Item Description', 'invoicing'), 'GetPaid_Meta_Box_Description::output', 'wpi_item', 'normal'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | } |
@@ -104,21 +104,21 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * Register invoice metaboxes. |
106 | 106 | */ |
107 | - protected static function add_invoice_meta_boxes( $post_type, $post ) { |
|
107 | + protected static function add_invoice_meta_boxes($post_type, $post) { |
|
108 | 108 | |
109 | 109 | // For invoices... |
110 | - if ( getpaid_is_invoice_post_type( $post_type ) ) { |
|
111 | - $invoice = new WPInv_Invoice( $post ); |
|
110 | + if (getpaid_is_invoice_post_type($post_type)) { |
|
111 | + $invoice = new WPInv_Invoice($post); |
|
112 | 112 | |
113 | 113 | // Resend invoice. |
114 | - if ( ! $invoice->is_draft() ) { |
|
114 | + if (!$invoice->is_draft()) { |
|
115 | 115 | |
116 | 116 | add_meta_box( |
117 | 117 | 'wpinv-mb-resend-invoice', |
118 | 118 | sprintf( |
119 | 119 | // translators: %s is the invoice type. |
120 | - __( 'Resend %s', 'invoicing' ), |
|
121 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
120 | + __('Resend %s', 'invoicing'), |
|
121 | + ucfirst($invoice->get_invoice_quote_type()) |
|
122 | 122 | ), |
123 | 123 | 'GetPaid_Meta_Box_Resend_Invoice::output', |
124 | 124 | $post_type, |
@@ -129,17 +129,17 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | // Subscriptions. |
132 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
133 | - if ( ! empty( $subscriptions ) ) { |
|
132 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
133 | + if (!empty($subscriptions)) { |
|
134 | 134 | |
135 | - if ( is_array( $subscriptions ) ) { |
|
136 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Related Subscriptions', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced' ); |
|
135 | + if (is_array($subscriptions)) { |
|
136 | + add_meta_box('wpinv-mb-subscriptions', __('Related Subscriptions', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced'); |
|
137 | 137 | } else { |
138 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
|
138 | + add_meta_box('wpinv-mb-subscriptions', __('Subscription Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced'); |
|
139 | 139 | } |
140 | 140 | |
141 | - if ( getpaid_count_subscription_invoices( $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id() ) > 1 ) { |
|
142 | - add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
|
141 | + if (getpaid_count_subscription_invoices($invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id()) > 1) { |
|
142 | + add_meta_box('wpinv-mb-subscription-invoices', __('Related Payments', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced'); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | 'wpinv-details', |
149 | 149 | sprintf( |
150 | 150 | // translators: %s is the invoice type. |
151 | - __( '%s Details', 'invoicing' ), |
|
152 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
151 | + __('%s Details', 'invoicing'), |
|
152 | + ucfirst($invoice->get_invoice_quote_type()) |
|
153 | 153 | ), |
154 | 154 | 'GetPaid_Meta_Box_Invoice_Details::output', |
155 | 155 | $post_type, |
@@ -157,18 +157,18 @@ discard block |
||
157 | 157 | ); |
158 | 158 | |
159 | 159 | // Payment details. |
160 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
|
160 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default'); |
|
161 | 161 | |
162 | 162 | // Billing details. |
163 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
|
163 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high'); |
|
164 | 164 | |
165 | 165 | // Invoice items. |
166 | 166 | add_meta_box( |
167 | 167 | 'wpinv-items', |
168 | 168 | sprintf( |
169 | 169 | // translators: %s is the invoice type. |
170 | - __( '%s Items', 'invoicing' ), |
|
171 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
170 | + __('%s Items', 'invoicing'), |
|
171 | + ucfirst($invoice->get_invoice_quote_type()) |
|
172 | 172 | ), |
173 | 173 | 'GetPaid_Meta_Box_Invoice_Items::output', |
174 | 174 | $post_type, |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | 'wpinv-notes', |
182 | 182 | sprintf( |
183 | 183 | // translators: %s is the invoice type. |
184 | - __( '%s Notes', 'invoicing' ), |
|
185 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
184 | + __('%s Notes', 'invoicing'), |
|
185 | + ucfirst($invoice->get_invoice_quote_type()) |
|
186 | 186 | ), |
187 | 187 | 'WPInv_Meta_Box_Notes::output', |
188 | 188 | $post_type, |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | ); |
192 | 192 | |
193 | 193 | // Shipping Address. |
194 | - if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) { |
|
195 | - add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' ); |
|
194 | + if (get_post_meta($invoice->get_id(), 'shipping_address', true)) { |
|
195 | + add_meta_box('wpinv-invoice-shipping-details', __('Shipping Address', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high'); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | // Payment form information. |
199 | - if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) { |
|
200 | - add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
|
199 | + if (get_post_meta($invoice->get_id(), 'payment_form_data', true)) { |
|
200 | + add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high'); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | * Remove some metaboxes. |
208 | 208 | */ |
209 | 209 | public static function remove_meta_boxes() { |
210 | - remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
211 | - remove_meta_box( 'postexcerpt', 'wpi_item', 'normal' ); |
|
210 | + remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal'); |
|
211 | + remove_meta_box('postexcerpt', 'wpi_item', 'normal'); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -224,46 +224,46 @@ discard block |
||
224 | 224 | * @param int $post_id Post ID. |
225 | 225 | * @param object $post Post object. |
226 | 226 | */ |
227 | - public static function save_meta_boxes( $post_id, $post ) { |
|
228 | - $post_id = absint( $post_id ); |
|
229 | - $data = wp_kses_post_deep( wp_unslash( $_POST ) ); |
|
227 | + public static function save_meta_boxes($post_id, $post) { |
|
228 | + $post_id = absint($post_id); |
|
229 | + $data = wp_kses_post_deep(wp_unslash($_POST)); |
|
230 | 230 | |
231 | 231 | // Do not save for ajax requests. |
232 | - if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
232 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
233 | 233 | return; |
234 | 234 | } |
235 | 235 | |
236 | 236 | // $post_id and $post are required |
237 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
237 | + if (empty($post_id) || empty($post) || self::$saved_meta_boxes) { |
|
238 | 238 | return; |
239 | 239 | } |
240 | 240 | |
241 | 241 | // Dont' save meta boxes for revisions or autosaves. |
242 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
242 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
243 | 243 | return; |
244 | 244 | } |
245 | 245 | |
246 | 246 | // Check the nonce. |
247 | - if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) { |
|
247 | + if (empty($data['getpaid_meta_nonce']) || !wp_verify_nonce($data['getpaid_meta_nonce'], 'getpaid_meta_nonce')) { |
|
248 | 248 | return; |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
252 | - if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) { |
|
252 | + if (empty($data['post_ID']) || absint($data['post_ID']) !== $post_id) { |
|
253 | 253 | return; |
254 | 254 | } |
255 | 255 | |
256 | 256 | // Check user has permission to edit. |
257 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
257 | + if (!current_user_can('edit_post', $post_id)) { |
|
258 | 258 | return; |
259 | 259 | } |
260 | 260 | |
261 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
261 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
262 | 262 | |
263 | 263 | // We need this save event to run once to avoid potential endless loops. |
264 | 264 | self::$saved_meta_boxes = true; |
265 | 265 | |
266 | - return GetPaid_Meta_Box_Invoice_Address::save( $post_id, wp_kses_post_deep( $_POST ) ); |
|
266 | + return GetPaid_Meta_Box_Invoice_Address::save($post_id, wp_kses_post_deep($_POST)); |
|
267 | 267 | |
268 | 268 | } |
269 | 269 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | ); |
276 | 276 | |
277 | 277 | // Is this our post type? |
278 | - if ( ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
278 | + if (!isset($post_types_map[$post->post_type])) { |
|
279 | 279 | return; |
280 | 280 | } |
281 | 281 | |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | self::$saved_meta_boxes = true; |
284 | 284 | |
285 | 285 | // Save the post. |
286 | - $class = $post_types_map[ $post->post_type ]; |
|
287 | - $class::save( $post_id, wp_kses_post_deep( $_POST ), $post ); |
|
286 | + $class = $post_types_map[$post->post_type]; |
|
287 | + $class::save($post_id, wp_kses_post_deep($_POST), $post); |
|
288 | 288 | |
289 | 289 | } |
290 | 290 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; // Exit if accessed directly |
5 | 5 | } |
6 | 6 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return string The rendered component. |
20 | 20 | */ |
21 | - public static function get($args = array()){ |
|
21 | + public static function get($args = array()) { |
|
22 | 22 | global $aui_bs5; |
23 | 23 | $defaults = array( |
24 | 24 | 'type' => 'info', |
@@ -34,47 +34,47 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * Parse incoming $args into an array and merge it with $defaults |
36 | 36 | */ |
37 | - $args = wp_parse_args( $args, $defaults ); |
|
37 | + $args = wp_parse_args($args, $defaults); |
|
38 | 38 | $output = ''; |
39 | - if ( ! empty( $args['content'] ) ) { |
|
40 | - $type = sanitize_html_class( $args['type'] ); |
|
41 | - if($type=='error'){$type='danger';} |
|
42 | - $icon = !empty($args['icon']) ? "<i class='".esc_attr($args['icon'])."'></i>" : ''; |
|
39 | + if (!empty($args['content'])) { |
|
40 | + $type = sanitize_html_class($args['type']); |
|
41 | + if ($type == 'error') {$type = 'danger'; } |
|
42 | + $icon = !empty($args['icon']) ? "<i class='" . esc_attr($args['icon']) . "'></i>" : ''; |
|
43 | 43 | |
44 | 44 | // set default icon |
45 | - if(!$icon && $args['icon']!==false && $type){ |
|
46 | - if($type=='danger'){$icon = '<i class="fas fa-exclamation-circle"></i>';} |
|
47 | - elseif($type=='warning'){$icon = '<i class="fas fa-exclamation-triangle"></i>';} |
|
48 | - elseif($type=='success'){$icon = '<i class="fas fa-check-circle"></i>';} |
|
49 | - elseif($type=='info'){$icon = '<i class="fas fa-info-circle"></i>';} |
|
45 | + if (!$icon && $args['icon'] !== false && $type) { |
|
46 | + if ($type == 'danger') {$icon = '<i class="fas fa-exclamation-circle"></i>'; } |
|
47 | + elseif ($type == 'warning') {$icon = '<i class="fas fa-exclamation-triangle"></i>'; } |
|
48 | + elseif ($type == 'success') {$icon = '<i class="fas fa-check-circle"></i>'; } |
|
49 | + elseif ($type == 'info') {$icon = '<i class="fas fa-info-circle"></i>'; } |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $data = ''; |
53 | 53 | $class = !empty($args['class']) ? esc_attr($args['class']) : ''; |
54 | - if($args['dismissible']){$class .= " alert-dismissible fade show";} |
|
54 | + if ($args['dismissible']) {$class .= " alert-dismissible fade show"; } |
|
55 | 55 | |
56 | 56 | // open |
57 | - $output .= '<div class="alert alert-' . $type . ' '.$class.'" role="alert" '.$data.'>'; |
|
57 | + $output .= '<div class="alert alert-' . $type . ' ' . $class . '" role="alert" ' . $data . '>'; |
|
58 | 58 | |
59 | 59 | // heading |
60 | - if ( ! empty( $args['heading'] ) ) { |
|
60 | + if (!empty($args['heading'])) { |
|
61 | 61 | $output .= '<h4 class="alert-heading">' . $args['heading'] . '</h4>'; |
62 | 62 | } |
63 | 63 | |
64 | 64 | // icon |
65 | - if ( ! empty( $icon) ) { |
|
66 | - $output .= $icon." "; |
|
65 | + if (!empty($icon)) { |
|
66 | + $output .= $icon . " "; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // content |
70 | 70 | $output .= $args['content']; |
71 | 71 | |
72 | 72 | // dismissible |
73 | - if($args['dismissible']){ |
|
73 | + if ($args['dismissible']) { |
|
74 | 74 | |
75 | - if ( $aui_bs5 ) { |
|
75 | + if ($aui_bs5) { |
|
76 | 76 | $output .= '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>'; |
77 | - }else{ |
|
77 | + } else { |
|
78 | 78 | $output .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close">'; |
79 | 79 | $output .= '<span aria-hidden="true">×</span>'; |
80 | 80 | $output .= '</button>'; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | // footer |
85 | - if ( ! empty( $args['footer'] ) ) { |
|
85 | + if (!empty($args['footer'])) { |
|
86 | 86 | $output .= '<hr>'; |
87 | 87 | $output .= '<p class="mb-0">' . $args['footer'] . '</p>'; |
88 | 88 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; // Exit if accessed directly |
5 | 5 | } |
6 | 6 | |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @return string |
21 | 21 | */ |
22 | - public static function name( $text, $multiple = false ) { |
|
22 | + public static function name($text, $multiple = false) { |
|
23 | 23 | $output = ''; |
24 | 24 | |
25 | - if ( $text ) { |
|
26 | - $is_multiple = strpos( $text, '[' ) === false && $multiple ? '[]' : ''; |
|
27 | - $output = ' name="' . esc_attr( $text ) . $is_multiple . '" '; |
|
25 | + if ($text) { |
|
26 | + $is_multiple = strpos($text, '[') === false && $multiple ? '[]' : ''; |
|
27 | + $output = ' name="' . esc_attr($text) . $is_multiple . '" '; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | return $output; |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @return string The sanitized item. |
39 | 39 | */ |
40 | - public static function id( $text ) { |
|
40 | + public static function id($text) { |
|
41 | 41 | $output = ''; |
42 | 42 | |
43 | - if ( $text ) { |
|
44 | - $output = ' id="' . sanitize_html_class( $text ) . '" '; |
|
43 | + if ($text) { |
|
44 | + $output = ' id="' . sanitize_html_class($text) . '" '; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | return $output; |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return string The sanitized item. |
56 | 56 | */ |
57 | - public static function title( $text ) { |
|
57 | + public static function title($text) { |
|
58 | 58 | $output = ''; |
59 | 59 | |
60 | - if ( $text ) { |
|
61 | - $output = ' title="' . esc_attr( $text ) . '" '; |
|
60 | + if ($text) { |
|
61 | + $output = ' title="' . esc_attr($text) . '" '; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | return $output; |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return string The sanitized item. |
73 | 73 | */ |
74 | - public static function value( $text ) { |
|
74 | + public static function value($text) { |
|
75 | 75 | $output = ''; |
76 | 76 | |
77 | - if ( $text !== null && $text !== false ) { |
|
78 | - $output = ' value="' . esc_attr( wp_unslash( $text ) ) . '" '; |
|
77 | + if ($text !== null && $text !== false) { |
|
78 | + $output = ' value="' . esc_attr(wp_unslash($text)) . '" '; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | return $output; |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string The sanitized item. |
90 | 90 | */ |
91 | - public static function class_attr( $text ) { |
|
91 | + public static function class_attr($text) { |
|
92 | 92 | $output = ''; |
93 | 93 | |
94 | - if ( $text ) { |
|
95 | - $classes = self::esc_classes( $text ); |
|
96 | - if ( ! empty( $classes ) ) { |
|
94 | + if ($text) { |
|
95 | + $classes = self::esc_classes($text); |
|
96 | + if (!empty($classes)) { |
|
97 | 97 | $output = ' class="' . $classes . '" '; |
98 | 98 | } |
99 | 99 | } |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return string |
110 | 110 | */ |
111 | - public static function esc_classes( $text ) { |
|
111 | + public static function esc_classes($text) { |
|
112 | 112 | $output = ''; |
113 | 113 | |
114 | - if ( $text ) { |
|
115 | - $classes = explode( " ", $text ); |
|
116 | - $classes = array_map( "trim", $classes ); |
|
117 | - $classes = array_map( "sanitize_html_class", $classes ); |
|
118 | - if ( ! empty( $classes ) ) { |
|
119 | - $output = implode( " ", $classes ); |
|
114 | + if ($text) { |
|
115 | + $classes = explode(" ", $text); |
|
116 | + $classes = array_map("trim", $classes); |
|
117 | + $classes = array_map("sanitize_html_class", $classes); |
|
118 | + if (!empty($classes)) { |
|
119 | + $output = implode(" ", $classes); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return string |
131 | 131 | */ |
132 | - public static function data_attributes( $args ) { |
|
132 | + public static function data_attributes($args) { |
|
133 | 133 | $output = ''; |
134 | 134 | |
135 | - if ( ! empty( $args ) ) { |
|
135 | + if (!empty($args)) { |
|
136 | 136 | |
137 | - foreach ( $args as $key => $val ) { |
|
138 | - if ( substr( $key, 0, 5 ) === "data-" ) { |
|
139 | - $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" '; |
|
137 | + foreach ($args as $key => $val) { |
|
138 | + if (substr($key, 0, 5) === "data-") { |
|
139 | + $output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" '; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | } |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @return string |
151 | 151 | */ |
152 | - public static function aria_attributes( $args ) { |
|
152 | + public static function aria_attributes($args) { |
|
153 | 153 | $output = ''; |
154 | 154 | |
155 | - if ( ! empty( $args ) ) { |
|
155 | + if (!empty($args)) { |
|
156 | 156 | |
157 | - foreach ( $args as $key => $val ) { |
|
158 | - if ( substr( $key, 0, 5 ) === "aria-" ) { |
|
159 | - $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" '; |
|
157 | + foreach ($args as $key => $val) { |
|
158 | + if (substr($key, 0, 5) === "aria-") { |
|
159 | + $output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" '; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | } |
@@ -173,19 +173,19 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return string |
175 | 175 | */ |
176 | - public static function icon( $class, $space_after = false, $extra_attributes = array() ) { |
|
176 | + public static function icon($class, $space_after = false, $extra_attributes = array()) { |
|
177 | 177 | $output = ''; |
178 | 178 | |
179 | - if ( $class ) { |
|
180 | - $classes = self::esc_classes( $class ); |
|
181 | - if ( ! empty( $classes ) ) { |
|
179 | + if ($class) { |
|
180 | + $classes = self::esc_classes($class); |
|
181 | + if (!empty($classes)) { |
|
182 | 182 | $output = '<i class="' . $classes . '" '; |
183 | 183 | // extra attributes |
184 | - if ( ! empty( $extra_attributes ) ) { |
|
185 | - $output .= AUI_Component_Helper::extra_attributes( $extra_attributes ); |
|
184 | + if (!empty($extra_attributes)) { |
|
185 | + $output .= AUI_Component_Helper::extra_attributes($extra_attributes); |
|
186 | 186 | } |
187 | 187 | $output .= '></i>'; |
188 | - if ( $space_after ) { |
|
188 | + if ($space_after) { |
|
189 | 189 | $output .= " "; |
190 | 190 | } |
191 | 191 | } |
@@ -199,14 +199,14 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public static function extra_attributes( $args ) { |
|
202 | + public static function extra_attributes($args) { |
|
203 | 203 | $output = ''; |
204 | 204 | |
205 | - if ( ! empty( $args ) ) { |
|
205 | + if (!empty($args)) { |
|
206 | 206 | |
207 | - if ( is_array( $args ) ) { |
|
208 | - foreach ( $args as $key => $val ) { |
|
209 | - $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" '; |
|
207 | + if (is_array($args)) { |
|
208 | + foreach ($args as $key => $val) { |
|
209 | + $output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" '; |
|
210 | 210 | } |
211 | 211 | } else { |
212 | 212 | $output .= ' ' . $args . ' '; |
@@ -222,11 +222,11 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return string |
224 | 224 | */ |
225 | - public static function help_text( $text ) { |
|
225 | + public static function help_text($text) { |
|
226 | 226 | $output = ''; |
227 | 227 | |
228 | - if ( $text ) { |
|
229 | - $output .= '<small class="form-text text-muted d-block">' . wp_kses_post( $text ) . '</small>'; |
|
228 | + if ($text) { |
|
229 | + $output .= '<small class="form-text text-muted d-block">' . wp_kses_post($text) . '</small>'; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | |
@@ -240,17 +240,17 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return string|void |
242 | 242 | */ |
243 | - public static function element_require( $input ) { |
|
243 | + public static function element_require($input) { |
|
244 | 244 | |
245 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
245 | + $input = str_replace("'", '"', $input); // we only want double quotes |
|
246 | 246 | |
247 | - $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array( |
|
247 | + $output = esc_attr(str_replace(array("[%", "%]", "%:checked]"), array( |
|
248 | 248 | "jQuery(form).find('[data-argument=\"", |
249 | 249 | "\"]').find('input,select,textarea').val()", |
250 | 250 | "\"]').find('input:checked').val()", |
251 | - ), $input ) ); |
|
251 | + ), $input)); |
|
252 | 252 | |
253 | - if ( $output ) { |
|
253 | + if ($output) { |
|
254 | 254 | $output = ' data-element-require="' . $output . '" '; |
255 | 255 | } |
256 | 256 | |
@@ -267,21 +267,21 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @return mixed Stripped value. |
269 | 269 | */ |
270 | - public static function sanitize_html_field( $value, $input = array() ) { |
|
270 | + public static function sanitize_html_field($value, $input = array()) { |
|
271 | 271 | $original = $value; |
272 | 272 | |
273 | - if ( is_array( $value ) ) { |
|
274 | - foreach ( $value as $index => $item ) { |
|
275 | - $value[ $index ] = self::_sanitize_html_field( $value, $input ); |
|
273 | + if (is_array($value)) { |
|
274 | + foreach ($value as $index => $item) { |
|
275 | + $value[$index] = self::_sanitize_html_field($value, $input); |
|
276 | 276 | } |
277 | - } elseif ( is_object( $value ) ) { |
|
278 | - $object_vars = get_object_vars( $value ); |
|
277 | + } elseif (is_object($value)) { |
|
278 | + $object_vars = get_object_vars($value); |
|
279 | 279 | |
280 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
281 | - $value->$property_name = self::_sanitize_html_field( $property_value, $input ); |
|
280 | + foreach ($object_vars as $property_name => $property_value) { |
|
281 | + $value->$property_name = self::_sanitize_html_field($property_value, $input); |
|
282 | 282 | } |
283 | 283 | } else { |
284 | - $value = self::_sanitize_html_field( $value, $input ); |
|
284 | + $value = self::_sanitize_html_field($value, $input); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @param string|array $value Original content without filter. |
294 | 294 | * @param array $input Input Field. |
295 | 295 | */ |
296 | - return apply_filters( 'ayecode_ui_sanitize_html_field', $value, $original, $input ); |
|
296 | + return apply_filters('ayecode_ui_sanitize_html_field', $value, $original, $input); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -316,20 +316,20 @@ discard block |
||
316 | 316 | * |
317 | 317 | * @return string Filtered content with only allowed HTML elements. |
318 | 318 | */ |
319 | - public static function _sanitize_html_field( $value, $input = array() ) { |
|
320 | - if ( $value === '' ) { |
|
319 | + public static function _sanitize_html_field($value, $input = array()) { |
|
320 | + if ($value === '') { |
|
321 | 321 | return $value; |
322 | 322 | } |
323 | 323 | |
324 | - $allowed_html = self::kses_allowed_html( 'post', $input ); |
|
324 | + $allowed_html = self::kses_allowed_html('post', $input); |
|
325 | 325 | |
326 | - if ( ! is_array( $allowed_html ) ) { |
|
327 | - $allowed_html = wp_kses_allowed_html( 'post' ); |
|
326 | + if (!is_array($allowed_html)) { |
|
327 | + $allowed_html = wp_kses_allowed_html('post'); |
|
328 | 328 | } |
329 | 329 | |
330 | - $filtered = trim( wp_unslash( $value ) ); |
|
331 | - $filtered = wp_kses( $filtered, $allowed_html ); |
|
332 | - $filtered = balanceTags( $filtered ); // Balances tags |
|
330 | + $filtered = trim(wp_unslash($value)); |
|
331 | + $filtered = wp_kses($filtered, $allowed_html); |
|
332 | + $filtered = balanceTags($filtered); // Balances tags |
|
333 | 333 | |
334 | 334 | return $filtered; |
335 | 335 | } |
@@ -346,12 +346,12 @@ discard block |
||
346 | 346 | * |
347 | 347 | * @return array Array of allowed HTML tags and their allowed attributes. |
348 | 348 | */ |
349 | - public static function kses_allowed_html( $context = 'post', $input = array() ) { |
|
350 | - $allowed_html = wp_kses_allowed_html( $context ); |
|
349 | + public static function kses_allowed_html($context = 'post', $input = array()) { |
|
350 | + $allowed_html = wp_kses_allowed_html($context); |
|
351 | 351 | |
352 | - if ( is_array( $allowed_html ) ) { |
|
352 | + if (is_array($allowed_html)) { |
|
353 | 353 | // <iframe> |
354 | - if ( ! isset( $allowed_html['iframe'] ) && $context == 'post' ) { |
|
354 | + if (!isset($allowed_html['iframe']) && $context == 'post') { |
|
355 | 355 | $allowed_html['iframe'] = array( |
356 | 356 | 'class' => true, |
357 | 357 | 'id' => true, |
@@ -380,23 +380,23 @@ discard block |
||
380 | 380 | * @param @param string|array $context The context for which to retrieve tags. |
381 | 381 | * @param array $input Input field. |
382 | 382 | */ |
383 | - return apply_filters( 'ayecode_ui_kses_allowed_html', $allowed_html, $context, $input ); |
|
383 | + return apply_filters('ayecode_ui_kses_allowed_html', $allowed_html, $context, $input); |
|
384 | 384 | } |
385 | 385 | |
386 | - public static function get_column_class( $label_number = 2, $type = 'label' ) { |
|
386 | + public static function get_column_class($label_number = 2, $type = 'label') { |
|
387 | 387 | |
388 | 388 | $class = ''; |
389 | 389 | |
390 | 390 | // set default if empty |
391 | - if( $label_number === '' ){ |
|
391 | + if ($label_number === '') { |
|
392 | 392 | $label_number = 2; |
393 | 393 | } |
394 | 394 | |
395 | - if ( $label_number && $label_number < 12 && $label_number > 0 ) { |
|
396 | - if ( $type == 'label' ) { |
|
397 | - $class = 'col-sm-' . absint( $label_number ); |
|
398 | - } elseif ( $type == 'input' ) { |
|
399 | - $class = 'col-sm-' . ( 12 - absint( $label_number ) ); |
|
395 | + if ($label_number && $label_number < 12 && $label_number > 0) { |
|
396 | + if ($type == 'label') { |
|
397 | + $class = 'col-sm-' . absint($label_number); |
|
398 | + } elseif ($type == 'input') { |
|
399 | + $class = 'col-sm-' . (12 - absint($label_number)); |
|
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | * @param string $str String to sanitize. |
416 | 416 | * @return string Sanitized string. |
417 | 417 | */ |
418 | - public static function sanitize_textarea_field( $str ) { |
|
419 | - $filtered = self::_sanitize_text_fields( $str, true ); |
|
418 | + public static function sanitize_textarea_field($str) { |
|
419 | + $filtered = self::_sanitize_text_fields($str, true); |
|
420 | 420 | |
421 | 421 | /** |
422 | 422 | * Filters a sanitized textarea field string. |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @param string $filtered The sanitized string. |
427 | 427 | * @param string $str The string prior to being sanitized. |
428 | 428 | */ |
429 | - return apply_filters( 'sanitize_textarea_field', $filtered, $str ); |
|
429 | + return apply_filters('sanitize_textarea_field', $filtered, $str); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -439,40 +439,40 @@ discard block |
||
439 | 439 | * @param bool $keep_newlines Optional. Whether to keep newlines. Default: false. |
440 | 440 | * @return string Sanitized string. |
441 | 441 | */ |
442 | - public static function _sanitize_text_fields( $str, $keep_newlines = false ) { |
|
443 | - if ( is_object( $str ) || is_array( $str ) ) { |
|
442 | + public static function _sanitize_text_fields($str, $keep_newlines = false) { |
|
443 | + if (is_object($str) || is_array($str)) { |
|
444 | 444 | return ''; |
445 | 445 | } |
446 | 446 | |
447 | 447 | $str = (string) $str; |
448 | 448 | |
449 | - $filtered = wp_check_invalid_utf8( $str ); |
|
449 | + $filtered = wp_check_invalid_utf8($str); |
|
450 | 450 | |
451 | - if ( strpos( $filtered, '<' ) !== false ) { |
|
452 | - $filtered = wp_pre_kses_less_than( $filtered ); |
|
451 | + if (strpos($filtered, '<') !== false) { |
|
452 | + $filtered = wp_pre_kses_less_than($filtered); |
|
453 | 453 | // This will strip extra whitespace for us. |
454 | - $filtered = wp_strip_all_tags( $filtered, false ); |
|
454 | + $filtered = wp_strip_all_tags($filtered, false); |
|
455 | 455 | |
456 | 456 | // Use HTML entities in a special case to make sure no later |
457 | 457 | // newline stripping stage could lead to a functional tag. |
458 | - $filtered = str_replace( "<\n", "<\n", $filtered ); |
|
458 | + $filtered = str_replace("<\n", "<\n", $filtered); |
|
459 | 459 | } |
460 | 460 | |
461 | - if ( ! $keep_newlines ) { |
|
462 | - $filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered ); |
|
461 | + if (!$keep_newlines) { |
|
462 | + $filtered = preg_replace('/[\r\n\t ]+/', ' ', $filtered); |
|
463 | 463 | } |
464 | - $filtered = trim( $filtered ); |
|
464 | + $filtered = trim($filtered); |
|
465 | 465 | |
466 | 466 | $found = false; |
467 | - while ( preg_match( '`[^%](%[a-f0-9]{2})`i', $filtered, $match ) ) { |
|
468 | - $filtered = str_replace( $match[1], '', $filtered ); |
|
467 | + while (preg_match('`[^%](%[a-f0-9]{2})`i', $filtered, $match)) { |
|
468 | + $filtered = str_replace($match[1], '', $filtered); |
|
469 | 469 | $found = true; |
470 | 470 | } |
471 | - unset( $match ); |
|
471 | + unset($match); |
|
472 | 472 | |
473 | - if ( $found ) { |
|
473 | + if ($found) { |
|
474 | 474 | // Strip out the whitespace that may now exist after removing the octets. |
475 | - $filtered = trim( preg_replace( '` +`', ' ', $filtered ) ); |
|
475 | + $filtered = trim(preg_replace('` +`', ' ', $filtered)); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | return $filtered; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | |
17 | 17 | // If this file is called directly, abort. |
18 | -if ( ! defined( 'WPINC' ) ) { |
|
18 | +if (!defined('WPINC')) { |
|
19 | 19 | die; |
20 | 20 | } |
21 | 21 | |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | public function __construct() { |
30 | 30 | |
31 | 31 | // load AUI |
32 | - require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' ); |
|
32 | + require_once(dirname(__FILE__) . '/ayecode-ui-loader.php'); |
|
33 | 33 | |
34 | 34 | // Maybe show example page |
35 | - add_action( 'template_redirect', array( $this,'maybe_show_examples' ) ); |
|
35 | + add_action('template_redirect', array($this, 'maybe_show_examples')); |
|
36 | 36 | } |
37 | 37 | |
38 | - public function maybe_show_examples(){ |
|
39 | - if ( current_user_can( 'manage_options' ) && isset( $_REQUEST['preview-aui'] ) ) { |
|
38 | + public function maybe_show_examples() { |
|
39 | + if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) { |
|
40 | 40 | echo "<head>"; |
41 | 41 | wp_head(); |
42 | 42 | echo "</head>"; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | - public function get_examples(){ |
|
51 | + public function get_examples() { |
|
52 | 52 | $output = ''; |
53 | 53 | |
54 | 54 | // open form |
@@ -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 | * Returns the errors as html |
@@ -15,35 +15,35 @@ discard block |
||
15 | 15 | * @param bool $wrap whether or not to wrap the errors. |
16 | 16 | * @since 1.0.19 |
17 | 17 | */ |
18 | -function getpaid_get_errors_html( $clear = true, $wrap = true ) { |
|
18 | +function getpaid_get_errors_html($clear = true, $wrap = true) { |
|
19 | 19 | |
20 | 20 | $errors = ''; |
21 | - foreach ( wpinv_get_errors() as $id => $error ) { |
|
22 | - $type = 'error'; |
|
21 | + foreach (wpinv_get_errors() as $id => $error) { |
|
22 | + $type = 'error'; |
|
23 | 23 | |
24 | - if ( is_array( $error ) ) { |
|
24 | + if (is_array($error)) { |
|
25 | 25 | $type = $error['type']; |
26 | 26 | $error = $error['text']; |
27 | 27 | } |
28 | 28 | |
29 | - if ( $wrap ) { |
|
29 | + if ($wrap) { |
|
30 | 30 | |
31 | 31 | $errors .= aui()->alert( |
32 | 32 | array( |
33 | - 'content' => wp_kses_post( $error ), |
|
33 | + 'content' => wp_kses_post($error), |
|
34 | 34 | 'type' => $type, |
35 | 35 | ) |
36 | 36 | ); |
37 | 37 | |
38 | 38 | } else { |
39 | 39 | |
40 | - $id = esc_attr( $id ); |
|
41 | - $error = wp_kses_post( $error ); |
|
40 | + $id = esc_attr($id); |
|
41 | + $error = wp_kses_post($error); |
|
42 | 42 | $errors .= "<div data-code='$id'>$error</div>"; |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | - if ( $clear ) { |
|
46 | + if ($clear) { |
|
47 | 47 | wpinv_clear_errors(); |
48 | 48 | } |
49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * Prints (then clears) all available errors. |
56 | 56 | */ |
57 | 57 | function wpinv_print_errors() { |
58 | - echo wp_kses_post( getpaid_get_errors_html() ); |
|
58 | + echo wp_kses_post(getpaid_get_errors_html()); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -69,54 +69,54 @@ discard block |
||
69 | 69 | $all_errors = array( |
70 | 70 | 'perm_cancel_subscription' => array( |
71 | 71 | 'type' => 'error', |
72 | - 'text' => __( 'You do not have permission to cancel this subscription', 'invoicing' ), |
|
72 | + 'text' => __('You do not have permission to cancel this subscription', 'invoicing'), |
|
73 | 73 | ), |
74 | 74 | 'cannot_cancel_subscription' => array( |
75 | 75 | 'type' => 'error', |
76 | - 'text' => __( 'This subscription cannot be cancelled as it is not active.', 'invoicing' ), |
|
76 | + 'text' => __('This subscription cannot be cancelled as it is not active.', 'invoicing'), |
|
77 | 77 | ), |
78 | 78 | 'cancelled_subscription' => array( |
79 | 79 | 'type' => 'success', |
80 | - 'text' => __( 'Subscription cancelled successfully.', 'invoicing' ), |
|
80 | + 'text' => __('Subscription cancelled successfully.', 'invoicing'), |
|
81 | 81 | ), |
82 | 82 | 'address_updated' => array( |
83 | 83 | 'type' => 'success', |
84 | - 'text' => __( 'Address updated successfully.', 'invoicing' ), |
|
84 | + 'text' => __('Address updated successfully.', 'invoicing'), |
|
85 | 85 | ), |
86 | 86 | 'perm_delete_invoice' => array( |
87 | 87 | 'type' => 'error', |
88 | - 'text' => __( 'You do not have permission to delete this invoice', 'invoicing' ), |
|
88 | + 'text' => __('You do not have permission to delete this invoice', 'invoicing'), |
|
89 | 89 | ), |
90 | 90 | 'cannot_delete_invoice' => array( |
91 | 91 | 'type' => 'error', |
92 | - 'text' => __( 'This invoice cannot be deleted as it has already been paid.', 'invoicing' ), |
|
92 | + 'text' => __('This invoice cannot be deleted as it has already been paid.', 'invoicing'), |
|
93 | 93 | ), |
94 | 94 | 'deleted_invoice' => array( |
95 | 95 | 'type' => 'success', |
96 | - 'text' => __( 'Invoice deleted successfully.', 'invoicing' ), |
|
96 | + 'text' => __('Invoice deleted successfully.', 'invoicing'), |
|
97 | 97 | ), |
98 | 98 | 'card_declined' => array( |
99 | 99 | 'type' => 'error', |
100 | - 'text' => __( 'Your card was declined.', 'invoicing' ), |
|
100 | + 'text' => __('Your card was declined.', 'invoicing'), |
|
101 | 101 | ), |
102 | 102 | 'invalid_currency' => array( |
103 | 103 | 'type' => 'error', |
104 | - 'text' => __( 'The chosen payment gateway does not support this currency.', 'invoicing' ), |
|
104 | + 'text' => __('The chosen payment gateway does not support this currency.', 'invoicing'), |
|
105 | 105 | ), |
106 | 106 | ); |
107 | 107 | |
108 | - $errors = apply_filters( 'wpinv_errors', array() ); |
|
108 | + $errors = apply_filters('wpinv_errors', array()); |
|
109 | 109 | |
110 | - if ( isset( $_GET['wpinv-notice'] ) && isset( $all_errors[ $_GET['wpinv-notice'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
111 | - $errors[ $_GET['wpinv-notice'] ] = $all_errors[ $_GET['wpinv-notice'] ]; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
110 | + if (isset($_GET['wpinv-notice']) && isset($all_errors[$_GET['wpinv-notice']])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
111 | + $errors[$_GET['wpinv-notice']] = $all_errors[$_GET['wpinv-notice']]; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
112 | 112 | } |
113 | 113 | |
114 | - if ( isset( $GLOBALS['wpinv_notice'] ) && isset( $all_errors[ $GLOBALS['wpinv_notice'] ] ) ) { |
|
115 | - $errors[ $GLOBALS['wpinv_notice'] ] = $all_errors[ $GLOBALS['wpinv_notice'] ]; |
|
114 | + if (isset($GLOBALS['wpinv_notice']) && isset($all_errors[$GLOBALS['wpinv_notice']])) { |
|
115 | + $errors[$GLOBALS['wpinv_notice']] = $all_errors[$GLOBALS['wpinv_notice']]; |
|
116 | 116 | } |
117 | 117 | |
118 | - if ( isset( $GLOBALS['wpinv_custom_notice'] ) ) { |
|
119 | - $errors[ $GLOBALS['wpinv_custom_notice']['code'] ] = $GLOBALS['wpinv_custom_notice']; |
|
118 | + if (isset($GLOBALS['wpinv_custom_notice'])) { |
|
119 | + $errors[$GLOBALS['wpinv_custom_notice']['code']] = $GLOBALS['wpinv_custom_notice']; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | return $errors; |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | * @param string $error The error message. |
130 | 130 | * @param string $type The error type. |
131 | 131 | */ |
132 | -function wpinv_set_error( $error_id, $message = '', $type = 'error' ) { |
|
132 | +function wpinv_set_error($error_id, $message = '', $type = 'error') { |
|
133 | 133 | |
134 | - if ( ! empty( $message ) ) { |
|
134 | + if (!empty($message)) { |
|
135 | 135 | $GLOBALS['wpinv_custom_notice'] = array( |
136 | 136 | 'code' => $error_id, |
137 | 137 | 'type' => $type, |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * |
148 | 148 | */ |
149 | 149 | function wpinv_has_errors() { |
150 | - return count( wpinv_get_errors() ) > 0; |
|
150 | + return count(wpinv_get_errors()) > 0; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * |
156 | 156 | */ |
157 | 157 | function wpinv_clear_errors() { |
158 | - unset( $GLOBALS['wpinv_notice'] ); |
|
158 | + unset($GLOBALS['wpinv_notice']); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * |
164 | 164 | */ |
165 | 165 | function wpinv_unset_error() { |
166 | - unset( $GLOBALS['wpinv_notice'] ); |
|
166 | + unset($GLOBALS['wpinv_notice']); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -174,15 +174,15 @@ discard block |
||
174 | 174 | * @param string $message Message to log. |
175 | 175 | * @param string $version Version the message was added in. |
176 | 176 | */ |
177 | -function getpaid_doing_it_wrong( $function, $message, $version ) { |
|
177 | +function getpaid_doing_it_wrong($function, $message, $version) { |
|
178 | 178 | |
179 | 179 | $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
180 | 180 | |
181 | - if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
182 | - do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
183 | - error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
181 | + if (wp_doing_ajax() || defined('REST_REQUEST')) { |
|
182 | + do_action('doing_it_wrong_run', $function, $message, $version); |
|
183 | + error_log("{$function} was called incorrectly. {$message}. This message was added in version {$version}."); |
|
184 | 184 | } else { |
185 | - _doing_it_wrong( esc_html( $function ), wp_kses_post( $message ), esc_html( $version ) ); |
|
185 | + _doing_it_wrong(esc_html($function), wp_kses_post($message), esc_html($version)); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } |
@@ -196,41 +196,41 @@ discard block |
||
196 | 196 | * @param string $line The line that contains the error. |
197 | 197 | * @param bool $exit Whether or not to exit function execution. |
198 | 198 | */ |
199 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
199 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
200 | 200 | |
201 | - if ( true === apply_filters( 'wpinv_log_errors', true ) ) { |
|
201 | + if (true === apply_filters('wpinv_log_errors', true)) { |
|
202 | 202 | |
203 | 203 | // Ensure the log is a scalar. |
204 | - if ( ! is_scalar( $log ) ) { |
|
205 | - $log = print_r( $log, true ); |
|
204 | + if (!is_scalar($log)) { |
|
205 | + $log = print_r($log, true); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | // Add title. |
209 | - if ( ! empty( $title ) ) { |
|
210 | - $log = $title . ' ' . trim( $log ); |
|
209 | + if (!empty($title)) { |
|
210 | + $log = $title . ' ' . trim($log); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | // Add the file to the label. |
214 | - if ( ! empty( $file ) ) { |
|
214 | + if (!empty($file)) { |
|
215 | 215 | $log .= ' in ' . $file; |
216 | 216 | } |
217 | 217 | |
218 | 218 | // Add the line number to the label. |
219 | - if ( ! empty( $line ) ) { |
|
219 | + if (!empty($line)) { |
|
220 | 220 | $log .= ' on line ' . $line; |
221 | 221 | } |
222 | 222 | |
223 | 223 | // Log the message. |
224 | - error_log( trim( $log ) ); |
|
224 | + error_log(trim($log)); |
|
225 | 225 | |
226 | 226 | // ... and a backtrace. |
227 | - if ( false !== $title && false !== $file ) { |
|
228 | - error_log( 'Backtrace ' . wp_debug_backtrace_summary() ); |
|
227 | + if (false !== $title && false !== $file) { |
|
228 | + error_log('Backtrace ' . wp_debug_backtrace_summary()); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | 232 | // Maybe exit. |
233 | - if ( $exit ) { |
|
233 | + if ($exit) { |
|
234 | 234 | exit; |
235 | 235 | } |
236 | 236 |