@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -75,16 +75,16 @@ discard block |
||
75 | 75 | $class .= ' wpi-recurring'; |
76 | 76 | } |
77 | 77 | |
78 | - $refund_url = wp_nonce_url( |
|
79 | - add_query_arg( |
|
80 | - array( |
|
81 | - 'getpaid-admin-action' => 'refund_invoice', |
|
82 | - 'invoice_id' => $invoice->get_id(), |
|
83 | - ) |
|
84 | - ), |
|
85 | - 'getpaid-nonce', |
|
86 | - 'getpaid-nonce' |
|
87 | - ); |
|
78 | + $refund_url = wp_nonce_url( |
|
79 | + add_query_arg( |
|
80 | + array( |
|
81 | + 'getpaid-admin-action' => 'refund_invoice', |
|
82 | + 'invoice_id' => $invoice->get_id(), |
|
83 | + ) |
|
84 | + ), |
|
85 | + 'getpaid-nonce', |
|
86 | + 'getpaid-nonce' |
|
87 | + ); |
|
88 | 88 | ?> |
89 | 89 | |
90 | 90 | <div class="wpinv-items-wrap<?php echo esc_attr( $class ); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>"> |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | <th class=" |
97 | 97 | <?php |
98 | 98 | echo esc_attr( $key ); |
99 | - echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : ''; |
|
100 | - ?> |
|
99 | + echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : ''; |
|
100 | + ?> |
|
101 | 101 | "><?php echo wp_kses_post( $label ); ?></th> |
102 | 102 | <?php endforeach; ?> |
103 | 103 | </tr> |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | <tbody class="wpinv-line-items"> |
107 | 107 | <?php |
108 | 108 | foreach ( $invoice->get_items() as $int => $item ) { |
109 | - self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' ); |
|
109 | + self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' ); |
|
110 | 110 | } |
111 | 111 | ?> |
112 | 112 | </tbody> |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | <?php |
152 | 152 | wpinv_html_select( |
153 | 153 | array( |
154 | - 'options' => $item_types, |
|
155 | - 'name' => '_wpinv_quick[type]', |
|
156 | - 'id' => '_wpinv_quick_type', |
|
157 | - 'selected' => 'custom', |
|
158 | - 'show_option_all' => false, |
|
159 | - 'show_option_none' => false, |
|
160 | - 'class' => 'gdmbx2-text-medium wpinv-quick-type', |
|
154 | + 'options' => $item_types, |
|
155 | + 'name' => '_wpinv_quick[type]', |
|
156 | + 'id' => '_wpinv_quick_type', |
|
157 | + 'selected' => 'custom', |
|
158 | + 'show_option_all' => false, |
|
159 | + 'show_option_none' => false, |
|
160 | + 'class' => 'gdmbx2-text-medium wpinv-quick-type', |
|
161 | 161 | ) |
162 | 162 | ); |
163 | 163 | ?> |
@@ -172,16 +172,16 @@ discard block |
||
172 | 172 | <?php |
173 | 173 | wpinv_html_select( |
174 | 174 | array( |
175 | - 'options' => array_merge( |
|
176 | - array( '' => __( 'Select VAT Rule', 'invoicing' ) ), |
|
177 | - getpaid_get_tax_rules() |
|
178 | - ), |
|
179 | - 'name' => '_wpinv_quick[vat_rule]', |
|
180 | - 'id' => '_wpinv_quick_vat_rule', |
|
181 | - 'show_option_all' => false, |
|
182 | - 'show_option_none' => false, |
|
183 | - 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule', |
|
184 | - 'selected' => 'digital', |
|
175 | + 'options' => array_merge( |
|
176 | + array( '' => __( 'Select VAT Rule', 'invoicing' ) ), |
|
177 | + getpaid_get_tax_rules() |
|
178 | + ), |
|
179 | + 'name' => '_wpinv_quick[vat_rule]', |
|
180 | + 'id' => '_wpinv_quick_vat_rule', |
|
181 | + 'show_option_all' => false, |
|
182 | + 'show_option_none' => false, |
|
183 | + 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule', |
|
184 | + 'selected' => 'digital', |
|
185 | 185 | ) |
186 | 186 | ); |
187 | 187 | ?> |
@@ -194,16 +194,16 @@ discard block |
||
194 | 194 | <?php |
195 | 195 | wpinv_html_select( |
196 | 196 | array( |
197 | - 'options' => array_merge( |
|
198 | - array( '' => __( 'Select VAT Class', 'invoicing' ) ), |
|
199 | - getpaid_get_tax_classes() |
|
200 | - ), |
|
201 | - 'name' => '_wpinv_quick[vat_class]', |
|
202 | - 'id' => '_wpinv_quick_vat_class', |
|
203 | - 'show_option_all' => false, |
|
204 | - 'show_option_none' => false, |
|
205 | - 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class', |
|
206 | - 'selected' => '_standard', |
|
197 | + 'options' => array_merge( |
|
198 | + array( '' => __( 'Select VAT Class', 'invoicing' ) ), |
|
199 | + getpaid_get_tax_classes() |
|
200 | + ), |
|
201 | + 'name' => '_wpinv_quick[vat_class]', |
|
202 | + 'id' => '_wpinv_quick_vat_class', |
|
203 | + 'show_option_all' => false, |
|
204 | + 'show_option_none' => false, |
|
205 | + 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class', |
|
206 | + 'selected' => '_standard', |
|
207 | 207 | ) |
208 | 208 | ); |
209 | 209 | ?> |
@@ -294,37 +294,37 @@ discard block |
||
294 | 294 | </p> |
295 | 295 | <?php if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) ) : ?> |
296 | 296 | <?php |
297 | - aui()->input( |
|
298 | - array( |
|
299 | - 'type' => 'checkbox', |
|
300 | - 'name' => 'getpaid_refund_remote', |
|
301 | - 'id' => 'getpaid_refund_remote', |
|
302 | - 'label' => sprintf( |
|
303 | - 'Refund payment in %s', |
|
304 | - wpinv_get_gateway_admin_label( $invoice->get_gateway() ) |
|
305 | - ), |
|
306 | - 'value' => 1, |
|
307 | - 'class' => 'getpaid-refund-field', |
|
308 | - ), |
|
309 | - true |
|
310 | - ); |
|
311 | - ?> |
|
297 | + aui()->input( |
|
298 | + array( |
|
299 | + 'type' => 'checkbox', |
|
300 | + 'name' => 'getpaid_refund_remote', |
|
301 | + 'id' => 'getpaid_refund_remote', |
|
302 | + 'label' => sprintf( |
|
303 | + 'Refund payment in %s', |
|
304 | + wpinv_get_gateway_admin_label( $invoice->get_gateway() ) |
|
305 | + ), |
|
306 | + 'value' => 1, |
|
307 | + 'class' => 'getpaid-refund-field', |
|
308 | + ), |
|
309 | + true |
|
310 | + ); |
|
311 | + ?> |
|
312 | 312 | <?php endif; ?> |
313 | 313 | |
314 | 314 | <?php if ( getpaid_get_invoice_subscriptions( $invoice ) ) : ?> |
315 | 315 | <?php |
316 | - aui()->input( |
|
317 | - array( |
|
318 | - 'type' => 'checkbox', |
|
319 | - 'name' => 'getpaid_cancel_subscription', |
|
320 | - 'id' => 'getpaid_cancel_subscription', |
|
321 | - 'label' => __( 'Cancel subscription', 'invoicing' ), |
|
322 | - 'value' => 1, |
|
323 | - 'class' => 'getpaid-refund-field', |
|
324 | - ), |
|
325 | - true |
|
326 | - ); |
|
327 | - ?> |
|
316 | + aui()->input( |
|
317 | + array( |
|
318 | + 'type' => 'checkbox', |
|
319 | + 'name' => 'getpaid_cancel_subscription', |
|
320 | + 'id' => 'getpaid_cancel_subscription', |
|
321 | + 'label' => __( 'Cancel subscription', 'invoicing' ), |
|
322 | + 'value' => 1, |
|
323 | + 'class' => 'getpaid-refund-field', |
|
324 | + ), |
|
325 | + true |
|
326 | + ); |
|
327 | + ?> |
|
328 | 328 | <?php endif; ?> |
329 | 329 | </div> |
330 | 330 | <div class="modal-footer"> |
@@ -364,23 +364,23 @@ discard block |
||
364 | 364 | <?php |
365 | 365 | if ( $invoice->is_paid() ) { |
366 | 366 | |
367 | - printf( |
|
368 | - '<span class="bsui"><button type="button" class="button button-primary" data-toggle="modal" data-bs-toggle="modal" data-bs-target="#getpaid-refund-invoice-modal" data-target="#getpaid-refund-invoice-modal">%s</button></span>', |
|
369 | - esc_html__( 'Refund', 'invoicing' ) |
|
370 | - ); |
|
367 | + printf( |
|
368 | + '<span class="bsui"><button type="button" class="button button-primary" data-toggle="modal" data-bs-toggle="modal" data-bs-target="#getpaid-refund-invoice-modal" data-target="#getpaid-refund-invoice-modal">%s</button></span>', |
|
369 | + esc_html__( 'Refund', 'invoicing' ) |
|
370 | + ); |
|
371 | 371 | } elseif ( ! $invoice->is_refunded() ) { |
372 | - wpinv_item_dropdown( |
|
373 | - array( |
|
374 | - 'name' => 'wpinv_invoice_item', |
|
375 | - 'id' => 'wpinv_invoice_item', |
|
376 | - 'show_recurring' => true, |
|
377 | - 'class' => 'wpi_select2', |
|
378 | - ) |
|
379 | - ); |
|
380 | - |
|
381 | - echo ' ' . '<button type="button" class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), esc_html( $invoice->get_label() ) ) . '</button>'; |
|
382 | - echo ' ' . '<button type="button" class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>'; |
|
383 | - echo ' ' . '<button type="button" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>'; |
|
372 | + wpinv_item_dropdown( |
|
373 | + array( |
|
374 | + 'name' => 'wpinv_invoice_item', |
|
375 | + 'id' => 'wpinv_invoice_item', |
|
376 | + 'show_recurring' => true, |
|
377 | + 'class' => 'wpi_select2', |
|
378 | + ) |
|
379 | + ); |
|
380 | + |
|
381 | + echo ' ' . '<button type="button" class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), esc_html( $invoice->get_label() ) ) . '</button>'; |
|
382 | + echo ' ' . '<button type="button" class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>'; |
|
383 | + echo ' ' . '<button type="button" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>'; |
|
384 | 384 | |
385 | 385 | } |
386 | 386 | ?> |
@@ -397,72 +397,72 @@ discard block |
||
397 | 397 | <?php foreach ( array_keys( $columns ) as $column ) : ?> |
398 | 398 | <td class=" |
399 | 399 | <?php |
400 | - echo esc_attr( $column ); |
|
401 | - echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : ''; |
|
402 | - ?> |
|
400 | + echo esc_attr( $column ); |
|
401 | + echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : ''; |
|
402 | + ?> |
|
403 | 403 | "> |
404 | 404 | <?php |
405 | 405 | switch ( $column ) { |
406 | - case 'id': |
|
407 | - echo (int) $item->get_id(); |
|
408 | - break; |
|
409 | - case 'title': |
|
410 | - printf( |
|
411 | - '<a href="%s" target="_blank">%s</a>', |
|
412 | - esc_url( get_edit_post_link( $item->get_id() ) ), |
|
413 | - esc_html( $item->get_raw_name() ) |
|
414 | - ); |
|
415 | - |
|
416 | - $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
417 | - if ( $summary !== '' ) { |
|
418 | - printf( |
|
419 | - '<span class="meta">%s</span>', |
|
420 | - wp_kses_post( wpautop( $summary ) ) |
|
421 | - ); |
|
422 | - } |
|
423 | - |
|
424 | - printf( |
|
425 | - '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />', |
|
426 | - esc_attr( $item->get_raw_name() ), |
|
427 | - (int) $item->get_id() |
|
428 | - ); |
|
429 | - |
|
430 | - printf( |
|
431 | - '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>', |
|
432 | - (int) $item->get_id(), |
|
433 | - esc_attr( $item->get_description() ) |
|
434 | - ); |
|
435 | - |
|
436 | - break; |
|
437 | - case 'price': |
|
438 | - printf( |
|
439 | - '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />', |
|
440 | - esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ), |
|
441 | - (int) $item->get_id() |
|
442 | - ); |
|
443 | - |
|
444 | - break; |
|
445 | - case 'qty': |
|
446 | - printf( |
|
447 | - '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />', |
|
448 | - floatval( $item->get_quantity() ), |
|
449 | - (int) $item->get_id() |
|
450 | - ); |
|
451 | - |
|
452 | - break; |
|
453 | - case 'total': |
|
454 | - wpinv_the_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
455 | - |
|
456 | - break; |
|
457 | - case 'tax': |
|
458 | - echo floatval( wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
459 | - |
|
460 | - break; |
|
461 | - case 'action': |
|
462 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
463 | - echo '<i class="fa fa-trash wpinv-item-remove"></i>'; |
|
406 | + case 'id': |
|
407 | + echo (int) $item->get_id(); |
|
408 | + break; |
|
409 | + case 'title': |
|
410 | + printf( |
|
411 | + '<a href="%s" target="_blank">%s</a>', |
|
412 | + esc_url( get_edit_post_link( $item->get_id() ) ), |
|
413 | + esc_html( $item->get_raw_name() ) |
|
414 | + ); |
|
415 | + |
|
416 | + $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
417 | + if ( $summary !== '' ) { |
|
418 | + printf( |
|
419 | + '<span class="meta">%s</span>', |
|
420 | + wp_kses_post( wpautop( $summary ) ) |
|
421 | + ); |
|
422 | + } |
|
423 | + |
|
424 | + printf( |
|
425 | + '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />', |
|
426 | + esc_attr( $item->get_raw_name() ), |
|
427 | + (int) $item->get_id() |
|
428 | + ); |
|
429 | + |
|
430 | + printf( |
|
431 | + '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>', |
|
432 | + (int) $item->get_id(), |
|
433 | + esc_attr( $item->get_description() ) |
|
434 | + ); |
|
435 | + |
|
436 | + break; |
|
437 | + case 'price': |
|
438 | + printf( |
|
439 | + '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />', |
|
440 | + esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ), |
|
441 | + (int) $item->get_id() |
|
442 | + ); |
|
443 | + |
|
444 | + break; |
|
445 | + case 'qty': |
|
446 | + printf( |
|
447 | + '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />', |
|
448 | + floatval( $item->get_quantity() ), |
|
449 | + (int) $item->get_id() |
|
450 | + ); |
|
451 | + |
|
452 | + break; |
|
453 | + case 'total': |
|
454 | + wpinv_the_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
455 | + |
|
456 | + break; |
|
457 | + case 'tax': |
|
458 | + echo floatval( wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
459 | + |
|
460 | + break; |
|
461 | + case 'action': |
|
462 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
463 | + echo '<i class="fa fa-trash wpinv-item-remove"></i>'; |
|
464 | 464 | } |
465 | - break; |
|
465 | + break; |
|
466 | 466 | } |
467 | 467 | do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice ); |
468 | 468 | ?> |
@@ -473,10 +473,10 @@ discard block |
||
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
476 | - * Output the metabox. |
|
477 | - * |
|
478 | - * @param WP_Post $post |
|
479 | - */ |
|
476 | + * Output the metabox. |
|
477 | + * |
|
478 | + * @param WP_Post $post |
|
479 | + */ |
|
480 | 480 | public static function output2( $post ) { |
481 | 481 | |
482 | 482 | // Prepare the invoice. |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -16,62 +16,62 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class GetPaid_Meta_Box_Invoice_Items { |
18 | 18 | |
19 | - public static function get_columns( $invoice ) { |
|
19 | + public static function get_columns($invoice) { |
|
20 | 20 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
21 | 21 | $columns = array( |
22 | - 'id' => __( 'ID', 'invoicing' ), |
|
23 | - 'title' => __( 'Item', 'invoicing' ), |
|
22 | + 'id' => __('ID', 'invoicing'), |
|
23 | + 'title' => __('Item', 'invoicing'), |
|
24 | 24 | 'price' => sprintf( |
25 | 25 | '<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span> |
26 | 26 | <span class="getpaid-hide-if-hours hide-if-amount">%s</span> |
27 | 27 | <span class="getpaid-hide-if-quantity hide-if-amount">%s</span>', |
28 | - __( 'Amount', 'invoicing' ), |
|
29 | - __( 'Price', 'invoicing' ), |
|
30 | - __( 'Rate', 'invoicing' ) |
|
28 | + __('Amount', 'invoicing'), |
|
29 | + __('Price', 'invoicing'), |
|
30 | + __('Rate', 'invoicing') |
|
31 | 31 | ), |
32 | 32 | 'qty' => sprintf( |
33 | 33 | '<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>', |
34 | - __( 'Quantity', 'invoicing' ), |
|
35 | - __( 'Hours', 'invoicing' ) |
|
34 | + __('Quantity', 'invoicing'), |
|
35 | + __('Hours', 'invoicing') |
|
36 | 36 | ), |
37 | - 'total' => __( 'Total', 'invoicing' ), |
|
38 | - 'tax' => __( 'Tax (%)', 'invoicing' ), |
|
37 | + 'total' => __('Total', 'invoicing'), |
|
38 | + 'tax' => __('Tax (%)', 'invoicing'), |
|
39 | 39 | 'action' => '', |
40 | 40 | ); |
41 | 41 | |
42 | - if ( ! $use_taxes ) { |
|
43 | - unset( $columns['tax'] ); |
|
42 | + if (!$use_taxes) { |
|
43 | + unset($columns['tax']); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | return $columns; |
47 | 47 | } |
48 | 48 | |
49 | - public static function output( $post, $invoice = false ) { |
|
49 | + public static function output($post, $invoice = false) { |
|
50 | 50 | |
51 | - if ( apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) { |
|
52 | - return self::output2( $post ); |
|
51 | + if (apply_filters('getpaid_use_new_invoice_items_metabox', false)) { |
|
52 | + return self::output2($post); |
|
53 | 53 | } |
54 | 54 | |
55 | - $post_id = ! empty( $post->ID ) ? $post->ID : 0; |
|
56 | - $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id ); |
|
55 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
56 | + $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id); |
|
57 | 57 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
58 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
59 | - $columns = self::get_columns( $invoice ); |
|
60 | - $cols = count( $columns ); |
|
58 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
59 | + $columns = self::get_columns($invoice); |
|
60 | + $cols = count($columns); |
|
61 | 61 | $class = ''; |
62 | 62 | |
63 | - unset( $item_types['adv'] ); |
|
64 | - unset( $item_types['package'] ); |
|
63 | + unset($item_types['adv']); |
|
64 | + unset($item_types['package']); |
|
65 | 65 | |
66 | - if ( $invoice->is_paid() ) { |
|
66 | + if ($invoice->is_paid()) { |
|
67 | 67 | $class .= ' wpinv-paid'; |
68 | 68 | } |
69 | 69 | |
70 | - if ( $invoice->is_refunded() ) { |
|
70 | + if ($invoice->is_refunded()) { |
|
71 | 71 | $class .= ' wpinv-refunded'; |
72 | 72 | } |
73 | 73 | |
74 | - if ( $invoice->is_recurring() ) { |
|
74 | + if ($invoice->is_recurring()) { |
|
75 | 75 | $class .= ' wpi-recurring'; |
76 | 76 | } |
77 | 77 | |
@@ -87,26 +87,26 @@ discard block |
||
87 | 87 | ); |
88 | 88 | ?> |
89 | 89 | |
90 | - <div class="wpinv-items-wrap<?php echo esc_attr( $class ); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>"> |
|
90 | + <div class="wpinv-items-wrap<?php echo esc_attr($class); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>"> |
|
91 | 91 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
92 | 92 | |
93 | 93 | <thead> |
94 | 94 | <tr> |
95 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
95 | + <?php foreach ($columns as $key => $label) : ?> |
|
96 | 96 | <th class=" |
97 | 97 | <?php |
98 | - echo esc_attr( $key ); |
|
98 | + echo esc_attr($key); |
|
99 | 99 | echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : ''; |
100 | 100 | ?> |
101 | - "><?php echo wp_kses_post( $label ); ?></th> |
|
101 | + "><?php echo wp_kses_post($label); ?></th> |
|
102 | 102 | <?php endforeach; ?> |
103 | 103 | </tr> |
104 | 104 | </thead> |
105 | 105 | |
106 | 106 | <tbody class="wpinv-line-items"> |
107 | 107 | <?php |
108 | - foreach ( $invoice->get_items() as $int => $item ) { |
|
109 | - self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' ); |
|
108 | + foreach ($invoice->get_items() as $int => $item) { |
|
109 | + self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd'); |
|
110 | 110 | } |
111 | 111 | ?> |
112 | 112 | </tbody> |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | <div class="wp-clearfix"> |
124 | 124 | <label class="wpi-item-name"> |
125 | 125 | <span class="input-text-wrap"> |
126 | - <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
126 | + <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
127 | 127 | </span> |
128 | 128 | </label> |
129 | 129 | </div> |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | <div class="wp-clearfix"> |
132 | 132 | <label class="wpi-item-price"> |
133 | 133 | <span class="input-text-wrap"> |
134 | - <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' ); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
135 | - × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' ); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
134 | + <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
135 | + × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
136 | 136 | </span> |
137 | 137 | </label> |
138 | 138 | </div> |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | <div class="wp-clearfix"> |
141 | 141 | <label class="wpi-item-name"> |
142 | 142 | <span class="input-text-wrap"> |
143 | - <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' ); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
143 | + <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
144 | 144 | </span> |
145 | 145 | </label> |
146 | 146 | </div> |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | </label> |
166 | 166 | </div> |
167 | 167 | |
168 | - <?php if ( $use_taxes ) : ?> |
|
168 | + <?php if ($use_taxes) : ?> |
|
169 | 169 | <div class="wp-clearfix"> |
170 | 170 | <label class="wpi-vat-rule"> |
171 | 171 | <span class="input-text-wrap"> |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | wpinv_html_select( |
174 | 174 | array( |
175 | 175 | 'options' => array_merge( |
176 | - array( '' => __( 'Select VAT Rule', 'invoicing' ) ), |
|
176 | + array('' => __('Select VAT Rule', 'invoicing')), |
|
177 | 177 | getpaid_get_tax_rules() |
178 | 178 | ), |
179 | 179 | 'name' => '_wpinv_quick[vat_rule]', |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | wpinv_html_select( |
196 | 196 | array( |
197 | 197 | 'options' => array_merge( |
198 | - array( '' => __( 'Select VAT Class', 'invoicing' ) ), |
|
198 | + array('' => __('Select VAT Class', 'invoicing')), |
|
199 | 199 | getpaid_get_tax_classes() |
200 | 200 | ), |
201 | 201 | 'name' => '_wpinv_quick[vat_class]', |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | 'type' => 'checkbox', |
220 | 220 | 'name' => '_wpinv_quick[one-time]', |
221 | 221 | 'id' => '_wpinv_quick-one-time', |
222 | - 'label' => __( "One time item (won't be saved to regular items list)", 'invoicing' ), |
|
222 | + 'label' => __("One time item (won't be saved to regular items list)", 'invoicing'), |
|
223 | 223 | 'value' => 1, |
224 | 224 | 'no_wrap' => true, |
225 | 225 | 'checked' => false, |
@@ -243,29 +243,29 @@ discard block |
||
243 | 243 | </td> |
244 | 244 | </tr> |
245 | 245 | <tr class="totals"> |
246 | - <td colspan="<?php echo ( (int) $cols - 4 ); ?>"></td> |
|
246 | + <td colspan="<?php echo ((int) $cols - 4); ?>"></td> |
|
247 | 247 | <td colspan="4"> |
248 | 248 | <table cellspacing="0" cellpadding="0"> |
249 | 249 | <tr class="subtotal"> |
250 | - <td class="name"><?php esc_html_e( 'Sub Total:', 'invoicing' ); ?></td> |
|
251 | - <td class="total"><?php wpinv_the_price( $invoice->get_subtotal(), $invoice->get_currency() ); ?></td> |
|
250 | + <td class="name"><?php esc_html_e('Sub Total:', 'invoicing'); ?></td> |
|
251 | + <td class="total"><?php wpinv_the_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td> |
|
252 | 252 | <td class="action"></td> |
253 | 253 | </tr> |
254 | 254 | <tr class="discount"> |
255 | - <td class="name"><?php esc_html_e( 'Discount:', 'invoicing' ); ?></td> |
|
256 | - <td class="total"><?php wpinv_the_price( $invoice->get_total_discount(), $invoice->get_currency() ); ?></td> |
|
255 | + <td class="name"><?php esc_html_e('Discount:', 'invoicing'); ?></td> |
|
256 | + <td class="total"><?php wpinv_the_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td> |
|
257 | 257 | <td class="action"></td> |
258 | 258 | </tr> |
259 | - <?php if ( $use_taxes ) : ?> |
|
259 | + <?php if ($use_taxes) : ?> |
|
260 | 260 | <tr class="tax"> |
261 | - <td class="name"><?php esc_html_e( 'Tax:', 'invoicing' ); ?></td> |
|
262 | - <td class="total"><?php wpinv_the_price( $invoice->get_total_tax(), $invoice->get_currency() ); ?></td> |
|
261 | + <td class="name"><?php esc_html_e('Tax:', 'invoicing'); ?></td> |
|
262 | + <td class="total"><?php wpinv_the_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td> |
|
263 | 263 | <td class="action"></td> |
264 | 264 | </tr> |
265 | 265 | <?php endif; ?> |
266 | 266 | <tr class="total"> |
267 | - <td class="name"><?php esc_html_e( 'Total:', 'invoicing' ); ?></td> |
|
268 | - <td class="total"><?php wpinv_the_price( $invoice->get_total(), $invoice->get_currency() ); ?></td> |
|
267 | + <td class="name"><?php esc_html_e('Total:', 'invoicing'); ?></td> |
|
268 | + <td class="total"><?php wpinv_the_price($invoice->get_total(), $invoice->get_currency()); ?></td> |
|
269 | 269 | <td class="action"></td> |
270 | 270 | </tr> |
271 | 271 | </table> |
@@ -281,18 +281,18 @@ discard block |
||
281 | 281 | <div class="modal-dialog modal-dialog-centered" role="document"> |
282 | 282 | <div class="modal-content"> |
283 | 283 | <div class="modal-header"> |
284 | - <h5 class="modal-title" id="getpaid-refund-invoice-modal-label"><?php esc_html_e( 'Refund Payment', 'invoicing' ); ?></h5> |
|
285 | - <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>"> |
|
286 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
284 | + <h5 class="modal-title" id="getpaid-refund-invoice-modal-label"><?php esc_html_e('Refund Payment', 'invoicing'); ?></h5> |
|
285 | + <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>"> |
|
286 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
287 | 287 | <span aria-hidden="true">×</span> |
288 | 288 | <?php endif; ?> |
289 | 289 | </button> |
290 | 290 | </div> |
291 | 291 | <div class="modal-body"> |
292 | 292 | <p> |
293 | - <?php esc_html_e( 'Are you sure you want to refund this payment?', 'invoicing' ); ?> |
|
293 | + <?php esc_html_e('Are you sure you want to refund this payment?', 'invoicing'); ?> |
|
294 | 294 | </p> |
295 | - <?php if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) ) : ?> |
|
295 | + <?php if (getpaid_payment_gateway_supports($invoice->get_gateway(), 'refunds')) : ?> |
|
296 | 296 | <?php |
297 | 297 | aui()->input( |
298 | 298 | array( |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | 'id' => 'getpaid_refund_remote', |
302 | 302 | 'label' => sprintf( |
303 | 303 | 'Refund payment in %s', |
304 | - wpinv_get_gateway_admin_label( $invoice->get_gateway() ) |
|
304 | + wpinv_get_gateway_admin_label($invoice->get_gateway()) |
|
305 | 305 | ), |
306 | 306 | 'value' => 1, |
307 | 307 | 'class' => 'getpaid-refund-field', |
@@ -311,14 +311,14 @@ discard block |
||
311 | 311 | ?> |
312 | 312 | <?php endif; ?> |
313 | 313 | |
314 | - <?php if ( getpaid_get_invoice_subscriptions( $invoice ) ) : ?> |
|
314 | + <?php if (getpaid_get_invoice_subscriptions($invoice)) : ?> |
|
315 | 315 | <?php |
316 | 316 | aui()->input( |
317 | 317 | array( |
318 | 318 | 'type' => 'checkbox', |
319 | 319 | 'name' => 'getpaid_cancel_subscription', |
320 | 320 | 'id' => 'getpaid_cancel_subscription', |
321 | - 'label' => __( 'Cancel subscription', 'invoicing' ), |
|
321 | + 'label' => __('Cancel subscription', 'invoicing'), |
|
322 | 322 | 'value' => 1, |
323 | 323 | 'class' => 'getpaid-refund-field', |
324 | 324 | ), |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | <?php endif; ?> |
329 | 329 | </div> |
330 | 330 | <div class="modal-footer"> |
331 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
331 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
332 | 332 | <a |
333 | - href="<?php echo esc_url_raw( $refund_url ); ?>" |
|
334 | - data-href="<?php echo esc_url_raw( $refund_url ); ?>" |
|
333 | + href="<?php echo esc_url_raw($refund_url); ?>" |
|
334 | + data-href="<?php echo esc_url_raw($refund_url); ?>" |
|
335 | 335 | class="btn btn-primary getpaid-refund-payment-button" |
336 | 336 | data-dismiss="modal" |
337 | - ><?php esc_html_e( 'Refund', 'invoicing' ); ?></a> |
|
337 | + ><?php esc_html_e('Refund', 'invoicing'); ?></a> |
|
338 | 338 | <script> |
339 | 339 | // Update the refund URL when the user changes the refund options. |
340 | 340 | jQuery( function( $ ) { |
@@ -362,13 +362,13 @@ discard block |
||
362 | 362 | |
363 | 363 | <div class="wpinv-actions"> |
364 | 364 | <?php |
365 | - if ( $invoice->is_paid() ) { |
|
365 | + if ($invoice->is_paid()) { |
|
366 | 366 | |
367 | 367 | printf( |
368 | 368 | '<span class="bsui"><button type="button" class="button button-primary" data-toggle="modal" data-bs-toggle="modal" data-bs-target="#getpaid-refund-invoice-modal" data-target="#getpaid-refund-invoice-modal">%s</button></span>', |
369 | - esc_html__( 'Refund', 'invoicing' ) |
|
369 | + esc_html__('Refund', 'invoicing') |
|
370 | 370 | ); |
371 | - } elseif ( ! $invoice->is_refunded() ) { |
|
371 | + } elseif (!$invoice->is_refunded()) { |
|
372 | 372 | wpinv_item_dropdown( |
373 | 373 | array( |
374 | 374 | 'name' => 'wpinv_invoice_item', |
@@ -378,66 +378,66 @@ discard block |
||
378 | 378 | ) |
379 | 379 | ); |
380 | 380 | |
381 | - echo ' ' . '<button type="button" class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), esc_html( $invoice->get_label() ) ) . '</button>'; |
|
382 | - echo ' ' . '<button type="button" class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>'; |
|
383 | - echo ' ' . '<button type="button" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>'; |
|
381 | + echo ' ' . '<button type="button" class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), esc_html($invoice->get_label())) . '</button>'; |
|
382 | + echo ' ' . '<button type="button" class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>'; |
|
383 | + echo ' ' . '<button type="button" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>'; |
|
384 | 384 | |
385 | 385 | } |
386 | 386 | ?> |
387 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
387 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
388 | 388 | </div> |
389 | 389 | </div> |
390 | 390 | <?php |
391 | 391 | } |
392 | 392 | |
393 | - public static function output_row( $columns, $item, $invoice, $class = 'even' ) { |
|
393 | + public static function output_row($columns, $item, $invoice, $class = 'even') { |
|
394 | 394 | |
395 | 395 | ?> |
396 | - <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>"> |
|
397 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
396 | + <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>"> |
|
397 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
398 | 398 | <td class=" |
399 | 399 | <?php |
400 | - echo esc_attr( $column ); |
|
400 | + echo esc_attr($column); |
|
401 | 401 | echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : ''; |
402 | 402 | ?> |
403 | 403 | "> |
404 | 404 | <?php |
405 | - switch ( $column ) { |
|
405 | + switch ($column) { |
|
406 | 406 | case 'id': |
407 | 407 | echo (int) $item->get_id(); |
408 | 408 | break; |
409 | 409 | case 'title': |
410 | 410 | printf( |
411 | 411 | '<a href="%s" target="_blank">%s</a>', |
412 | - esc_url( get_edit_post_link( $item->get_id() ) ), |
|
413 | - esc_html( $item->get_raw_name() ) |
|
412 | + esc_url(get_edit_post_link($item->get_id())), |
|
413 | + esc_html($item->get_raw_name()) |
|
414 | 414 | ); |
415 | 415 | |
416 | - $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
417 | - if ( $summary !== '' ) { |
|
416 | + $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice); |
|
417 | + if ($summary !== '') { |
|
418 | 418 | printf( |
419 | 419 | '<span class="meta">%s</span>', |
420 | - wp_kses_post( wpautop( $summary ) ) |
|
420 | + wp_kses_post(wpautop($summary)) |
|
421 | 421 | ); |
422 | 422 | } |
423 | 423 | |
424 | 424 | printf( |
425 | 425 | '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />', |
426 | - esc_attr( $item->get_raw_name() ), |
|
426 | + esc_attr($item->get_raw_name()), |
|
427 | 427 | (int) $item->get_id() |
428 | 428 | ); |
429 | 429 | |
430 | 430 | printf( |
431 | 431 | '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>', |
432 | 432 | (int) $item->get_id(), |
433 | - esc_attr( $item->get_description() ) |
|
433 | + esc_attr($item->get_description()) |
|
434 | 434 | ); |
435 | 435 | |
436 | 436 | break; |
437 | 437 | case 'price': |
438 | 438 | printf( |
439 | 439 | '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />', |
440 | - esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ), |
|
440 | + esc_attr(getpaid_unstandardize_amount($item->get_price())), |
|
441 | 441 | (int) $item->get_id() |
442 | 442 | ); |
443 | 443 | |
@@ -445,26 +445,26 @@ discard block |
||
445 | 445 | case 'qty': |
446 | 446 | printf( |
447 | 447 | '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />', |
448 | - floatval( $item->get_quantity() ), |
|
448 | + floatval($item->get_quantity()), |
|
449 | 449 | (int) $item->get_id() |
450 | 450 | ); |
451 | 451 | |
452 | 452 | break; |
453 | 453 | case 'total': |
454 | - wpinv_the_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
454 | + wpinv_the_price($item->get_sub_total(), $invoice->get_currency()); |
|
455 | 455 | |
456 | 456 | break; |
457 | 457 | case 'tax': |
458 | - echo floatval( wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
458 | + echo floatval(wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2)) . '%'; |
|
459 | 459 | |
460 | 460 | break; |
461 | 461 | case 'action': |
462 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
462 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
463 | 463 | echo '<i class="fa fa-trash wpinv-item-remove"></i>'; |
464 | 464 | } |
465 | 465 | break; |
466 | 466 | } |
467 | - do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice ); |
|
467 | + do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice); |
|
468 | 468 | ?> |
469 | 469 | </td> |
470 | 470 | <?php endforeach; ?> |
@@ -477,10 +477,10 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @param WP_Post $post |
479 | 479 | */ |
480 | - public static function output2( $post ) { |
|
480 | + public static function output2($post) { |
|
481 | 481 | |
482 | 482 | // Prepare the invoice. |
483 | - $invoice = new WPInv_Invoice( $post ); |
|
483 | + $invoice = new WPInv_Invoice($post); |
|
484 | 484 | |
485 | 485 | // Invoice items. |
486 | 486 | $items = $invoice->get_items(); |
@@ -488,28 +488,28 @@ discard block |
||
488 | 488 | $totals = array( |
489 | 489 | |
490 | 490 | 'subtotal' => array( |
491 | - 'label' => __( 'Items Subtotal', 'invoicing' ), |
|
492 | - 'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
491 | + 'label' => __('Items Subtotal', 'invoicing'), |
|
492 | + 'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
493 | 493 | ), |
494 | 494 | |
495 | 495 | 'discount' => array( |
496 | - 'label' => __( 'Total Discount', 'invoicing' ), |
|
497 | - 'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
496 | + 'label' => __('Total Discount', 'invoicing'), |
|
497 | + 'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
498 | 498 | ), |
499 | 499 | |
500 | 500 | 'tax' => array( |
501 | - 'label' => __( 'Total Tax', 'invoicing' ), |
|
502 | - 'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
501 | + 'label' => __('Total Tax', 'invoicing'), |
|
502 | + 'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
503 | 503 | ), |
504 | 504 | |
505 | 505 | 'total' => array( |
506 | - 'label' => __( 'Invoice Total', 'invoicing' ), |
|
507 | - 'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
|
506 | + 'label' => __('Invoice Total', 'invoicing'), |
|
507 | + 'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()), |
|
508 | 508 | ), |
509 | 509 | ); |
510 | 510 | |
511 | - if ( ! wpinv_use_taxes() ) { |
|
512 | - unset( $totals['tax'] ); |
|
511 | + if (!wpinv_use_taxes()) { |
|
512 | + unset($totals['tax']); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | $item_args = array( |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | 'orderby' => 'title', |
518 | 518 | 'order' => 'ASC', |
519 | 519 | 'posts_per_page' => -1, |
520 | - 'post_status' => array( 'publish' ), |
|
520 | + 'post_status' => array('publish'), |
|
521 | 521 | 'meta_query' => array( |
522 | 522 | array( |
523 | 523 | 'key' => '_wpinv_type', |
@@ -545,10 +545,10 @@ discard block |
||
545 | 545 | } |
546 | 546 | </style> |
547 | 547 | |
548 | - <div class="bsui getpaid-invoice-items-inner <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
|
548 | + <div class="bsui getpaid-invoice-items-inner <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
|
549 | 549 | |
550 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
551 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
550 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
551 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
552 | 552 | |
553 | 553 | <div class="row"> |
554 | 554 | <div class="col-12 col-sm-6"> |
@@ -557,15 +557,15 @@ discard block |
||
557 | 557 | array( |
558 | 558 | 'id' => 'wpinv_template', |
559 | 559 | 'name' => 'wpinv_template', |
560 | - 'label' => __( 'Template', 'invoicing' ), |
|
560 | + 'label' => __('Template', 'invoicing'), |
|
561 | 561 | 'label_type' => 'vertical', |
562 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
562 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
563 | 563 | 'class' => 'form-control-sm', |
564 | - 'value' => $invoice->get_template( 'edit' ), |
|
564 | + 'value' => $invoice->get_template('edit'), |
|
565 | 565 | 'options' => array( |
566 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
567 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
568 | - 'amount' => __( 'Amount Only', 'invoicing' ), |
|
566 | + 'quantity' => __('Quantity', 'invoicing'), |
|
567 | + 'hours' => __('Hours', 'invoicing'), |
|
568 | + 'amount' => __('Amount Only', 'invoicing'), |
|
569 | 569 | ), |
570 | 570 | 'data-allow-clear' => 'false', |
571 | 571 | 'select2' => true, |
@@ -582,11 +582,11 @@ discard block |
||
582 | 582 | array( |
583 | 583 | 'id' => 'wpinv_currency', |
584 | 584 | 'name' => 'wpinv_currency', |
585 | - 'label' => __( 'Currency', 'invoicing' ), |
|
585 | + 'label' => __('Currency', 'invoicing'), |
|
586 | 586 | 'label_type' => 'vertical', |
587 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
587 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
588 | 588 | 'class' => 'form-control-sm', |
589 | - 'value' => $invoice->get_currency( 'edit' ), |
|
589 | + 'value' => $invoice->get_currency('edit'), |
|
590 | 590 | 'required' => false, |
591 | 591 | 'data-allow-clear' => 'false', |
592 | 592 | 'select2' => true, |
@@ -599,24 +599,24 @@ discard block |
||
599 | 599 | </div> |
600 | 600 | </div> |
601 | 601 | |
602 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
602 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
603 | 603 | <?php endif; ?> |
604 | 604 | |
605 | 605 | <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items"> |
606 | 606 | <thead> |
607 | 607 | <tr> |
608 | - <th class="getpaid-item" colspan="2"><?php esc_html_e( 'Item', 'invoicing' ); ?></th> |
|
608 | + <th class="getpaid-item" colspan="2"><?php esc_html_e('Item', 'invoicing'); ?></th> |
|
609 | 609 | <th class="getpaid-quantity hide-if-amount text-right"> |
610 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
611 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ); ?></span> |
|
610 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
611 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing'); ?></span> |
|
612 | 612 | </th> |
613 | 613 | <th class="getpaid-price hide-if-amount text-right"> |
614 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
615 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Rate', 'invoicing' ); ?></span> |
|
614 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
615 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Rate', 'invoicing'); ?></span> |
|
616 | 616 | </th> |
617 | 617 | <th class="getpaid-item-subtotal text-right"> |
618 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
619 | - <span class="hide-if-amount"><?php esc_html_e( 'Total', 'invoicing' ); ?></span> |
|
618 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
619 | + <span class="hide-if-amount"><?php esc_html_e('Total', 'invoicing'); ?></span> |
|
620 | 620 | </th> |
621 | 621 | <th class="getpaid-item-actions hide-if-not-editable" width="70px"> </th> |
622 | 622 | </tr> |
@@ -624,8 +624,8 @@ discard block |
||
624 | 624 | <tbody class="getpaid_invoice_line_items"> |
625 | 625 | <tr class="hide-if-has-items hide-if-not-editable"> |
626 | 626 | <td colspan="2" class="pt-4 pb-4"> |
627 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Items', 'invoicing' ); ?></button> |
|
628 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ); ?></button> |
|
627 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Items', 'invoicing'); ?></button> |
|
628 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing'); ?></button> |
|
629 | 629 | </td> |
630 | 630 | <td class="hide-if-amount"> </th> |
631 | 631 | <td class="hide-if-amount"> </th> |
@@ -657,11 +657,11 @@ discard block |
||
657 | 657 | <div class="col-12 col-sm-6 offset-sm-6"> |
658 | 658 | <table class="getpaid-invoice-totals text-right w-100"> |
659 | 659 | <tbody> |
660 | - <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?> |
|
661 | - <tr class="getpaid-totals-<?php echo esc_attr( $key ); ?>"> |
|
662 | - <td class="label"><?php echo esc_html( $data['label'] ); ?>:</td> |
|
660 | + <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?> |
|
661 | + <tr class="getpaid-totals-<?php echo esc_attr($key); ?>"> |
|
662 | + <td class="label"><?php echo esc_html($data['label']); ?>:</td> |
|
663 | 663 | <td width="1%"></td> |
664 | - <td class="value"><?php echo wp_kses_post( $data['value'] ); ?></td> |
|
664 | + <td class="value"><?php echo wp_kses_post($data['value']); ?></td> |
|
665 | 665 | </tr> |
666 | 666 | <?php endforeach; ?> |
667 | 667 | </tbody> |
@@ -674,18 +674,18 @@ discard block |
||
674 | 674 | <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable"> |
675 | 675 | <div class="row"> |
676 | 676 | <div class="text-left col-12 col-sm-8"> |
677 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Item', 'invoicing' ); ?></button> |
|
678 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ); ?></button> |
|
679 | - <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?> |
|
677 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Item', 'invoicing'); ?></button> |
|
678 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing'); ?></button> |
|
679 | + <?php do_action('getpaid-invoice-items-actions', $invoice); ?> |
|
680 | 680 | </div> |
681 | 681 | <div class="text-right col-12 col-sm-4"> |
682 | - <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e( 'Recalculate Totals', 'invoicing' ); ?></button> |
|
682 | + <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e('Recalculate Totals', 'invoicing'); ?></button> |
|
683 | 683 | </div> |
684 | 684 | </div> |
685 | 685 | </div> |
686 | 686 | |
687 | 687 | <div class="getpaid-invoice-item-actions hide-if-editable"> |
688 | - <p class="description m-2 text-right text-muted"><?php esc_html_e( 'This invoice is no longer editable', 'invoicing' ); ?></p> |
|
688 | + <p class="description m-2 text-right text-muted"><?php esc_html_e('This invoice is no longer editable', 'invoicing'); ?></p> |
|
689 | 689 | </div> |
690 | 690 | |
691 | 691 | <!-- Add items to an invoice --> |
@@ -693,9 +693,9 @@ discard block |
||
693 | 693 | <div class="modal-dialog modal-dialog-centered" role="document"> |
694 | 694 | <div class="modal-content"> |
695 | 695 | <div class="modal-header"> |
696 | - <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e( 'Add Item(s)', 'invoicing' ); ?></h5> |
|
697 | - <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>"> |
|
698 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
696 | + <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e('Add Item(s)', 'invoicing'); ?></h5> |
|
697 | + <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>"> |
|
698 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
699 | 699 | <span aria-hidden="true">×</span> |
700 | 700 | <?php endif; ?> |
701 | 701 | </button> |
@@ -704,10 +704,10 @@ discard block |
||
704 | 704 | <table class="widefat"> |
705 | 705 | <thead> |
706 | 706 | <tr> |
707 | - <th class="pl-0 text-left"><?php esc_html_e( 'Item', 'invoicing' ); ?></th> |
|
707 | + <th class="pl-0 text-left"><?php esc_html_e('Item', 'invoicing'); ?></th> |
|
708 | 708 | <th class="pr-0 text-right hide-if-amount"> |
709 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
710 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ); ?></span> |
|
709 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
710 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing'); ?></span> |
|
711 | 711 | </th> |
712 | 712 | </tr> |
713 | 713 | </thead> |
@@ -715,9 +715,9 @@ discard block |
||
715 | 715 | <tr> |
716 | 716 | <td class="pl-0 text-left"> |
717 | 717 | <select class="regular-text getpaid-add-invoice-item-select"> |
718 | - <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option> |
|
719 | - <?php foreach ( get_posts( $item_args ) as $item ) : ?> |
|
720 | - <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html( $item->post_title ); ?></option> |
|
718 | + <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option> |
|
719 | + <?php foreach (get_posts($item_args) as $item) : ?> |
|
720 | + <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html($item->post_title); ?></option> |
|
721 | 721 | <?php endforeach; ?> |
722 | 722 | </select> |
723 | 723 | </td> |
@@ -729,8 +729,8 @@ discard block |
||
729 | 729 | </table> |
730 | 730 | </div> |
731 | 731 | <div class="modal-footer"> |
732 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
733 | - <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e( 'Add', 'invoicing' ); ?></button> |
|
732 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
733 | + <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e('Add', 'invoicing'); ?></button> |
|
734 | 734 | </div> |
735 | 735 | </div> |
736 | 736 | </div> |
@@ -741,9 +741,9 @@ discard block |
||
741 | 741 | <div class="modal-dialog modal-dialog-centered" role="document"> |
742 | 742 | <div class="modal-content"> |
743 | 743 | <div class="modal-header"> |
744 | - <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e( 'Create Item', 'invoicing' ); ?></h5> |
|
745 | - <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>"> |
|
746 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
744 | + <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e('Create Item', 'invoicing'); ?></h5> |
|
745 | + <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>"> |
|
746 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
747 | 747 | <span aria-hidden="true">×</span> |
748 | 748 | <?php endif; ?> |
749 | 749 | </button> |
@@ -752,27 +752,27 @@ discard block |
||
752 | 752 | <div class="getpaid-create-item-div"> |
753 | 753 | <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id"> |
754 | 754 | <label class="form-group mb-3 w-100"> |
755 | - <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span> |
|
756 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
755 | + <span><?php esc_html_e('Name', 'invoicing'); ?></span> |
|
756 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
757 | 757 | </label> |
758 | 758 | <label class="form-group mb-3 w-100"> |
759 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
760 | - <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
761 | - <input type="text" name="price" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control form-control-sm item-price"> |
|
759 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
760 | + <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
761 | + <input type="text" name="price" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control form-control-sm item-price"> |
|
762 | 762 | </label> |
763 | 763 | <label class="form-group mb-3 w-100 hide-if-amount"> |
764 | - <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
764 | + <span><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
765 | 765 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
766 | 766 | </label> |
767 | 767 | <label class="form-group mb-3 w-100"> |
768 | - <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span> |
|
769 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
768 | + <span><?php esc_html_e('Item Description', 'invoicing'); ?></span> |
|
769 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
770 | 770 | </label> |
771 | 771 | </div> |
772 | 772 | </div> |
773 | 773 | <div class="modal-footer"> |
774 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
775 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Create', 'invoicing' ); ?></button> |
|
774 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
775 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Create', 'invoicing'); ?></button> |
|
776 | 776 | </div> |
777 | 777 | </div> |
778 | 778 | </div> |
@@ -783,9 +783,9 @@ discard block |
||
783 | 783 | <div class="modal-dialog modal-dialog-centered" role="document"> |
784 | 784 | <div class="modal-content"> |
785 | 785 | <div class="modal-header"> |
786 | - <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e( 'Edit Item', 'invoicing' ); ?></h5> |
|
787 | - <button type="button" class="close close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>"> |
|
788 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
786 | + <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e('Edit Item', 'invoicing'); ?></h5> |
|
787 | + <button type="button" class="close close" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>"> |
|
788 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
789 | 789 | <span aria-hidden="true">×</span> |
790 | 790 | <?php endif; ?> |
791 | 791 | </button> |
@@ -794,27 +794,27 @@ discard block |
||
794 | 794 | <div class="getpaid-edit-item-div"> |
795 | 795 | <input type="hidden" name="id" class="form-control form-control-sm item-id"> |
796 | 796 | <label class="form-group mb-3 w-100"> |
797 | - <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span> |
|
798 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
797 | + <span><?php esc_html_e('Name', 'invoicing'); ?></span> |
|
798 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
799 | 799 | </label> |
800 | 800 | <label class="form-group mb-3 w-100"> |
801 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
802 | - <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
803 | - <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price"> |
|
801 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
802 | + <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
803 | + <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price"> |
|
804 | 804 | </label> |
805 | 805 | <label class="form-group mb-3 w-100 hide-if-amount"> |
806 | - <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
806 | + <span><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
807 | 807 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
808 | 808 | </label> |
809 | 809 | <label class="form-group mb-3 w-100"> |
810 | - <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span> |
|
811 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
810 | + <span><?php esc_html_e('Item Description', 'invoicing'); ?></span> |
|
811 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
812 | 812 | </label> |
813 | 813 | </div> |
814 | 814 | </div> |
815 | 815 | <div class="modal-footer"> |
816 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
817 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Save', 'invoicing' ); ?></button> |
|
816 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
817 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Save', 'invoicing'); ?></button> |
|
818 | 818 | </div> |
819 | 819 | </div> |
820 | 820 | </div> |
@@ -14,94 +14,94 @@ discard block |
||
14 | 14 | class GetPaid_Admin { |
15 | 15 | |
16 | 16 | /** |
17 | - * Local path to this plugins admin directory |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - public $admin_path; |
|
22 | - |
|
23 | - /** |
|
24 | - * Web path to this plugins admin directory |
|
25 | - * |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - public $admin_url; |
|
29 | - |
|
30 | - /** |
|
31 | - * Reports components. |
|
32 | - * |
|
33 | - * @var GetPaid_Reports |
|
34 | - */ |
|
17 | + * Local path to this plugins admin directory |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + public $admin_path; |
|
22 | + |
|
23 | + /** |
|
24 | + * Web path to this plugins admin directory |
|
25 | + * |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + public $admin_url; |
|
29 | + |
|
30 | + /** |
|
31 | + * Reports components. |
|
32 | + * |
|
33 | + * @var GetPaid_Reports |
|
34 | + */ |
|
35 | 35 | public $reports; |
36 | 36 | |
37 | 37 | /** |
38 | - * Class constructor. |
|
39 | - */ |
|
40 | - public function __construct() { |
|
38 | + * Class constructor. |
|
39 | + */ |
|
40 | + public function __construct() { |
|
41 | 41 | |
42 | 42 | $this->admin_path = plugin_dir_path( __FILE__ ); |
43 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
44 | - $this->reports = new GetPaid_Reports(); |
|
43 | + $this->admin_url = plugins_url( '/', __FILE__ ); |
|
44 | + $this->reports = new GetPaid_Reports(); |
|
45 | 45 | |
46 | 46 | if ( is_admin() ) { |
47 | - $this->init_admin_hooks(); |
|
47 | + $this->init_admin_hooks(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | - * Init action and filter hooks |
|
54 | - * |
|
55 | - */ |
|
56 | - private function init_admin_hooks() { |
|
53 | + * Init action and filter hooks |
|
54 | + * |
|
55 | + */ |
|
56 | + private function init_admin_hooks() { |
|
57 | 57 | add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 ); |
58 | 58 | add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
59 | 59 | add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
60 | 60 | add_action( 'admin_init', array( $this, 'activation_redirect' ) ); |
61 | 61 | add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) ); |
62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
63 | - add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
64 | - add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) ); |
|
65 | - add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) ); |
|
66 | - add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) ); |
|
67 | - add_action( 'getpaid_authenticated_admin_action_refund_invoice', array( $this, 'refund_invoice' ) ); |
|
68 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
69 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
62 | + add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
63 | + add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
64 | + add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) ); |
|
65 | + add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) ); |
|
66 | + add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) ); |
|
67 | + add_action( 'getpaid_authenticated_admin_action_refund_invoice', array( $this, 'refund_invoice' ) ); |
|
68 | + add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
69 | + add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
70 | 70 | add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) ); |
71 | - add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
72 | - add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) ); |
|
73 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
74 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
75 | - add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
76 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
77 | - add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
78 | - add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
79 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
80 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
81 | - |
|
82 | - // Setup/welcome |
|
83 | - if ( ! empty( $_GET['page'] ) ) { |
|
84 | - switch ( sanitize_text_field( $_GET['page'] ) ) { |
|
85 | - case 'gp-setup': |
|
86 | - include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php'; |
|
87 | - break; |
|
88 | - } |
|
89 | - } |
|
90 | - |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Register admin scripts |
|
95 | - * |
|
96 | - */ |
|
97 | - public function enqeue_scripts() { |
|
71 | + add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
72 | + add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) ); |
|
73 | + add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
74 | + add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
75 | + add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
76 | + add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
77 | + add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
78 | + add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
79 | + add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
80 | + do_action( 'getpaid_init_admin_hooks', $this ); |
|
81 | + |
|
82 | + // Setup/welcome |
|
83 | + if ( ! empty( $_GET['page'] ) ) { |
|
84 | + switch ( sanitize_text_field( $_GET['page'] ) ) { |
|
85 | + case 'gp-setup': |
|
86 | + include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php'; |
|
87 | + break; |
|
88 | + } |
|
89 | + } |
|
90 | + |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Register admin scripts |
|
95 | + * |
|
96 | + */ |
|
97 | + public function enqeue_scripts() { |
|
98 | 98 | global $current_screen, $pagenow; |
99 | 99 | |
100 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
101 | - $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
100 | + $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
101 | + $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
102 | 102 | |
103 | 103 | if ( ! empty( $current_screen->post_type ) ) { |
104 | - $page = $current_screen->post_type; |
|
104 | + $page = $current_screen->post_type; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | // General styles. |
@@ -122,53 +122,53 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | // Payment form scripts. |
125 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
125 | + if ( 'wpi_payment_form' == $page && $editing ) { |
|
126 | 126 | $this->load_payment_form_scripts(); |
127 | 127 | } |
128 | 128 | |
129 | - if ( $page == 'wpinv-subscriptions' ) { |
|
130 | - wp_enqueue_script( 'postbox' ); |
|
131 | - } |
|
129 | + if ( $page == 'wpinv-subscriptions' ) { |
|
130 | + wp_enqueue_script( 'postbox' ); |
|
131 | + } |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | - * Returns admin js translations. |
|
137 | - * |
|
138 | - */ |
|
139 | - protected function get_admin_i18() { |
|
136 | + * Returns admin js translations. |
|
137 | + * |
|
138 | + */ |
|
139 | + protected function get_admin_i18() { |
|
140 | 140 | global $post; |
141 | 141 | |
142 | - $date_range = array( |
|
143 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days', |
|
144 | - ); |
|
142 | + $date_range = array( |
|
143 | + 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days', |
|
144 | + ); |
|
145 | 145 | |
146 | - if ( $date_range['period'] == 'custom' ) { |
|
146 | + if ( $date_range['period'] == 'custom' ) { |
|
147 | 147 | |
148 | - if ( isset( $_GET['from'] ) ) { |
|
149 | - $date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
150 | - } |
|
148 | + if ( isset( $_GET['from'] ) ) { |
|
149 | + $date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
150 | + } |
|
151 | 151 | |
152 | - if ( isset( $_GET['to'] ) ) { |
|
153 | - $date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
154 | - } |
|
152 | + if ( isset( $_GET['to'] ) ) { |
|
153 | + $date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
154 | + } |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | $i18n = array( |
158 | 158 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
159 | 159 | 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
160 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
161 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
162 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
163 | - 'date_range' => $date_range, |
|
160 | + 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
161 | + 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
162 | + 'rest_root' => esc_url_raw( rest_url() ), |
|
163 | + 'date_range' => $date_range, |
|
164 | 164 | 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
165 | 165 | 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
166 | 166 | 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
167 | 167 | 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
168 | 168 | 'tax' => wpinv_tax_amount(), |
169 | 169 | 'discount' => 0, |
170 | - 'currency_symbol' => wpinv_currency_symbol(), |
|
171 | - 'currency' => wpinv_get_currency(), |
|
170 | + 'currency_symbol' => wpinv_currency_symbol(), |
|
171 | + 'currency' => wpinv_get_currency(), |
|
172 | 172 | 'currency_pos' => wpinv_currency_position(), |
173 | 173 | 'thousand_sep' => wpinv_thousands_separator(), |
174 | 174 | 'decimal_sep' => wpinv_decimal_separator(), |
@@ -188,118 +188,118 @@ discard block |
||
188 | 188 | 'item_description' => __( 'Item Description', 'invoicing' ), |
189 | 189 | 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
190 | 190 | 'discount_description' => __( 'Discount Description', 'invoicing' ), |
191 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
192 | - 'loading' => __( 'Loading...', 'invoicing' ), |
|
193 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
194 | - 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
195 | - 'graphs' => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ), |
|
191 | + 'searching' => __( 'Searching', 'invoicing' ), |
|
192 | + 'loading' => __( 'Loading...', 'invoicing' ), |
|
193 | + 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
194 | + 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
195 | + 'graphs' => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ), |
|
196 | 196 | ); |
197 | 197 | |
198 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
198 | + if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
199 | 199 | |
200 | - $invoice = new WPInv_Invoice( $post ); |
|
201 | - $i18n['save_invoice'] = sprintf( |
|
202 | - __( 'Save %s', 'invoicing' ), |
|
203 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
204 | - ); |
|
200 | + $invoice = new WPInv_Invoice( $post ); |
|
201 | + $i18n['save_invoice'] = sprintf( |
|
202 | + __( 'Save %s', 'invoicing' ), |
|
203 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
204 | + ); |
|
205 | 205 | |
206 | - $i18n['invoice_description'] = sprintf( |
|
207 | - __( '%s Description', 'invoicing' ), |
|
208 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
209 | - ); |
|
206 | + $i18n['invoice_description'] = sprintf( |
|
207 | + __( '%s Description', 'invoicing' ), |
|
208 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
209 | + ); |
|
210 | 210 | |
211 | - } |
|
212 | - return $i18n; |
|
213 | - } |
|
211 | + } |
|
212 | + return $i18n; |
|
213 | + } |
|
214 | 214 | |
215 | - /** |
|
216 | - * Change the admin footer text on GetPaid admin pages. |
|
217 | - * |
|
218 | - * @since 2.0.0 |
|
219 | - * @param string $footer_text |
|
220 | - * @return string |
|
221 | - */ |
|
222 | - public function admin_footer_text( $footer_text ) { |
|
223 | - global $current_screen; |
|
215 | + /** |
|
216 | + * Change the admin footer text on GetPaid admin pages. |
|
217 | + * |
|
218 | + * @since 2.0.0 |
|
219 | + * @param string $footer_text |
|
220 | + * @return string |
|
221 | + */ |
|
222 | + public function admin_footer_text( $footer_text ) { |
|
223 | + global $current_screen; |
|
224 | 224 | |
225 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
225 | + $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
226 | 226 | |
227 | 227 | if ( ! empty( $current_screen->post_type ) ) { |
228 | - $page = $current_screen->post_type; |
|
228 | + $page = $current_screen->post_type; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | // General styles. |
232 | 232 | if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
233 | 233 | |
234 | - // Change the footer text |
|
235 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
234 | + // Change the footer text |
|
235 | + if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
236 | 236 | |
237 | - $rating_url = esc_url( |
|
238 | - wp_nonce_url( |
|
239 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
240 | - 'getpaid-nonce', |
|
241 | - 'getpaid-nonce' |
|
237 | + $rating_url = esc_url( |
|
238 | + wp_nonce_url( |
|
239 | + admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
240 | + 'getpaid-nonce', |
|
241 | + 'getpaid-nonce' |
|
242 | 242 | ) |
243 | - ); |
|
243 | + ); |
|
244 | 244 | |
245 | - $footer_text = sprintf( |
|
246 | - /* translators: %s: five stars */ |
|
247 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
248 | - "<a href='$rating_url'>★★★★★</a>" |
|
249 | - ); |
|
245 | + $footer_text = sprintf( |
|
246 | + /* translators: %s: five stars */ |
|
247 | + __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
248 | + "<a href='$rating_url'>★★★★★</a>" |
|
249 | + ); |
|
250 | 250 | |
251 | - } else { |
|
251 | + } else { |
|
252 | 252 | |
253 | - $footer_text = sprintf( |
|
254 | - /* translators: %s: GetPaid */ |
|
255 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
256 | - "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
|
257 | - ); |
|
253 | + $footer_text = sprintf( |
|
254 | + /* translators: %s: GetPaid */ |
|
255 | + __( 'Thank you for using %s!', 'invoicing' ), |
|
256 | + "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
|
257 | + ); |
|
258 | 258 | |
259 | - } |
|
259 | + } |
|
260 | 260 | } |
261 | 261 | |
262 | - return $footer_text; |
|
263 | - } |
|
264 | - |
|
265 | - /** |
|
266 | - * Redirects to wp.org to rate the plugin. |
|
267 | - * |
|
268 | - * @since 2.0.0 |
|
269 | - */ |
|
270 | - public function redirect_to_wordpress_rating_page() { |
|
271 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
272 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
273 | - exit; |
|
274 | - } |
|
275 | - |
|
276 | - /** |
|
277 | - * Loads payment form js. |
|
278 | - * |
|
279 | - */ |
|
280 | - protected function load_payment_form_scripts() { |
|
262 | + return $footer_text; |
|
263 | + } |
|
264 | + |
|
265 | + /** |
|
266 | + * Redirects to wp.org to rate the plugin. |
|
267 | + * |
|
268 | + * @since 2.0.0 |
|
269 | + */ |
|
270 | + public function redirect_to_wordpress_rating_page() { |
|
271 | + update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
272 | + wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
273 | + exit; |
|
274 | + } |
|
275 | + |
|
276 | + /** |
|
277 | + * Loads payment form js. |
|
278 | + * |
|
279 | + */ |
|
280 | + protected function load_payment_form_scripts() { |
|
281 | 281 | global $post; |
282 | 282 | |
283 | 283 | wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION ); |
284 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
285 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
284 | + wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
285 | + wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
286 | 286 | |
287 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
288 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version ); |
|
287 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
288 | + wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version ); |
|
289 | 289 | |
290 | - wp_localize_script( |
|
290 | + wp_localize_script( |
|
291 | 291 | 'wpinv-admin-payment-form-script', |
292 | 292 | 'wpinvPaymentFormAdmin', |
293 | 293 | array( |
294 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
295 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
296 | - 'currency' => wpinv_currency_symbol(), |
|
297 | - 'position' => wpinv_currency_position(), |
|
298 | - 'decimals' => (int) wpinv_decimals(), |
|
299 | - 'thousands_sep' => wpinv_thousands_separator(), |
|
300 | - 'decimals_sep' => wpinv_decimal_separator(), |
|
301 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
302 | - 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
294 | + 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
295 | + 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
296 | + 'currency' => wpinv_currency_symbol(), |
|
297 | + 'position' => wpinv_currency_position(), |
|
298 | + 'decimals' => (int) wpinv_decimals(), |
|
299 | + 'thousands_sep' => wpinv_thousands_separator(), |
|
300 | + 'decimals_sep' => wpinv_decimal_separator(), |
|
301 | + 'form_items' => gepaid_get_form_items( $post->ID ), |
|
302 | + 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
303 | 303 | ) |
304 | 304 | ); |
305 | 305 | |
@@ -308,19 +308,19 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
311 | - * Add our classes to admin pages. |
|
311 | + * Add our classes to admin pages. |
|
312 | 312 | * |
313 | 313 | * @param string $classes |
314 | 314 | * @return string |
315 | - * |
|
316 | - */ |
|
315 | + * |
|
316 | + */ |
|
317 | 317 | public function admin_body_class( $classes ) { |
318 | - global $pagenow, $post, $current_screen; |
|
318 | + global $pagenow, $post, $current_screen; |
|
319 | 319 | |
320 | 320 | $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
321 | 321 | |
322 | 322 | if ( ! empty( $current_screen->post_type ) ) { |
323 | - $page = $current_screen->post_type; |
|
323 | + $page = $current_screen->post_type; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | if ( false !== stripos( $page, 'wpi' ) ) { |
@@ -329,70 +329,70 @@ discard block |
||
329 | 329 | |
330 | 330 | if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
331 | 331 | $classes .= ' wpinv-cpt wpinv'; |
332 | - } |
|
332 | + } |
|
333 | 333 | |
334 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
334 | + if ( getpaid_is_invoice_post_type( $page ) ) { |
|
335 | 335 | $classes .= ' getpaid-is-invoice-cpt'; |
336 | 336 | } |
337 | 337 | |
338 | - return $classes; |
|
338 | + return $classes; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
342 | - * Maybe show the AyeCode Connect Notice. |
|
343 | - */ |
|
344 | - public function init_ayecode_connect_helper() { |
|
342 | + * Maybe show the AyeCode Connect Notice. |
|
343 | + */ |
|
344 | + public function init_ayecode_connect_helper() { |
|
345 | 345 | |
346 | - // Register with the deactivation survey class. |
|
347 | - AyeCode_Deactivation_Survey::instance( |
|
346 | + // Register with the deactivation survey class. |
|
347 | + AyeCode_Deactivation_Survey::instance( |
|
348 | 348 | array( |
349 | - 'slug' => 'invoicing', |
|
350 | - 'version' => WPINV_VERSION, |
|
351 | - 'support_url' => 'https://wpgetpaid.com/support/', |
|
352 | - 'documentation_url' => 'https://docs.wpgetpaid.com/', |
|
353 | - 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
349 | + 'slug' => 'invoicing', |
|
350 | + 'version' => WPINV_VERSION, |
|
351 | + 'support_url' => 'https://wpgetpaid.com/support/', |
|
352 | + 'documentation_url' => 'https://docs.wpgetpaid.com/', |
|
353 | + 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | |
357 | 357 | new AyeCode_Connect_Helper( |
358 | 358 | array( |
359 | - 'connect_title' => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ), |
|
360 | - 'connect_external' => __( 'Please confirm you wish to connect your site?', 'invoicing' ), |
|
361 | - 'connect' => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ), |
|
362 | - 'connect_button' => __( 'Connect Site', 'invoicing' ), |
|
363 | - 'connecting_button' => __( 'Connecting...', 'invoicing' ), |
|
364 | - 'error_localhost' => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ), |
|
365 | - 'error' => __( 'Something went wrong, please refresh and try again.', 'invoicing' ), |
|
359 | + 'connect_title' => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ), |
|
360 | + 'connect_external' => __( 'Please confirm you wish to connect your site?', 'invoicing' ), |
|
361 | + 'connect' => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ), |
|
362 | + 'connect_button' => __( 'Connect Site', 'invoicing' ), |
|
363 | + 'connecting_button' => __( 'Connecting...', 'invoicing' ), |
|
364 | + 'error_localhost' => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ), |
|
365 | + 'error' => __( 'Something went wrong, please refresh and try again.', 'invoicing' ), |
|
366 | 366 | ), |
367 | 367 | array( 'wpi-addons' ) |
368 | 368 | ); |
369 | 369 | |
370 | 370 | } |
371 | 371 | |
372 | - /** |
|
373 | - * Redirect users to settings on activation. |
|
374 | - * |
|
375 | - * @return void |
|
376 | - */ |
|
377 | - public function activation_redirect() { |
|
372 | + /** |
|
373 | + * Redirect users to settings on activation. |
|
374 | + * |
|
375 | + * @return void |
|
376 | + */ |
|
377 | + public function activation_redirect() { |
|
378 | 378 | |
379 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
379 | + $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
380 | 380 | |
381 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
382 | - return; |
|
383 | - } |
|
381 | + if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
382 | + return; |
|
383 | + } |
|
384 | 384 | |
385 | - // Bail if activating from network, or bulk |
|
386 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
387 | - return; |
|
388 | - } |
|
385 | + // Bail if activating from network, or bulk |
|
386 | + if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
387 | + return; |
|
388 | + } |
|
389 | 389 | |
390 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
390 | + update_option( 'wpinv_redirected_to_settings', 1 ); |
|
391 | 391 | |
392 | 392 | wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) ); |
393 | 393 | exit; |
394 | 394 | |
395 | - } |
|
395 | + } |
|
396 | 396 | |
397 | 397 | /** |
398 | 398 | * Fires an admin action after verifying that a user can fire them. |
@@ -405,555 +405,555 @@ discard block |
||
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
408 | - /** |
|
408 | + /** |
|
409 | 409 | * Duplicate invoice. |
410 | - * |
|
411 | - * @param array $args |
|
410 | + * |
|
411 | + * @param array $args |
|
412 | 412 | */ |
413 | 413 | public function duplicate_invoice( $args ) { |
414 | 414 | |
415 | - if ( empty( $args['invoice_id'] ) ) { |
|
416 | - return; |
|
417 | - } |
|
415 | + if ( empty( $args['invoice_id'] ) ) { |
|
416 | + return; |
|
417 | + } |
|
418 | 418 | |
419 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
419 | + $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
420 | 420 | |
421 | - if ( ! $invoice->exists() ) { |
|
422 | - return; |
|
423 | - } |
|
421 | + if ( ! $invoice->exists() ) { |
|
422 | + return; |
|
423 | + } |
|
424 | 424 | |
425 | - $new_invoice = getpaid_duplicate_invoice( $invoice ); |
|
426 | - $new_invoice->save(); |
|
425 | + $new_invoice = getpaid_duplicate_invoice( $invoice ); |
|
426 | + $new_invoice->save(); |
|
427 | 427 | |
428 | - if ( $new_invoice->exists() ) { |
|
428 | + if ( $new_invoice->exists() ) { |
|
429 | 429 | |
430 | - getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) ); |
|
430 | + getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) ); |
|
431 | 431 | |
432 | - wp_safe_redirect( |
|
433 | - add_query_arg( |
|
434 | - array( |
|
435 | - 'action' => 'edit', |
|
436 | - 'post' => $new_invoice->get_id(), |
|
437 | - ), |
|
438 | - admin_url( 'post.php' ) |
|
439 | - ) |
|
440 | - ); |
|
441 | - exit; |
|
432 | + wp_safe_redirect( |
|
433 | + add_query_arg( |
|
434 | + array( |
|
435 | + 'action' => 'edit', |
|
436 | + 'post' => $new_invoice->get_id(), |
|
437 | + ), |
|
438 | + admin_url( 'post.php' ) |
|
439 | + ) |
|
440 | + ); |
|
441 | + exit; |
|
442 | 442 | |
443 | - } |
|
443 | + } |
|
444 | 444 | |
445 | - getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) ); |
|
445 | + getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) ); |
|
446 | 446 | |
447 | - } |
|
447 | + } |
|
448 | 448 | |
449 | - /** |
|
449 | + /** |
|
450 | 450 | * Refund an invoice. |
451 | - * |
|
452 | - * @param array $args |
|
451 | + * |
|
452 | + * @param array $args |
|
453 | 453 | */ |
454 | 454 | public function refund_invoice( $args ) { |
455 | 455 | |
456 | - if ( empty( $args['invoice_id'] ) ) { |
|
457 | - return; |
|
458 | - } |
|
459 | - |
|
460 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
461 | - |
|
462 | - if ( ! $invoice->exists() || $invoice->is_refunded() ) { |
|
463 | - return; |
|
464 | - } |
|
465 | - |
|
466 | - $invoice->refund(); |
|
467 | - |
|
468 | - // Refund remotely. |
|
469 | - if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) && ! empty( $args['getpaid_refund_remote'] ) ) { |
|
470 | - do_action( 'getpaid_refund_invoice_remotely', $invoice ); |
|
471 | - } |
|
472 | - |
|
473 | - // Cancel subscriptions. |
|
474 | - if ( ! empty( $args['getpaid_cancel_subscription'] ) ) { |
|
475 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
476 | - |
|
477 | - if ( ! empty( $subscriptions ) ) { |
|
478 | - if ( ! is_array( $subscriptions ) ) { |
|
479 | - $subscriptions = array( $subscriptions ); |
|
480 | - } |
|
481 | - |
|
482 | - foreach ( $subscriptions as $subscription ) { |
|
483 | - $subscription->cancel(); |
|
484 | - $invoice->add_system_note( |
|
485 | - sprintf( |
|
486 | - // translators: %s: subscription ID. |
|
487 | - __( 'Subscription #%s cancelled', 'invoicing' ), |
|
488 | - $subscription->get_id() |
|
489 | - ) |
|
490 | - ); |
|
491 | - } |
|
492 | - } |
|
493 | - } |
|
494 | - |
|
495 | - // Add notice. |
|
496 | - $this->show_success( __( 'Invoice refunded successfully.', 'invoicing' ) ); |
|
497 | - |
|
498 | - // Redirect. |
|
499 | - wp_safe_redirect( |
|
500 | - remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote' ) ) |
|
501 | - ); |
|
502 | - } |
|
503 | - |
|
504 | - /** |
|
456 | + if ( empty( $args['invoice_id'] ) ) { |
|
457 | + return; |
|
458 | + } |
|
459 | + |
|
460 | + $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
461 | + |
|
462 | + if ( ! $invoice->exists() || $invoice->is_refunded() ) { |
|
463 | + return; |
|
464 | + } |
|
465 | + |
|
466 | + $invoice->refund(); |
|
467 | + |
|
468 | + // Refund remotely. |
|
469 | + if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) && ! empty( $args['getpaid_refund_remote'] ) ) { |
|
470 | + do_action( 'getpaid_refund_invoice_remotely', $invoice ); |
|
471 | + } |
|
472 | + |
|
473 | + // Cancel subscriptions. |
|
474 | + if ( ! empty( $args['getpaid_cancel_subscription'] ) ) { |
|
475 | + $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
476 | + |
|
477 | + if ( ! empty( $subscriptions ) ) { |
|
478 | + if ( ! is_array( $subscriptions ) ) { |
|
479 | + $subscriptions = array( $subscriptions ); |
|
480 | + } |
|
481 | + |
|
482 | + foreach ( $subscriptions as $subscription ) { |
|
483 | + $subscription->cancel(); |
|
484 | + $invoice->add_system_note( |
|
485 | + sprintf( |
|
486 | + // translators: %s: subscription ID. |
|
487 | + __( 'Subscription #%s cancelled', 'invoicing' ), |
|
488 | + $subscription->get_id() |
|
489 | + ) |
|
490 | + ); |
|
491 | + } |
|
492 | + } |
|
493 | + } |
|
494 | + |
|
495 | + // Add notice. |
|
496 | + $this->show_success( __( 'Invoice refunded successfully.', 'invoicing' ) ); |
|
497 | + |
|
498 | + // Redirect. |
|
499 | + wp_safe_redirect( |
|
500 | + remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote' ) ) |
|
501 | + ); |
|
502 | + } |
|
503 | + |
|
504 | + /** |
|
505 | 505 | * Sends a payment reminder to a customer. |
506 | - * |
|
507 | - * @param array $args |
|
506 | + * |
|
507 | + * @param array $args |
|
508 | 508 | */ |
509 | 509 | public function duplicate_payment_form( $args ) { |
510 | 510 | |
511 | - if ( empty( $args['form_id'] ) ) { |
|
512 | - return; |
|
513 | - } |
|
514 | - |
|
515 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
511 | + if ( empty( $args['form_id'] ) ) { |
|
512 | + return; |
|
513 | + } |
|
516 | 514 | |
517 | - if ( ! $form->exists() ) { |
|
518 | - return; |
|
519 | - } |
|
515 | + $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
520 | 516 | |
521 | - $new_form = new GetPaid_Payment_Form(); |
|
522 | - $new_form->set_author( $form->get_author( 'edit' ) ); |
|
523 | - $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
524 | - $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
525 | - $new_form->set_items( $form->get_items( 'edit' ) ); |
|
526 | - $new_form->save(); |
|
517 | + if ( ! $form->exists() ) { |
|
518 | + return; |
|
519 | + } |
|
527 | 520 | |
528 | - if ( $new_form->exists() ) { |
|
529 | - $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
530 | - $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
531 | - } else { |
|
532 | - $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
533 | - $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
534 | - } |
|
521 | + $new_form = new GetPaid_Payment_Form(); |
|
522 | + $new_form->set_author( $form->get_author( 'edit' ) ); |
|
523 | + $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
524 | + $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
525 | + $new_form->set_items( $form->get_items( 'edit' ) ); |
|
526 | + $new_form->save(); |
|
527 | + |
|
528 | + if ( $new_form->exists() ) { |
|
529 | + $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
530 | + $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
531 | + } else { |
|
532 | + $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
533 | + $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
534 | + } |
|
535 | 535 | |
536 | - wp_redirect( $url ); |
|
537 | - exit; |
|
538 | - } |
|
536 | + wp_redirect( $url ); |
|
537 | + exit; |
|
538 | + } |
|
539 | 539 | |
540 | - /** |
|
540 | + /** |
|
541 | 541 | * Resets form stats. |
542 | - * |
|
543 | - * @param array $args |
|
542 | + * |
|
543 | + * @param array $args |
|
544 | 544 | */ |
545 | 545 | public function reset_form_stats( $args ) { |
546 | 546 | |
547 | - if ( empty( $args['form_id'] ) ) { |
|
548 | - return; |
|
549 | - } |
|
547 | + if ( empty( $args['form_id'] ) ) { |
|
548 | + return; |
|
549 | + } |
|
550 | 550 | |
551 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
551 | + $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
552 | 552 | |
553 | - if ( ! $form->exists() ) { |
|
554 | - return; |
|
555 | - } |
|
553 | + if ( ! $form->exists() ) { |
|
554 | + return; |
|
555 | + } |
|
556 | 556 | |
557 | - $form->set_earned( 0 ); |
|
558 | - $form->set_refunded( 0 ); |
|
559 | - $form->set_cancelled( 0 ); |
|
560 | - $form->set_failed( 0 ); |
|
561 | - $form->save(); |
|
557 | + $form->set_earned( 0 ); |
|
558 | + $form->set_refunded( 0 ); |
|
559 | + $form->set_cancelled( 0 ); |
|
560 | + $form->set_failed( 0 ); |
|
561 | + $form->save(); |
|
562 | 562 | |
563 | - $this->show_success( __( 'Form stats reset successfully', 'invoicing' ) ); |
|
563 | + $this->show_success( __( 'Form stats reset successfully', 'invoicing' ) ); |
|
564 | 564 | |
565 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) ); |
|
566 | - exit; |
|
567 | - } |
|
565 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) ); |
|
566 | + exit; |
|
567 | + } |
|
568 | 568 | |
569 | - /** |
|
569 | + /** |
|
570 | 570 | * Sends a payment reminder to a customer. |
571 | - * |
|
572 | - * @param array $args |
|
571 | + * |
|
572 | + * @param array $args |
|
573 | 573 | */ |
574 | 574 | public function send_customer_invoice( $args ) { |
575 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
576 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
577 | - exit; |
|
578 | - } |
|
575 | + getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
576 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
577 | + exit; |
|
578 | + } |
|
579 | 579 | |
580 | - /** |
|
580 | + /** |
|
581 | 581 | * Sends a payment reminder to a customer. |
582 | - * |
|
583 | - * @param array $args |
|
582 | + * |
|
583 | + * @param array $args |
|
584 | 584 | */ |
585 | 585 | public function send_customer_payment_reminder( $args ) { |
586 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
586 | + $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
587 | 587 | |
588 | - if ( $sent ) { |
|
589 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
590 | - } else { |
|
591 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
592 | - } |
|
588 | + if ( $sent ) { |
|
589 | + $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
590 | + } else { |
|
591 | + $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
592 | + } |
|
593 | 593 | |
594 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
595 | - exit; |
|
596 | - } |
|
594 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
595 | + exit; |
|
596 | + } |
|
597 | 597 | |
598 | - /** |
|
598 | + /** |
|
599 | 599 | * Resets tax rates. |
600 | - * |
|
600 | + * |
|
601 | 601 | */ |
602 | 602 | public function admin_reset_tax_rates() { |
603 | 603 | |
604 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
605 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
606 | - exit; |
|
604 | + update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
605 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
606 | + exit; |
|
607 | 607 | |
608 | - } |
|
608 | + } |
|
609 | 609 | |
610 | - /** |
|
610 | + /** |
|
611 | 611 | * Resets admin pages. |
612 | - * |
|
612 | + * |
|
613 | 613 | */ |
614 | 614 | public function admin_create_missing_pages() { |
615 | - $installer = new GetPaid_Installer(); |
|
616 | - $installer->create_pages(); |
|
617 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
618 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
619 | - exit; |
|
620 | - } |
|
621 | - |
|
622 | - /** |
|
623 | - * Refreshes the permalinks. |
|
624 | - */ |
|
625 | - public function admin_refresh_permalinks() { |
|
626 | - flush_rewrite_rules(); |
|
627 | - $this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) ); |
|
628 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
629 | - exit; |
|
630 | - } |
|
631 | - |
|
632 | - /** |
|
615 | + $installer = new GetPaid_Installer(); |
|
616 | + $installer->create_pages(); |
|
617 | + $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
618 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
619 | + exit; |
|
620 | + } |
|
621 | + |
|
622 | + /** |
|
623 | + * Refreshes the permalinks. |
|
624 | + */ |
|
625 | + public function admin_refresh_permalinks() { |
|
626 | + flush_rewrite_rules(); |
|
627 | + $this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) ); |
|
628 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
629 | + exit; |
|
630 | + } |
|
631 | + |
|
632 | + /** |
|
633 | 633 | * Creates missing admin tables. |
634 | - * |
|
634 | + * |
|
635 | 635 | */ |
636 | 636 | public function admin_create_missing_tables() { |
637 | - global $wpdb; |
|
637 | + global $wpdb; |
|
638 | 638 | |
639 | - GetPaid_Installer::create_db_tables(); |
|
640 | - GetPaid_Installer::migrate_old_customers(); |
|
639 | + GetPaid_Installer::create_db_tables(); |
|
640 | + GetPaid_Installer::migrate_old_customers(); |
|
641 | 641 | |
642 | - if ( '' !== $wpdb->last_error ) { |
|
643 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
644 | - } else { |
|
645 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
646 | - } |
|
642 | + if ( '' !== $wpdb->last_error ) { |
|
643 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
644 | + } else { |
|
645 | + $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
646 | + } |
|
647 | 647 | |
648 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
649 | - exit; |
|
650 | - } |
|
648 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
649 | + exit; |
|
650 | + } |
|
651 | 651 | |
652 | - /** |
|
652 | + /** |
|
653 | 653 | * Migrates old invoices to the new database tables. |
654 | - * |
|
654 | + * |
|
655 | 655 | */ |
656 | 656 | public function admin_migrate_old_invoices() { |
657 | 657 | |
658 | - // Migrate the invoices. |
|
659 | - $installer = new GetPaid_Installer(); |
|
660 | - $installer->migrate_old_invoices(); |
|
658 | + // Migrate the invoices. |
|
659 | + $installer = new GetPaid_Installer(); |
|
660 | + $installer->migrate_old_invoices(); |
|
661 | 661 | |
662 | - // Show an admin message. |
|
663 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
662 | + // Show an admin message. |
|
663 | + $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
664 | 664 | |
665 | - // Redirect the admin. |
|
666 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
667 | - exit; |
|
665 | + // Redirect the admin. |
|
666 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
667 | + exit; |
|
668 | 668 | |
669 | - } |
|
669 | + } |
|
670 | 670 | |
671 | - /** |
|
671 | + /** |
|
672 | 672 | * Download customers. |
673 | - * |
|
673 | + * |
|
674 | 674 | */ |
675 | 675 | public function admin_download_customers() { |
676 | 676 | |
677 | - $output = fopen( 'php://output', 'w' ); |
|
677 | + $output = fopen( 'php://output', 'w' ); |
|
678 | 678 | |
679 | - if ( false === $output ) { |
|
680 | - wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 ); |
|
681 | - } |
|
679 | + if ( false === $output ) { |
|
680 | + wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 ); |
|
681 | + } |
|
682 | 682 | |
683 | - header( 'Content-Type:text/csv' ); |
|
684 | - header( 'Content-Disposition:attachment;filename=customers.csv' ); |
|
683 | + header( 'Content-Type:text/csv' ); |
|
684 | + header( 'Content-Disposition:attachment;filename=customers.csv' ); |
|
685 | 685 | |
686 | - /** @var GetPaid_Customer[] $customers */ |
|
687 | - $customers = getpaid_get_customers( array( 'number' => -1 ) ); |
|
688 | - $columns = array_keys( GetPaid_Customer_Data_Store::get_database_fields() ); |
|
686 | + /** @var GetPaid_Customer[] $customers */ |
|
687 | + $customers = getpaid_get_customers( array( 'number' => -1 ) ); |
|
688 | + $columns = array_keys( GetPaid_Customer_Data_Store::get_database_fields() ); |
|
689 | 689 | |
690 | - // Output the csv column headers. |
|
691 | - fputcsv( $output, $columns ); |
|
690 | + // Output the csv column headers. |
|
691 | + fputcsv( $output, $columns ); |
|
692 | 692 | |
693 | - // Loop through |
|
694 | - foreach ( $customers as $customer ) { |
|
693 | + // Loop through |
|
694 | + foreach ( $customers as $customer ) { |
|
695 | 695 | |
696 | - $row = array(); |
|
696 | + $row = array(); |
|
697 | 697 | |
698 | - foreach ( $columns as $column ) { |
|
699 | - $row[] = (string) maybe_serialize( $customer->get( $column, 'edit' ) ); |
|
700 | - } |
|
698 | + foreach ( $columns as $column ) { |
|
699 | + $row[] = (string) maybe_serialize( $customer->get( $column, 'edit' ) ); |
|
700 | + } |
|
701 | 701 | |
702 | - fputcsv( $output, $row ); |
|
703 | - } |
|
702 | + fputcsv( $output, $row ); |
|
703 | + } |
|
704 | 704 | |
705 | - fclose( $output ); |
|
706 | - exit; |
|
705 | + fclose( $output ); |
|
706 | + exit; |
|
707 | 707 | |
708 | - } |
|
708 | + } |
|
709 | 709 | |
710 | - /** |
|
710 | + /** |
|
711 | 711 | * Installs a plugin. |
712 | - * |
|
713 | - * @param array $data |
|
712 | + * |
|
713 | + * @param array $data |
|
714 | 714 | */ |
715 | 715 | public function admin_install_plugin( $data ) { |
716 | 716 | |
717 | - if ( ! empty( $data['plugins'] ) ) { |
|
718 | - include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
719 | - wp_cache_flush(); |
|
717 | + if ( ! empty( $data['plugins'] ) ) { |
|
718 | + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
719 | + wp_cache_flush(); |
|
720 | 720 | |
721 | - foreach ( $data['plugins'] as $slug => $file ) { |
|
722 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
723 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
724 | - $installed = $upgrader->install( $plugin_zip ); |
|
721 | + foreach ( $data['plugins'] as $slug => $file ) { |
|
722 | + $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
723 | + $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
724 | + $installed = $upgrader->install( $plugin_zip ); |
|
725 | 725 | |
726 | - if ( ! is_wp_error( $installed ) && $installed ) { |
|
727 | - activate_plugin( $file, '', false, true ); |
|
728 | - } else { |
|
729 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
730 | - } |
|
726 | + if ( ! is_wp_error( $installed ) && $installed ) { |
|
727 | + activate_plugin( $file, '', false, true ); |
|
728 | + } else { |
|
729 | + wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
730 | + } |
|
731 | 731 | } |
732 | 732 | } |
733 | 733 | |
734 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
735 | - wp_safe_redirect( $redirect ); |
|
736 | - exit; |
|
734 | + $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
735 | + wp_safe_redirect( $redirect ); |
|
736 | + exit; |
|
737 | 737 | |
738 | - } |
|
738 | + } |
|
739 | 739 | |
740 | - /** |
|
740 | + /** |
|
741 | 741 | * Connects a gateway. |
742 | - * |
|
743 | - * @param array $data |
|
742 | + * |
|
743 | + * @param array $data |
|
744 | 744 | */ |
745 | 745 | public function admin_connect_gateway( $data ) { |
746 | 746 | |
747 | - if ( ! empty( $data['plugin'] ) ) { |
|
747 | + if ( ! empty( $data['plugin'] ) ) { |
|
748 | 748 | |
749 | - $gateway = sanitize_key( $data['plugin'] ); |
|
750 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
749 | + $gateway = sanitize_key( $data['plugin'] ); |
|
750 | + $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
751 | 751 | |
752 | - if ( ! empty( $connect_url ) ) { |
|
753 | - wp_redirect( $connect_url ); |
|
754 | - exit; |
|
755 | - } |
|
752 | + if ( ! empty( $connect_url ) ) { |
|
753 | + wp_redirect( $connect_url ); |
|
754 | + exit; |
|
755 | + } |
|
756 | 756 | |
757 | - if ( 'stripe' == $data['plugin'] ) { |
|
758 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
759 | - include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
760 | - wp_cache_flush(); |
|
757 | + if ( 'stripe' == $data['plugin'] ) { |
|
758 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
759 | + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
760 | + wp_cache_flush(); |
|
761 | 761 | |
762 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
763 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
764 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
765 | - $upgrader->install( $plugin_zip ); |
|
766 | - } |
|
762 | + if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
763 | + $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
764 | + $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
765 | + $upgrader->install( $plugin_zip ); |
|
766 | + } |
|
767 | 767 | |
768 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
769 | - } |
|
768 | + activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
769 | + } |
|
770 | 770 | |
771 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
772 | - if ( ! empty( $connect_url ) ) { |
|
773 | - wp_redirect( $connect_url ); |
|
774 | - exit; |
|
775 | - } |
|
771 | + $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
772 | + if ( ! empty( $connect_url ) ) { |
|
773 | + wp_redirect( $connect_url ); |
|
774 | + exit; |
|
775 | + } |
|
776 | 776 | } |
777 | 777 | |
778 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
779 | - wp_safe_redirect( $redirect ); |
|
780 | - exit; |
|
778 | + $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
779 | + wp_safe_redirect( $redirect ); |
|
780 | + exit; |
|
781 | 781 | |
782 | - } |
|
782 | + } |
|
783 | 783 | |
784 | - /** |
|
784 | + /** |
|
785 | 785 | * Recalculates discounts. |
786 | - * |
|
786 | + * |
|
787 | 787 | */ |
788 | 788 | public function admin_recalculate_discounts() { |
789 | - global $wpdb; |
|
789 | + global $wpdb; |
|
790 | 790 | |
791 | - // Fetch all invoices that have discount codes. |
|
792 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
793 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
791 | + // Fetch all invoices that have discount codes. |
|
792 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
793 | + $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
794 | 794 | |
795 | - foreach ( $invoices as $invoice ) { |
|
795 | + foreach ( $invoices as $invoice ) { |
|
796 | 796 | |
797 | - $invoice = new WPInv_Invoice( $invoice ); |
|
797 | + $invoice = new WPInv_Invoice( $invoice ); |
|
798 | 798 | |
799 | - if ( ! $invoice->exists() ) { |
|
800 | - continue; |
|
801 | - } |
|
799 | + if ( ! $invoice->exists() ) { |
|
800 | + continue; |
|
801 | + } |
|
802 | 802 | |
803 | - // Abort if the discount does not exist or does not apply here. |
|
804 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
805 | - if ( ! $discount->exists() ) { |
|
806 | - continue; |
|
807 | - } |
|
803 | + // Abort if the discount does not exist or does not apply here. |
|
804 | + $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
805 | + if ( ! $discount->exists() ) { |
|
806 | + continue; |
|
807 | + } |
|
808 | 808 | |
809 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
810 | - $invoice->recalculate_total(); |
|
809 | + $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
810 | + $invoice->recalculate_total(); |
|
811 | 811 | |
812 | - if ( $invoice->get_total_discount() > 0 ) { |
|
813 | - $invoice->save(); |
|
814 | - } |
|
812 | + if ( $invoice->get_total_discount() > 0 ) { |
|
813 | + $invoice->save(); |
|
814 | + } |
|
815 | 815 | } |
816 | 816 | |
817 | - // Show an admin message. |
|
818 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
817 | + // Show an admin message. |
|
818 | + $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
819 | 819 | |
820 | - // Redirect the admin. |
|
821 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
822 | - exit; |
|
820 | + // Redirect the admin. |
|
821 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
822 | + exit; |
|
823 | 823 | |
824 | - } |
|
824 | + } |
|
825 | 825 | |
826 | 826 | /** |
827 | - * Returns an array of admin notices. |
|
828 | - * |
|
829 | - * @since 1.0.19 |
|
827 | + * Returns an array of admin notices. |
|
828 | + * |
|
829 | + * @since 1.0.19 |
|
830 | 830 | * @return array |
831 | - */ |
|
832 | - public function get_notices() { |
|
833 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
831 | + */ |
|
832 | + public function get_notices() { |
|
833 | + $notices = get_option( 'wpinv_admin_notices' ); |
|
834 | 834 | return is_array( $notices ) ? $notices : array(); |
835 | - } |
|
835 | + } |
|
836 | 836 | |
837 | - /** |
|
838 | - * Checks if we have any admin notices. |
|
839 | - * |
|
840 | - * @since 2.0.4 |
|
837 | + /** |
|
838 | + * Checks if we have any admin notices. |
|
839 | + * |
|
840 | + * @since 2.0.4 |
|
841 | 841 | * @return array |
842 | - */ |
|
843 | - public function has_notices() { |
|
844 | - return count( $this->get_notices() ) > 0; |
|
845 | - } |
|
846 | - |
|
847 | - /** |
|
848 | - * Clears all admin notices |
|
849 | - * |
|
850 | - * @access public |
|
851 | - * @since 1.0.19 |
|
852 | - */ |
|
853 | - public function clear_notices() { |
|
854 | - delete_option( 'wpinv_admin_notices' ); |
|
855 | - } |
|
856 | - |
|
857 | - /** |
|
858 | - * Saves a new admin notice |
|
859 | - * |
|
860 | - * @access public |
|
861 | - * @since 1.0.19 |
|
862 | - */ |
|
863 | - public function save_notice( $type, $message ) { |
|
864 | - $notices = $this->get_notices(); |
|
865 | - |
|
866 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) { |
|
867 | - $notices[ $type ] = array(); |
|
868 | - } |
|
869 | - |
|
870 | - $notices[ $type ][] = $message; |
|
871 | - |
|
872 | - update_option( 'wpinv_admin_notices', $notices ); |
|
873 | - } |
|
874 | - |
|
875 | - /** |
|
876 | - * Displays a success notice |
|
877 | - * |
|
878 | - * @param string $msg The message to qeue. |
|
879 | - * @access public |
|
880 | - * @since 1.0.19 |
|
881 | - */ |
|
882 | - public function show_success( $msg ) { |
|
883 | - $this->save_notice( 'success', $msg ); |
|
884 | - } |
|
885 | - |
|
886 | - /** |
|
887 | - * Displays a error notice |
|
888 | - * |
|
889 | - * @access public |
|
890 | - * @param string $msg The message to qeue. |
|
891 | - * @since 1.0.19 |
|
892 | - */ |
|
893 | - public function show_error( $msg ) { |
|
894 | - $this->save_notice( 'error', $msg ); |
|
895 | - } |
|
896 | - |
|
897 | - /** |
|
898 | - * Displays a warning notice |
|
899 | - * |
|
900 | - * @access public |
|
901 | - * @param string $msg The message to qeue. |
|
902 | - * @since 1.0.19 |
|
903 | - */ |
|
904 | - public function show_warning( $msg ) { |
|
905 | - $this->save_notice( 'warning', $msg ); |
|
906 | - } |
|
907 | - |
|
908 | - /** |
|
909 | - * Displays a info notice |
|
910 | - * |
|
911 | - * @access public |
|
912 | - * @param string $msg The message to qeue. |
|
913 | - * @since 1.0.19 |
|
914 | - */ |
|
915 | - public function show_info( $msg ) { |
|
916 | - $this->save_notice( 'info', $msg ); |
|
917 | - } |
|
918 | - |
|
919 | - /** |
|
920 | - * Show notices |
|
921 | - * |
|
922 | - * @access public |
|
923 | - * @since 1.0.19 |
|
924 | - */ |
|
925 | - public function show_notices() { |
|
842 | + */ |
|
843 | + public function has_notices() { |
|
844 | + return count( $this->get_notices() ) > 0; |
|
845 | + } |
|
846 | + |
|
847 | + /** |
|
848 | + * Clears all admin notices |
|
849 | + * |
|
850 | + * @access public |
|
851 | + * @since 1.0.19 |
|
852 | + */ |
|
853 | + public function clear_notices() { |
|
854 | + delete_option( 'wpinv_admin_notices' ); |
|
855 | + } |
|
856 | + |
|
857 | + /** |
|
858 | + * Saves a new admin notice |
|
859 | + * |
|
860 | + * @access public |
|
861 | + * @since 1.0.19 |
|
862 | + */ |
|
863 | + public function save_notice( $type, $message ) { |
|
864 | + $notices = $this->get_notices(); |
|
865 | + |
|
866 | + if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) { |
|
867 | + $notices[ $type ] = array(); |
|
868 | + } |
|
869 | + |
|
870 | + $notices[ $type ][] = $message; |
|
871 | + |
|
872 | + update_option( 'wpinv_admin_notices', $notices ); |
|
873 | + } |
|
874 | + |
|
875 | + /** |
|
876 | + * Displays a success notice |
|
877 | + * |
|
878 | + * @param string $msg The message to qeue. |
|
879 | + * @access public |
|
880 | + * @since 1.0.19 |
|
881 | + */ |
|
882 | + public function show_success( $msg ) { |
|
883 | + $this->save_notice( 'success', $msg ); |
|
884 | + } |
|
885 | + |
|
886 | + /** |
|
887 | + * Displays a error notice |
|
888 | + * |
|
889 | + * @access public |
|
890 | + * @param string $msg The message to qeue. |
|
891 | + * @since 1.0.19 |
|
892 | + */ |
|
893 | + public function show_error( $msg ) { |
|
894 | + $this->save_notice( 'error', $msg ); |
|
895 | + } |
|
896 | + |
|
897 | + /** |
|
898 | + * Displays a warning notice |
|
899 | + * |
|
900 | + * @access public |
|
901 | + * @param string $msg The message to qeue. |
|
902 | + * @since 1.0.19 |
|
903 | + */ |
|
904 | + public function show_warning( $msg ) { |
|
905 | + $this->save_notice( 'warning', $msg ); |
|
906 | + } |
|
907 | + |
|
908 | + /** |
|
909 | + * Displays a info notice |
|
910 | + * |
|
911 | + * @access public |
|
912 | + * @param string $msg The message to qeue. |
|
913 | + * @since 1.0.19 |
|
914 | + */ |
|
915 | + public function show_info( $msg ) { |
|
916 | + $this->save_notice( 'info', $msg ); |
|
917 | + } |
|
918 | + |
|
919 | + /** |
|
920 | + * Show notices |
|
921 | + * |
|
922 | + * @access public |
|
923 | + * @since 1.0.19 |
|
924 | + */ |
|
925 | + public function show_notices() { |
|
926 | 926 | |
927 | 927 | $notices = $this->get_notices(); |
928 | 928 | $this->clear_notices(); |
929 | 929 | |
930 | - foreach ( $notices as $type => $messages ) { |
|
930 | + foreach ( $notices as $type => $messages ) { |
|
931 | 931 | |
932 | - if ( ! is_array( $messages ) ) { |
|
933 | - continue; |
|
934 | - } |
|
932 | + if ( ! is_array( $messages ) ) { |
|
933 | + continue; |
|
934 | + } |
|
935 | 935 | |
936 | 936 | $type = esc_attr( $type ); |
937 | - foreach ( $messages as $message ) { |
|
938 | - echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" ); |
|
937 | + foreach ( $messages as $message ) { |
|
938 | + echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" ); |
|
939 | 939 | } |
940 | 940 | } |
941 | 941 | |
942 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
943 | - |
|
944 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
945 | - $url = wp_nonce_url( |
|
946 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
947 | - 'getpaid-nonce', |
|
948 | - 'getpaid-nonce' |
|
949 | - ); |
|
950 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
951 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
952 | - echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" ); |
|
953 | - break; |
|
954 | - } |
|
942 | + foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
943 | + |
|
944 | + if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
945 | + $url = wp_nonce_url( |
|
946 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
947 | + 'getpaid-nonce', |
|
948 | + 'getpaid-nonce' |
|
949 | + ); |
|
950 | + $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
951 | + $message2 = __( 'Generate Pages', 'invoicing' ); |
|
952 | + echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" ); |
|
953 | + break; |
|
954 | + } |
|
955 | 955 | } |
956 | 956 | |
957 | - } |
|
957 | + } |
|
958 | 958 | |
959 | 959 | } |
@@ -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 | * The main admin class. |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function __construct() { |
41 | 41 | |
42 | - $this->admin_path = plugin_dir_path( __FILE__ ); |
|
43 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
42 | + $this->admin_path = plugin_dir_path(__FILE__); |
|
43 | + $this->admin_url = plugins_url('/', __FILE__); |
|
44 | 44 | $this->reports = new GetPaid_Reports(); |
45 | 45 | |
46 | - if ( is_admin() ) { |
|
46 | + if (is_admin()) { |
|
47 | 47 | $this->init_admin_hooks(); |
48 | 48 | } |
49 | 49 | |
@@ -54,36 +54,36 @@ discard block |
||
54 | 54 | * |
55 | 55 | */ |
56 | 56 | private function init_admin_hooks() { |
57 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 ); |
|
58 | - add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
|
59 | - add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
|
60 | - add_action( 'admin_init', array( $this, 'activation_redirect' ) ); |
|
61 | - add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) ); |
|
62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
63 | - add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
64 | - add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) ); |
|
65 | - add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) ); |
|
66 | - add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) ); |
|
67 | - add_action( 'getpaid_authenticated_admin_action_refund_invoice', array( $this, 'refund_invoice' ) ); |
|
68 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
69 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
70 | - add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) ); |
|
71 | - add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
72 | - add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) ); |
|
73 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
74 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
75 | - add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
76 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
77 | - add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
78 | - add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
79 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
80 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
57 | + add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'), 9); |
|
58 | + add_filter('admin_body_class', array($this, 'admin_body_class')); |
|
59 | + add_action('admin_init', array($this, 'init_ayecode_connect_helper')); |
|
60 | + add_action('admin_init', array($this, 'activation_redirect')); |
|
61 | + add_action('admin_init', array($this, 'maybe_do_admin_action')); |
|
62 | + add_action('admin_notices', array($this, 'show_notices')); |
|
63 | + add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page')); |
|
64 | + add_action('getpaid_authenticated_admin_action_duplicate_form', array($this, 'duplicate_payment_form')); |
|
65 | + add_action('getpaid_authenticated_admin_action_reset_form_stats', array($this, 'reset_form_stats')); |
|
66 | + add_action('getpaid_authenticated_admin_action_duplicate_invoice', array($this, 'duplicate_invoice')); |
|
67 | + add_action('getpaid_authenticated_admin_action_refund_invoice', array($this, 'refund_invoice')); |
|
68 | + add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice')); |
|
69 | + add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder')); |
|
70 | + add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates')); |
|
71 | + add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages')); |
|
72 | + add_action('getpaid_authenticated_admin_action_refresh_permalinks', array($this, 'admin_refresh_permalinks')); |
|
73 | + add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables')); |
|
74 | + add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices')); |
|
75 | + add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers')); |
|
76 | + add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts')); |
|
77 | + add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin')); |
|
78 | + add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway')); |
|
79 | + add_filter('admin_footer_text', array($this, 'admin_footer_text')); |
|
80 | + do_action('getpaid_init_admin_hooks', $this); |
|
81 | 81 | |
82 | 82 | // Setup/welcome |
83 | - if ( ! empty( $_GET['page'] ) ) { |
|
84 | - switch ( sanitize_text_field( $_GET['page'] ) ) { |
|
83 | + if (!empty($_GET['page'])) { |
|
84 | + switch (sanitize_text_field($_GET['page'])) { |
|
85 | 85 | case 'gp-setup': |
86 | - include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php'; |
|
86 | + include_once dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php'; |
|
87 | 87 | break; |
88 | 88 | } |
89 | 89 | } |
@@ -97,37 +97,37 @@ discard block |
||
97 | 97 | public function enqeue_scripts() { |
98 | 98 | global $current_screen, $pagenow; |
99 | 99 | |
100 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
100 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
101 | 101 | $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
102 | 102 | |
103 | - if ( ! empty( $current_screen->post_type ) ) { |
|
103 | + if (!empty($current_screen->post_type)) { |
|
104 | 104 | $page = $current_screen->post_type; |
105 | 105 | } |
106 | 106 | |
107 | 107 | // General styles. |
108 | - if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page || false !== stripos( $page, 'geodir-tickets' ) ) { |
|
108 | + if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page || false !== stripos($page, 'geodir-tickets')) { |
|
109 | 109 | |
110 | 110 | // Styles. |
111 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
112 | - wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version ); |
|
113 | - wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' ); |
|
111 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
112 | + wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version); |
|
113 | + wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all'); |
|
114 | 114 | |
115 | 115 | // Scripts. |
116 | - wp_enqueue_script( 'select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION ); |
|
116 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION); |
|
117 | 117 | |
118 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
119 | - wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ), $version ); |
|
120 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) ); |
|
118 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
119 | + wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version); |
|
120 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18())); |
|
121 | 121 | |
122 | 122 | } |
123 | 123 | |
124 | 124 | // Payment form scripts. |
125 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
125 | + if ('wpi_payment_form' == $page && $editing) { |
|
126 | 126 | $this->load_payment_form_scripts(); |
127 | 127 | } |
128 | 128 | |
129 | - if ( $page == 'wpinv-subscriptions' ) { |
|
130 | - wp_enqueue_script( 'postbox' ); |
|
129 | + if ($page == 'wpinv-subscriptions') { |
|
130 | + wp_enqueue_script('postbox'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | } |
@@ -140,31 +140,31 @@ discard block |
||
140 | 140 | global $post; |
141 | 141 | |
142 | 142 | $date_range = array( |
143 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days', |
|
143 | + 'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days', |
|
144 | 144 | ); |
145 | 145 | |
146 | - if ( $date_range['period'] == 'custom' ) { |
|
146 | + if ($date_range['period'] == 'custom') { |
|
147 | 147 | |
148 | - if ( isset( $_GET['from'] ) ) { |
|
149 | - $date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
148 | + if (isset($_GET['from'])) { |
|
149 | + $date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS); |
|
150 | 150 | } |
151 | 151 | |
152 | - if ( isset( $_GET['to'] ) ) { |
|
153 | - $date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
152 | + if (isset($_GET['to'])) { |
|
153 | + $date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | 157 | $i18n = array( |
158 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
159 | - 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
|
160 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
161 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
162 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
158 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
159 | + 'post_ID' => isset($post->ID) ? $post->ID : '', |
|
160 | + 'wpinv_nonce' => wp_create_nonce('wpinv-nonce'), |
|
161 | + 'rest_nonce' => wp_create_nonce('wp_rest'), |
|
162 | + 'rest_root' => esc_url_raw(rest_url()), |
|
163 | 163 | 'date_range' => $date_range, |
164 | - 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
|
165 | - 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
|
166 | - 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
|
167 | - 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
|
164 | + 'add_invoice_note_nonce' => wp_create_nonce('add-invoice-note'), |
|
165 | + 'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'), |
|
166 | + 'invoice_item_nonce' => wp_create_nonce('invoice-item'), |
|
167 | + 'billing_details_nonce' => wp_create_nonce('get-billing-details'), |
|
168 | 168 | 'tax' => wpinv_tax_amount(), |
169 | 169 | 'discount' => 0, |
170 | 170 | 'currency_symbol' => wpinv_currency_symbol(), |
@@ -173,39 +173,39 @@ discard block |
||
173 | 173 | 'thousand_sep' => wpinv_thousands_separator(), |
174 | 174 | 'decimal_sep' => wpinv_decimal_separator(), |
175 | 175 | 'decimals' => wpinv_decimals(), |
176 | - 'save_invoice' => __( 'Save Invoice', 'invoicing' ), |
|
177 | - 'status_publish' => wpinv_status_nicename( 'publish' ), |
|
178 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
179 | - 'delete_tax_rate' => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ), |
|
180 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
181 | - 'FillBillingDetails' => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ), |
|
182 | - 'confirmCalcTotals' => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ), |
|
183 | - 'AreYouSure' => __( 'Are you sure?', 'invoicing' ), |
|
184 | - 'errDeleteItem' => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ), |
|
185 | - 'delete_subscription' => __( 'Are you sure you want to delete this subscription?', 'invoicing' ), |
|
186 | - 'action_edit' => __( 'Edit', 'invoicing' ), |
|
187 | - 'action_cancel' => __( 'Cancel', 'invoicing' ), |
|
188 | - 'item_description' => __( 'Item Description', 'invoicing' ), |
|
189 | - 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
|
190 | - 'discount_description' => __( 'Discount Description', 'invoicing' ), |
|
191 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
192 | - 'loading' => __( 'Loading...', 'invoicing' ), |
|
193 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
194 | - 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
195 | - 'graphs' => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ), |
|
176 | + 'save_invoice' => __('Save Invoice', 'invoicing'), |
|
177 | + 'status_publish' => wpinv_status_nicename('publish'), |
|
178 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
179 | + 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'invoicing'), |
|
180 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
181 | + 'FillBillingDetails' => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'), |
|
182 | + 'confirmCalcTotals' => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'), |
|
183 | + 'AreYouSure' => __('Are you sure?', 'invoicing'), |
|
184 | + 'errDeleteItem' => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'), |
|
185 | + 'delete_subscription' => __('Are you sure you want to delete this subscription?', 'invoicing'), |
|
186 | + 'action_edit' => __('Edit', 'invoicing'), |
|
187 | + 'action_cancel' => __('Cancel', 'invoicing'), |
|
188 | + 'item_description' => __('Item Description', 'invoicing'), |
|
189 | + 'invoice_description' => __('Invoice Description', 'invoicing'), |
|
190 | + 'discount_description' => __('Discount Description', 'invoicing'), |
|
191 | + 'searching' => __('Searching', 'invoicing'), |
|
192 | + 'loading' => __('Loading...', 'invoicing'), |
|
193 | + 'search_customers' => __('Enter customer name or email', 'invoicing'), |
|
194 | + 'search_items' => __('Enter item name', 'invoicing'), |
|
195 | + 'graphs' => array_merge(array('refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'), array_keys(wpinv_get_report_graphs())), |
|
196 | 196 | ); |
197 | 197 | |
198 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
198 | + if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) { |
|
199 | 199 | |
200 | - $invoice = new WPInv_Invoice( $post ); |
|
200 | + $invoice = new WPInv_Invoice($post); |
|
201 | 201 | $i18n['save_invoice'] = sprintf( |
202 | - __( 'Save %s', 'invoicing' ), |
|
203 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
202 | + __('Save %s', 'invoicing'), |
|
203 | + ucfirst($invoice->get_invoice_quote_type()) |
|
204 | 204 | ); |
205 | 205 | |
206 | 206 | $i18n['invoice_description'] = sprintf( |
207 | - __( '%s Description', 'invoicing' ), |
|
208 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
207 | + __('%s Description', 'invoicing'), |
|
208 | + ucfirst($invoice->get_invoice_quote_type()) |
|
209 | 209 | ); |
210 | 210 | |
211 | 211 | } |
@@ -219,24 +219,24 @@ discard block |
||
219 | 219 | * @param string $footer_text |
220 | 220 | * @return string |
221 | 221 | */ |
222 | - public function admin_footer_text( $footer_text ) { |
|
222 | + public function admin_footer_text($footer_text) { |
|
223 | 223 | global $current_screen; |
224 | 224 | |
225 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
225 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
226 | 226 | |
227 | - if ( ! empty( $current_screen->post_type ) ) { |
|
227 | + if (!empty($current_screen->post_type)) { |
|
228 | 228 | $page = $current_screen->post_type; |
229 | 229 | } |
230 | 230 | |
231 | 231 | // General styles. |
232 | - if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
|
232 | + if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) { |
|
233 | 233 | |
234 | 234 | // Change the footer text |
235 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
235 | + if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) { |
|
236 | 236 | |
237 | - $rating_url = esc_url( |
|
237 | + $rating_url = esc_url( |
|
238 | 238 | wp_nonce_url( |
239 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
239 | + admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'), |
|
240 | 240 | 'getpaid-nonce', |
241 | 241 | 'getpaid-nonce' |
242 | 242 | ) |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | $footer_text = sprintf( |
246 | 246 | /* translators: %s: five stars */ |
247 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
247 | + __('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'), |
|
248 | 248 | "<a href='$rating_url'>★★★★★</a>" |
249 | 249 | ); |
250 | 250 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | |
253 | 253 | $footer_text = sprintf( |
254 | 254 | /* translators: %s: GetPaid */ |
255 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
255 | + __('Thank you for using %s!', 'invoicing'), |
|
256 | 256 | "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
257 | 257 | ); |
258 | 258 | |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | * @since 2.0.0 |
269 | 269 | */ |
270 | 270 | public function redirect_to_wordpress_rating_page() { |
271 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
272 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
271 | + update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1); |
|
272 | + wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post'); |
|
273 | 273 | exit; |
274 | 274 | } |
275 | 275 | |
@@ -280,30 +280,30 @@ discard block |
||
280 | 280 | protected function load_payment_form_scripts() { |
281 | 281 | global $post; |
282 | 282 | |
283 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION ); |
|
284 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
285 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
283 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION); |
|
284 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
285 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
286 | 286 | |
287 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
288 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version ); |
|
287 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
288 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable', 'wp-hooks'), $version); |
|
289 | 289 | |
290 | 290 | wp_localize_script( |
291 | 291 | 'wpinv-admin-payment-form-script', |
292 | 292 | 'wpinvPaymentFormAdmin', |
293 | 293 | array( |
294 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
295 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
294 | + 'elements' => wpinv_get_data('payment-form-elements'), |
|
295 | + 'form_elements' => getpaid_get_payment_form_elements($post->ID), |
|
296 | 296 | 'currency' => wpinv_currency_symbol(), |
297 | 297 | 'position' => wpinv_currency_position(), |
298 | 298 | 'decimals' => (int) wpinv_decimals(), |
299 | 299 | 'thousands_sep' => wpinv_thousands_separator(), |
300 | 300 | 'decimals_sep' => wpinv_decimal_separator(), |
301 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
301 | + 'form_items' => gepaid_get_form_items($post->ID), |
|
302 | 302 | 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
303 | 303 | ) |
304 | 304 | ); |
305 | 305 | |
306 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
306 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
307 | 307 | |
308 | 308 | } |
309 | 309 | |
@@ -314,24 +314,24 @@ discard block |
||
314 | 314 | * @return string |
315 | 315 | * |
316 | 316 | */ |
317 | - public function admin_body_class( $classes ) { |
|
317 | + public function admin_body_class($classes) { |
|
318 | 318 | global $pagenow, $post, $current_screen; |
319 | 319 | |
320 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
320 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
321 | 321 | |
322 | - if ( ! empty( $current_screen->post_type ) ) { |
|
322 | + if (!empty($current_screen->post_type)) { |
|
323 | 323 | $page = $current_screen->post_type; |
324 | 324 | } |
325 | 325 | |
326 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
327 | - $classes .= ' wpi-' . sanitize_key( $page ); |
|
326 | + if (false !== stripos($page, 'wpi')) { |
|
327 | + $classes .= ' wpi-' . sanitize_key($page); |
|
328 | 328 | } |
329 | 329 | |
330 | - if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
|
330 | + if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) { |
|
331 | 331 | $classes .= ' wpinv-cpt wpinv'; |
332 | 332 | } |
333 | 333 | |
334 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
334 | + if (getpaid_is_invoice_post_type($page)) { |
|
335 | 335 | $classes .= ' getpaid-is-invoice-cpt'; |
336 | 336 | } |
337 | 337 | |
@@ -350,21 +350,21 @@ discard block |
||
350 | 350 | 'version' => WPINV_VERSION, |
351 | 351 | 'support_url' => 'https://wpgetpaid.com/support/', |
352 | 352 | 'documentation_url' => 'https://docs.wpgetpaid.com/', |
353 | - 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
353 | + 'activated' => (int) get_option('gepaid_installed_on'), |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | |
357 | 357 | new AyeCode_Connect_Helper( |
358 | 358 | array( |
359 | - 'connect_title' => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ), |
|
360 | - 'connect_external' => __( 'Please confirm you wish to connect your site?', 'invoicing' ), |
|
361 | - 'connect' => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ), |
|
362 | - 'connect_button' => __( 'Connect Site', 'invoicing' ), |
|
363 | - 'connecting_button' => __( 'Connecting...', 'invoicing' ), |
|
364 | - 'error_localhost' => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ), |
|
365 | - 'error' => __( 'Something went wrong, please refresh and try again.', 'invoicing' ), |
|
359 | + 'connect_title' => __('WP Invoicing - an AyeCode product!', 'invoicing'), |
|
360 | + 'connect_external' => __('Please confirm you wish to connect your site?', 'invoicing'), |
|
361 | + 'connect' => sprintf(__('<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing'), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>'), |
|
362 | + 'connect_button' => __('Connect Site', 'invoicing'), |
|
363 | + 'connecting_button' => __('Connecting...', 'invoicing'), |
|
364 | + 'error_localhost' => __('This service will only work with a live domain, not a localhost.', 'invoicing'), |
|
365 | + 'error' => __('Something went wrong, please refresh and try again.', 'invoicing'), |
|
366 | 366 | ), |
367 | - array( 'wpi-addons' ) |
|
367 | + array('wpi-addons') |
|
368 | 368 | ); |
369 | 369 | |
370 | 370 | } |
@@ -376,20 +376,20 @@ discard block |
||
376 | 376 | */ |
377 | 377 | public function activation_redirect() { |
378 | 378 | |
379 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
379 | + $redirected = get_option('wpinv_redirected_to_settings'); |
|
380 | 380 | |
381 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
381 | + if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) { |
|
382 | 382 | return; |
383 | 383 | } |
384 | 384 | |
385 | 385 | // Bail if activating from network, or bulk |
386 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
386 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
387 | 387 | return; |
388 | 388 | } |
389 | 389 | |
390 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
390 | + update_option('wpinv_redirected_to_settings', 1); |
|
391 | 391 | |
392 | - wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) ); |
|
392 | + wp_safe_redirect(admin_url('index.php?page=gp-setup')); |
|
393 | 393 | exit; |
394 | 394 | |
395 | 395 | } |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | * Fires an admin action after verifying that a user can fire them. |
399 | 399 | */ |
400 | 400 | public function maybe_do_admin_action() { |
401 | - if ( isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) && wpinv_current_user_can( sanitize_text_field( $_REQUEST['getpaid-admin-action'] ), $_REQUEST ) ) { |
|
402 | - $key = sanitize_key( $_REQUEST['getpaid-admin-action'] ); |
|
401 | + if (isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce') && wpinv_current_user_can(sanitize_text_field($_REQUEST['getpaid-admin-action']), $_REQUEST)) { |
|
402 | + $key = sanitize_key($_REQUEST['getpaid-admin-action']); |
|
403 | 403 | |
404 | - do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST ); |
|
404 | + do_action("getpaid_authenticated_admin_action_$key", $_REQUEST); |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
@@ -410,24 +410,24 @@ discard block |
||
410 | 410 | * |
411 | 411 | * @param array $args |
412 | 412 | */ |
413 | - public function duplicate_invoice( $args ) { |
|
413 | + public function duplicate_invoice($args) { |
|
414 | 414 | |
415 | - if ( empty( $args['invoice_id'] ) ) { |
|
415 | + if (empty($args['invoice_id'])) { |
|
416 | 416 | return; |
417 | 417 | } |
418 | 418 | |
419 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
419 | + $invoice = new WPInv_Invoice((int) $args['invoice_id']); |
|
420 | 420 | |
421 | - if ( ! $invoice->exists() ) { |
|
421 | + if (!$invoice->exists()) { |
|
422 | 422 | return; |
423 | 423 | } |
424 | 424 | |
425 | - $new_invoice = getpaid_duplicate_invoice( $invoice ); |
|
425 | + $new_invoice = getpaid_duplicate_invoice($invoice); |
|
426 | 426 | $new_invoice->save(); |
427 | 427 | |
428 | - if ( $new_invoice->exists() ) { |
|
428 | + if ($new_invoice->exists()) { |
|
429 | 429 | |
430 | - getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) ); |
|
430 | + getpaid_admin()->show_success(__('Invoice duplicated successfully.', 'invoicing')); |
|
431 | 431 | |
432 | 432 | wp_safe_redirect( |
433 | 433 | add_query_arg( |
@@ -435,14 +435,14 @@ discard block |
||
435 | 435 | 'action' => 'edit', |
436 | 436 | 'post' => $new_invoice->get_id(), |
437 | 437 | ), |
438 | - admin_url( 'post.php' ) |
|
438 | + admin_url('post.php') |
|
439 | 439 | ) |
440 | 440 | ); |
441 | 441 | exit; |
442 | 442 | |
443 | 443 | } |
444 | 444 | |
445 | - getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) ); |
|
445 | + getpaid_admin()->show_error(__('There was an error duplicating this invoice. Please try again.', 'invoicing')); |
|
446 | 446 | |
447 | 447 | } |
448 | 448 | |
@@ -451,40 +451,40 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @param array $args |
453 | 453 | */ |
454 | - public function refund_invoice( $args ) { |
|
454 | + public function refund_invoice($args) { |
|
455 | 455 | |
456 | - if ( empty( $args['invoice_id'] ) ) { |
|
456 | + if (empty($args['invoice_id'])) { |
|
457 | 457 | return; |
458 | 458 | } |
459 | 459 | |
460 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
460 | + $invoice = new WPInv_Invoice((int) $args['invoice_id']); |
|
461 | 461 | |
462 | - if ( ! $invoice->exists() || $invoice->is_refunded() ) { |
|
462 | + if (!$invoice->exists() || $invoice->is_refunded()) { |
|
463 | 463 | return; |
464 | 464 | } |
465 | 465 | |
466 | 466 | $invoice->refund(); |
467 | 467 | |
468 | 468 | // Refund remotely. |
469 | - if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) && ! empty( $args['getpaid_refund_remote'] ) ) { |
|
470 | - do_action( 'getpaid_refund_invoice_remotely', $invoice ); |
|
469 | + if (getpaid_payment_gateway_supports($invoice->get_gateway(), 'refunds') && !empty($args['getpaid_refund_remote'])) { |
|
470 | + do_action('getpaid_refund_invoice_remotely', $invoice); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | // Cancel subscriptions. |
474 | - if ( ! empty( $args['getpaid_cancel_subscription'] ) ) { |
|
475 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
474 | + if (!empty($args['getpaid_cancel_subscription'])) { |
|
475 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
476 | 476 | |
477 | - if ( ! empty( $subscriptions ) ) { |
|
478 | - if ( ! is_array( $subscriptions ) ) { |
|
479 | - $subscriptions = array( $subscriptions ); |
|
477 | + if (!empty($subscriptions)) { |
|
478 | + if (!is_array($subscriptions)) { |
|
479 | + $subscriptions = array($subscriptions); |
|
480 | 480 | } |
481 | 481 | |
482 | - foreach ( $subscriptions as $subscription ) { |
|
482 | + foreach ($subscriptions as $subscription) { |
|
483 | 483 | $subscription->cancel(); |
484 | 484 | $invoice->add_system_note( |
485 | 485 | sprintf( |
486 | 486 | // translators: %s: subscription ID. |
487 | - __( 'Subscription #%s cancelled', 'invoicing' ), |
|
487 | + __('Subscription #%s cancelled', 'invoicing'), |
|
488 | 488 | $subscription->get_id() |
489 | 489 | ) |
490 | 490 | ); |
@@ -493,11 +493,11 @@ discard block |
||
493 | 493 | } |
494 | 494 | |
495 | 495 | // Add notice. |
496 | - $this->show_success( __( 'Invoice refunded successfully.', 'invoicing' ) ); |
|
496 | + $this->show_success(__('Invoice refunded successfully.', 'invoicing')); |
|
497 | 497 | |
498 | 498 | // Redirect. |
499 | 499 | wp_safe_redirect( |
500 | - remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote' ) ) |
|
500 | + remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote')) |
|
501 | 501 | ); |
502 | 502 | } |
503 | 503 | |
@@ -506,34 +506,34 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @param array $args |
508 | 508 | */ |
509 | - public function duplicate_payment_form( $args ) { |
|
509 | + public function duplicate_payment_form($args) { |
|
510 | 510 | |
511 | - if ( empty( $args['form_id'] ) ) { |
|
511 | + if (empty($args['form_id'])) { |
|
512 | 512 | return; |
513 | 513 | } |
514 | 514 | |
515 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
515 | + $form = new GetPaid_Payment_Form((int) $args['form_id']); |
|
516 | 516 | |
517 | - if ( ! $form->exists() ) { |
|
517 | + if (!$form->exists()) { |
|
518 | 518 | return; |
519 | 519 | } |
520 | 520 | |
521 | 521 | $new_form = new GetPaid_Payment_Form(); |
522 | - $new_form->set_author( $form->get_author( 'edit' ) ); |
|
523 | - $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
524 | - $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
525 | - $new_form->set_items( $form->get_items( 'edit' ) ); |
|
522 | + $new_form->set_author($form->get_author('edit')); |
|
523 | + $new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing')); |
|
524 | + $new_form->set_elements($form->get_elements('edit')); |
|
525 | + $new_form->set_items($form->get_items('edit')); |
|
526 | 526 | $new_form->save(); |
527 | 527 | |
528 | - if ( $new_form->exists() ) { |
|
529 | - $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
530 | - $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
528 | + if ($new_form->exists()) { |
|
529 | + $this->show_success(__('Form duplicated successfully', 'invoicing')); |
|
530 | + $url = get_edit_post_link($new_form->get_id(), 'edit'); |
|
531 | 531 | } else { |
532 | - $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
533 | - $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
532 | + $this->show_error(__('Unable to duplicate form', 'invoicing')); |
|
533 | + $url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce')); |
|
534 | 534 | } |
535 | 535 | |
536 | - wp_redirect( $url ); |
|
536 | + wp_redirect($url); |
|
537 | 537 | exit; |
538 | 538 | } |
539 | 539 | |
@@ -542,27 +542,27 @@ discard block |
||
542 | 542 | * |
543 | 543 | * @param array $args |
544 | 544 | */ |
545 | - public function reset_form_stats( $args ) { |
|
545 | + public function reset_form_stats($args) { |
|
546 | 546 | |
547 | - if ( empty( $args['form_id'] ) ) { |
|
547 | + if (empty($args['form_id'])) { |
|
548 | 548 | return; |
549 | 549 | } |
550 | 550 | |
551 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
551 | + $form = new GetPaid_Payment_Form((int) $args['form_id']); |
|
552 | 552 | |
553 | - if ( ! $form->exists() ) { |
|
553 | + if (!$form->exists()) { |
|
554 | 554 | return; |
555 | 555 | } |
556 | 556 | |
557 | - $form->set_earned( 0 ); |
|
558 | - $form->set_refunded( 0 ); |
|
559 | - $form->set_cancelled( 0 ); |
|
560 | - $form->set_failed( 0 ); |
|
557 | + $form->set_earned(0); |
|
558 | + $form->set_refunded(0); |
|
559 | + $form->set_cancelled(0); |
|
560 | + $form->set_failed(0); |
|
561 | 561 | $form->save(); |
562 | 562 | |
563 | - $this->show_success( __( 'Form stats reset successfully', 'invoicing' ) ); |
|
563 | + $this->show_success(__('Form stats reset successfully', 'invoicing')); |
|
564 | 564 | |
565 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) ); |
|
565 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce'))); |
|
566 | 566 | exit; |
567 | 567 | } |
568 | 568 | |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | * |
572 | 572 | * @param array $args |
573 | 573 | */ |
574 | - public function send_customer_invoice( $args ) { |
|
575 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
576 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
574 | + public function send_customer_invoice($args) { |
|
575 | + getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true); |
|
576 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
577 | 577 | exit; |
578 | 578 | } |
579 | 579 | |
@@ -582,16 +582,16 @@ discard block |
||
582 | 582 | * |
583 | 583 | * @param array $args |
584 | 584 | */ |
585 | - public function send_customer_payment_reminder( $args ) { |
|
586 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
585 | + public function send_customer_payment_reminder($args) { |
|
586 | + $sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id'])); |
|
587 | 587 | |
588 | - if ( $sent ) { |
|
589 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
588 | + if ($sent) { |
|
589 | + $this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing')); |
|
590 | 590 | } else { |
591 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
591 | + $this->show_error(__('Could not sent payment reminder to the customer', 'invoicing')); |
|
592 | 592 | } |
593 | 593 | |
594 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
594 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
595 | 595 | exit; |
596 | 596 | } |
597 | 597 | |
@@ -601,8 +601,8 @@ discard block |
||
601 | 601 | */ |
602 | 602 | public function admin_reset_tax_rates() { |
603 | 603 | |
604 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
605 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
604 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
605 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
606 | 606 | exit; |
607 | 607 | |
608 | 608 | } |
@@ -614,8 +614,8 @@ discard block |
||
614 | 614 | public function admin_create_missing_pages() { |
615 | 615 | $installer = new GetPaid_Installer(); |
616 | 616 | $installer->create_pages(); |
617 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
618 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
617 | + $this->show_success(__('GetPaid pages updated.', 'invoicing')); |
|
618 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
619 | 619 | exit; |
620 | 620 | } |
621 | 621 | |
@@ -624,8 +624,8 @@ discard block |
||
624 | 624 | */ |
625 | 625 | public function admin_refresh_permalinks() { |
626 | 626 | flush_rewrite_rules(); |
627 | - $this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) ); |
|
628 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
627 | + $this->show_success(__('Permalinks refreshed.', 'invoicing')); |
|
628 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
629 | 629 | exit; |
630 | 630 | } |
631 | 631 | |
@@ -639,13 +639,13 @@ discard block |
||
639 | 639 | GetPaid_Installer::create_db_tables(); |
640 | 640 | GetPaid_Installer::migrate_old_customers(); |
641 | 641 | |
642 | - if ( '' !== $wpdb->last_error ) { |
|
643 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
642 | + if ('' !== $wpdb->last_error) { |
|
643 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
644 | 644 | } else { |
645 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
645 | + $this->show_success(__('Your GetPaid tables have been updated.', 'invoicing')); |
|
646 | 646 | } |
647 | 647 | |
648 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
648 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
649 | 649 | exit; |
650 | 650 | } |
651 | 651 | |
@@ -660,10 +660,10 @@ discard block |
||
660 | 660 | $installer->migrate_old_invoices(); |
661 | 661 | |
662 | 662 | // Show an admin message. |
663 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
663 | + $this->show_success(__('Your invoices have been migrated.', 'invoicing')); |
|
664 | 664 | |
665 | 665 | // Redirect the admin. |
666 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
666 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
667 | 667 | exit; |
668 | 668 | |
669 | 669 | } |
@@ -674,35 +674,35 @@ discard block |
||
674 | 674 | */ |
675 | 675 | public function admin_download_customers() { |
676 | 676 | |
677 | - $output = fopen( 'php://output', 'w' ); |
|
677 | + $output = fopen('php://output', 'w'); |
|
678 | 678 | |
679 | - if ( false === $output ) { |
|
680 | - wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 ); |
|
679 | + if (false === $output) { |
|
680 | + wp_die(esc_html__('Unsupported server', 'invoicing'), 500); |
|
681 | 681 | } |
682 | 682 | |
683 | - header( 'Content-Type:text/csv' ); |
|
684 | - header( 'Content-Disposition:attachment;filename=customers.csv' ); |
|
683 | + header('Content-Type:text/csv'); |
|
684 | + header('Content-Disposition:attachment;filename=customers.csv'); |
|
685 | 685 | |
686 | 686 | /** @var GetPaid_Customer[] $customers */ |
687 | - $customers = getpaid_get_customers( array( 'number' => -1 ) ); |
|
688 | - $columns = array_keys( GetPaid_Customer_Data_Store::get_database_fields() ); |
|
687 | + $customers = getpaid_get_customers(array('number' => -1)); |
|
688 | + $columns = array_keys(GetPaid_Customer_Data_Store::get_database_fields()); |
|
689 | 689 | |
690 | 690 | // Output the csv column headers. |
691 | - fputcsv( $output, $columns ); |
|
691 | + fputcsv($output, $columns); |
|
692 | 692 | |
693 | 693 | // Loop through |
694 | - foreach ( $customers as $customer ) { |
|
694 | + foreach ($customers as $customer) { |
|
695 | 695 | |
696 | - $row = array(); |
|
696 | + $row = array(); |
|
697 | 697 | |
698 | - foreach ( $columns as $column ) { |
|
699 | - $row[] = (string) maybe_serialize( $customer->get( $column, 'edit' ) ); |
|
698 | + foreach ($columns as $column) { |
|
699 | + $row[] = (string) maybe_serialize($customer->get($column, 'edit')); |
|
700 | 700 | } |
701 | 701 | |
702 | - fputcsv( $output, $row ); |
|
702 | + fputcsv($output, $row); |
|
703 | 703 | } |
704 | 704 | |
705 | - fclose( $output ); |
|
705 | + fclose($output); |
|
706 | 706 | exit; |
707 | 707 | |
708 | 708 | } |
@@ -712,27 +712,27 @@ discard block |
||
712 | 712 | * |
713 | 713 | * @param array $data |
714 | 714 | */ |
715 | - public function admin_install_plugin( $data ) { |
|
715 | + public function admin_install_plugin($data) { |
|
716 | 716 | |
717 | - if ( ! empty( $data['plugins'] ) ) { |
|
717 | + if (!empty($data['plugins'])) { |
|
718 | 718 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
719 | 719 | wp_cache_flush(); |
720 | 720 | |
721 | - foreach ( $data['plugins'] as $slug => $file ) { |
|
722 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
723 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
724 | - $installed = $upgrader->install( $plugin_zip ); |
|
721 | + foreach ($data['plugins'] as $slug => $file) { |
|
722 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip'); |
|
723 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
724 | + $installed = $upgrader->install($plugin_zip); |
|
725 | 725 | |
726 | - if ( ! is_wp_error( $installed ) && $installed ) { |
|
727 | - activate_plugin( $file, '', false, true ); |
|
726 | + if (!is_wp_error($installed) && $installed) { |
|
727 | + activate_plugin($file, '', false, true); |
|
728 | 728 | } else { |
729 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
729 | + wpinv_error_log($upgrader->skin->get_upgrade_messages(), false); |
|
730 | 730 | } |
731 | 731 | } |
732 | 732 | } |
733 | 733 | |
734 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
735 | - wp_safe_redirect( $redirect ); |
|
734 | + $redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php'); |
|
735 | + wp_safe_redirect($redirect); |
|
736 | 736 | exit; |
737 | 737 | |
738 | 738 | } |
@@ -742,41 +742,41 @@ discard block |
||
742 | 742 | * |
743 | 743 | * @param array $data |
744 | 744 | */ |
745 | - public function admin_connect_gateway( $data ) { |
|
745 | + public function admin_connect_gateway($data) { |
|
746 | 746 | |
747 | - if ( ! empty( $data['plugin'] ) ) { |
|
747 | + if (!empty($data['plugin'])) { |
|
748 | 748 | |
749 | - $gateway = sanitize_key( $data['plugin'] ); |
|
750 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
749 | + $gateway = sanitize_key($data['plugin']); |
|
750 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
751 | 751 | |
752 | - if ( ! empty( $connect_url ) ) { |
|
753 | - wp_redirect( $connect_url ); |
|
752 | + if (!empty($connect_url)) { |
|
753 | + wp_redirect($connect_url); |
|
754 | 754 | exit; |
755 | 755 | } |
756 | 756 | |
757 | - if ( 'stripe' == $data['plugin'] ) { |
|
757 | + if ('stripe' == $data['plugin']) { |
|
758 | 758 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
759 | 759 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
760 | 760 | wp_cache_flush(); |
761 | 761 | |
762 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
763 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
764 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
765 | - $upgrader->install( $plugin_zip ); |
|
762 | + if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) { |
|
763 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip'); |
|
764 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
765 | + $upgrader->install($plugin_zip); |
|
766 | 766 | } |
767 | 767 | |
768 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
768 | + activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true); |
|
769 | 769 | } |
770 | 770 | |
771 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
772 | - if ( ! empty( $connect_url ) ) { |
|
773 | - wp_redirect( $connect_url ); |
|
771 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
772 | + if (!empty($connect_url)) { |
|
773 | + wp_redirect($connect_url); |
|
774 | 774 | exit; |
775 | 775 | } |
776 | 776 | } |
777 | 777 | |
778 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
779 | - wp_safe_redirect( $redirect ); |
|
778 | + $redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
|
779 | + wp_safe_redirect($redirect); |
|
780 | 780 | exit; |
781 | 781 | |
782 | 782 | } |
@@ -790,35 +790,35 @@ discard block |
||
790 | 790 | |
791 | 791 | // Fetch all invoices that have discount codes. |
792 | 792 | $table = $wpdb->prefix . 'getpaid_invoices'; |
793 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
793 | + $invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''"); |
|
794 | 794 | |
795 | - foreach ( $invoices as $invoice ) { |
|
795 | + foreach ($invoices as $invoice) { |
|
796 | 796 | |
797 | - $invoice = new WPInv_Invoice( $invoice ); |
|
797 | + $invoice = new WPInv_Invoice($invoice); |
|
798 | 798 | |
799 | - if ( ! $invoice->exists() ) { |
|
799 | + if (!$invoice->exists()) { |
|
800 | 800 | continue; |
801 | 801 | } |
802 | 802 | |
803 | 803 | // Abort if the discount does not exist or does not apply here. |
804 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
805 | - if ( ! $discount->exists() ) { |
|
804 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
805 | + if (!$discount->exists()) { |
|
806 | 806 | continue; |
807 | 807 | } |
808 | 808 | |
809 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
809 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
810 | 810 | $invoice->recalculate_total(); |
811 | 811 | |
812 | - if ( $invoice->get_total_discount() > 0 ) { |
|
812 | + if ($invoice->get_total_discount() > 0) { |
|
813 | 813 | $invoice->save(); |
814 | 814 | } |
815 | 815 | } |
816 | 816 | |
817 | 817 | // Show an admin message. |
818 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
818 | + $this->show_success(__('Discounts have been recalculated.', 'invoicing')); |
|
819 | 819 | |
820 | 820 | // Redirect the admin. |
821 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
821 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
822 | 822 | exit; |
823 | 823 | |
824 | 824 | } |
@@ -830,8 +830,8 @@ discard block |
||
830 | 830 | * @return array |
831 | 831 | */ |
832 | 832 | public function get_notices() { |
833 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
834 | - return is_array( $notices ) ? $notices : array(); |
|
833 | + $notices = get_option('wpinv_admin_notices'); |
|
834 | + return is_array($notices) ? $notices : array(); |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | /** |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | * @return array |
842 | 842 | */ |
843 | 843 | public function has_notices() { |
844 | - return count( $this->get_notices() ) > 0; |
|
844 | + return count($this->get_notices()) > 0; |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | /** |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | * @since 1.0.19 |
852 | 852 | */ |
853 | 853 | public function clear_notices() { |
854 | - delete_option( 'wpinv_admin_notices' ); |
|
854 | + delete_option('wpinv_admin_notices'); |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | /** |
@@ -860,16 +860,16 @@ discard block |
||
860 | 860 | * @access public |
861 | 861 | * @since 1.0.19 |
862 | 862 | */ |
863 | - public function save_notice( $type, $message ) { |
|
863 | + public function save_notice($type, $message) { |
|
864 | 864 | $notices = $this->get_notices(); |
865 | 865 | |
866 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) { |
|
867 | - $notices[ $type ] = array(); |
|
866 | + if (empty($notices[$type]) || !is_array($notices[$type])) { |
|
867 | + $notices[$type] = array(); |
|
868 | 868 | } |
869 | 869 | |
870 | - $notices[ $type ][] = $message; |
|
870 | + $notices[$type][] = $message; |
|
871 | 871 | |
872 | - update_option( 'wpinv_admin_notices', $notices ); |
|
872 | + update_option('wpinv_admin_notices', $notices); |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | /** |
@@ -879,8 +879,8 @@ discard block |
||
879 | 879 | * @access public |
880 | 880 | * @since 1.0.19 |
881 | 881 | */ |
882 | - public function show_success( $msg ) { |
|
883 | - $this->save_notice( 'success', $msg ); |
|
882 | + public function show_success($msg) { |
|
883 | + $this->save_notice('success', $msg); |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | /** |
@@ -890,8 +890,8 @@ discard block |
||
890 | 890 | * @param string $msg The message to qeue. |
891 | 891 | * @since 1.0.19 |
892 | 892 | */ |
893 | - public function show_error( $msg ) { |
|
894 | - $this->save_notice( 'error', $msg ); |
|
893 | + public function show_error($msg) { |
|
894 | + $this->save_notice('error', $msg); |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | /** |
@@ -901,8 +901,8 @@ discard block |
||
901 | 901 | * @param string $msg The message to qeue. |
902 | 902 | * @since 1.0.19 |
903 | 903 | */ |
904 | - public function show_warning( $msg ) { |
|
905 | - $this->save_notice( 'warning', $msg ); |
|
904 | + public function show_warning($msg) { |
|
905 | + $this->save_notice('warning', $msg); |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | /** |
@@ -912,8 +912,8 @@ discard block |
||
912 | 912 | * @param string $msg The message to qeue. |
913 | 913 | * @since 1.0.19 |
914 | 914 | */ |
915 | - public function show_info( $msg ) { |
|
916 | - $this->save_notice( 'info', $msg ); |
|
915 | + public function show_info($msg) { |
|
916 | + $this->save_notice('info', $msg); |
|
917 | 917 | } |
918 | 918 | |
919 | 919 | /** |
@@ -927,29 +927,29 @@ discard block |
||
927 | 927 | $notices = $this->get_notices(); |
928 | 928 | $this->clear_notices(); |
929 | 929 | |
930 | - foreach ( $notices as $type => $messages ) { |
|
930 | + foreach ($notices as $type => $messages) { |
|
931 | 931 | |
932 | - if ( ! is_array( $messages ) ) { |
|
932 | + if (!is_array($messages)) { |
|
933 | 933 | continue; |
934 | 934 | } |
935 | 935 | |
936 | - $type = esc_attr( $type ); |
|
937 | - foreach ( $messages as $message ) { |
|
938 | - echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" ); |
|
936 | + $type = esc_attr($type); |
|
937 | + foreach ($messages as $message) { |
|
938 | + echo wp_kses_post("<div class='notice notice-$type is-dismissible'><p>$message</p></div>"); |
|
939 | 939 | } |
940 | 940 | } |
941 | 941 | |
942 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
942 | + foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) { |
|
943 | 943 | |
944 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
945 | - $url = wp_nonce_url( |
|
946 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
944 | + if (!is_numeric(wpinv_get_option($page, false))) { |
|
945 | + $url = wp_nonce_url( |
|
946 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
947 | 947 | 'getpaid-nonce', |
948 | 948 | 'getpaid-nonce' |
949 | 949 | ); |
950 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
951 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
952 | - echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" ); |
|
950 | + $message = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing'); |
|
951 | + $message2 = __('Generate Pages', 'invoicing'); |
|
952 | + echo wp_kses_post("<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"); |
|
953 | 953 | break; |
954 | 954 | } |
955 | 955 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | /** |
9 | 9 | * Main Subscriptions class. |
10 | 10 | * |
@@ -17,28 +17,28 @@ discard block |
||
17 | 17 | public function __construct() { |
18 | 18 | |
19 | 19 | // Fire gateway specific hooks when a subscription changes. |
20 | - add_action( 'getpaid_subscription_status_changed', array( $this, 'process_subscription_status_change' ), 10, 3 ); |
|
20 | + add_action('getpaid_subscription_status_changed', array($this, 'process_subscription_status_change'), 10, 3); |
|
21 | 21 | |
22 | 22 | // De-activate a subscription whenever the invoice changes payment statuses. |
23 | 23 | // add_action( 'getpaid_invoice_status_wpi-refunded', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
24 | - add_action( 'getpaid_invoice_status_wpi-failed', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
25 | - add_action( 'getpaid_invoice_status_wpi-cancelled', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
26 | - add_action( 'getpaid_invoice_status_wpi-pending', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
24 | + add_action('getpaid_invoice_status_wpi-failed', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
25 | + add_action('getpaid_invoice_status_wpi-cancelled', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
26 | + add_action('getpaid_invoice_status_wpi-pending', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
27 | 27 | |
28 | 28 | // Handles subscription cancelations. |
29 | - add_action( 'getpaid_authenticated_action_subscription_cancel', array( $this, 'user_cancel_single_subscription' ) ); |
|
29 | + add_action('getpaid_authenticated_action_subscription_cancel', array($this, 'user_cancel_single_subscription')); |
|
30 | 30 | |
31 | 31 | // Create a subscription whenever an invoice is created, (and update it when it is updated). |
32 | - add_action( 'wpinv_invoice_metabox_saved', array( $this, 'maybe_update_invoice_subscription' ), 5 ); |
|
33 | - add_action( 'getpaid_checkout_invoice_updated', array( $this, 'maybe_update_invoice_subscription' ), 5 ); |
|
32 | + add_action('wpinv_invoice_metabox_saved', array($this, 'maybe_update_invoice_subscription'), 5); |
|
33 | + add_action('getpaid_checkout_invoice_updated', array($this, 'maybe_update_invoice_subscription'), 5); |
|
34 | 34 | |
35 | 35 | // Handles admin subscription update actions. |
36 | - add_action( 'getpaid_authenticated_admin_action_update_single_subscription', array( $this, 'admin_update_single_subscription' ) ); |
|
37 | - add_action( 'getpaid_authenticated_admin_action_subscription_manual_renew', array( $this, 'admin_renew_single_subscription' ) ); |
|
38 | - add_action( 'getpaid_authenticated_admin_action_subscription_manual_delete', array( $this, 'admin_delete_single_subscription' ) ); |
|
36 | + add_action('getpaid_authenticated_admin_action_update_single_subscription', array($this, 'admin_update_single_subscription')); |
|
37 | + add_action('getpaid_authenticated_admin_action_subscription_manual_renew', array($this, 'admin_renew_single_subscription')); |
|
38 | + add_action('getpaid_authenticated_admin_action_subscription_manual_delete', array($this, 'admin_delete_single_subscription')); |
|
39 | 39 | |
40 | 40 | // Filter invoice item row actions. |
41 | - add_action( 'getpaid-invoice-page-line-item-actions', array( $this, 'filter_invoice_line_item_actions' ), 10, 3 ); |
|
41 | + add_action('getpaid-invoice-page-line-item-actions', array($this, 'filter_invoice_line_item_actions'), 10, 3); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | * @param WPInv_Invoice $invoice |
48 | 48 | * @return WPInv_Subscription|bool |
49 | 49 | */ |
50 | - public function get_invoice_subscription( $invoice ) { |
|
50 | + public function get_invoice_subscription($invoice) { |
|
51 | 51 | $subscription_id = $invoice->get_subscription_id(); |
52 | 52 | |
53 | 53 | // Fallback to the parent invoice if the child invoice has no subscription id. |
54 | - if ( empty( $subscription_id ) && $invoice->is_renewal() ) { |
|
54 | + if (empty($subscription_id) && $invoice->is_renewal()) { |
|
55 | 55 | $subscription_id = $invoice->get_parent_payment()->get_subscription_id(); |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Fetch the subscription. |
59 | - $subscription = new WPInv_Subscription( $subscription_id ); |
|
59 | + $subscription = new WPInv_Subscription($subscription_id); |
|
60 | 60 | |
61 | 61 | // Return subscription or use a fallback for backwards compatibility. |
62 | - return $subscription->exists() ? $subscription : wpinv_get_invoice_subscription( $invoice ); |
|
62 | + return $subscription->exists() ? $subscription : wpinv_get_invoice_subscription($invoice); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -67,21 +67,21 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @param WPInv_Invoice $invoice |
69 | 69 | */ |
70 | - public function maybe_deactivate_invoice_subscription( $invoice ) { |
|
70 | + public function maybe_deactivate_invoice_subscription($invoice) { |
|
71 | 71 | |
72 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
72 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
73 | 73 | |
74 | - if ( empty( $subscriptions ) ) { |
|
74 | + if (empty($subscriptions)) { |
|
75 | 75 | return; |
76 | 76 | } |
77 | 77 | |
78 | - if ( ! is_array( $subscriptions ) ) { |
|
79 | - $subscriptions = array( $subscriptions ); |
|
78 | + if (!is_array($subscriptions)) { |
|
79 | + $subscriptions = array($subscriptions); |
|
80 | 80 | } |
81 | 81 | |
82 | - foreach ( $subscriptions as $subscription ) { |
|
83 | - if ( $subscription->is_active() ) { |
|
84 | - $subscription->set_status( 'pending' ); |
|
82 | + foreach ($subscriptions as $subscription) { |
|
83 | + if ($subscription->is_active()) { |
|
84 | + $subscription->set_status('pending'); |
|
85 | 85 | $subscription->save(); |
86 | 86 | } |
87 | 87 | } |
@@ -95,15 +95,15 @@ discard block |
||
95 | 95 | * @param string $from |
96 | 96 | * @param string $to |
97 | 97 | */ |
98 | - public function process_subscription_status_change( $subscription, $from, $to ) { |
|
98 | + public function process_subscription_status_change($subscription, $from, $to) { |
|
99 | 99 | |
100 | 100 | $gateway = $subscription->get_gateway(); |
101 | 101 | |
102 | - if ( ! empty( $gateway ) ) { |
|
103 | - $gateway = sanitize_key( $gateway ); |
|
104 | - $from = sanitize_key( $from ); |
|
105 | - $to = sanitize_key( $to ); |
|
106 | - do_action( "getpaid_{$gateway}_subscription_$to", $subscription, $from ); |
|
102 | + if (!empty($gateway)) { |
|
103 | + $gateway = sanitize_key($gateway); |
|
104 | + $from = sanitize_key($from); |
|
105 | + $to = sanitize_key($to); |
|
106 | + do_action("getpaid_{$gateway}_subscription_$to", $subscription, $from); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | } |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * @deprecated |
117 | 117 | * @return mixed|string|void |
118 | 118 | */ |
119 | - public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1 ) { |
|
120 | - return getpaid_get_subscription_period_label( $period, $frequency_count ); |
|
119 | + public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) { |
|
120 | + return getpaid_get_subscription_period_label($period, $frequency_count); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -127,21 +127,21 @@ discard block |
||
127 | 127 | * @since 1.0.0 |
128 | 128 | * @return void |
129 | 129 | */ |
130 | - public function user_cancel_single_subscription( $data ) { |
|
130 | + public function user_cancel_single_subscription($data) { |
|
131 | 131 | |
132 | 132 | // Ensure there is a subscription to cancel. |
133 | - if ( empty( $data['subscription'] ) ) { |
|
133 | + if (empty($data['subscription'])) { |
|
134 | 134 | return; |
135 | 135 | } |
136 | 136 | |
137 | - $subscription = new WPInv_Subscription( (int) $data['subscription'] ); |
|
137 | + $subscription = new WPInv_Subscription((int) $data['subscription']); |
|
138 | 138 | |
139 | 139 | // Ensure that it exists and that it belongs to the current user. |
140 | - if ( ! $subscription->exists() || $subscription->get_customer_id() != get_current_user_id() ) { |
|
140 | + if (!$subscription->exists() || $subscription->get_customer_id() != get_current_user_id()) { |
|
141 | 141 | $notice = 'perm_cancel_subscription'; |
142 | 142 | |
143 | 143 | // Can it be cancelled. |
144 | - } elseif ( ! $subscription->can_cancel() ) { |
|
144 | + } elseif (!$subscription->can_cancel()) { |
|
145 | 145 | $notice = 'cannot_cancel_subscription'; |
146 | 146 | |
147 | 147 | // Cancel it. |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | 'wpinv-notice' => $notice, |
158 | 158 | ); |
159 | 159 | |
160 | - wp_safe_redirect( add_query_arg( $redirect ) ); |
|
160 | + wp_safe_redirect(add_query_arg($redirect)); |
|
161 | 161 | exit; |
162 | 162 | |
163 | 163 | } |
@@ -169,41 +169,41 @@ discard block |
||
169 | 169 | * @param WPInv_Invoice $invoice |
170 | 170 | * @since 1.0.0 |
171 | 171 | */ |
172 | - public function maybe_create_invoice_subscription( $invoice ) { |
|
172 | + public function maybe_create_invoice_subscription($invoice) { |
|
173 | 173 | global $getpaid_subscriptions_skip_invoice_update; |
174 | 174 | |
175 | 175 | // Abort if it is not recurring. |
176 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_free() || ! $invoice->is_recurring() || $invoice->is_renewal() ) { |
|
176 | + if (!$invoice->is_type('invoice') || $invoice->is_free() || !$invoice->is_recurring() || $invoice->is_renewal()) { |
|
177 | 177 | return; |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Either group the subscriptions or only process a single suscription. |
181 | - if ( getpaid_should_group_subscriptions( $invoice ) ) { |
|
181 | + if (getpaid_should_group_subscriptions($invoice)) { |
|
182 | 182 | |
183 | 183 | $subscription_groups = array(); |
184 | 184 | $is_first = true; |
185 | 185 | |
186 | - foreach ( getpaid_calculate_subscription_totals( $invoice ) as $group_key => $totals ) { |
|
187 | - $subscription_groups[ $group_key ] = $this->create_invoice_subscription_group( $totals, $invoice, 0, $is_first ); |
|
186 | + foreach (getpaid_calculate_subscription_totals($invoice) as $group_key => $totals) { |
|
187 | + $subscription_groups[$group_key] = $this->create_invoice_subscription_group($totals, $invoice, 0, $is_first); |
|
188 | 188 | |
189 | - if ( $is_first ) { |
|
189 | + if ($is_first) { |
|
190 | 190 | $getpaid_subscriptions_skip_invoice_update = true; |
191 | - $invoice->set_subscription_id( $subscription_groups[ $group_key ]['subscription_id'] ); |
|
191 | + $invoice->set_subscription_id($subscription_groups[$group_key]['subscription_id']); |
|
192 | 192 | $invoice->save(); |
193 | 193 | $getpaid_subscriptions_skip_invoice_update = false; |
194 | 194 | } |
195 | 195 | |
196 | - $is_first = false; |
|
196 | + $is_first = false; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | // Cache subscription groups. |
200 | - update_post_meta( $invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups ); |
|
200 | + update_post_meta($invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups); |
|
201 | 201 | return true; |
202 | 202 | |
203 | 203 | } |
204 | 204 | |
205 | 205 | $subscription = new WPInv_Subscription(); |
206 | - return $this->update_invoice_subscription( $subscription, $invoice ); |
|
206 | + return $this->update_invoice_subscription($subscription, $invoice); |
|
207 | 207 | |
208 | 208 | } |
209 | 209 | |
@@ -218,46 +218,46 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @since 2.3.0 |
220 | 220 | */ |
221 | - public function create_invoice_subscription_group( $totals, $invoice, $subscription_id = 0, $is_first = false ) { |
|
221 | + public function create_invoice_subscription_group($totals, $invoice, $subscription_id = 0, $is_first = false) { |
|
222 | 222 | |
223 | - $subscription = new WPInv_Subscription( (int) $subscription_id ); |
|
223 | + $subscription = new WPInv_Subscription((int) $subscription_id); |
|
224 | 224 | $initial_amt = $totals['initial_total']; |
225 | 225 | $recurring_amt = $totals['recurring_total']; |
226 | 226 | $fees = array(); |
227 | 227 | |
228 | 228 | // Maybe add recurring fees. |
229 | - if ( $is_first ) { |
|
229 | + if ($is_first) { |
|
230 | 230 | |
231 | - foreach ( $invoice->get_fees() as $i => $fee ) { |
|
232 | - if ( ! empty( $fee['recurring_fee'] ) ) { |
|
233 | - $initial_amt += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
234 | - $recurring_amt += wpinv_sanitize_amount( $fee['recurring_fee'] ); |
|
235 | - $fees[ $i ] = $fee; |
|
231 | + foreach ($invoice->get_fees() as $i => $fee) { |
|
232 | + if (!empty($fee['recurring_fee'])) { |
|
233 | + $initial_amt += wpinv_sanitize_amount($fee['initial_fee']); |
|
234 | + $recurring_amt += wpinv_sanitize_amount($fee['recurring_fee']); |
|
235 | + $fees[$i] = $fee; |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
240 | - $subscription->set_customer_id( $invoice->get_customer_id() ); |
|
241 | - $subscription->set_parent_invoice_id( $invoice->get_id() ); |
|
242 | - $subscription->set_initial_amount( $initial_amt ); |
|
243 | - $subscription->set_recurring_amount( $recurring_amt ); |
|
244 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
245 | - $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' ); |
|
246 | - $subscription->set_product_id( $totals['item_id'] ); |
|
247 | - $subscription->set_period( $totals['period'] ); |
|
248 | - $subscription->set_frequency( $totals['interval'] ); |
|
249 | - $subscription->set_bill_times( $totals['recurring_limit'] ); |
|
250 | - $subscription->set_next_renewal_date( $totals['renews_on'] ); |
|
240 | + $subscription->set_customer_id($invoice->get_customer_id()); |
|
241 | + $subscription->set_parent_invoice_id($invoice->get_id()); |
|
242 | + $subscription->set_initial_amount($initial_amt); |
|
243 | + $subscription->set_recurring_amount($recurring_amt); |
|
244 | + $subscription->set_date_created(current_time('mysql')); |
|
245 | + $subscription->set_status($invoice->is_paid() ? 'active' : 'pending'); |
|
246 | + $subscription->set_product_id($totals['item_id']); |
|
247 | + $subscription->set_period($totals['period']); |
|
248 | + $subscription->set_frequency($totals['interval']); |
|
249 | + $subscription->set_bill_times($totals['recurring_limit']); |
|
250 | + $subscription->set_next_renewal_date($totals['renews_on']); |
|
251 | 251 | |
252 | 252 | // Trial periods. |
253 | - if ( ! empty( $totals['trialling'] ) ) { |
|
254 | - $subscription->set_trial_period( $totals['trialling'] ); |
|
255 | - $subscription->set_status( 'trialling' ); |
|
253 | + if (!empty($totals['trialling'])) { |
|
254 | + $subscription->set_trial_period($totals['trialling']); |
|
255 | + $subscription->set_status('trialling'); |
|
256 | 256 | |
257 | 257 | // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial. |
258 | - } elseif ( empty( $initial_amt ) ) { |
|
259 | - $subscription->set_trial_period( $totals['interval'] . ' ' . $totals['period'] ); |
|
260 | - $subscription->set_status( 'trialling' ); |
|
258 | + } elseif (empty($initial_amt)) { |
|
259 | + $subscription->set_trial_period($totals['interval'] . ' ' . $totals['period']); |
|
260 | + $subscription->set_status('trialling'); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | $subscription->save(); |
@@ -275,86 +275,86 @@ discard block |
||
275 | 275 | * @param WPInv_Invoice $invoice |
276 | 276 | * @since 1.0.19 |
277 | 277 | */ |
278 | - public function maybe_update_invoice_subscription( $invoice ) { |
|
278 | + public function maybe_update_invoice_subscription($invoice) { |
|
279 | 279 | global $getpaid_subscriptions_skip_invoice_update; |
280 | 280 | |
281 | 281 | // Avoid infinite loops. |
282 | - if ( ! empty( $getpaid_subscriptions_skip_invoice_update ) ) { |
|
282 | + if (!empty($getpaid_subscriptions_skip_invoice_update)) { |
|
283 | 283 | return; |
284 | 284 | } |
285 | 285 | |
286 | 286 | // Do not process renewals. |
287 | - if ( $invoice->is_renewal() ) { |
|
287 | + if ($invoice->is_renewal()) { |
|
288 | 288 | return; |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Delete existing subscriptions if available and the invoice is not recurring. |
292 | - if ( ! $invoice->is_recurring() ) { |
|
293 | - $this->delete_invoice_subscriptions( $invoice ); |
|
292 | + if (!$invoice->is_recurring()) { |
|
293 | + $this->delete_invoice_subscriptions($invoice); |
|
294 | 294 | return; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Fetch existing subscriptions. |
298 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
298 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
299 | 299 | |
300 | 300 | // Create new ones if no existing subscriptions. |
301 | - if ( empty( $subscriptions ) ) { |
|
302 | - return $this->maybe_create_invoice_subscription( $invoice ); |
|
301 | + if (empty($subscriptions)) { |
|
302 | + return $this->maybe_create_invoice_subscription($invoice); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | // Abort if an invoice is paid and already has a subscription. |
306 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
306 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | - $is_grouped = is_array( $subscriptions ); |
|
311 | - $should_group = getpaid_should_group_subscriptions( $invoice ); |
|
310 | + $is_grouped = is_array($subscriptions); |
|
311 | + $should_group = getpaid_should_group_subscriptions($invoice); |
|
312 | 312 | |
313 | 313 | // Ensure that the subscriptions are only grouped if there are more than 1 recurring items. |
314 | - if ( $is_grouped != $should_group ) { |
|
315 | - $this->delete_invoice_subscriptions( $invoice ); |
|
316 | - delete_post_meta( $invoice->get_id(), 'getpaid_subscription_groups' ); |
|
317 | - return $this->maybe_create_invoice_subscription( $invoice ); |
|
314 | + if ($is_grouped != $should_group) { |
|
315 | + $this->delete_invoice_subscriptions($invoice); |
|
316 | + delete_post_meta($invoice->get_id(), 'getpaid_subscription_groups'); |
|
317 | + return $this->maybe_create_invoice_subscription($invoice); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | // If there is only one recurring item... |
321 | - if ( ! $is_grouped ) { |
|
322 | - return $this->update_invoice_subscription( $subscriptions, $invoice ); |
|
321 | + if (!$is_grouped) { |
|
322 | + return $this->update_invoice_subscription($subscriptions, $invoice); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | // Process subscription groups. |
326 | - $current_groups = getpaid_get_invoice_subscription_groups( $invoice->get_id() ); |
|
326 | + $current_groups = getpaid_get_invoice_subscription_groups($invoice->get_id()); |
|
327 | 327 | $subscription_groups = array(); |
328 | 328 | $is_first = true; |
329 | 329 | |
330 | 330 | // Create new subscription groups. |
331 | - foreach ( getpaid_calculate_subscription_totals( $invoice ) as $group_key => $totals ) { |
|
332 | - $subscription_id = isset( $current_groups[ $group_key ] ) ? $current_groups[ $group_key ]['subscription_id'] : 0; |
|
333 | - $subscription_groups[ $group_key ] = $this->create_invoice_subscription_group( $totals, $invoice, $subscription_id, $is_first ); |
|
331 | + foreach (getpaid_calculate_subscription_totals($invoice) as $group_key => $totals) { |
|
332 | + $subscription_id = isset($current_groups[$group_key]) ? $current_groups[$group_key]['subscription_id'] : 0; |
|
333 | + $subscription_groups[$group_key] = $this->create_invoice_subscription_group($totals, $invoice, $subscription_id, $is_first); |
|
334 | 334 | |
335 | - if ( $is_first && $invoice->get_subscription_id() !== $subscription_groups[ $group_key ]['subscription_id'] ) { |
|
335 | + if ($is_first && $invoice->get_subscription_id() !== $subscription_groups[$group_key]['subscription_id']) { |
|
336 | 336 | $getpaid_subscriptions_skip_invoice_update = true; |
337 | - $invoice->set_subscription_id( $subscription_groups[ $group_key ]['subscription_id'] ); |
|
337 | + $invoice->set_subscription_id($subscription_groups[$group_key]['subscription_id']); |
|
338 | 338 | $invoice->save(); |
339 | 339 | $getpaid_subscriptions_skip_invoice_update = false; |
340 | 340 | } |
341 | 341 | |
342 | - $is_first = false; |
|
342 | + $is_first = false; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | // Delete non-existent subscription groups. |
346 | - foreach ( $current_groups as $group_key => $data ) { |
|
347 | - if ( ! isset( $subscription_groups[ $group_key ] ) ) { |
|
348 | - $subscription = new WPInv_Subscription( (int) $data['subscription_id'] ); |
|
346 | + foreach ($current_groups as $group_key => $data) { |
|
347 | + if (!isset($subscription_groups[$group_key])) { |
|
348 | + $subscription = new WPInv_Subscription((int) $data['subscription_id']); |
|
349 | 349 | |
350 | - if ( $subscription->exists() ) { |
|
351 | - $subscription->delete( true ); |
|
350 | + if ($subscription->exists()) { |
|
351 | + $subscription->delete(true); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
356 | 356 | // Cache subscription groups. |
357 | - update_post_meta( $invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups ); |
|
357 | + update_post_meta($invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups); |
|
358 | 358 | return true; |
359 | 359 | |
360 | 360 | } |
@@ -364,20 +364,20 @@ discard block |
||
364 | 364 | * |
365 | 365 | * @param WPInv_Invoice $invoice |
366 | 366 | */ |
367 | - public function delete_invoice_subscriptions( $invoice ) { |
|
367 | + public function delete_invoice_subscriptions($invoice) { |
|
368 | 368 | |
369 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
369 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
370 | 370 | |
371 | - if ( empty( $subscriptions ) ) { |
|
371 | + if (empty($subscriptions)) { |
|
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | - if ( ! is_array( $subscriptions ) ) { |
|
376 | - $subscriptions = array( $subscriptions ); |
|
375 | + if (!is_array($subscriptions)) { |
|
376 | + $subscriptions = array($subscriptions); |
|
377 | 377 | } |
378 | 378 | |
379 | - foreach ( $subscriptions as $subscription ) { |
|
380 | - $subscription->delete( true ); |
|
379 | + foreach ($subscriptions as $subscription) { |
|
380 | + $subscription->delete(true); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | } |
@@ -390,57 +390,57 @@ discard block |
||
390 | 390 | * @param WPInv_Invoice $invoice |
391 | 391 | * @since 1.0.19 |
392 | 392 | */ |
393 | - public function update_invoice_subscription( $subscription, $invoice ) { |
|
393 | + public function update_invoice_subscription($subscription, $invoice) { |
|
394 | 394 | |
395 | 395 | // Delete the subscription if an invoice is free or nolonger recurring. |
396 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_free() || ! $invoice->is_recurring() ) { |
|
396 | + if (!$invoice->is_type('invoice') || $invoice->is_free() || !$invoice->is_recurring()) { |
|
397 | 397 | return $subscription->delete(); |
398 | 398 | } |
399 | 399 | |
400 | - $subscription->set_customer_id( $invoice->get_customer_id() ); |
|
401 | - $subscription->set_parent_invoice_id( $invoice->get_id() ); |
|
402 | - $subscription->set_initial_amount( $invoice->get_initial_total() ); |
|
403 | - $subscription->set_recurring_amount( $invoice->get_recurring_total() ); |
|
404 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
405 | - $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' ); |
|
400 | + $subscription->set_customer_id($invoice->get_customer_id()); |
|
401 | + $subscription->set_parent_invoice_id($invoice->get_id()); |
|
402 | + $subscription->set_initial_amount($invoice->get_initial_total()); |
|
403 | + $subscription->set_recurring_amount($invoice->get_recurring_total()); |
|
404 | + $subscription->set_date_created(current_time('mysql')); |
|
405 | + $subscription->set_status($invoice->is_paid() ? 'active' : 'pending'); |
|
406 | 406 | |
407 | 407 | // Get the recurring item and abort if it does not exist. |
408 | - $subscription_item = $invoice->get_recurring( true ); |
|
409 | - if ( ! $subscription_item->get_id() ) { |
|
410 | - $invoice->set_subscription_id( 0 ); |
|
408 | + $subscription_item = $invoice->get_recurring(true); |
|
409 | + if (!$subscription_item->get_id()) { |
|
410 | + $invoice->set_subscription_id(0); |
|
411 | 411 | $invoice->save(); |
412 | 412 | return $subscription->delete(); |
413 | 413 | } |
414 | 414 | |
415 | - $subscription->set_product_id( $subscription_item->get_id() ); |
|
416 | - $subscription->set_period( $subscription_item->get_recurring_period( true ) ); |
|
417 | - $subscription->set_frequency( $subscription_item->get_recurring_interval() ); |
|
418 | - $subscription->set_bill_times( $subscription_item->get_recurring_limit() ); |
|
415 | + $subscription->set_product_id($subscription_item->get_id()); |
|
416 | + $subscription->set_period($subscription_item->get_recurring_period(true)); |
|
417 | + $subscription->set_frequency($subscription_item->get_recurring_interval()); |
|
418 | + $subscription->set_bill_times($subscription_item->get_recurring_limit()); |
|
419 | 419 | |
420 | 420 | // Calculate the next renewal date. |
421 | - $period = $subscription_item->get_recurring_period( true ); |
|
421 | + $period = $subscription_item->get_recurring_period(true); |
|
422 | 422 | $interval = $subscription_item->get_recurring_interval(); |
423 | 423 | |
424 | 424 | // If the subscription item has a trial period... |
425 | - if ( $subscription_item->has_free_trial() ) { |
|
426 | - $period = $subscription_item->get_trial_period( true ); |
|
425 | + if ($subscription_item->has_free_trial()) { |
|
426 | + $period = $subscription_item->get_trial_period(true); |
|
427 | 427 | $interval = $subscription_item->get_trial_interval(); |
428 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
429 | - $subscription->set_status( 'trialling' ); |
|
428 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
429 | + $subscription->set_status('trialling'); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial. |
433 | - if ( $invoice->has_free_trial() ) { |
|
434 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
435 | - $subscription->set_status( 'trialling' ); |
|
433 | + if ($invoice->has_free_trial()) { |
|
434 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
435 | + $subscription->set_status('trialling'); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | // Calculate the next renewal date. |
439 | - $expiration = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", strtotime( $subscription->get_date_created() ) ) ); |
|
439 | + $expiration = date('Y-m-d H:i:s', strtotime("+$interval $period", strtotime($subscription->get_date_created()))); |
|
440 | 440 | |
441 | - $subscription->set_next_renewal_date( $expiration ); |
|
441 | + $subscription->set_next_renewal_date($expiration); |
|
442 | 442 | $subscription->save(); |
443 | - $invoice->set_subscription_id( $subscription->get_id() ); |
|
443 | + $invoice->set_subscription_id($subscription->get_id()); |
|
444 | 444 | return $subscription->get_id(); |
445 | 445 | |
446 | 446 | } |
@@ -451,34 +451,34 @@ discard block |
||
451 | 451 | * @param array $data |
452 | 452 | * @since 1.0.19 |
453 | 453 | */ |
454 | - public function admin_update_single_subscription( $args ) { |
|
454 | + public function admin_update_single_subscription($args) { |
|
455 | 455 | |
456 | 456 | // Ensure the subscription exists and that a status has been given. |
457 | - if ( empty( $args['subscription_id'] ) ) { |
|
457 | + if (empty($args['subscription_id'])) { |
|
458 | 458 | return; |
459 | 459 | } |
460 | 460 | |
461 | 461 | // Retrieve the subscriptions. |
462 | - $subscription = new WPInv_Subscription( $args['subscription_id'] ); |
|
462 | + $subscription = new WPInv_Subscription($args['subscription_id']); |
|
463 | 463 | |
464 | - if ( $subscription->get_id() ) { |
|
464 | + if ($subscription->get_id()) { |
|
465 | 465 | |
466 | 466 | $subscription->set_props( |
467 | 467 | array( |
468 | - 'status' => isset( $args['subscription_status'] ) ? $args['subscription_status'] : null, |
|
469 | - 'profile_id' => isset( $args['wpinv_subscription_profile_id'] ) ? $args['wpinv_subscription_profile_id'] : null, |
|
470 | - 'date_created' => ! empty( $args['wpinv_subscription_date_created'] ) ? $args['wpinv_subscription_date_created'] : null, |
|
471 | - 'expiration' => ! empty( $args['wpinv_subscription_expiration'] ) ? $args['wpinv_subscription_expiration'] : null, |
|
472 | - 'bill_times' => ! empty( $args['wpinv_subscription_max_bill_times'] ) ? $args['wpinv_subscription_max_bill_times'] : null, |
|
468 | + 'status' => isset($args['subscription_status']) ? $args['subscription_status'] : null, |
|
469 | + 'profile_id' => isset($args['wpinv_subscription_profile_id']) ? $args['wpinv_subscription_profile_id'] : null, |
|
470 | + 'date_created' => !empty($args['wpinv_subscription_date_created']) ? $args['wpinv_subscription_date_created'] : null, |
|
471 | + 'expiration' => !empty($args['wpinv_subscription_expiration']) ? $args['wpinv_subscription_expiration'] : null, |
|
472 | + 'bill_times' => !empty($args['wpinv_subscription_max_bill_times']) ? $args['wpinv_subscription_max_bill_times'] : null, |
|
473 | 473 | ) |
474 | 474 | ); |
475 | 475 | |
476 | 476 | $changes = $subscription->get_changes(); |
477 | 477 | |
478 | 478 | $subscription->save(); |
479 | - getpaid_admin()->show_info( __( 'Subscription updated', 'invoicing' ) ); |
|
479 | + getpaid_admin()->show_info(__('Subscription updated', 'invoicing')); |
|
480 | 480 | |
481 | - do_action( 'getpaid_admin_updated_subscription', $subscription, $args, $changes ); |
|
481 | + do_action('getpaid_admin_updated_subscription', $subscription, $args, $changes); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | } |
@@ -489,27 +489,27 @@ discard block |
||
489 | 489 | * @param array $data |
490 | 490 | * @since 1.0.19 |
491 | 491 | */ |
492 | - public function admin_renew_single_subscription( $args ) { |
|
492 | + public function admin_renew_single_subscription($args) { |
|
493 | 493 | |
494 | 494 | // Ensure the subscription exists and that a status has been given. |
495 | - if ( empty( $args['id'] ) ) { |
|
495 | + if (empty($args['id'])) { |
|
496 | 496 | return; |
497 | 497 | } |
498 | 498 | |
499 | 499 | // Retrieve the subscriptions. |
500 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
500 | + $subscription = new WPInv_Subscription($args['id']); |
|
501 | 501 | |
502 | - if ( $subscription->get_id() ) { |
|
502 | + if ($subscription->get_id()) { |
|
503 | 503 | |
504 | - do_action( 'getpaid_admin_renew_subscription', $subscription ); |
|
504 | + do_action('getpaid_admin_renew_subscription', $subscription); |
|
505 | 505 | |
506 | - $args = array( 'transaction_id', $subscription->get_parent_invoice()->generate_key( 'renewal_' ) ); |
|
506 | + $args = array('transaction_id', $subscription->get_parent_invoice()->generate_key('renewal_')); |
|
507 | 507 | |
508 | - if ( ! $subscription->add_payment( $args ) ) { |
|
509 | - getpaid_admin()->show_error( __( 'We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing' ) ); |
|
508 | + if (!$subscription->add_payment($args)) { |
|
509 | + getpaid_admin()->show_error(__('We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing')); |
|
510 | 510 | } else { |
511 | 511 | $subscription->renew(); |
512 | - getpaid_admin()->show_info( __( 'This subscription has been renewed and extended.', 'invoicing' ) ); |
|
512 | + getpaid_admin()->show_info(__('This subscription has been renewed and extended.', 'invoicing')); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | wp_safe_redirect( |
@@ -532,20 +532,20 @@ discard block |
||
532 | 532 | * @param array $data |
533 | 533 | * @since 1.0.19 |
534 | 534 | */ |
535 | - public function admin_delete_single_subscription( $args ) { |
|
535 | + public function admin_delete_single_subscription($args) { |
|
536 | 536 | |
537 | 537 | // Ensure the subscription exists and that a status has been given. |
538 | - if ( empty( $args['id'] ) ) { |
|
538 | + if (empty($args['id'])) { |
|
539 | 539 | return; |
540 | 540 | } |
541 | 541 | |
542 | 542 | // Retrieve the subscriptions. |
543 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
543 | + $subscription = new WPInv_Subscription($args['id']); |
|
544 | 544 | |
545 | - if ( $subscription->delete() ) { |
|
546 | - getpaid_admin()->show_info( __( 'This subscription has been deleted.', 'invoicing' ) ); |
|
545 | + if ($subscription->delete()) { |
|
546 | + getpaid_admin()->show_info(__('This subscription has been deleted.', 'invoicing')); |
|
547 | 547 | } else { |
548 | - getpaid_admin()->show_error( __( 'We are unable to delete this subscription. Please try again.', 'invoicing' ) ); |
|
548 | + getpaid_admin()->show_error(__('We are unable to delete this subscription. Please try again.', 'invoicing')); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | $redirected = wp_safe_redirect( |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | ) |
559 | 559 | ); |
560 | 560 | |
561 | - if ( $redirected ) { |
|
561 | + if ($redirected) { |
|
562 | 562 | exit; |
563 | 563 | } |
564 | 564 | |
@@ -571,16 +571,16 @@ discard block |
||
571 | 571 | * @param WPInv_Item $item |
572 | 572 | * @param WPInv_Invoice $invoice |
573 | 573 | */ |
574 | - public function filter_invoice_line_item_actions( $actions, $item, $invoice ) { |
|
574 | + public function filter_invoice_line_item_actions($actions, $item, $invoice) { |
|
575 | 575 | |
576 | 576 | // Abort if this invoice uses subscription groups. |
577 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
578 | - if ( ! $invoice->is_recurring() || ! is_object( $subscriptions ) ) { |
|
577 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
578 | + if (!$invoice->is_recurring() || !is_object($subscriptions)) { |
|
579 | 579 | return $actions; |
580 | 580 | } |
581 | 581 | |
582 | 582 | // Fetch item subscription. |
583 | - $args = array( |
|
583 | + $args = array( |
|
584 | 584 | 'invoice_in' => $invoice->is_parent() ? $invoice->get_id() : $invoice->get_parent_id(), |
585 | 585 | 'product_in' => $item->get_id(), |
586 | 586 | 'number' => 1, |
@@ -588,13 +588,13 @@ discard block |
||
588 | 588 | 'fields' => 'id', |
589 | 589 | ); |
590 | 590 | |
591 | - $subscription = new GetPaid_Subscriptions_Query( $args ); |
|
591 | + $subscription = new GetPaid_Subscriptions_Query($args); |
|
592 | 592 | $subscription = $subscription->get_results(); |
593 | 593 | |
594 | 594 | // In case we found a match... |
595 | - if ( ! empty( $subscription ) ) { |
|
596 | - $url = esc_url( add_query_arg( 'subscription', (int) $subscription[0], get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); |
|
597 | - $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
595 | + if (!empty($subscription)) { |
|
596 | + $url = esc_url(add_query_arg('subscription', (int) $subscription[0], get_permalink((int) wpinv_get_option('invoice_subscription_page')))); |
|
597 | + $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __('Manage Subscription', 'invoicing') . '</a>'; |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | return $actions; |