@@ -7,22 +7,22 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Totals rows. |
13 | -$totals = getpaid_invoice_totals_rows( $invoice ); |
|
13 | +$totals = getpaid_invoice_totals_rows($invoice); |
|
14 | 14 | |
15 | -do_action( 'getpaid_before_email_line_totals', $invoice, $totals ); |
|
15 | +do_action('getpaid_before_email_line_totals', $invoice, $totals); |
|
16 | 16 | |
17 | 17 | ?> |
18 | 18 | |
19 | 19 | |
20 | -<?php if ( has_action( 'wpinv_email_footer_buttons' ) ) : ?> |
|
20 | +<?php if (has_action('wpinv_email_footer_buttons')) : ?> |
|
21 | 21 | |
22 | 22 | <tr class="wpinv_cart_footer_row"> |
23 | 23 | |
24 | - <td colspan="<?php echo ( (int) $column_count ); ?>"> |
|
25 | - <?php do_action( 'wpinv_email_footer_buttons' ); ?> |
|
24 | + <td colspan="<?php echo ((int) $column_count); ?>"> |
|
25 | + <?php do_action('wpinv_email_footer_buttons'); ?> |
|
26 | 26 | </td> |
27 | 27 | |
28 | 28 | </tr> |
@@ -30,40 +30,40 @@ discard block |
||
30 | 30 | <?php endif; ?> |
31 | 31 | |
32 | 32 | |
33 | -<?php foreach ( $totals as $key => $label ) : ?> |
|
33 | +<?php foreach ($totals as $key => $label) : ?> |
|
34 | 34 | |
35 | - <tr class="wpinv_cart_footer_row wpinv_cart_<?php echo sanitize_html_class( $key ); ?>_row"> |
|
35 | + <tr class="wpinv_cart_footer_row wpinv_cart_<?php echo sanitize_html_class($key); ?>_row"> |
|
36 | 36 | |
37 | - <td colspan="<?php echo ( $column_count - 1 ); ?>" class="wpinv_cart_<?php echo sanitize_html_class( $key ); ?>_label text-right"> |
|
38 | - <strong><?php echo sanitize_text_field( $label ); ?>:</strong> |
|
37 | + <td colspan="<?php echo ($column_count - 1); ?>" class="wpinv_cart_<?php echo sanitize_html_class($key); ?>_label text-right"> |
|
38 | + <strong><?php echo sanitize_text_field($label); ?>:</strong> |
|
39 | 39 | </td> |
40 | 40 | |
41 | - <td class="wpinv_cart_<?php echo sanitize_html_class( $key ); ?> text-right"> |
|
41 | + <td class="wpinv_cart_<?php echo sanitize_html_class($key); ?> text-right"> |
|
42 | 42 | |
43 | 43 | <?php |
44 | 44 | |
45 | 45 | // Total tax. |
46 | - if ( 'tax' == $key ) { |
|
47 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ); |
|
46 | + if ('tax' == $key) { |
|
47 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // Total discount. |
51 | - if ( 'discount' == $key ) { |
|
52 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ); |
|
51 | + if ('discount' == $key) { |
|
52 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | // Sub total. |
56 | - if ( 'subtotal' == $key ) { |
|
57 | - echo wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ); |
|
56 | + if ('subtotal' == $key) { |
|
57 | + echo wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // Total. |
61 | - if ( 'total' == $key ) { |
|
62 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); |
|
61 | + if ('total' == $key) { |
|
62 | + echo wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Fires when printing a cart total in an email. |
66 | - do_action( "getpaid_email_cart_totals_$key", $invoice ); |
|
66 | + do_action("getpaid_email_cart_totals_$key", $invoice); |
|
67 | 67 | |
68 | 68 | ?> |
69 | 69 | |
@@ -75,4 +75,4 @@ discard block |
||
75 | 75 | |
76 | 76 | <?php |
77 | 77 | |
78 | - do_action( 'getpaid_after_email_line_totals', $invoice, $totals ); |
|
78 | + do_action('getpaid_after_email_line_totals', $invoice, $totals); |
@@ -7,63 +7,63 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | -<?php do_action( 'getpaid_before_email_line_item', $invoice, $item ); ?> |
|
14 | +<?php do_action('getpaid_before_email_line_item', $invoice, $item); ?> |
|
15 | 15 | |
16 | -<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class( $item->get_type() ); ?>"> |
|
16 | +<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class($item->get_type()); ?>"> |
|
17 | 17 | |
18 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
18 | + <?php foreach (array_keys($columns) as $column): ?> |
|
19 | 19 | |
20 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>"> |
|
20 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>"> |
|
21 | 21 | |
22 | 22 | <?php |
23 | 23 | |
24 | 24 | // Fires before printing a line item column. |
25 | - do_action( "getpaid_email_line_item_before_$column", $item, $invoice ); |
|
25 | + do_action("getpaid_email_line_item_before_$column", $item, $invoice); |
|
26 | 26 | |
27 | 27 | // Item name. |
28 | - if ( 'name' == $column ) { |
|
28 | + if ('name' == $column) { |
|
29 | 29 | |
30 | 30 | // Display the name. |
31 | - echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
31 | + echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($item->get_name()) . '</div>'; |
|
32 | 32 | |
33 | 33 | // And an optional description. |
34 | 34 | $description = $item->get_description(); |
35 | 35 | |
36 | - if ( ! empty( $description ) ) { |
|
37 | - $description = wp_kses_post( $description ); |
|
36 | + if (!empty($description)) { |
|
37 | + $description = wp_kses_post($description); |
|
38 | 38 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
39 | 39 | } |
40 | 40 | |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Item price. |
44 | - if ( 'price' == $column ) { |
|
44 | + if ('price' == $column) { |
|
45 | 45 | |
46 | 46 | // Display the item price (or recurring price if this is a renewal invoice) |
47 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
48 | - echo wpinv_price( wpinv_format_amount( $item->get_price() ), $invoice->get_currency() ); |
|
47 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
48 | + echo wpinv_price(wpinv_format_amount($item->get_price()), $invoice->get_currency()); |
|
49 | 49 | } else { |
50 | - echo wpinv_price( wpinv_format_amount( $item->get_initial_price() ), $invoice->get_currency() ); |
|
50 | + echo wpinv_price(wpinv_format_amount($item->get_initial_price()), $invoice->get_currency()); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Item quantity. |
56 | - if ( 'quantity' == $column ) { |
|
56 | + if ('quantity' == $column) { |
|
57 | 57 | echo (int) $item->get_qantity(); |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Item sub total. |
61 | - if ( 'subtotal' == $column ) { |
|
62 | - echo wpinv_price( wpinv_format_amount( $item->get_sub_total() ), $invoice->get_currency() ); |
|
61 | + if ('subtotal' == $column) { |
|
62 | + echo wpinv_price(wpinv_format_amount($item->get_sub_total()), $invoice->get_currency()); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Fires when printing a line item column. |
66 | - do_action( "getpaid_email_line_item_$column", $item, $invoice ); |
|
66 | + do_action("getpaid_email_line_item_$column", $item, $invoice); |
|
67 | 67 | |
68 | 68 | ?> |
69 | 69 | |
@@ -73,4 +73,4 @@ discard block |
||
73 | 73 | |
74 | 74 | </tr> |
75 | 75 | |
76 | -<?php do_action( 'getpaid_after_email_line_item', $invoice, $item ); ?> |
|
76 | +<?php do_action('getpaid_after_email_line_item', $invoice, $item); ?> |
@@ -2,12 +2,12 @@ discard block |
||
2 | 2 | global $wpi_invoice; |
3 | 3 | |
4 | 4 | // Backwards compatibility. |
5 | -if ( empty( $invoice ) ) { |
|
5 | +if (empty($invoice)) { |
|
6 | 6 | $invoice = $wpi_invoice; |
7 | 7 | } |
8 | 8 | |
9 | 9 | $success_page_uri = wpinv_get_success_page_uri(); |
10 | -if ( !empty( $wpi_invoice ) ) { |
|
10 | +if (!empty($wpi_invoice)) { |
|
11 | 11 | $success_page_uri = $invoice->get_receipt_url(); |
12 | 12 | } |
13 | 13 | ?> |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | <?php |
18 | 18 | echo |
19 | 19 | wp_sprintf( |
20 | - __( 'Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing' ), |
|
20 | + __('Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing'), |
|
21 | 21 | $success_page_uri |
22 | 22 | ); |
23 | 23 | ?> |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | <script type="text/javascript"> |
28 | 28 | setTimeout( |
29 | 29 | function(){ |
30 | - window.location = '<?php echo esc_url( $success_page_uri ); ?>'; |
|
30 | + window.location = '<?php echo esc_url($success_page_uri); ?>'; |
|
31 | 31 | }, |
32 | 32 | 10000 |
33 | 33 | ); |
@@ -8,26 +8,26 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | // Totals rows. |
14 | -$totals = getpaid_invoice_totals_rows( $invoice ); |
|
14 | +$totals = getpaid_invoice_totals_rows($invoice); |
|
15 | 15 | |
16 | -do_action( 'getpaid_before_invoice_line_totals', $invoice, $totals ); |
|
16 | +do_action('getpaid_before_invoice_line_totals', $invoice, $totals); |
|
17 | 17 | |
18 | 18 | ?> |
19 | 19 | <div class='border-top getpaid-invoice-line-totals'> |
20 | 20 | <div class="row"> |
21 | 21 | <div class="col-12 offset-sm-6 col-sm-6 border-left pl-0"> |
22 | 22 | |
23 | - <?php foreach ( $totals as $key => $label ) : ?> |
|
23 | + <?php foreach ($totals as $key => $label) : ?> |
|
24 | 24 | |
25 | - <div class="getpaid-invoice-line-totals-col <?php echo sanitize_html_class( $key ); ?>"> |
|
25 | + <div class="getpaid-invoice-line-totals-col <?php echo sanitize_html_class($key); ?>"> |
|
26 | 26 | |
27 | 27 | <div class="row"> |
28 | 28 | |
29 | 29 | <div class="col-12 col-sm-8 getpaid-invoice-line-totals-label"> |
30 | - <?php echo sanitize_text_field( $label ); ?> |
|
30 | + <?php echo sanitize_text_field($label); ?> |
|
31 | 31 | </div> |
32 | 32 | |
33 | 33 | <div class="col-12 col-sm-2 getpaid-invoice-line-totals-value"> |
@@ -35,27 +35,27 @@ discard block |
||
35 | 35 | <?php |
36 | 36 | |
37 | 37 | // Total tax. |
38 | - if ( 'tax' == $key ) { |
|
39 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ); |
|
38 | + if ('tax' == $key) { |
|
39 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | // Total discount. |
43 | - if ( 'discount' == $key ) { |
|
44 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ); |
|
43 | + if ('discount' == $key) { |
|
44 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | // Sub total. |
48 | - if ( 'subtotal' == $key ) { |
|
49 | - echo wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ); |
|
48 | + if ('subtotal' == $key) { |
|
49 | + echo wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | // Total. |
53 | - if ( 'total' == $key ) { |
|
54 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); |
|
53 | + if ('total' == $key) { |
|
54 | + echo wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // Fires when printing a cart total. |
58 | - do_action( "getpaid_invoice_cart_totals_$key", $invoice ); |
|
58 | + do_action("getpaid_invoice_cart_totals_$key", $invoice); |
|
59 | 59 | |
60 | 60 | ?> |
61 | 61 | |
@@ -69,4 +69,4 @@ discard block |
||
69 | 69 | </div> |
70 | 70 | </div> <!-- end .getpaid-invoice-line-totals --> |
71 | 71 | |
72 | -<?php do_action( 'getpaid_after_invoice_line_totals', $invoice, $totals ); ?> |
|
72 | +<?php do_action('getpaid_after_invoice_line_totals', $invoice, $totals); ?> |
@@ -7,35 +7,35 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div class="getpaid-header-right-actions"> |
15 | 15 | |
16 | - <?php if ( $invoice->is_type( 'invoice' ) ) : ?> |
|
16 | + <?php if ($invoice->is_type('invoice')) : ?> |
|
17 | 17 | |
18 | 18 | <a class="btn btn-secondary invoice-action-print" onclick="window.print();" href="javascript:void(0)"> |
19 | - <?php _e( 'Print Invoice', 'invoicing' ); ?> |
|
19 | + <?php _e('Print Invoice', 'invoicing'); ?> |
|
20 | 20 | </a> |
21 | 21 | |
22 | - <?php if ( is_user_logged_in() ) : ?> |
|
22 | + <?php if (is_user_logged_in()) : ?> |
|
23 | 23 | |
24 | - <a class="btn btn-secondary invoice-action-history" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"> |
|
25 | - <?php _e( 'Invoice History', 'invoicing' ); ?> |
|
24 | + <a class="btn btn-secondary invoice-action-history" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"> |
|
25 | + <?php _e('Invoice History', 'invoicing'); ?> |
|
26 | 26 | </a> |
27 | 27 | <?php endif; ?> |
28 | 28 | |
29 | - <?php if ( wpinv_current_user_can_manage_invoicing() ) : ?> |
|
29 | + <?php if (wpinv_current_user_can_manage_invoicing()) : ?> |
|
30 | 30 | |
31 | - <a class="btn btn-secondary invoice-action-edit" href="<?php echo esc_url( get_edit_post_link( $invoice->get_id() ) ); ?>"> |
|
32 | - <?php _e( 'Edit Invoice', 'invoicing' ); ?> |
|
31 | + <a class="btn btn-secondary invoice-action-edit" href="<?php echo esc_url(get_edit_post_link($invoice->get_id())); ?>"> |
|
32 | + <?php _e('Edit Invoice', 'invoicing'); ?> |
|
33 | 33 | </a> |
34 | 34 | <?php endif; ?> |
35 | 35 | |
36 | 36 | <?php endif; ?> |
37 | 37 | |
38 | - <?php do_action('wpinv_invoice_display_right_actions', $invoice ); ?> |
|
38 | + <?php do_action('wpinv_invoice_display_right_actions', $invoice); ?> |
|
39 | 39 | </div> |
40 | 40 | |
41 | 41 | <?php |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @deprecated |
247 | 247 | */ |
248 | 248 | function wpinv_get_payment_key( $invoice = 0 ) { |
249 | - $invoice = new WPInv_Invoice( $invoice ); |
|
249 | + $invoice = new WPInv_Invoice( $invoice ); |
|
250 | 250 | return $invoice->get_key(); |
251 | 251 | } |
252 | 252 | |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @deprecated |
425 | 425 | */ |
426 | 426 | function wpinv_get_checkout_session() { |
427 | - return false; |
|
427 | + return false; |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | /** |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @deprecated |
@@ -19,48 +19,48 @@ discard block |
||
19 | 19 | * @deprecated |
20 | 20 | */ |
21 | 21 | function wpinv_get_invoice_cart() { |
22 | - return wpinv_get_invoice( getpaid_get_current_invoice_id() ); |
|
22 | + return wpinv_get_invoice(getpaid_get_current_invoice_id()); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @deprecated |
27 | 27 | */ |
28 | -function wpinv_get_invoice_description( $invoice ) { |
|
29 | - $invoice = new WPInv_Invoice( $invoice ); |
|
28 | +function wpinv_get_invoice_description($invoice) { |
|
29 | + $invoice = new WPInv_Invoice($invoice); |
|
30 | 30 | return $invoice->get_description(); |
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @deprecated |
35 | 35 | */ |
36 | -function wpinv_get_invoice_currency_code( $invoice ) { |
|
37 | - $invoice = new WPInv_Invoice( $invoice ); |
|
36 | +function wpinv_get_invoice_currency_code($invoice) { |
|
37 | + $invoice = new WPInv_Invoice($invoice); |
|
38 | 38 | return $invoice->get_currency(); |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @deprecated |
43 | 43 | */ |
44 | -function wpinv_get_payment_user_email( $invoice ) { |
|
45 | - $invoice = new WPInv_Invoice( $invoice ); |
|
44 | +function wpinv_get_payment_user_email($invoice) { |
|
45 | + $invoice = new WPInv_Invoice($invoice); |
|
46 | 46 | return $invoice->get_email(); |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @deprecated |
51 | 51 | */ |
52 | -function wpinv_get_user_id( $invoice ) { |
|
53 | - $invoice = new WPInv_Invoice( $invoice ); |
|
52 | +function wpinv_get_user_id($invoice) { |
|
53 | + $invoice = new WPInv_Invoice($invoice); |
|
54 | 54 | return $invoice->get_user_id(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @deprecated |
59 | 59 | */ |
60 | -function wpinv_get_invoice_status( $invoice, $return_label = false ) { |
|
61 | - $invoice = new WPInv_Invoice( $invoice ); |
|
60 | +function wpinv_get_invoice_status($invoice, $return_label = false) { |
|
61 | + $invoice = new WPInv_Invoice($invoice); |
|
62 | 62 | |
63 | - if ( $return_label ) { |
|
63 | + if ($return_label) { |
|
64 | 64 | return $invoice->get_status_nicename(); |
65 | 65 | } |
66 | 66 | |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * @deprecated |
72 | 72 | */ |
73 | -function wpinv_get_payment_gateway( $invoice, $return_label = false ) { |
|
74 | - $invoice = new WPInv_Invoice( $invoice ); |
|
73 | +function wpinv_get_payment_gateway($invoice, $return_label = false) { |
|
74 | + $invoice = new WPInv_Invoice($invoice); |
|
75 | 75 | |
76 | - if ( $return_label ) { |
|
76 | + if ($return_label) { |
|
77 | 77 | return $invoice->get_gateway_title(); |
78 | 78 | } |
79 | 79 | |
@@ -83,75 +83,75 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @deprecated |
85 | 85 | */ |
86 | -function wpinv_get_payment_gateway_name( $invoice ) { |
|
87 | - return wpinv_get_payment_gateway( $invoice, true ); |
|
86 | +function wpinv_get_payment_gateway_name($invoice) { |
|
87 | + return wpinv_get_payment_gateway($invoice, true); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @deprecated |
92 | 92 | */ |
93 | -function wpinv_get_payment_transaction_id( $invoice ) { |
|
94 | - $invoice = new WPInv_Invoice( $invoice ); |
|
93 | +function wpinv_get_payment_transaction_id($invoice) { |
|
94 | + $invoice = new WPInv_Invoice($invoice); |
|
95 | 95 | return $invoice->get_transaction_id(); |
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * @deprecated |
100 | 100 | */ |
101 | -function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
102 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
103 | - return $invoice->get_meta( $meta_key, $single ); |
|
101 | +function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) { |
|
102 | + $invoice = new WPInv_Invoice($invoice_id); |
|
103 | + return $invoice->get_meta($meta_key, $single); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @deprecated |
108 | 108 | */ |
109 | -function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '' ) { |
|
110 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
111 | - return $invoice->update_meta_data( $meta_key, $meta_value ); |
|
109 | +function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '') { |
|
110 | + $invoice = new WPInv_Invoice($invoice_id); |
|
111 | + return $invoice->update_meta_data($meta_key, $meta_value); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @deprecated |
116 | 116 | */ |
117 | -function wpinv_get_items( $invoice = 0 ) { |
|
118 | - $invoice = new WPInv_Invoice( $invoice ); |
|
117 | +function wpinv_get_items($invoice = 0) { |
|
118 | + $invoice = new WPInv_Invoice($invoice); |
|
119 | 119 | return $invoice->get_items(); |
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * @deprecated |
124 | 124 | */ |
125 | -function wpinv_get_fees( $invoice = 0 ) { |
|
126 | - $invoice = new WPInv_Invoice( $invoice ); |
|
125 | +function wpinv_get_fees($invoice = 0) { |
|
126 | + $invoice = new WPInv_Invoice($invoice); |
|
127 | 127 | return $invoice->get_fees(); |
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | 131 | * @deprecated |
132 | 132 | */ |
133 | -function wpinv_get_invoice_ip( $invoice ) { |
|
134 | - $invoice = new WPInv_Invoice( $invoice ); |
|
133 | +function wpinv_get_invoice_ip($invoice) { |
|
134 | + $invoice = new WPInv_Invoice($invoice); |
|
135 | 135 | return $invoice->get_ip(); |
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | 139 | * @deprecated |
140 | 140 | */ |
141 | -function wpinv_get_invoice_user_info( $invoice ) { |
|
142 | - $invoice = new WPInv_Invoice( $invoice ); |
|
141 | +function wpinv_get_invoice_user_info($invoice) { |
|
142 | + $invoice = new WPInv_Invoice($invoice); |
|
143 | 143 | return $invoice->get_user_info(); |
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | 147 | * @deprecated |
148 | 148 | */ |
149 | -function wpinv_subtotal( $invoice = 0, $currency = false ) { |
|
150 | - $invoice = new WPInv_Invoice( $invoice ); |
|
149 | +function wpinv_subtotal($invoice = 0, $currency = false) { |
|
150 | + $invoice = new WPInv_Invoice($invoice); |
|
151 | 151 | $subtotal = $invoice->get_subtotal(); |
152 | 152 | |
153 | - if ( $currency ) { |
|
154 | - return wpinv_price( wpinv_format_amount( $subtotal ), $invoice->get_currency() ); |
|
153 | + if ($currency) { |
|
154 | + return wpinv_price(wpinv_format_amount($subtotal), $invoice->get_currency()); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $subtotal; |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | /** |
161 | 161 | * @deprecated |
162 | 162 | */ |
163 | -function wpinv_tax( $invoice = 0, $currency = false ) { |
|
164 | - $invoice = new WPInv_Invoice( $invoice ); |
|
163 | +function wpinv_tax($invoice = 0, $currency = false) { |
|
164 | + $invoice = new WPInv_Invoice($invoice); |
|
165 | 165 | $tax = $invoice->get_total_tax(); |
166 | 166 | |
167 | - if ( $currency ) { |
|
168 | - return wpinv_price( wpinv_format_amount( $tax ), $invoice->get_currency() ); |
|
167 | + if ($currency) { |
|
168 | + return wpinv_price(wpinv_format_amount($tax), $invoice->get_currency()); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | return $tax; |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * @deprecated |
176 | 176 | */ |
177 | -function wpinv_discount( $invoice = 0, $currency = false, $deprecated ) { |
|
178 | - $invoice = new WPInv_Invoice( $invoice ); |
|
177 | +function wpinv_discount($invoice = 0, $currency = false, $deprecated) { |
|
178 | + $invoice = new WPInv_Invoice($invoice); |
|
179 | 179 | $discount = $invoice->get_total_discount(); |
180 | 180 | |
181 | - if ( $currency ) { |
|
182 | - return wpinv_price( wpinv_format_amount( $discount ), $invoice->get_currency() ); |
|
181 | + if ($currency) { |
|
182 | + return wpinv_price(wpinv_format_amount($discount), $invoice->get_currency()); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | return $discount; |
@@ -188,20 +188,20 @@ discard block |
||
188 | 188 | /** |
189 | 189 | * @deprecated |
190 | 190 | */ |
191 | -function wpinv_discount_code( $invoice = 0 ) { |
|
192 | - $invoice = new WPInv_Invoice( $invoice ); |
|
191 | +function wpinv_discount_code($invoice = 0) { |
|
192 | + $invoice = new WPInv_Invoice($invoice); |
|
193 | 193 | return $invoice->get_discount_code(); |
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
197 | 197 | * @deprecated |
198 | 198 | */ |
199 | -function wpinv_payment_total( $invoice = 0, $currency = false ) { |
|
200 | - $invoice = new WPInv_Invoice( $invoice ); |
|
199 | +function wpinv_payment_total($invoice = 0, $currency = false) { |
|
200 | + $invoice = new WPInv_Invoice($invoice); |
|
201 | 201 | $total = $invoice->get_total(); |
202 | 202 | |
203 | - if ( $currency ) { |
|
204 | - return wpinv_price( wpinv_format_amount( $total ), $invoice->get_currency() ); |
|
203 | + if ($currency) { |
|
204 | + return wpinv_price(wpinv_format_amount($total), $invoice->get_currency()); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | return $total; |
@@ -210,51 +210,51 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * @deprecated |
212 | 212 | */ |
213 | -function wpinv_get_date_created( $invoice = 0, $format = '' ) { |
|
214 | - $invoice = new WPInv_Invoice( $invoice ); |
|
213 | +function wpinv_get_date_created($invoice = 0, $format = '') { |
|
214 | + $invoice = new WPInv_Invoice($invoice); |
|
215 | 215 | |
216 | - $format = ! empty( $format ) ? $format : get_option( 'date_format' ); |
|
216 | + $format = !empty($format) ? $format : get_option('date_format'); |
|
217 | 217 | $date_created = $invoice->get_created_date(); |
218 | 218 | |
219 | - return empty( $date_created ) ? date_i18n( $format, strtotime( $date_created ) ) : ''; |
|
219 | + return empty($date_created) ? date_i18n($format, strtotime($date_created)) : ''; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | 223 | * @deprecated |
224 | 224 | */ |
225 | -function wpinv_get_invoice_date( $invoice = 0, $format = '' ) { |
|
226 | - wpinv_get_date_created( $invoice, $format ); |
|
225 | +function wpinv_get_invoice_date($invoice = 0, $format = '') { |
|
226 | + wpinv_get_date_created($invoice, $format); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
230 | 230 | * @deprecated |
231 | 231 | */ |
232 | -function wpinv_get_invoice_vat_number( $invoice = 0 ) { |
|
233 | - $invoice = new WPInv_Invoice( $invoice ); |
|
232 | +function wpinv_get_invoice_vat_number($invoice = 0) { |
|
233 | + $invoice = new WPInv_Invoice($invoice); |
|
234 | 234 | return $invoice->get_vat_number(); |
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
238 | 238 | * @deprecated |
239 | 239 | */ |
240 | -function wpinv_insert_payment_note( $invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false ) { |
|
241 | - $invoice = new WPInv_Invoice( $invoice ); |
|
242 | - return $invoice->add_note( $note, $user_type, $added_by_user, $system ); |
|
240 | +function wpinv_insert_payment_note($invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false) { |
|
241 | + $invoice = new WPInv_Invoice($invoice); |
|
242 | + return $invoice->add_note($note, $user_type, $added_by_user, $system); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | 246 | * @deprecated |
247 | 247 | */ |
248 | -function wpinv_get_payment_key( $invoice = 0 ) { |
|
249 | - $invoice = new WPInv_Invoice( $invoice ); |
|
248 | +function wpinv_get_payment_key($invoice = 0) { |
|
249 | + $invoice = new WPInv_Invoice($invoice); |
|
250 | 250 | return $invoice->get_key(); |
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
254 | 254 | * @deprecated |
255 | 255 | */ |
256 | -function wpinv_get_invoice_number( $invoice = 0 ) { |
|
257 | - $invoice = new WPInv_Invoice( $invoice ); |
|
256 | +function wpinv_get_invoice_number($invoice = 0) { |
|
257 | + $invoice = new WPInv_Invoice($invoice); |
|
258 | 258 | return $invoice->get_number(); |
259 | 259 | } |
260 | 260 | |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | /** |
402 | 402 | * @deprecated |
403 | 403 | */ |
404 | -function wpinv_update_payment_status( $invoice, $new_status = 'publish' ) { |
|
405 | - $invoice = new WPInv_Invoice( $invoice ); |
|
406 | - return $invoice->update_status( $new_status ); |
|
404 | +function wpinv_update_payment_status($invoice, $new_status = 'publish') { |
|
405 | + $invoice = new WPInv_Invoice($invoice); |
|
406 | + return $invoice->update_status($new_status); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -456,22 +456,22 @@ discard block |
||
456 | 456 | /** |
457 | 457 | * @deprecated |
458 | 458 | */ |
459 | -function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) { |
|
459 | +function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') { |
|
460 | 460 | |
461 | 461 | // Fetch the invoice. |
462 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
462 | + $invoice = new WPInv_Invoice($invoice_id); |
|
463 | 463 | |
464 | - if ( 0 == $invoice->get_id() ) { |
|
464 | + if (0 == $invoice->get_id()) { |
|
465 | 465 | return false; |
466 | 466 | } |
467 | 467 | |
468 | 468 | // Prepare the transaction id. |
469 | - if ( empty( $transaction_id ) ) { |
|
469 | + if (empty($transaction_id)) { |
|
470 | 470 | $transaction_id = $invoice_id; |
471 | 471 | } |
472 | 472 | |
473 | 473 | // Set the transaction id; |
474 | - $invoice->set_transaction_id( apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice ) ); |
|
474 | + $invoice->set_transaction_id(apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice)); |
|
475 | 475 | |
476 | 476 | // Save the invoice. |
477 | 477 | return $invoice->save(); |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | * @param WPInv_Invoice $invoice |
485 | 485 | * @param string $gateway |
486 | 486 | */ |
487 | -function wpinv_send_to_gateway( $gateway, $invoice ) { |
|
487 | +function wpinv_send_to_gateway($gateway, $invoice) { |
|
488 | 488 | |
489 | 489 | $payment_data = array( |
490 | 490 | 'invoice_id' => $invoice->get_id(), |
491 | 491 | 'items' => $invoice->get_cart_details(), |
492 | - 'cart_discounts' => array( $invoice->get_discount_code() ), |
|
492 | + 'cart_discounts' => array($invoice->get_discount_code()), |
|
493 | 493 | 'fees' => $invoice->get_total_fees(), |
494 | 494 | 'subtotal' => $invoice->get_subtotal(), |
495 | 495 | 'discount' => $invoice->get_total_discount(), |
@@ -497,16 +497,16 @@ discard block |
||
497 | 497 | 'price' => $invoice->get_total(), |
498 | 498 | 'invoice_key' => $invoice->get_key(), |
499 | 499 | 'user_email' => $invoice->get_email(), |
500 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
500 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
501 | 501 | 'user_info' => $invoice->get_user_info(), |
502 | - 'post_data' => stripslashes_deep( $_POST ), |
|
502 | + 'post_data' => stripslashes_deep($_POST), |
|
503 | 503 | 'cart_details' => $invoice->get_cart_details(), |
504 | 504 | 'gateway' => $gateway, |
505 | 505 | 'card_info' => array(), |
506 | 506 | 'gateway_nonce' => wp_create_nonce('wpi-gateway'), |
507 | 507 | ); |
508 | 508 | |
509 | - do_action( 'wpinv_gateway_' . $gateway, $payment_data ); |
|
509 | + do_action('wpinv_gateway_' . $gateway, $payment_data); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | /** |
520 | 520 | * @deprecated |
521 | 521 | */ |
522 | -function wpinv_die( $message = '', $title = '', $status = 400 ) { |
|
523 | - add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 ); |
|
524 | - add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 ); |
|
525 | - wp_die( $message, $title, array( 'response' => $status )); |
|
522 | +function wpinv_die($message = '', $title = '', $status = 400) { |
|
523 | + add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3); |
|
524 | + add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3); |
|
525 | + wp_die($message, $title, array('response' => $status)); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -640,14 +640,14 @@ discard block |
||
640 | 640 | /** |
641 | 641 | * @deprecated |
642 | 642 | */ |
643 | -function wpinv_invoice_status_label( $status, $status_display = '' ) { |
|
644 | - return empty( $status_display ) ? sanitize_text_field( $status ) : sanitize_text_field( $status_display ); |
|
643 | +function wpinv_invoice_status_label($status, $status_display = '') { |
|
644 | + return empty($status_display) ? sanitize_text_field($status) : sanitize_text_field($status_display); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
648 | 648 | * @deprecated |
649 | 649 | */ |
650 | -function wpinv_clean_invoice_number( $number ) { |
|
650 | +function wpinv_clean_invoice_number($number) { |
|
651 | 651 | return $number; |
652 | 652 | } |
653 | 653 | |
@@ -852,12 +852,12 @@ discard block |
||
852 | 852 | /** |
853 | 853 | * @deprecated |
854 | 854 | */ |
855 | -function wpinv_item_show_price( $item_id = 0, $echo = true ) { |
|
855 | +function wpinv_item_show_price($item_id = 0, $echo = true) { |
|
856 | 856 | |
857 | - if ( $echo ) { |
|
858 | - echo wpinv_item_price( $item_id ); |
|
857 | + if ($echo) { |
|
858 | + echo wpinv_item_price($item_id); |
|
859 | 859 | } else { |
860 | - return wpinv_item_price( $item_id ); |
|
860 | + return wpinv_item_price($item_id); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | } |
864 | 864 | \ No newline at end of file |
@@ -67,7 +67,7 @@ |
||
67 | 67 | * Checks if the current user cna view an invoice receipt. |
68 | 68 | */ |
69 | 69 | function wpinv_can_view_receipt( $invoice ) { |
70 | - return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
70 | + return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves the current invoice. |
@@ -14,15 +14,15 @@ discard block |
||
14 | 14 | function getpaid_get_current_invoice_id() { |
15 | 15 | |
16 | 16 | // Ensure that we have an invoice key. |
17 | - if ( empty( $_GET['invoice_key'] ) ) { |
|
17 | + if (empty($_GET['invoice_key'])) { |
|
18 | 18 | return 0; |
19 | 19 | } |
20 | 20 | |
21 | 21 | // Retrieve an invoice using the key. |
22 | - $invoice = new WPInv_Invoice( $_GET['invoice_key'] ); |
|
22 | + $invoice = new WPInv_Invoice($_GET['invoice_key']); |
|
23 | 23 | |
24 | 24 | // Compare the invoice key and the parsed key. |
25 | - if ( $invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key'] ) { |
|
25 | + if ($invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key']) { |
|
26 | 26 | return $invoice->get_id(); |
27 | 27 | } |
28 | 28 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Checks if the current user cna view an invoice. |
34 | 34 | */ |
35 | -function wpinv_user_can_view_invoice( $invoice ) { |
|
36 | - $invoice = new WPInv_Invoice( $invoice ); |
|
35 | +function wpinv_user_can_view_invoice($invoice) { |
|
36 | + $invoice = new WPInv_Invoice($invoice); |
|
37 | 37 | |
38 | 38 | // Abort if the invoice does not exist. |
39 | - if ( 0 == $invoice->get_id() ) { |
|
39 | + if (0 == $invoice->get_id()) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Don't allow trash, draft status |
44 | - if ( $invoice->is_draft() ) { |
|
44 | + if ($invoice->is_draft()) { |
|
45 | 45 | return false; |
46 | 46 | } |
47 | 47 | |
48 | 48 | // If users are not required to login to check out, compare the invoice keys. |
49 | - if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && trim( $_GET['invoice_key'] ) == $invoice->get_key() ) { |
|
49 | + if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && trim($_GET['invoice_key']) == $invoice->get_key()) { |
|
50 | 50 | return true; |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Always enable for admins.. |
54 | - if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->get_id() ) ) { // Admin user |
|
54 | + if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->get_id())) { // Admin user |
|
55 | 55 | return true; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Else, ensure that this is their invoice. |
59 | - if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) { |
|
59 | + if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) { |
|
60 | 60 | return true; |
61 | 61 | } |
62 | 62 | |
63 | - return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice ); |
|
63 | + return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Checks if the current user cna view an invoice receipt. |
68 | 68 | */ |
69 | -function wpinv_can_view_receipt( $invoice ) { |
|
70 | - return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
69 | +function wpinv_can_view_receipt($invoice) { |
|
70 | + return (bool) apply_filters('wpinv_can_view_receipt', wpinv_user_can_view_invoice($invoice), $invoice); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | */ |
78 | 78 | function getpaid_get_invoice_post_types() { |
79 | 79 | $post_types = array( |
80 | - 'wpi_quote' => __( 'Quote', 'invoicing' ), |
|
81 | - 'wpi_invoice' => __( 'Invoice', 'invoicing' ), |
|
80 | + 'wpi_quote' => __('Quote', 'invoicing'), |
|
81 | + 'wpi_invoice' => __('Invoice', 'invoicing'), |
|
82 | 82 | ); |
83 | 83 | |
84 | - return apply_filters( 'getpaid_invoice_post_types', $post_types ); |
|
84 | + return apply_filters('getpaid_invoice_post_types', $post_types); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @param string $post_type The post type to check for. |
92 | 92 | */ |
93 | -function getpaid_is_invoice_post_type( $post_type ) { |
|
94 | - return ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() ); |
|
93 | +function getpaid_is_invoice_post_type($post_type) { |
|
94 | + return !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types()); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
102 | 102 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
103 | 103 | */ |
104 | -function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) { |
|
105 | - $data[ 'invoice_id' ] = 0; |
|
106 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
104 | +function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) { |
|
105 | + $data['invoice_id'] = 0; |
|
106 | + return wpinv_insert_invoice($data, $wp_error); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,36 +113,36 @@ discard block |
||
113 | 113 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
114 | 114 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
115 | 115 | */ |
116 | -function wpinv_update_invoice( $data = array(), $wp_error = false ) { |
|
116 | +function wpinv_update_invoice($data = array(), $wp_error = false) { |
|
117 | 117 | |
118 | 118 | // Backwards compatibility. |
119 | - if ( ! empty( $data['ID'] ) ) { |
|
119 | + if (!empty($data['ID'])) { |
|
120 | 120 | $data['invoice_id'] = $data['ID']; |
121 | 121 | } |
122 | 122 | |
123 | 123 | // Do we have an invoice id? |
124 | - if ( empty( $data['invoice_id'] ) ) { |
|
125 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0; |
|
124 | + if (empty($data['invoice_id'])) { |
|
125 | + return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // Retrieve the invoice. |
129 | - $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
|
129 | + $invoice = wpinv_get_invoice($data['invoice_id']); |
|
130 | 130 | |
131 | 131 | // And abort if it does not exist. |
132 | - if ( empty( $invoice ) ) { |
|
133 | - return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0; |
|
132 | + if (empty($invoice)) { |
|
133 | + return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | // Do not update totals for paid / refunded invoices. |
137 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
137 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
138 | 138 | |
139 | - if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) { |
|
140 | - return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0; |
|
139 | + if (!empty($data['items']) || !empty($data['cart_details'])) { |
|
140 | + return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | } |
144 | 144 | |
145 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
145 | + return wpinv_insert_invoice($data, $wp_error); |
|
146 | 146 | |
147 | 147 | } |
148 | 148 | |
@@ -153,34 +153,34 @@ discard block |
||
153 | 153 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
154 | 154 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
155 | 155 | */ |
156 | -function wpinv_insert_invoice( $data = array(), $wp_error = false ) { |
|
156 | +function wpinv_insert_invoice($data = array(), $wp_error = false) { |
|
157 | 157 | |
158 | 158 | // Ensure that we have invoice data. |
159 | - if ( empty( $data ) ) { |
|
159 | + if (empty($data)) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // The invoice id will be provided when updating an invoice. |
164 | - $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false; |
|
164 | + $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false; |
|
165 | 165 | |
166 | 166 | // Retrieve the invoice. |
167 | - $invoice = new WPInv_Invoice( $data['invoice_id'] ); |
|
167 | + $invoice = new WPInv_Invoice($data['invoice_id']); |
|
168 | 168 | |
169 | 169 | // Do we have an error? |
170 | - if ( ! empty( $invoice->last_error ) ) { |
|
171 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0; |
|
170 | + if (!empty($invoice->last_error)) { |
|
171 | + return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Backwards compatibility (billing address). |
175 | - if ( ! empty( $data['user_info'] ) ) { |
|
175 | + if (!empty($data['user_info'])) { |
|
176 | 176 | |
177 | - foreach ( $data['user_info'] as $key => $value ) { |
|
177 | + foreach ($data['user_info'] as $key => $value) { |
|
178 | 178 | |
179 | - if ( $key == 'discounts' ) { |
|
179 | + if ($key == 'discounts') { |
|
180 | 180 | $value = (array) $value; |
181 | - $data[ 'discount_code' ] = empty( $value ) ? null : $value[0]; |
|
181 | + $data['discount_code'] = empty($value) ? null : $value[0]; |
|
182 | 182 | } else { |
183 | - $data[ $key ] = $value; |
|
183 | + $data[$key] = $value; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | } |
@@ -188,30 +188,30 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | // Backwards compatibility. |
191 | - if ( ! empty( $data['payment_details'] ) ) { |
|
191 | + if (!empty($data['payment_details'])) { |
|
192 | 192 | |
193 | - foreach ( $data['payment_details'] as $key => $value ) { |
|
194 | - $data[ $key ] = $value; |
|
193 | + foreach ($data['payment_details'] as $key => $value) { |
|
194 | + $data[$key] = $value; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | } |
198 | 198 | |
199 | 199 | // Set up the owner of the invoice. |
200 | - $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id(); |
|
200 | + $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id(); |
|
201 | 201 | |
202 | 202 | // Make sure the user exists. |
203 | - if ( ! get_userdata( $user_id ) ) { |
|
204 | - return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0; |
|
203 | + if (!get_userdata($user_id)) { |
|
204 | + return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0; |
|
205 | 205 | } |
206 | 206 | |
207 | - $address = wpinv_get_user_address( $user_id ); |
|
207 | + $address = wpinv_get_user_address($user_id); |
|
208 | 208 | |
209 | - foreach ( $address as $key => $value ) { |
|
209 | + foreach ($address as $key => $value) { |
|
210 | 210 | |
211 | - if ( $value == '' ) { |
|
212 | - $address[ $key ] = null; |
|
211 | + if ($value == '') { |
|
212 | + $address[$key] = null; |
|
213 | 213 | } else { |
214 | - $address[ $key ] = wpinv_clean( $value ); |
|
214 | + $address[$key] = wpinv_clean($value); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | } |
@@ -222,103 +222,103 @@ discard block |
||
222 | 222 | array( |
223 | 223 | |
224 | 224 | // Basic info. |
225 | - 'template' => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null, |
|
226 | - 'email_cc' => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null, |
|
227 | - 'date_created' => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null, |
|
228 | - 'due_date' => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null, |
|
229 | - 'date_completed' => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null, |
|
230 | - 'number' => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null, |
|
231 | - 'key' => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null, |
|
232 | - 'status' => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null, |
|
233 | - 'post_type' => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null, |
|
234 | - 'user_ip' => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(), |
|
235 | - 'parent_id' => isset( $data['parent'] ) ? intval( $data['parent'] ) : null, |
|
236 | - 'mode' => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null, |
|
237 | - 'description' => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null, |
|
225 | + 'template' => isset($data['template']) ? wpinv_clean($data['template']) : null, |
|
226 | + 'email_cc' => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null, |
|
227 | + 'date_created' => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null, |
|
228 | + 'due_date' => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null, |
|
229 | + 'date_completed' => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null, |
|
230 | + 'number' => isset($data['number']) ? wpinv_clean($data['number']) : null, |
|
231 | + 'key' => isset($data['key']) ? wpinv_clean($data['key']) : null, |
|
232 | + 'status' => isset($data['status']) ? wpinv_clean($data['status']) : null, |
|
233 | + 'post_type' => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null, |
|
234 | + 'user_ip' => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(), |
|
235 | + 'parent_id' => isset($data['parent']) ? intval($data['parent']) : null, |
|
236 | + 'mode' => isset($data['mode']) ? wpinv_clean($data['mode']) : null, |
|
237 | + 'description' => isset($data['description']) ? wp_kses_post($data['description']) : null, |
|
238 | 238 | |
239 | 239 | // Payment info. |
240 | - 'disable_taxes' => ! empty( $data['disable_taxes'] ), |
|
241 | - 'currency' => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(), |
|
242 | - 'gateway' => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null, |
|
243 | - 'transaction_id' => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null, |
|
244 | - 'discount_code' => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null, |
|
245 | - 'payment_form' => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null, |
|
246 | - 'submission_id' => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null, |
|
247 | - 'subscription_id' => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null, |
|
248 | - 'is_viewed' => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null, |
|
249 | - 'fees' => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null, |
|
250 | - 'discounts' => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null, |
|
251 | - 'taxes' => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null, |
|
240 | + 'disable_taxes' => !empty($data['disable_taxes']), |
|
241 | + 'currency' => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(), |
|
242 | + 'gateway' => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null, |
|
243 | + 'transaction_id' => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null, |
|
244 | + 'discount_code' => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null, |
|
245 | + 'payment_form' => isset($data['payment_form']) ? intval($data['payment_form']) : null, |
|
246 | + 'submission_id' => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null, |
|
247 | + 'subscription_id' => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null, |
|
248 | + 'is_viewed' => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null, |
|
249 | + 'fees' => isset($data['fees']) ? wpinv_clean($data['fees']) : null, |
|
250 | + 'discounts' => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null, |
|
251 | + 'taxes' => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null, |
|
252 | 252 | |
253 | 253 | |
254 | 254 | // Billing details. |
255 | 255 | 'user_id' => $data['user_id'], |
256 | - 'first_name' => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'], |
|
257 | - 'last_name' => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'], |
|
258 | - 'address' => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] , |
|
259 | - 'vat_number' => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'], |
|
260 | - 'company' => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'], |
|
261 | - 'zip' => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'], |
|
262 | - 'state' => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'], |
|
263 | - 'city' => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'], |
|
264 | - 'country' => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'], |
|
265 | - 'phone' => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'], |
|
266 | - 'address_confirmed' => ! empty( $data['address_confirmed'] ), |
|
256 | + 'first_name' => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'], |
|
257 | + 'last_name' => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'], |
|
258 | + 'address' => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'], |
|
259 | + 'vat_number' => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'], |
|
260 | + 'company' => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'], |
|
261 | + 'zip' => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'], |
|
262 | + 'state' => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'], |
|
263 | + 'city' => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'], |
|
264 | + 'country' => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'], |
|
265 | + 'phone' => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'], |
|
266 | + 'address_confirmed' => !empty($data['address_confirmed']), |
|
267 | 267 | |
268 | 268 | ) |
269 | 269 | |
270 | 270 | ); |
271 | 271 | |
272 | 272 | // Backwards compatibililty. |
273 | - if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) { |
|
273 | + if (!empty($data['cart_details']) && is_array($data['cart_details'])) { |
|
274 | 274 | $data['items'] = array(); |
275 | 275 | |
276 | - foreach( $data['cart_details'] as $_item ) { |
|
276 | + foreach ($data['cart_details'] as $_item) { |
|
277 | 277 | |
278 | 278 | // Ensure that we have an item id. |
279 | - if ( empty( $_item['id'] ) ) { |
|
279 | + if (empty($_item['id'])) { |
|
280 | 280 | continue; |
281 | 281 | } |
282 | 282 | |
283 | 283 | // Retrieve the item. |
284 | - $item = new GetPaid_Form_Item( $_item['id'] ); |
|
284 | + $item = new GetPaid_Form_Item($_item['id']); |
|
285 | 285 | |
286 | 286 | // Ensure that it is purchasable. |
287 | - if ( ! $item->can_purchase() ) { |
|
287 | + if (!$item->can_purchase()) { |
|
288 | 288 | continue; |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Set quantity. |
292 | - if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) { |
|
293 | - $item->set_quantity( $_item['quantity'] ); |
|
292 | + if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) { |
|
293 | + $item->set_quantity($_item['quantity']); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | // Set price. |
297 | - if ( isset( $_item['item_price'] ) ) { |
|
298 | - $item->set_price( $_item['item_price'] ); |
|
297 | + if (isset($_item['item_price'])) { |
|
298 | + $item->set_price($_item['item_price']); |
|
299 | 299 | } |
300 | 300 | |
301 | - if ( isset( $_item['custom_price'] ) ) { |
|
302 | - $item->set_price( $_item['custom_price'] ); |
|
301 | + if (isset($_item['custom_price'])) { |
|
302 | + $item->set_price($_item['custom_price']); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | // Set name. |
306 | - if ( ! empty( $_item['name'] ) ) { |
|
307 | - $item->set_name( $_item['name'] ); |
|
306 | + if (!empty($_item['name'])) { |
|
307 | + $item->set_name($_item['name']); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | // Set description. |
311 | - if ( isset( $_item['description'] ) ) { |
|
312 | - $item->set_custom_description( $_item['description'] ); |
|
311 | + if (isset($_item['description'])) { |
|
312 | + $item->set_custom_description($_item['description']); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | // Set meta. |
316 | - if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) { |
|
316 | + if (isset($_item['meta']) && is_array($_item['meta'])) { |
|
317 | 317 | |
318 | - $item->set_item_meta( $_item['meta'] ); |
|
318 | + $item->set_item_meta($_item['meta']); |
|
319 | 319 | |
320 | - if ( isset( $_item['meta']['description'] ) ) { |
|
321 | - $item->set_custom_description( $_item['meta']['description'] ); |
|
320 | + if (isset($_item['meta']['description'])) { |
|
321 | + $item->set_custom_description($_item['meta']['description']); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | } |
@@ -329,14 +329,14 @@ discard block |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | // Add invoice items. |
332 | - if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) { |
|
332 | + if (!empty($data['items']) && is_array($data['items'])) { |
|
333 | 333 | |
334 | - $invoice->set_items( array() ); |
|
334 | + $invoice->set_items(array()); |
|
335 | 335 | |
336 | - foreach ( $data['items'] as $item ) { |
|
336 | + foreach ($data['items'] as $item) { |
|
337 | 337 | |
338 | - if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) { |
|
339 | - $invoice->add_item( $item ); |
|
338 | + if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) { |
|
339 | + $invoice->add_item($item); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | } |
@@ -346,30 +346,30 @@ discard block |
||
346 | 346 | // Save the invoice. |
347 | 347 | $invoice->save(); |
348 | 348 | |
349 | - if ( ! $invoice->get_id() ) { |
|
350 | - return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0; |
|
349 | + if (!$invoice->get_id()) { |
|
350 | + return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0; |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | // Add private note. |
354 | - if ( ! empty( $data['private_note'] ) ) { |
|
355 | - $invoice->add_note( $data['private_note'] ); |
|
354 | + if (!empty($data['private_note'])) { |
|
355 | + $invoice->add_note($data['private_note']); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | // User notes. |
359 | - if ( !empty( $data['user_note'] ) ) { |
|
360 | - $invoice->add_note( $data['user_note'], true ); |
|
359 | + if (!empty($data['user_note'])) { |
|
360 | + $invoice->add_note($data['user_note'], true); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | // Created via. |
364 | - if ( isset( $data['created_via'] ) ) { |
|
365 | - update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] ); |
|
364 | + if (isset($data['created_via'])) { |
|
365 | + update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | // Backwards compatiblity. |
369 | - if ( $invoice->is_quote() ) { |
|
369 | + if ($invoice->is_quote()) { |
|
370 | 370 | |
371 | - if ( isset( $data['valid_until'] ) ) { |
|
372 | - update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] ); |
|
371 | + if (isset($data['valid_until'])) { |
|
372 | + update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']); |
|
373 | 373 | } |
374 | 374 | return $invoice; |
375 | 375 | |
@@ -384,18 +384,18 @@ discard block |
||
384 | 384 | * @param $bool $deprecated |
385 | 385 | * @return WPInv_Invoice|null |
386 | 386 | */ |
387 | -function wpinv_get_invoice( $invoice = 0, $deprecated = false ) { |
|
387 | +function wpinv_get_invoice($invoice = 0, $deprecated = false) { |
|
388 | 388 | |
389 | 389 | // If we are retrieving the invoice from the cart... |
390 | - if ( $deprecated && empty( $invoice ) ) { |
|
390 | + if ($deprecated && empty($invoice)) { |
|
391 | 391 | $invoice = (int) getpaid_get_current_invoice_id(); |
392 | 392 | } |
393 | 393 | |
394 | 394 | // Retrieve the invoice. |
395 | - $invoice = new WPInv_Invoice( $invoice ); |
|
395 | + $invoice = new WPInv_Invoice($invoice); |
|
396 | 396 | |
397 | 397 | // Check if it exists. |
398 | - if ( $invoice->get_id() != 0 ) { |
|
398 | + if ($invoice->get_id() != 0) { |
|
399 | 399 | return $invoice; |
400 | 400 | } |
401 | 401 | |
@@ -408,15 +408,15 @@ discard block |
||
408 | 408 | * @param array $args Args to search for. |
409 | 409 | * @return WPInv_Invoice[]|int[]|object |
410 | 410 | */ |
411 | -function wpinv_get_invoices( $args ) { |
|
411 | +function wpinv_get_invoices($args) { |
|
412 | 412 | |
413 | 413 | // Prepare args. |
414 | 414 | $args = wp_parse_args( |
415 | 415 | $args, |
416 | 416 | array( |
417 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
417 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
418 | 418 | 'type' => 'wpi_invoice', |
419 | - 'limit' => get_option( 'posts_per_page' ), |
|
419 | + 'limit' => get_option('posts_per_page'), |
|
420 | 420 | 'return' => 'objects', |
421 | 421 | ) |
422 | 422 | ); |
@@ -434,24 +434,24 @@ discard block |
||
434 | 434 | 'post__in' => 'include', |
435 | 435 | ); |
436 | 436 | |
437 | - foreach ( $map_legacy as $to => $from ) { |
|
438 | - if ( isset( $args[ $from ] ) ) { |
|
439 | - $args[ $to ] = $args[ $from ]; |
|
440 | - unset( $args[ $from ] ); |
|
437 | + foreach ($map_legacy as $to => $from) { |
|
438 | + if (isset($args[$from])) { |
|
439 | + $args[$to] = $args[$from]; |
|
440 | + unset($args[$from]); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | 444 | // Backwards compatibility. |
445 | - if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) { |
|
445 | + if (!empty($args['email']) && empty($args['user'])) { |
|
446 | 446 | $args['user'] = $args['email']; |
447 | - unset( $args['email'] ); |
|
447 | + unset($args['email']); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | // Handle cases where the user is set as an email. |
451 | - if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) { |
|
452 | - $user = get_user_by( 'email', $args['user'] ); |
|
451 | + if (!empty($args['author']) && is_email($args['author'])) { |
|
452 | + $user = get_user_by('email', $args['user']); |
|
453 | 453 | |
454 | - if ( $user ) { |
|
454 | + if ($user) { |
|
455 | 455 | $args['author'] = $user->user_email; |
456 | 456 | } |
457 | 457 | |
@@ -462,31 +462,31 @@ discard block |
||
462 | 462 | |
463 | 463 | // Show all posts. |
464 | 464 | $paginate = true; |
465 | - if ( isset( $args['paginate'] ) ) { |
|
465 | + if (isset($args['paginate'])) { |
|
466 | 466 | |
467 | 467 | $paginate = $args['paginate']; |
468 | - $args['no_found_rows'] = empty( $args['paginate'] ); |
|
469 | - unset( $args['paginate'] ); |
|
468 | + $args['no_found_rows'] = empty($args['paginate']); |
|
469 | + unset($args['paginate']); |
|
470 | 470 | |
471 | 471 | } |
472 | 472 | |
473 | 473 | // Whether to return objects or fields. |
474 | 474 | $return = $args['return']; |
475 | - unset( $args['return'] ); |
|
475 | + unset($args['return']); |
|
476 | 476 | |
477 | 477 | // Get invoices. |
478 | - $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) ); |
|
478 | + $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args)); |
|
479 | 479 | |
480 | 480 | // Prepare the results. |
481 | - if ( 'objects' === $return ) { |
|
482 | - $results = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
483 | - } elseif ( 'self' === $return ) { |
|
481 | + if ('objects' === $return) { |
|
482 | + $results = array_map('wpinv_get_invoice', $invoices->posts); |
|
483 | + } elseif ('self' === $return) { |
|
484 | 484 | return $invoices; |
485 | 485 | } else { |
486 | 486 | $results = $invoices->posts; |
487 | 487 | } |
488 | 488 | |
489 | - if ( $paginate ) { |
|
489 | + if ($paginate) { |
|
490 | 490 | return (object) array( |
491 | 491 | 'invoices' => $results, |
492 | 492 | 'total' => $invoices->found_posts, |
@@ -504,8 +504,8 @@ discard block |
||
504 | 504 | * @param string $transaction_id The transaction id to check. |
505 | 505 | * @return int Invoice id on success or 0 on failure |
506 | 506 | */ |
507 | -function wpinv_get_id_by_transaction_id( $transaction_id ) { |
|
508 | - return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' ); |
|
507 | +function wpinv_get_id_by_transaction_id($transaction_id) { |
|
508 | + return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id'); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | /** |
@@ -514,8 +514,8 @@ discard block |
||
514 | 514 | * @param string $invoice_number The invoice number to check. |
515 | 515 | * @return int Invoice id on success or 0 on failure |
516 | 516 | */ |
517 | -function wpinv_get_id_by_invoice_number( $invoice_number ) { |
|
518 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' ); |
|
517 | +function wpinv_get_id_by_invoice_number($invoice_number) { |
|
518 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number'); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -524,8 +524,8 @@ discard block |
||
524 | 524 | * @param string $invoice_key The invoice key to check. |
525 | 525 | * @return int Invoice id on success or 0 on failure |
526 | 526 | */ |
527 | -function wpinv_get_invoice_id_by_key( $invoice_key ) { |
|
528 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' ); |
|
527 | +function wpinv_get_invoice_id_by_key($invoice_key) { |
|
528 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key'); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |
@@ -535,19 +535,19 @@ discard block |
||
535 | 535 | * @param string $type Optionally filter by type i.e customer|system |
536 | 536 | * @return array|null |
537 | 537 | */ |
538 | -function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) { |
|
538 | +function wpinv_get_invoice_notes($invoice = 0, $type = '') { |
|
539 | 539 | |
540 | 540 | // Prepare the invoice. |
541 | - $invoice = wpinv_get_invoice( $invoice ); |
|
542 | - if ( empty( $invoice ) ) { |
|
541 | + $invoice = wpinv_get_invoice($invoice); |
|
542 | + if (empty($invoice)) { |
|
543 | 543 | return NULL; |
544 | 544 | } |
545 | 545 | |
546 | 546 | // Fetch notes. |
547 | - $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type ); |
|
547 | + $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type); |
|
548 | 548 | |
549 | 549 | // Filter the notes. |
550 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type ); |
|
550 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -557,27 +557,27 @@ discard block |
||
557 | 557 | $columns = array( |
558 | 558 | |
559 | 559 | 'invoice-number' => array( |
560 | - 'title' => __( 'Invoice', 'invoicing' ), |
|
560 | + 'title' => __('Invoice', 'invoicing'), |
|
561 | 561 | 'class' => 'text-left' |
562 | 562 | ), |
563 | 563 | |
564 | 564 | 'created-date' => array( |
565 | - 'title' => __( 'Created Date', 'invoicing' ), |
|
565 | + 'title' => __('Created Date', 'invoicing'), |
|
566 | 566 | 'class' => 'text-left' |
567 | 567 | ), |
568 | 568 | |
569 | 569 | 'payment-date' => array( |
570 | - 'title' => __( 'Payment Date', 'invoicing' ), |
|
570 | + 'title' => __('Payment Date', 'invoicing'), |
|
571 | 571 | 'class' => 'text-left' |
572 | 572 | ), |
573 | 573 | |
574 | 574 | 'invoice-status' => array( |
575 | - 'title' => __( 'Status', 'invoicing' ), |
|
575 | + 'title' => __('Status', 'invoicing'), |
|
576 | 576 | 'class' => 'text-center' |
577 | 577 | ), |
578 | 578 | |
579 | 579 | 'invoice-total' => array( |
580 | - 'title' => __( 'Total', 'invoicing' ), |
|
580 | + 'title' => __('Total', 'invoicing'), |
|
581 | 581 | 'class' => 'text-right' |
582 | 582 | ), |
583 | 583 | |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | |
589 | 589 | ); |
590 | 590 | |
591 | - return apply_filters( 'wpinv_user_invoices_columns', $columns ); |
|
591 | + return apply_filters('wpinv_user_invoices_columns', $columns); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
@@ -598,54 +598,54 @@ discard block |
||
598 | 598 | |
599 | 599 | // Find the invoice. |
600 | 600 | $invoice_id = getpaid_get_current_invoice_id(); |
601 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
601 | + $invoice = new WPInv_Invoice($invoice_id); |
|
602 | 602 | |
603 | 603 | // Abort if non was found. |
604 | - if ( empty( $invoice_id ) || $invoice->is_draft() ) { |
|
604 | + if (empty($invoice_id) || $invoice->is_draft()) { |
|
605 | 605 | |
606 | 606 | return aui()->alert( |
607 | 607 | array( |
608 | 608 | 'type' => 'warning', |
609 | - 'content' => __( 'We could not find your invoice', 'invoicing' ), |
|
609 | + 'content' => __('We could not find your invoice', 'invoicing'), |
|
610 | 610 | ) |
611 | 611 | ); |
612 | 612 | |
613 | 613 | } |
614 | 614 | |
615 | 615 | // Can the user view this invoice? |
616 | - if ( ! wpinv_can_view_receipt( $invoice_id ) ) { |
|
616 | + if (!wpinv_can_view_receipt($invoice_id)) { |
|
617 | 617 | |
618 | 618 | return aui()->alert( |
619 | 619 | array( |
620 | 620 | 'type' => 'warning', |
621 | - 'content' => __( 'You are not allowed to view this receipt', 'invoicing' ), |
|
621 | + 'content' => __('You are not allowed to view this receipt', 'invoicing'), |
|
622 | 622 | ) |
623 | 623 | ); |
624 | 624 | |
625 | 625 | } |
626 | 626 | |
627 | 627 | // Load the template. |
628 | - return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) ); |
|
628 | + return wpinv_get_template_html('invoice-receipt.php', compact('invoice')); |
|
629 | 629 | |
630 | 630 | } |
631 | 631 | |
632 | 632 | /** |
633 | 633 | * Displays the invoice history. |
634 | 634 | */ |
635 | -function getpaid_invoice_history( $user_id = 0 ) { |
|
635 | +function getpaid_invoice_history($user_id = 0) { |
|
636 | 636 | |
637 | 637 | // Ensure that we have a user id. |
638 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
638 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
639 | 639 | $user_id = get_current_user_id(); |
640 | 640 | } |
641 | 641 | |
642 | 642 | // View user id. |
643 | - if ( empty( $user_id ) ) { |
|
643 | + if (empty($user_id)) { |
|
644 | 644 | |
645 | 645 | return aui()->alert( |
646 | 646 | array( |
647 | 647 | 'type' => 'warning', |
648 | - 'content' => __( 'You must be logged in to view your invoice history.', 'invoicing' ), |
|
648 | + 'content' => __('You must be logged in to view your invoice history.', 'invoicing'), |
|
649 | 649 | ) |
650 | 650 | ); |
651 | 651 | |
@@ -655,55 +655,55 @@ discard block |
||
655 | 655 | $invoices = wpinv_get_invoices( |
656 | 656 | |
657 | 657 | array( |
658 | - 'page' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
658 | + 'page' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
659 | 659 | 'user' => $user_id, |
660 | 660 | 'paginate' => true, |
661 | 661 | ) |
662 | 662 | |
663 | 663 | ); |
664 | 664 | |
665 | - if ( empty( $invoices->total ) ) { |
|
665 | + if (empty($invoices->total)) { |
|
666 | 666 | |
667 | 667 | return aui()->alert( |
668 | 668 | array( |
669 | 669 | 'type' => 'info', |
670 | - 'content' => __( 'No invoices found.', 'invoicing' ), |
|
670 | + 'content' => __('No invoices found.', 'invoicing'), |
|
671 | 671 | ) |
672 | 672 | ); |
673 | 673 | |
674 | 674 | } |
675 | 675 | |
676 | 676 | // Load the template. |
677 | - return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices' ) ); |
|
677 | + return wpinv_get_template_html('invoice-history.php', compact('invoices')); |
|
678 | 678 | |
679 | 679 | } |
680 | 680 | |
681 | 681 | /** |
682 | 682 | * Formats an invoice number given an invoice type. |
683 | 683 | */ |
684 | -function wpinv_format_invoice_number( $number, $type = '' ) { |
|
684 | +function wpinv_format_invoice_number($number, $type = '') { |
|
685 | 685 | |
686 | 686 | // Allow other plugins to overide this. |
687 | - $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type ); |
|
688 | - if ( null !== $check ) { |
|
687 | + $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type); |
|
688 | + if (null !== $check) { |
|
689 | 689 | return $check; |
690 | 690 | } |
691 | 691 | |
692 | 692 | // Ensure that we have a numeric number. |
693 | - if ( ! is_numeric( $number ) ) { |
|
693 | + if (!is_numeric($number)) { |
|
694 | 694 | return $number; |
695 | 695 | } |
696 | 696 | |
697 | 697 | // Format the number. |
698 | - $padd = absint( (int) wpinv_get_option( 'invoice_number_padd' ) ); |
|
699 | - $prefix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) ); |
|
700 | - $postfix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) ); |
|
701 | - $formatted_number = zeroise( absint( $number ), $padd ); |
|
698 | + $padd = absint((int) wpinv_get_option('invoice_number_padd')); |
|
699 | + $prefix = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-')); |
|
700 | + $postfix = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix')); |
|
701 | + $formatted_number = zeroise(absint($number), $padd); |
|
702 | 702 | |
703 | 703 | // Add the prefix and post fix. |
704 | 704 | $formatted_number = $prefix . $formatted_number . $postfix; |
705 | 705 | |
706 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
706 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | /** |
@@ -712,58 +712,58 @@ discard block |
||
712 | 712 | * @param string $type. |
713 | 713 | * @return int|null|bool |
714 | 714 | */ |
715 | -function wpinv_get_next_invoice_number( $type = '' ) { |
|
715 | +function wpinv_get_next_invoice_number($type = '') { |
|
716 | 716 | |
717 | 717 | // Allow plugins to overide this. |
718 | - $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type ); |
|
719 | - if ( null !== $check ) { |
|
718 | + $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type); |
|
719 | + if (null !== $check) { |
|
720 | 720 | return $check; |
721 | 721 | } |
722 | 722 | |
723 | 723 | // Ensure sequential invoice numbers is active. |
724 | - if ( ! wpinv_sequential_number_active() ) { |
|
724 | + if (!wpinv_sequential_number_active()) { |
|
725 | 725 | return false; |
726 | 726 | } |
727 | 727 | |
728 | 728 | // Retrieve the current number and the start number. |
729 | - $number = (int) get_option( 'wpinv_last_invoice_number', 0 ); |
|
730 | - $start = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) ); |
|
729 | + $number = (int) get_option('wpinv_last_invoice_number', 0); |
|
730 | + $start = absint((int) wpinv_get_option('invoice_sequence_start', 1)); |
|
731 | 731 | |
732 | 732 | // Ensure that we are starting at a positive integer. |
733 | - $start = max( $start, 1 ); |
|
733 | + $start = max($start, 1); |
|
734 | 734 | |
735 | 735 | // If this is the first invoice, use the start number. |
736 | - $number = max( $start, $number ); |
|
736 | + $number = max($start, $number); |
|
737 | 737 | |
738 | 738 | // Format the invoice number. |
739 | - $formatted_number = wpinv_format_invoice_number( $number, $type ); |
|
739 | + $formatted_number = wpinv_format_invoice_number($number, $type); |
|
740 | 740 | |
741 | 741 | // Ensure that this number is unique. |
742 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' ); |
|
742 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number'); |
|
743 | 743 | |
744 | 744 | // We found a match. Nice. |
745 | - if ( empty( $invoice_id ) ) { |
|
746 | - update_option( 'wpinv_last_invoice_number', $number ); |
|
747 | - return apply_filters( 'wpinv_get_next_invoice_number', $number ); |
|
745 | + if (empty($invoice_id)) { |
|
746 | + update_option('wpinv_last_invoice_number', $number); |
|
747 | + return apply_filters('wpinv_get_next_invoice_number', $number); |
|
748 | 748 | } |
749 | 749 | |
750 | - update_option( 'wpinv_last_invoice_number', $number + 1 ); |
|
751 | - return wpinv_get_next_invoice_number( $type ); |
|
750 | + update_option('wpinv_last_invoice_number', $number + 1); |
|
751 | + return wpinv_get_next_invoice_number($type); |
|
752 | 752 | |
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
756 | 756 | * The prefix used for invoice paths. |
757 | 757 | */ |
758 | -function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) { |
|
759 | - return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type ); |
|
758 | +function wpinv_post_name_prefix($post_type = 'wpi_invoice') { |
|
759 | + return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type); |
|
760 | 760 | } |
761 | 761 | |
762 | -function wpinv_generate_post_name( $post_ID ) { |
|
763 | - $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) ); |
|
764 | - $post_name = sanitize_title( $prefix . $post_ID ); |
|
762 | +function wpinv_generate_post_name($post_ID) { |
|
763 | + $prefix = wpinv_post_name_prefix(get_post_type($post_ID)); |
|
764 | + $post_name = sanitize_title($prefix . $post_ID); |
|
765 | 765 | |
766 | - return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix ); |
|
766 | + return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | /** |
@@ -771,8 +771,8 @@ discard block |
||
771 | 771 | * |
772 | 772 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
773 | 773 | */ |
774 | -function wpinv_is_invoice_viewed( $invoice ) { |
|
775 | - $invoice = new WPInv_Invoice( $invoice ); |
|
774 | +function wpinv_is_invoice_viewed($invoice) { |
|
775 | + $invoice = new WPInv_Invoice($invoice); |
|
776 | 776 | return (bool) $invoice->get_is_viewed(); |
777 | 777 | } |
778 | 778 | |
@@ -781,17 +781,17 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
783 | 783 | */ |
784 | -function getpaid_maybe_mark_invoice_as_viewed( $invoice ) { |
|
785 | - $invoice = new WPInv_Invoice( $invoice ); |
|
784 | +function getpaid_maybe_mark_invoice_as_viewed($invoice) { |
|
785 | + $invoice = new WPInv_Invoice($invoice); |
|
786 | 786 | |
787 | - if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) { |
|
788 | - $invoice->set_is_viewed( true ); |
|
787 | + if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) { |
|
788 | + $invoice->set_is_viewed(true); |
|
789 | 789 | $invoice->save(); |
790 | 790 | } |
791 | 791 | |
792 | 792 | } |
793 | -add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
794 | -add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
793 | +add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
794 | +add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
795 | 795 | |
796 | 796 | /** |
797 | 797 | * Processes an invoice refund. |
@@ -801,27 +801,27 @@ discard block |
||
801 | 801 | * @param array $status_transition |
802 | 802 | * @todo: descrease customer/store earnings |
803 | 803 | */ |
804 | -function getpaid_maybe_process_refund( $invoice_id, $invoice, $status_transition ) { |
|
804 | +function getpaid_maybe_process_refund($invoice_id, $invoice, $status_transition) { |
|
805 | 805 | |
806 | - if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
806 | + if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
807 | 807 | return; |
808 | 808 | } |
809 | 809 | |
810 | 810 | $discount_code = $invoice->get_discount_code(); |
811 | - if ( ! empty( $discount_code ) ) { |
|
812 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
811 | + if (!empty($discount_code)) { |
|
812 | + $discount = wpinv_get_discount_obj($discount_code); |
|
813 | 813 | |
814 | - if ( $discount->exists() ) { |
|
814 | + if ($discount->exists()) { |
|
815 | 815 | $discount->increase_usage( -1 ); |
816 | 816 | } |
817 | 817 | |
818 | 818 | } |
819 | 819 | |
820 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice_id ); |
|
821 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice_id ); |
|
822 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice_id ); |
|
820 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice_id); |
|
821 | + do_action('wpinv_refund_invoice', $invoice, $invoice_id); |
|
822 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice_id); |
|
823 | 823 | } |
824 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 3 ); |
|
824 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 3); |
|
825 | 825 | |
826 | 826 | |
827 | 827 | /** |
@@ -829,48 +829,48 @@ discard block |
||
829 | 829 | * |
830 | 830 | * @param int $invoice_id |
831 | 831 | */ |
832 | -function getpaid_process_invoice_payment( $invoice_id ) { |
|
832 | +function getpaid_process_invoice_payment($invoice_id) { |
|
833 | 833 | |
834 | 834 | // Fetch the invoice. |
835 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
835 | + $invoice = new WPInv_Invoice($invoice_id); |
|
836 | 836 | |
837 | 837 | // We only want to do this once. |
838 | - if ( 1 == get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) { |
|
838 | + if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) { |
|
839 | 839 | return; |
840 | 840 | } |
841 | 841 | |
842 | - update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 ); |
|
842 | + update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1); |
|
843 | 843 | |
844 | 844 | // Fires when processing a payment. |
845 | - do_action( 'getpaid_process_payment', $invoice ); |
|
845 | + do_action('getpaid_process_payment', $invoice); |
|
846 | 846 | |
847 | 847 | // Fire an action for each invoice item. |
848 | - foreach( $invoice->get_items() as $item ) { |
|
849 | - do_action( 'getpaid_process_item_payment', $item, $invoice ); |
|
848 | + foreach ($invoice->get_items() as $item) { |
|
849 | + do_action('getpaid_process_item_payment', $item, $invoice); |
|
850 | 850 | } |
851 | 851 | |
852 | 852 | // Increase discount usage. |
853 | 853 | $discount_code = $invoice->get_discount_code(); |
854 | - if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) { |
|
855 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
854 | + if (!empty($discount_code) && !$invoice->is_renewal()) { |
|
855 | + $discount = wpinv_get_discount_obj($discount_code); |
|
856 | 856 | |
857 | - if ( $discount->exists() ) { |
|
857 | + if ($discount->exists()) { |
|
858 | 858 | $discount->increase_usage(); |
859 | 859 | } |
860 | 860 | |
861 | 861 | } |
862 | 862 | |
863 | 863 | // Record reverse vat. |
864 | - if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
864 | + if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
865 | 865 | |
866 | - if ( WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country( $invoice->get_country() ) ) { |
|
867 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
866 | + if (WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country($invoice->get_country())) { |
|
867 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | } |
871 | 871 | |
872 | 872 | } |
873 | -add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' ); |
|
873 | +add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment'); |
|
874 | 874 | |
875 | 875 | /** |
876 | 876 | * Returns an array of invoice item columns |
@@ -878,13 +878,13 @@ discard block |
||
878 | 878 | * @param int|WPInv_Invoice $invoice |
879 | 879 | * @return array |
880 | 880 | */ |
881 | -function getpaid_invoice_item_columns( $invoice ) { |
|
881 | +function getpaid_invoice_item_columns($invoice) { |
|
882 | 882 | |
883 | 883 | // Prepare the invoice. |
884 | - $invoice = new WPInv_Invoice( $invoice ); |
|
884 | + $invoice = new WPInv_Invoice($invoice); |
|
885 | 885 | |
886 | 886 | // Abort if there is no invoice. |
887 | - if ( 0 == $invoice->get_id() ) { |
|
887 | + if (0 == $invoice->get_id()) { |
|
888 | 888 | return array(); |
889 | 889 | } |
890 | 890 | |
@@ -892,47 +892,47 @@ discard block |
||
892 | 892 | $columns = apply_filters( |
893 | 893 | 'getpaid_invoice_item_columns', |
894 | 894 | array( |
895 | - 'name' => __( 'Item', 'invoicing' ), |
|
896 | - 'price' => __( 'Price', 'invoicing' ), |
|
897 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
898 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
895 | + 'name' => __('Item', 'invoicing'), |
|
896 | + 'price' => __('Price', 'invoicing'), |
|
897 | + 'quantity' => __('Quantity', 'invoicing'), |
|
898 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
899 | 899 | ), |
900 | 900 | $invoice |
901 | 901 | ); |
902 | 902 | |
903 | 903 | // Quantities. |
904 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
904 | + if (isset($columns['quantity'])) { |
|
905 | 905 | |
906 | - if ( 'hours' == $invoice->get_template() ) { |
|
907 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
906 | + if ('hours' == $invoice->get_template()) { |
|
907 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
908 | 908 | } |
909 | 909 | |
910 | - if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) { |
|
911 | - unset( $columns[ 'quantity' ] ); |
|
910 | + if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) { |
|
911 | + unset($columns['quantity']); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | } |
915 | 915 | |
916 | 916 | |
917 | 917 | // Price. |
918 | - if ( isset( $columns[ 'price' ] ) ) { |
|
918 | + if (isset($columns['price'])) { |
|
919 | 919 | |
920 | - if ( 'amount' == $invoice->get_template() ) { |
|
921 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
920 | + if ('amount' == $invoice->get_template()) { |
|
921 | + $columns['price'] = __('Amount', 'invoicing'); |
|
922 | 922 | } |
923 | 923 | |
924 | - if ( 'hours' == $invoice->get_template() ) { |
|
925 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
924 | + if ('hours' == $invoice->get_template()) { |
|
925 | + $columns['price'] = __('Rate', 'invoicing'); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | } |
929 | 929 | |
930 | 930 | |
931 | 931 | // Sub total. |
932 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
932 | + if (isset($columns['subtotal'])) { |
|
933 | 933 | |
934 | - if ( 'amount' == $invoice->get_template() ) { |
|
935 | - unset( $columns[ 'subtotal' ] ); |
|
934 | + if ('amount' == $invoice->get_template()) { |
|
935 | + unset($columns['subtotal']); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | } |
@@ -946,29 +946,29 @@ discard block |
||
946 | 946 | * @param int|WPInv_Invoice $invoice |
947 | 947 | * @return array |
948 | 948 | */ |
949 | -function getpaid_invoice_totals_rows( $invoice ) { |
|
949 | +function getpaid_invoice_totals_rows($invoice) { |
|
950 | 950 | |
951 | 951 | // Prepare the invoice. |
952 | - $invoice = new WPInv_Invoice( $invoice ); |
|
952 | + $invoice = new WPInv_Invoice($invoice); |
|
953 | 953 | |
954 | 954 | // Abort if there is no invoice. |
955 | - if ( 0 == $invoice->get_id() ) { |
|
955 | + if (0 == $invoice->get_id()) { |
|
956 | 956 | return array(); |
957 | 957 | } |
958 | 958 | |
959 | 959 | $totals = apply_filters( |
960 | 960 | 'getpaid_invoice_totals_rows', |
961 | 961 | array( |
962 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
963 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
964 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
965 | - 'total' => __( 'Total', 'invoicing' ), |
|
962 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
963 | + 'tax' => __('Tax', 'invoicing'), |
|
964 | + 'discount' => __('Discount', 'invoicing'), |
|
965 | + 'total' => __('Total', 'invoicing'), |
|
966 | 966 | ), |
967 | 967 | $invoice |
968 | 968 | ); |
969 | 969 | |
970 | - if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) { |
|
971 | - unset( $totals['tax'] ); |
|
970 | + if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) { |
|
971 | + unset($totals['tax']); |
|
972 | 972 | } |
973 | 973 | |
974 | 974 | return $totals; |
@@ -979,46 +979,46 @@ discard block |
||
979 | 979 | * |
980 | 980 | * @param WPInv_Invoice $invoice |
981 | 981 | */ |
982 | -function getpaid_new_invoice( $invoice ) { |
|
982 | +function getpaid_new_invoice($invoice) { |
|
983 | 983 | |
984 | - if ( ! $invoice->get_status() ) { |
|
984 | + if (!$invoice->get_status()) { |
|
985 | 985 | return; |
986 | 986 | } |
987 | 987 | |
988 | 988 | // Add an invoice created note. |
989 | 989 | $invoice->add_note( |
990 | 990 | wp_sprintf( |
991 | - __( 'Invoice created with the status "%s".', 'invoicing' ), |
|
992 | - wpinv_status_nicename( $invoice->get_status() ) |
|
991 | + __('Invoice created with the status "%s".', 'invoicing'), |
|
992 | + wpinv_status_nicename($invoice->get_status()) |
|
993 | 993 | ) |
994 | 994 | ); |
995 | 995 | |
996 | 996 | } |
997 | -add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' ); |
|
997 | +add_action('getpaid_new_invoice', 'getpaid_new_invoice'); |
|
998 | 998 | |
999 | 999 | /** |
1000 | 1000 | * This function updates invoice caches. |
1001 | 1001 | * |
1002 | 1002 | * @param WPInv_Invoice $invoice |
1003 | 1003 | */ |
1004 | -function getpaid_update_invoice_caches( $invoice ) { |
|
1004 | +function getpaid_update_invoice_caches($invoice) { |
|
1005 | 1005 | |
1006 | 1006 | // Cache invoice number. |
1007 | - wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" ); |
|
1007 | + wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids"); |
|
1008 | 1008 | |
1009 | 1009 | // Cache invoice key. |
1010 | - wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" ); |
|
1010 | + wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids"); |
|
1011 | 1011 | |
1012 | 1012 | // (Maybe) cache transaction id. |
1013 | 1013 | $transaction_id = $invoice->get_transaction_id(); |
1014 | 1014 | |
1015 | - if ( ! empty( $transaction_id ) ) { |
|
1016 | - wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" ); |
|
1015 | + if (!empty($transaction_id)) { |
|
1016 | + wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids"); |
|
1017 | 1017 | } |
1018 | 1018 | |
1019 | 1019 | } |
1020 | -add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1021 | -add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1020 | +add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5); |
|
1021 | +add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5); |
|
1022 | 1022 | |
1023 | 1023 | /** |
1024 | 1024 | * Duplicates an invoice. |
@@ -1028,7 +1028,7 @@ discard block |
||
1028 | 1028 | * @param WPInv_Invoice $old_invoice The invoice to duplicate |
1029 | 1029 | * @return WPInv_Invoice The new invoice. |
1030 | 1030 | */ |
1031 | -function getpaid_duplicate_invoice( $old_invoice ) { |
|
1031 | +function getpaid_duplicate_invoice($old_invoice) { |
|
1032 | 1032 | |
1033 | 1033 | // Create the new invoice. |
1034 | 1034 | $invoice = new WPInv_Invoice(); |
@@ -218,8 +218,9 @@ discard block |
||
218 | 218 | |
219 | 219 | // Setup possible parts |
220 | 220 | $templates = array(); |
221 | - if ( isset( $name ) ) |
|
222 | - $templates[] = $slug . '-' . $name . '.php'; |
|
221 | + if ( isset( $name ) ) { |
|
222 | + $templates[] = $slug . '-' . $name . '.php'; |
|
223 | + } |
|
223 | 224 | $templates[] = $slug . '.php'; |
224 | 225 | |
225 | 226 | // Allow template parts to be filtered |
@@ -237,8 +238,9 @@ discard block |
||
237 | 238 | foreach ( (array)$template_names as $template_name ) { |
238 | 239 | |
239 | 240 | // Continue if template is empty |
240 | - if ( empty( $template_name ) ) |
|
241 | - continue; |
|
241 | + if ( empty( $template_name ) ) { |
|
242 | + continue; |
|
243 | + } |
|
242 | 244 | |
243 | 245 | // Trim off any slashes from the template name |
244 | 246 | $template_name = ltrim( $template_name, '/' ); |
@@ -257,8 +259,9 @@ discard block |
||
257 | 259 | } |
258 | 260 | } |
259 | 261 | |
260 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
261 | - load_template( $located, $require_once ); |
|
262 | + if ( ( true == $load ) && ! empty( $located ) ) { |
|
263 | + load_template( $located, $require_once ); |
|
264 | + } |
|
262 | 265 | |
263 | 266 | return $located; |
264 | 267 | } |
@@ -336,8 +339,9 @@ discard block |
||
336 | 339 | function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
337 | 340 | $args = array( 'nopaging' => true ); |
338 | 341 | |
339 | - if ( ! empty( $status ) ) |
|
340 | - $args['post_status'] = $status; |
|
342 | + if ( ! empty( $status ) ) { |
|
343 | + $args['post_status'] = $status; |
|
344 | + } |
|
341 | 345 | |
342 | 346 | $discounts = wpinv_get_discounts( $args ); |
343 | 347 | $options = array(); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | 142 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
143 | + return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -175,122 +175,122 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
178 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
179 | 179 | |
180 | - // Setup possible parts |
|
181 | - $templates = array(); |
|
182 | - if ( isset( $name ) ) |
|
183 | - $templates[] = $slug . '-' . $name . '.php'; |
|
184 | - $templates[] = $slug . '.php'; |
|
180 | + // Setup possible parts |
|
181 | + $templates = array(); |
|
182 | + if ( isset( $name ) ) |
|
183 | + $templates[] = $slug . '-' . $name . '.php'; |
|
184 | + $templates[] = $slug . '.php'; |
|
185 | 185 | |
186 | - // Allow template parts to be filtered |
|
187 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
186 | + // Allow template parts to be filtered |
|
187 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
188 | 188 | |
189 | - // Return the part that is found |
|
190 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
189 | + // Return the part that is found |
|
190 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
194 | - // No file found yet |
|
195 | - $located = false; |
|
194 | + // No file found yet |
|
195 | + $located = false; |
|
196 | 196 | |
197 | - // Try to find a template file |
|
198 | - foreach ( (array)$template_names as $template_name ) { |
|
197 | + // Try to find a template file |
|
198 | + foreach ( (array)$template_names as $template_name ) { |
|
199 | 199 | |
200 | - // Continue if template is empty |
|
201 | - if ( empty( $template_name ) ) |
|
202 | - continue; |
|
200 | + // Continue if template is empty |
|
201 | + if ( empty( $template_name ) ) |
|
202 | + continue; |
|
203 | 203 | |
204 | - // Trim off any slashes from the template name |
|
205 | - $template_name = ltrim( $template_name, '/' ); |
|
204 | + // Trim off any slashes from the template name |
|
205 | + $template_name = ltrim( $template_name, '/' ); |
|
206 | 206 | |
207 | - // try locating this template file by looping through the template paths |
|
208 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
207 | + // try locating this template file by looping through the template paths |
|
208 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
209 | 209 | |
210 | - if( file_exists( $template_path . $template_name ) ) { |
|
211 | - $located = $template_path . $template_name; |
|
212 | - break; |
|
213 | - } |
|
214 | - } |
|
210 | + if( file_exists( $template_path . $template_name ) ) { |
|
211 | + $located = $template_path . $template_name; |
|
212 | + break; |
|
213 | + } |
|
214 | + } |
|
215 | 215 | |
216 | - if( !empty( $located ) ) { |
|
217 | - break; |
|
218 | - } |
|
219 | - } |
|
216 | + if( !empty( $located ) ) { |
|
217 | + break; |
|
218 | + } |
|
219 | + } |
|
220 | 220 | |
221 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
222 | - load_template( $located, $require_once ); |
|
221 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
222 | + load_template( $located, $require_once ); |
|
223 | 223 | |
224 | - return $located; |
|
224 | + return $located; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | function wpinv_get_theme_template_paths() { |
228 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
228 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
229 | 229 | |
230 | - $file_paths = array( |
|
231 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
232 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
233 | - 100 => wpinv_get_templates_dir() |
|
234 | - ); |
|
230 | + $file_paths = array( |
|
231 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
232 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
233 | + 100 => wpinv_get_templates_dir() |
|
234 | + ); |
|
235 | 235 | |
236 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
236 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
237 | 237 | |
238 | - // sort the file paths based on priority |
|
239 | - ksort( $file_paths, SORT_NUMERIC ); |
|
238 | + // sort the file paths based on priority |
|
239 | + ksort( $file_paths, SORT_NUMERIC ); |
|
240 | 240 | |
241 | - return array_map( 'trailingslashit', $file_paths ); |
|
241 | + return array_map( 'trailingslashit', $file_paths ); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | function wpinv_checkout_meta_tags() { |
245 | 245 | |
246 | - $pages = array(); |
|
247 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
248 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
249 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
250 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
246 | + $pages = array(); |
|
247 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
248 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
249 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
250 | + $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
251 | 251 | |
252 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
253 | - return; |
|
254 | - } |
|
252 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
253 | + return; |
|
254 | + } |
|
255 | 255 | |
256 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
256 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
257 | 257 | } |
258 | 258 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
259 | 259 | |
260 | 260 | function wpinv_add_body_classes( $class ) { |
261 | - $classes = (array)$class; |
|
261 | + $classes = (array)$class; |
|
262 | 262 | |
263 | - if( wpinv_is_checkout() ) { |
|
264 | - $classes[] = 'wpinv-checkout'; |
|
265 | - $classes[] = 'wpinv-page'; |
|
266 | - } |
|
263 | + if( wpinv_is_checkout() ) { |
|
264 | + $classes[] = 'wpinv-checkout'; |
|
265 | + $classes[] = 'wpinv-page'; |
|
266 | + } |
|
267 | 267 | |
268 | - if( wpinv_is_success_page() ) { |
|
269 | - $classes[] = 'wpinv-success'; |
|
270 | - $classes[] = 'wpinv-page'; |
|
271 | - } |
|
268 | + if( wpinv_is_success_page() ) { |
|
269 | + $classes[] = 'wpinv-success'; |
|
270 | + $classes[] = 'wpinv-page'; |
|
271 | + } |
|
272 | 272 | |
273 | - if( wpinv_is_failed_transaction_page() ) { |
|
274 | - $classes[] = 'wpinv-failed-transaction'; |
|
275 | - $classes[] = 'wpinv-page'; |
|
276 | - } |
|
273 | + if( wpinv_is_failed_transaction_page() ) { |
|
274 | + $classes[] = 'wpinv-failed-transaction'; |
|
275 | + $classes[] = 'wpinv-page'; |
|
276 | + } |
|
277 | 277 | |
278 | - if( wpinv_is_invoice_history_page() ) { |
|
279 | - $classes[] = 'wpinv-history'; |
|
280 | - $classes[] = 'wpinv-page'; |
|
281 | - } |
|
278 | + if( wpinv_is_invoice_history_page() ) { |
|
279 | + $classes[] = 'wpinv-history'; |
|
280 | + $classes[] = 'wpinv-page'; |
|
281 | + } |
|
282 | 282 | |
283 | - if( wpinv_is_subscriptions_history_page() ) { |
|
284 | - $classes[] = 'wpinv-subscription'; |
|
285 | - $classes[] = 'wpinv-page'; |
|
286 | - } |
|
283 | + if( wpinv_is_subscriptions_history_page() ) { |
|
284 | + $classes[] = 'wpinv-subscription'; |
|
285 | + $classes[] = 'wpinv-page'; |
|
286 | + } |
|
287 | 287 | |
288 | - if( wpinv_is_test_mode() ) { |
|
289 | - $classes[] = 'wpinv-test-mode'; |
|
290 | - $classes[] = 'wpinv-page'; |
|
291 | - } |
|
288 | + if( wpinv_is_test_mode() ) { |
|
289 | + $classes[] = 'wpinv-test-mode'; |
|
290 | + $classes[] = 'wpinv-page'; |
|
291 | + } |
|
292 | 292 | |
293 | - return array_unique( $classes ); |
|
293 | + return array_unique( $classes ); |
|
294 | 294 | } |
295 | 295 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
296 | 296 | |
@@ -992,21 +992,21 @@ discard block |
||
992 | 992 | |
993 | 993 | $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
994 | 994 | |
995 | - // Remove unavailable tags. |
|
995 | + // Remove unavailable tags. |
|
996 | 996 | $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
997 | 997 | |
998 | 998 | // Clean up white space. |
999 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
999 | + $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
1000 | 1000 | $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
1001 | 1001 | |
1002 | 1002 | // Break newlines apart and remove empty lines/trim commas and white space. |
1003 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
1003 | + $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
1004 | 1004 | |
1005 | 1005 | // Add html breaks. |
1006 | - $formatted_address = implode( $separator, $formatted_address ); |
|
1006 | + $formatted_address = implode( $separator, $formatted_address ); |
|
1007 | 1007 | |
1008 | - // We're done! |
|
1009 | - return $formatted_address; |
|
1008 | + // We're done! |
|
1009 | + return $formatted_address; |
|
1010 | 1010 | |
1011 | 1011 | } |
1012 | 1012 | |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | function wpinv_empty_cart_message() { |
1211 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1211 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | /** |
@@ -1498,10 +1498,10 @@ discard block |
||
1498 | 1498 | |
1499 | 1499 | if ( 0 == count( $form->get_items() ) ) { |
1500 | 1500 | echo aui()->alert( |
1501 | - array( |
|
1502 | - 'type' => 'warning', |
|
1503 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1504 | - ) |
|
1501 | + array( |
|
1502 | + 'type' => 'warning', |
|
1503 | + 'content' => __( 'No published items found', 'invoicing' ), |
|
1504 | + ) |
|
1505 | 1505 | ); |
1506 | 1506 | return; |
1507 | 1507 | } |
@@ -1517,21 +1517,21 @@ discard block |
||
1517 | 1517 | $invoice = wpinv_get_invoice( $invoice_id ); |
1518 | 1518 | |
1519 | 1519 | if ( empty( $invoice ) ) { |
1520 | - echo aui()->alert( |
|
1521 | - array( |
|
1522 | - 'type' => 'warning', |
|
1523 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1524 | - ) |
|
1520 | + echo aui()->alert( |
|
1521 | + array( |
|
1522 | + 'type' => 'warning', |
|
1523 | + 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1524 | + ) |
|
1525 | 1525 | ); |
1526 | 1526 | return; |
1527 | 1527 | } |
1528 | 1528 | |
1529 | 1529 | if ( $invoice->is_paid() ) { |
1530 | - echo aui()->alert( |
|
1531 | - array( |
|
1532 | - 'type' => 'warning', |
|
1533 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1534 | - ) |
|
1530 | + echo aui()->alert( |
|
1531 | + array( |
|
1532 | + 'type' => 'warning', |
|
1533 | + 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1534 | + ) |
|
1535 | 1535 | ); |
1536 | 1536 | return; |
1537 | 1537 | } |
@@ -1594,7 +1594,7 @@ discard block |
||
1594 | 1594 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; |
1595 | 1595 | } |
1596 | 1596 | |
1597 | - if ( ! empty( $items ) ) { |
|
1597 | + if ( ! empty( $items ) ) { |
|
1598 | 1598 | $items = esc_attr( $items ); |
1599 | 1599 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; |
1600 | 1600 | } |
@@ -4,99 +4,99 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Displays an invoice. |
11 | 11 | * |
12 | 12 | * @param WPInv_Invoice $invoice. |
13 | 13 | */ |
14 | -function getpaid_invoice( $invoice ) { |
|
15 | - if ( ! empty( $invoice ) ) { |
|
16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
14 | +function getpaid_invoice($invoice) { |
|
15 | + if (!empty($invoice)) { |
|
16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
17 | 17 | } |
18 | 18 | } |
19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Displays the invoice footer. |
23 | 23 | */ |
24 | -function getpaid_invoice_footer( $invoice ) { |
|
25 | - if ( ! empty( $invoice ) ) { |
|
26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
24 | +function getpaid_invoice_footer($invoice) { |
|
25 | + if (!empty($invoice)) { |
|
26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
27 | 27 | } |
28 | 28 | } |
29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Displays the invoice top bar. |
33 | 33 | */ |
34 | -function getpaid_invoice_header( $invoice ) { |
|
35 | - if ( ! empty( $invoice ) ) { |
|
36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
34 | +function getpaid_invoice_header($invoice) { |
|
35 | + if (!empty($invoice)) { |
|
36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
37 | 37 | } |
38 | 38 | } |
39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Displays actions on the left side of the header. |
43 | 43 | */ |
44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
45 | - if ( ! empty( $invoice ) ) { |
|
46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
45 | + if (!empty($invoice)) { |
|
46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
47 | 47 | } |
48 | 48 | } |
49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Displays actions on the right side of the invoice top bar. |
53 | 53 | */ |
54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
55 | - if ( ! empty( $invoice ) ) { |
|
56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
55 | + if (!empty($invoice)) { |
|
56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
57 | 57 | } |
58 | 58 | } |
59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Displays the invoice title, watermark, logo etc. |
63 | 63 | */ |
64 | -function getpaid_invoice_details_top( $invoice ) { |
|
65 | - if ( ! empty( $invoice ) ) { |
|
66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
64 | +function getpaid_invoice_details_top($invoice) { |
|
65 | + if (!empty($invoice)) { |
|
66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
67 | 67 | } |
68 | 68 | } |
69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Displays the company logo. |
73 | 73 | */ |
74 | -function getpaid_invoice_logo( $invoice ) { |
|
75 | - if ( ! empty( $invoice ) ) { |
|
76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
74 | +function getpaid_invoice_logo($invoice) { |
|
75 | + if (!empty($invoice)) { |
|
76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
77 | 77 | } |
78 | 78 | } |
79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Displays the type of invoice. |
83 | 83 | */ |
84 | -function getpaid_invoice_type( $invoice ) { |
|
85 | - if ( ! empty( $invoice ) ) { |
|
86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
84 | +function getpaid_invoice_type($invoice) { |
|
85 | + if (!empty($invoice)) { |
|
86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
87 | 87 | } |
88 | 88 | } |
89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Displays the invoice details. |
93 | 93 | */ |
94 | -function getpaid_invoice_details_main( $invoice ) { |
|
95 | - if ( ! empty( $invoice ) ) { |
|
96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
94 | +function getpaid_invoice_details_main($invoice) { |
|
95 | + if (!empty($invoice)) { |
|
96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
97 | 97 | } |
98 | 98 | } |
99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
127 | 127 | */ |
128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
129 | - return getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
129 | + return getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return string |
150 | 150 | */ |
151 | 151 | function wpinv_template_path() { |
152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,56 +170,56 @@ discard block |
||
170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
172 | 172 | */ |
173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
175 | 175 | } |
176 | 176 | |
177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
179 | 179 | |
180 | 180 | // Setup possible parts |
181 | 181 | $templates = array(); |
182 | - if ( isset( $name ) ) |
|
182 | + if (isset($name)) |
|
183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
184 | 184 | $templates[] = $slug . '.php'; |
185 | 185 | |
186 | 186 | // Allow template parts to be filtered |
187 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
187 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
188 | 188 | |
189 | 189 | // Return the part that is found |
190 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
190 | + return wpinv_locate_tmpl($templates, $load, false); |
|
191 | 191 | } |
192 | 192 | |
193 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
193 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
194 | 194 | // No file found yet |
195 | 195 | $located = false; |
196 | 196 | |
197 | 197 | // Try to find a template file |
198 | - foreach ( (array)$template_names as $template_name ) { |
|
198 | + foreach ((array) $template_names as $template_name) { |
|
199 | 199 | |
200 | 200 | // Continue if template is empty |
201 | - if ( empty( $template_name ) ) |
|
201 | + if (empty($template_name)) |
|
202 | 202 | continue; |
203 | 203 | |
204 | 204 | // Trim off any slashes from the template name |
205 | - $template_name = ltrim( $template_name, '/' ); |
|
205 | + $template_name = ltrim($template_name, '/'); |
|
206 | 206 | |
207 | 207 | // try locating this template file by looping through the template paths |
208 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
208 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
209 | 209 | |
210 | - if( file_exists( $template_path . $template_name ) ) { |
|
210 | + if (file_exists($template_path . $template_name)) { |
|
211 | 211 | $located = $template_path . $template_name; |
212 | 212 | break; |
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
216 | - if( !empty( $located ) ) { |
|
216 | + if (!empty($located)) { |
|
217 | 217 | break; |
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
222 | - load_template( $located, $require_once ); |
|
221 | + if ((true == $load) && !empty($located)) |
|
222 | + load_template($located, $require_once); |
|
223 | 223 | |
224 | 224 | return $located; |
225 | 225 | } |
@@ -228,155 +228,155 @@ discard block |
||
228 | 228 | $template_dir = wpinv_get_theme_template_dir_name(); |
229 | 229 | |
230 | 230 | $file_paths = array( |
231 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
232 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
231 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
232 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
233 | 233 | 100 => wpinv_get_templates_dir() |
234 | 234 | ); |
235 | 235 | |
236 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
236 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
237 | 237 | |
238 | 238 | // sort the file paths based on priority |
239 | - ksort( $file_paths, SORT_NUMERIC ); |
|
239 | + ksort($file_paths, SORT_NUMERIC); |
|
240 | 240 | |
241 | - return array_map( 'trailingslashit', $file_paths ); |
|
241 | + return array_map('trailingslashit', $file_paths); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | function wpinv_checkout_meta_tags() { |
245 | 245 | |
246 | 246 | $pages = array(); |
247 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
248 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
249 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
250 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
247 | + $pages[] = wpinv_get_option('success_page'); |
|
248 | + $pages[] = wpinv_get_option('failure_page'); |
|
249 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
250 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
251 | 251 | |
252 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
252 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
253 | 253 | return; |
254 | 254 | } |
255 | 255 | |
256 | 256 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
257 | 257 | } |
258 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
258 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
259 | 259 | |
260 | -function wpinv_add_body_classes( $class ) { |
|
261 | - $classes = (array)$class; |
|
260 | +function wpinv_add_body_classes($class) { |
|
261 | + $classes = (array) $class; |
|
262 | 262 | |
263 | - if( wpinv_is_checkout() ) { |
|
263 | + if (wpinv_is_checkout()) { |
|
264 | 264 | $classes[] = 'wpinv-checkout'; |
265 | 265 | $classes[] = 'wpinv-page'; |
266 | 266 | } |
267 | 267 | |
268 | - if( wpinv_is_success_page() ) { |
|
268 | + if (wpinv_is_success_page()) { |
|
269 | 269 | $classes[] = 'wpinv-success'; |
270 | 270 | $classes[] = 'wpinv-page'; |
271 | 271 | } |
272 | 272 | |
273 | - if( wpinv_is_failed_transaction_page() ) { |
|
273 | + if (wpinv_is_failed_transaction_page()) { |
|
274 | 274 | $classes[] = 'wpinv-failed-transaction'; |
275 | 275 | $classes[] = 'wpinv-page'; |
276 | 276 | } |
277 | 277 | |
278 | - if( wpinv_is_invoice_history_page() ) { |
|
278 | + if (wpinv_is_invoice_history_page()) { |
|
279 | 279 | $classes[] = 'wpinv-history'; |
280 | 280 | $classes[] = 'wpinv-page'; |
281 | 281 | } |
282 | 282 | |
283 | - if( wpinv_is_subscriptions_history_page() ) { |
|
283 | + if (wpinv_is_subscriptions_history_page()) { |
|
284 | 284 | $classes[] = 'wpinv-subscription'; |
285 | 285 | $classes[] = 'wpinv-page'; |
286 | 286 | } |
287 | 287 | |
288 | - if( wpinv_is_test_mode() ) { |
|
288 | + if (wpinv_is_test_mode()) { |
|
289 | 289 | $classes[] = 'wpinv-test-mode'; |
290 | 290 | $classes[] = 'wpinv-page'; |
291 | 291 | } |
292 | 292 | |
293 | - return array_unique( $classes ); |
|
293 | + return array_unique($classes); |
|
294 | 294 | } |
295 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
295 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
296 | 296 | |
297 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
298 | - $args = array( 'nopaging' => true ); |
|
297 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
298 | + $args = array('nopaging' => true); |
|
299 | 299 | |
300 | - if ( ! empty( $status ) ) |
|
300 | + if (!empty($status)) |
|
301 | 301 | $args['post_status'] = $status; |
302 | 302 | |
303 | - $discounts = wpinv_get_discounts( $args ); |
|
303 | + $discounts = wpinv_get_discounts($args); |
|
304 | 304 | $options = array(); |
305 | 305 | |
306 | - if ( $discounts ) { |
|
307 | - foreach ( $discounts as $discount ) { |
|
308 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
306 | + if ($discounts) { |
|
307 | + foreach ($discounts as $discount) { |
|
308 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
309 | 309 | } |
310 | 310 | } else { |
311 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
311 | + $options[0] = __('No discounts found', 'invoicing'); |
|
312 | 312 | } |
313 | 313 | |
314 | - $output = wpinv_html_select( array( |
|
314 | + $output = wpinv_html_select(array( |
|
315 | 315 | 'name' => $name, |
316 | 316 | 'selected' => $selected, |
317 | 317 | 'options' => $options, |
318 | 318 | 'show_option_all' => false, |
319 | 319 | 'show_option_none' => false, |
320 | - ) ); |
|
320 | + )); |
|
321 | 321 | |
322 | 322 | return $output; |
323 | 323 | } |
324 | 324 | |
325 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
326 | - $current = date( 'Y' ); |
|
327 | - $start_year = $current - absint( $years_before ); |
|
328 | - $end_year = $current + absint( $years_after ); |
|
329 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
325 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
326 | + $current = date('Y'); |
|
327 | + $start_year = $current - absint($years_before); |
|
328 | + $end_year = $current + absint($years_after); |
|
329 | + $selected = empty($selected) ? date('Y') : $selected; |
|
330 | 330 | $options = array(); |
331 | 331 | |
332 | - while ( $start_year <= $end_year ) { |
|
333 | - $options[ absint( $start_year ) ] = $start_year; |
|
332 | + while ($start_year <= $end_year) { |
|
333 | + $options[absint($start_year)] = $start_year; |
|
334 | 334 | $start_year++; |
335 | 335 | } |
336 | 336 | |
337 | - $output = wpinv_html_select( array( |
|
337 | + $output = wpinv_html_select(array( |
|
338 | 338 | 'name' => $name, |
339 | 339 | 'selected' => $selected, |
340 | 340 | 'options' => $options, |
341 | 341 | 'show_option_all' => false, |
342 | 342 | 'show_option_none' => false |
343 | - ) ); |
|
343 | + )); |
|
344 | 344 | |
345 | 345 | return $output; |
346 | 346 | } |
347 | 347 | |
348 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
348 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
349 | 349 | |
350 | 350 | $options = array( |
351 | - '1' => __( 'January', 'invoicing' ), |
|
352 | - '2' => __( 'February', 'invoicing' ), |
|
353 | - '3' => __( 'March', 'invoicing' ), |
|
354 | - '4' => __( 'April', 'invoicing' ), |
|
355 | - '5' => __( 'May', 'invoicing' ), |
|
356 | - '6' => __( 'June', 'invoicing' ), |
|
357 | - '7' => __( 'July', 'invoicing' ), |
|
358 | - '8' => __( 'August', 'invoicing' ), |
|
359 | - '9' => __( 'September', 'invoicing' ), |
|
360 | - '10' => __( 'October', 'invoicing' ), |
|
361 | - '11' => __( 'November', 'invoicing' ), |
|
362 | - '12' => __( 'December', 'invoicing' ), |
|
351 | + '1' => __('January', 'invoicing'), |
|
352 | + '2' => __('February', 'invoicing'), |
|
353 | + '3' => __('March', 'invoicing'), |
|
354 | + '4' => __('April', 'invoicing'), |
|
355 | + '5' => __('May', 'invoicing'), |
|
356 | + '6' => __('June', 'invoicing'), |
|
357 | + '7' => __('July', 'invoicing'), |
|
358 | + '8' => __('August', 'invoicing'), |
|
359 | + '9' => __('September', 'invoicing'), |
|
360 | + '10' => __('October', 'invoicing'), |
|
361 | + '11' => __('November', 'invoicing'), |
|
362 | + '12' => __('December', 'invoicing'), |
|
363 | 363 | ); |
364 | 364 | |
365 | 365 | // If no month is selected, default to the current month |
366 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
366 | + $selected = empty($selected) ? date('n') : $selected; |
|
367 | 367 | |
368 | - $output = wpinv_html_select( array( |
|
368 | + $output = wpinv_html_select(array( |
|
369 | 369 | 'name' => $name, |
370 | 370 | 'selected' => $selected, |
371 | 371 | 'options' => $options, |
372 | 372 | 'show_option_all' => false, |
373 | 373 | 'show_option_none' => false |
374 | - ) ); |
|
374 | + )); |
|
375 | 375 | |
376 | 376 | return $output; |
377 | 377 | } |
378 | 378 | |
379 | -function wpinv_html_select( $args = array() ) { |
|
379 | +function wpinv_html_select($args = array()) { |
|
380 | 380 | $defaults = array( |
381 | 381 | 'options' => array(), |
382 | 382 | 'name' => null, |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | 'selected' => 0, |
386 | 386 | 'placeholder' => null, |
387 | 387 | 'multiple' => false, |
388 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
389 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
388 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
389 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
390 | 390 | 'data' => array(), |
391 | 391 | 'onchange' => null, |
392 | 392 | 'required' => false, |
@@ -394,74 +394,74 @@ discard block |
||
394 | 394 | 'readonly' => false, |
395 | 395 | ); |
396 | 396 | |
397 | - $args = wp_parse_args( $args, $defaults ); |
|
397 | + $args = wp_parse_args($args, $defaults); |
|
398 | 398 | |
399 | 399 | $data_elements = ''; |
400 | - foreach ( $args['data'] as $key => $value ) { |
|
401 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
400 | + foreach ($args['data'] as $key => $value) { |
|
401 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
402 | 402 | } |
403 | 403 | |
404 | - if( $args['multiple'] ) { |
|
404 | + if ($args['multiple']) { |
|
405 | 405 | $multiple = ' MULTIPLE'; |
406 | 406 | } else { |
407 | 407 | $multiple = ''; |
408 | 408 | } |
409 | 409 | |
410 | - if( $args['placeholder'] ) { |
|
410 | + if ($args['placeholder']) { |
|
411 | 411 | $placeholder = $args['placeholder']; |
412 | 412 | } else { |
413 | 413 | $placeholder = ''; |
414 | 414 | } |
415 | 415 | |
416 | 416 | $options = ''; |
417 | - if( !empty( $args['onchange'] ) ) { |
|
418 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
417 | + if (!empty($args['onchange'])) { |
|
418 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
419 | 419 | } |
420 | 420 | |
421 | - if( !empty( $args['required'] ) ) { |
|
421 | + if (!empty($args['required'])) { |
|
422 | 422 | $options .= ' required="required"'; |
423 | 423 | } |
424 | 424 | |
425 | - if( !empty( $args['disabled'] ) ) { |
|
425 | + if (!empty($args['disabled'])) { |
|
426 | 426 | $options .= ' disabled'; |
427 | 427 | } |
428 | 428 | |
429 | - if( !empty( $args['readonly'] ) ) { |
|
429 | + if (!empty($args['readonly'])) { |
|
430 | 430 | $options .= ' readonly'; |
431 | 431 | } |
432 | 432 | |
433 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
434 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
433 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
434 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
435 | 435 | |
436 | - if ( $args['show_option_all'] ) { |
|
437 | - if( $args['multiple'] ) { |
|
438 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
436 | + if ($args['show_option_all']) { |
|
437 | + if ($args['multiple']) { |
|
438 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
439 | 439 | } else { |
440 | - $selected = selected( $args['selected'], 0, false ); |
|
440 | + $selected = selected($args['selected'], 0, false); |
|
441 | 441 | } |
442 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
442 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
443 | 443 | } |
444 | 444 | |
445 | - if ( !empty( $args['options'] ) ) { |
|
445 | + if (!empty($args['options'])) { |
|
446 | 446 | |
447 | - if ( $args['show_option_none'] ) { |
|
448 | - if( $args['multiple'] ) { |
|
449 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
447 | + if ($args['show_option_none']) { |
|
448 | + if ($args['multiple']) { |
|
449 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
450 | 450 | } else { |
451 | - $selected = selected( $args['selected'] === "", true, false ); |
|
451 | + $selected = selected($args['selected'] === "", true, false); |
|
452 | 452 | } |
453 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
453 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
454 | 454 | } |
455 | 455 | |
456 | - foreach( $args['options'] as $key => $option ) { |
|
456 | + foreach ($args['options'] as $key => $option) { |
|
457 | 457 | |
458 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
459 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
458 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
459 | + $selected = selected(true, (bool) in_array($key, $args['selected']), false); |
|
460 | 460 | } else { |
461 | - $selected = selected( $args['selected'], $key, false ); |
|
461 | + $selected = selected($args['selected'], $key, false); |
|
462 | 462 | } |
463 | 463 | |
464 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
464 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | return $output; |
471 | 471 | } |
472 | 472 | |
473 | -function wpinv_item_dropdown( $args = array() ) { |
|
473 | +function wpinv_item_dropdown($args = array()) { |
|
474 | 474 | $defaults = array( |
475 | 475 | 'name' => 'wpi_item', |
476 | 476 | 'id' => 'wpi_item', |
@@ -478,14 +478,14 @@ discard block |
||
478 | 478 | 'multiple' => false, |
479 | 479 | 'selected' => 0, |
480 | 480 | 'number' => 100, |
481 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
482 | - 'data' => array( 'search-type' => 'item' ), |
|
481 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
482 | + 'data' => array('search-type' => 'item'), |
|
483 | 483 | 'show_option_all' => false, |
484 | 484 | 'show_option_none' => false, |
485 | 485 | 'show_recurring' => false, |
486 | 486 | ); |
487 | 487 | |
488 | - $args = wp_parse_args( $args, $defaults ); |
|
488 | + $args = wp_parse_args($args, $defaults); |
|
489 | 489 | |
490 | 490 | $item_args = array( |
491 | 491 | 'post_type' => 'wpi_item', |
@@ -494,44 +494,44 @@ discard block |
||
494 | 494 | 'posts_per_page' => $args['number'] |
495 | 495 | ); |
496 | 496 | |
497 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
497 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
498 | 498 | |
499 | - $items = get_posts( $item_args ); |
|
499 | + $items = get_posts($item_args); |
|
500 | 500 | $options = array(); |
501 | - if ( $items ) { |
|
502 | - foreach ( $items as $item ) { |
|
503 | - $title = esc_html( $item->post_title ); |
|
501 | + if ($items) { |
|
502 | + foreach ($items as $item) { |
|
503 | + $title = esc_html($item->post_title); |
|
504 | 504 | |
505 | - if ( !empty( $args['show_recurring'] ) ) { |
|
506 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
505 | + if (!empty($args['show_recurring'])) { |
|
506 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
507 | 507 | } |
508 | 508 | |
509 | - $options[ absint( $item->ID ) ] = $title; |
|
509 | + $options[absint($item->ID)] = $title; |
|
510 | 510 | } |
511 | 511 | } |
512 | 512 | |
513 | 513 | // This ensures that any selected items are included in the drop down |
514 | - if( is_array( $args['selected'] ) ) { |
|
515 | - foreach( $args['selected'] as $item ) { |
|
516 | - if( ! in_array( $item, $options ) ) { |
|
517 | - $title = get_the_title( $item ); |
|
518 | - if ( !empty( $args['show_recurring'] ) ) { |
|
519 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
514 | + if (is_array($args['selected'])) { |
|
515 | + foreach ($args['selected'] as $item) { |
|
516 | + if (!in_array($item, $options)) { |
|
517 | + $title = get_the_title($item); |
|
518 | + if (!empty($args['show_recurring'])) { |
|
519 | + $title .= wpinv_get_item_suffix($item, false); |
|
520 | 520 | } |
521 | 521 | $options[$item] = $title; |
522 | 522 | } |
523 | 523 | } |
524 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
525 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
526 | - $title = get_the_title( $args['selected'] ); |
|
527 | - if ( !empty( $args['show_recurring'] ) ) { |
|
528 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
524 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
525 | + if (!in_array($args['selected'], $options)) { |
|
526 | + $title = get_the_title($args['selected']); |
|
527 | + if (!empty($args['show_recurring'])) { |
|
528 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
529 | 529 | } |
530 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
530 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
534 | - $output = wpinv_html_select( array( |
|
534 | + $output = wpinv_html_select(array( |
|
535 | 535 | 'name' => $args['name'], |
536 | 536 | 'selected' => $args['selected'], |
537 | 537 | 'id' => $args['id'], |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | 'show_option_all' => $args['show_option_all'], |
543 | 543 | 'show_option_none' => $args['show_option_none'], |
544 | 544 | 'data' => $args['data'], |
545 | - ) ); |
|
545 | + )); |
|
546 | 546 | |
547 | 547 | return $output; |
548 | 548 | } |
@@ -562,16 +562,16 @@ discard block |
||
562 | 562 | ); |
563 | 563 | |
564 | 564 | $options = array(); |
565 | - if ( $items ) { |
|
566 | - foreach ( $items as $item ) { |
|
567 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
565 | + if ($items) { |
|
566 | + foreach ($items as $item) { |
|
567 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
571 | 571 | return $options; |
572 | 572 | } |
573 | 573 | |
574 | -function wpinv_html_checkbox( $args = array() ) { |
|
574 | +function wpinv_html_checkbox($args = array()) { |
|
575 | 575 | $defaults = array( |
576 | 576 | 'name' => null, |
577 | 577 | 'current' => null, |
@@ -582,17 +582,17 @@ discard block |
||
582 | 582 | ) |
583 | 583 | ); |
584 | 584 | |
585 | - $args = wp_parse_args( $args, $defaults ); |
|
585 | + $args = wp_parse_args($args, $defaults); |
|
586 | 586 | |
587 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
587 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
588 | 588 | $options = ''; |
589 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
589 | + if (!empty($args['options']['disabled'])) { |
|
590 | 590 | $options .= ' disabled="disabled"'; |
591 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
591 | + } elseif (!empty($args['options']['readonly'])) { |
|
592 | 592 | $options .= ' readonly'; |
593 | 593 | } |
594 | 594 | |
595 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
595 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
596 | 596 | |
597 | 597 | return $output; |
598 | 598 | } |
@@ -600,30 +600,30 @@ discard block |
||
600 | 600 | /** |
601 | 601 | * Displays a hidden field. |
602 | 602 | */ |
603 | -function getpaid_hidden_field( $name, $value ) { |
|
604 | - $name = sanitize_text_field( $name ); |
|
605 | - $value = esc_attr( $value ); |
|
603 | +function getpaid_hidden_field($name, $value) { |
|
604 | + $name = sanitize_text_field($name); |
|
605 | + $value = esc_attr($value); |
|
606 | 606 | |
607 | 607 | echo "<input type='hidden' name='$name' value='$value' />"; |
608 | 608 | } |
609 | 609 | |
610 | -function wpinv_html_text( $args = array() ) { |
|
610 | +function wpinv_html_text($args = array()) { |
|
611 | 611 | // Backwards compatibility |
612 | - if ( func_num_args() > 1 ) { |
|
612 | + if (func_num_args() > 1) { |
|
613 | 613 | $args = func_get_args(); |
614 | 614 | |
615 | 615 | $name = $args[0]; |
616 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
617 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
618 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
616 | + $value = isset($args[1]) ? $args[1] : ''; |
|
617 | + $label = isset($args[2]) ? $args[2] : ''; |
|
618 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | $defaults = array( |
622 | 622 | 'id' => '', |
623 | - 'name' => isset( $name ) ? $name : 'text', |
|
624 | - 'value' => isset( $value ) ? $value : null, |
|
625 | - 'label' => isset( $label ) ? $label : null, |
|
626 | - 'desc' => isset( $desc ) ? $desc : null, |
|
623 | + 'name' => isset($name) ? $name : 'text', |
|
624 | + 'value' => isset($value) ? $value : null, |
|
625 | + 'label' => isset($label) ? $label : null, |
|
626 | + 'desc' => isset($desc) ? $desc : null, |
|
627 | 627 | 'placeholder' => '', |
628 | 628 | 'class' => 'regular-text', |
629 | 629 | 'disabled' => false, |
@@ -633,51 +633,51 @@ discard block |
||
633 | 633 | 'data' => false |
634 | 634 | ); |
635 | 635 | |
636 | - $args = wp_parse_args( $args, $defaults ); |
|
636 | + $args = wp_parse_args($args, $defaults); |
|
637 | 637 | |
638 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
638 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
639 | 639 | $options = ''; |
640 | - if( $args['required'] ) { |
|
640 | + if ($args['required']) { |
|
641 | 641 | $options .= ' required="required"'; |
642 | 642 | } |
643 | - if( $args['readonly'] ) { |
|
643 | + if ($args['readonly']) { |
|
644 | 644 | $options .= ' readonly'; |
645 | 645 | } |
646 | - if( $args['readonly'] ) { |
|
646 | + if ($args['readonly']) { |
|
647 | 647 | $options .= ' readonly'; |
648 | 648 | } |
649 | 649 | |
650 | 650 | $data = ''; |
651 | - if ( !empty( $args['data'] ) ) { |
|
652 | - foreach ( $args['data'] as $key => $value ) { |
|
653 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
651 | + if (!empty($args['data'])) { |
|
652 | + foreach ($args['data'] as $key => $value) { |
|
653 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | |
657 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
658 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
659 | - if ( ! empty( $args['desc'] ) ) { |
|
660 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
657 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
658 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
659 | + if (!empty($args['desc'])) { |
|
660 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
661 | 661 | } |
662 | 662 | |
663 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
663 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
664 | 664 | |
665 | 665 | $output .= '</span>'; |
666 | 666 | |
667 | 667 | return $output; |
668 | 668 | } |
669 | 669 | |
670 | -function wpinv_html_date_field( $args = array() ) { |
|
671 | - if( empty( $args['class'] ) ) { |
|
670 | +function wpinv_html_date_field($args = array()) { |
|
671 | + if (empty($args['class'])) { |
|
672 | 672 | $args['class'] = 'wpiDatepicker'; |
673 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
673 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
674 | 674 | $args['class'] .= ' wpiDatepicker'; |
675 | 675 | } |
676 | 676 | |
677 | - return wpinv_html_text( $args ); |
|
677 | + return wpinv_html_text($args); |
|
678 | 678 | } |
679 | 679 | |
680 | -function wpinv_html_textarea( $args = array() ) { |
|
680 | +function wpinv_html_textarea($args = array()) { |
|
681 | 681 | $defaults = array( |
682 | 682 | 'name' => 'textarea', |
683 | 683 | 'value' => null, |
@@ -688,31 +688,31 @@ discard block |
||
688 | 688 | 'placeholder' => '', |
689 | 689 | ); |
690 | 690 | |
691 | - $args = wp_parse_args( $args, $defaults ); |
|
691 | + $args = wp_parse_args($args, $defaults); |
|
692 | 692 | |
693 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
693 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
694 | 694 | $disabled = ''; |
695 | - if( $args['disabled'] ) { |
|
695 | + if ($args['disabled']) { |
|
696 | 696 | $disabled = ' disabled="disabled"'; |
697 | 697 | } |
698 | 698 | |
699 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
700 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
701 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
699 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
700 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
701 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
702 | 702 | |
703 | - if ( ! empty( $args['desc'] ) ) { |
|
704 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
703 | + if (!empty($args['desc'])) { |
|
704 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
705 | 705 | } |
706 | 706 | $output .= '</span>'; |
707 | 707 | |
708 | 708 | return $output; |
709 | 709 | } |
710 | 710 | |
711 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
711 | +function wpinv_html_ajax_user_search($args = array()) { |
|
712 | 712 | $defaults = array( |
713 | 713 | 'name' => 'user_id', |
714 | 714 | 'value' => null, |
715 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
715 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
716 | 716 | 'label' => null, |
717 | 717 | 'desc' => null, |
718 | 718 | 'class' => '', |
@@ -721,13 +721,13 @@ discard block |
||
721 | 721 | 'data' => false |
722 | 722 | ); |
723 | 723 | |
724 | - $args = wp_parse_args( $args, $defaults ); |
|
724 | + $args = wp_parse_args($args, $defaults); |
|
725 | 725 | |
726 | 726 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
727 | 727 | |
728 | 728 | $output = '<span class="wpinv_user_search_wrap">'; |
729 | - $output .= wpinv_html_text( $args ); |
|
730 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
729 | + $output .= wpinv_html_text($args); |
|
730 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
731 | 731 | $output .= '</span>'; |
732 | 732 | |
733 | 733 | return $output; |
@@ -743,20 +743,20 @@ discard block |
||
743 | 743 | * |
744 | 744 | * @param string $template the template that is currently being used. |
745 | 745 | */ |
746 | -function wpinv_template( $template ) { |
|
746 | +function wpinv_template($template) { |
|
747 | 747 | global $post; |
748 | 748 | |
749 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
749 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
750 | 750 | |
751 | 751 | // If the user can view this invoice, display it. |
752 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
752 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
753 | 753 | |
754 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
754 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
755 | 755 | |
756 | 756 | // Else display an error message. |
757 | 757 | } else { |
758 | 758 | |
759 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
759 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
760 | 760 | |
761 | 761 | } |
762 | 762 | |
@@ -764,46 +764,46 @@ discard block |
||
764 | 764 | |
765 | 765 | return $template; |
766 | 766 | } |
767 | -add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
767 | +add_filter('template_include', 'wpinv_template', 10, 1); |
|
768 | 768 | |
769 | 769 | function wpinv_get_business_address() { |
770 | 770 | $business_address = wpinv_store_address(); |
771 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
771 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
772 | 772 | |
773 | 773 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
774 | 774 | |
775 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
775 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | /** |
779 | 779 | * Displays the company address. |
780 | 780 | */ |
781 | 781 | function wpinv_display_from_address() { |
782 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
782 | + wpinv_get_template('invoice/company-address.php'); |
|
783 | 783 | } |
784 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
784 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
785 | 785 | |
786 | -function wpinv_watermark( $id = 0 ) { |
|
787 | - $output = wpinv_get_watermark( $id ); |
|
788 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
786 | +function wpinv_watermark($id = 0) { |
|
787 | + $output = wpinv_get_watermark($id); |
|
788 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
789 | 789 | } |
790 | 790 | |
791 | -function wpinv_get_watermark( $id ) { |
|
792 | - if ( !$id > 0 ) { |
|
791 | +function wpinv_get_watermark($id) { |
|
792 | + if (!$id > 0) { |
|
793 | 793 | return NULL; |
794 | 794 | } |
795 | 795 | |
796 | - $invoice = wpinv_get_invoice( $id ); |
|
796 | + $invoice = wpinv_get_invoice($id); |
|
797 | 797 | |
798 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
799 | - if ( $invoice->is_paid() ) { |
|
800 | - return __( 'Paid', 'invoicing' ); |
|
798 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
799 | + if ($invoice->is_paid()) { |
|
800 | + return __('Paid', 'invoicing'); |
|
801 | 801 | } |
802 | - if ( $invoice->is_refunded() ) { |
|
803 | - return __( 'Refunded', 'invoicing' ); |
|
802 | + if ($invoice->is_refunded()) { |
|
803 | + return __('Refunded', 'invoicing'); |
|
804 | 804 | } |
805 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
806 | - return __( 'Cancelled', 'invoicing' ); |
|
805 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
806 | + return __('Cancelled', 'invoicing'); |
|
807 | 807 | } |
808 | 808 | } |
809 | 809 | |
@@ -813,140 +813,140 @@ discard block |
||
813 | 813 | /** |
814 | 814 | * @deprecated |
815 | 815 | */ |
816 | -function wpinv_display_invoice_details( $invoice ) { |
|
817 | - return getpaid_invoice_meta( $invoice ); |
|
816 | +function wpinv_display_invoice_details($invoice) { |
|
817 | + return getpaid_invoice_meta($invoice); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | /** |
821 | 821 | * Displays invoice meta. |
822 | 822 | */ |
823 | -function getpaid_invoice_meta( $invoice ) { |
|
823 | +function getpaid_invoice_meta($invoice) { |
|
824 | 824 | |
825 | - $invoice = new WPInv_Invoice( $invoice ); |
|
825 | + $invoice = new WPInv_Invoice($invoice); |
|
826 | 826 | |
827 | 827 | // Ensure that we have an invoice. |
828 | - if ( 0 == $invoice->get_id() ) { |
|
828 | + if (0 == $invoice->get_id()) { |
|
829 | 829 | return; |
830 | 830 | } |
831 | 831 | |
832 | 832 | // Load the invoice meta. |
833 | - $meta = array( |
|
833 | + $meta = array( |
|
834 | 834 | |
835 | 835 | 'number' => array( |
836 | 836 | 'label' => sprintf( |
837 | - __( '%s Number', 'invoicing' ), |
|
838 | - ucfirst( $invoice->get_type() ) |
|
837 | + __('%s Number', 'invoicing'), |
|
838 | + ucfirst($invoice->get_type()) |
|
839 | 839 | ), |
840 | - 'value' => sanitize_text_field( $invoice->get_number() ), |
|
840 | + 'value' => sanitize_text_field($invoice->get_number()), |
|
841 | 841 | ), |
842 | 842 | |
843 | 843 | 'status' => array( |
844 | 844 | 'label' => sprintf( |
845 | - __( '%s Status', 'invoicing' ), |
|
846 | - ucfirst( $invoice->get_type() ) |
|
845 | + __('%s Status', 'invoicing'), |
|
846 | + ucfirst($invoice->get_type()) |
|
847 | 847 | ), |
848 | 848 | 'value' => $invoice->get_status_label_html(), |
849 | 849 | ), |
850 | 850 | |
851 | 851 | 'date' => array( |
852 | 852 | 'label' => sprintf( |
853 | - __( '%s Date', 'invoicing' ), |
|
854 | - ucfirst( $invoice->get_type() ) |
|
853 | + __('%s Date', 'invoicing'), |
|
854 | + ucfirst($invoice->get_type()) |
|
855 | 855 | ), |
856 | - 'value' => getpaid_format_date( $invoice->get_created_date() ), |
|
856 | + 'value' => getpaid_format_date($invoice->get_created_date()), |
|
857 | 857 | ), |
858 | 858 | |
859 | 859 | 'date_paid' => array( |
860 | - 'label' => __( 'Paid On', 'invoicing' ), |
|
861 | - 'value' => getpaid_format_date( $invoice->get_completed_date() ), |
|
860 | + 'label' => __('Paid On', 'invoicing'), |
|
861 | + 'value' => getpaid_format_date($invoice->get_completed_date()), |
|
862 | 862 | ), |
863 | 863 | |
864 | 864 | 'gateway' => array( |
865 | - 'label' => __( 'Payment Method', 'invoicing' ), |
|
866 | - 'value' => sanitize_text_field( $invoice->get_gateway_title() ), |
|
865 | + 'label' => __('Payment Method', 'invoicing'), |
|
866 | + 'value' => sanitize_text_field($invoice->get_gateway_title()), |
|
867 | 867 | ), |
868 | 868 | |
869 | 869 | 'transaction_id' => array( |
870 | - 'label' => __( 'Transaction ID', 'invoicing' ), |
|
871 | - 'value' => sanitize_text_field( $invoice->get_transaction_id() ), |
|
870 | + 'label' => __('Transaction ID', 'invoicing'), |
|
871 | + 'value' => sanitize_text_field($invoice->get_transaction_id()), |
|
872 | 872 | ), |
873 | 873 | |
874 | 874 | 'due_date' => array( |
875 | - 'label' => __( 'Due Date', 'invoicing' ), |
|
876 | - 'value' => getpaid_format_date( $invoice->get_due_date() ), |
|
875 | + 'label' => __('Due Date', 'invoicing'), |
|
876 | + 'value' => getpaid_format_date($invoice->get_due_date()), |
|
877 | 877 | ), |
878 | 878 | |
879 | 879 | 'vat_number' => array( |
880 | 880 | 'label' => sprintf( |
881 | - __( '%s Number', 'invoicing' ), |
|
881 | + __('%s Number', 'invoicing'), |
|
882 | 882 | getpaid_tax()->get_vat_name() |
883 | 883 | ), |
884 | - 'value' => sanitize_text_field( $invoice->get_vat_number() ), |
|
884 | + 'value' => sanitize_text_field($invoice->get_vat_number()), |
|
885 | 885 | ), |
886 | 886 | |
887 | 887 | ); |
888 | 888 | |
889 | 889 | // If it is not paid, remove the date of payment. |
890 | - if ( ! $invoice->is_paid() ) { |
|
891 | - unset( $meta[ 'date_paid' ] ); |
|
892 | - unset( $meta[ 'transaction_id' ] ); |
|
890 | + if (!$invoice->is_paid()) { |
|
891 | + unset($meta['date_paid']); |
|
892 | + unset($meta['transaction_id']); |
|
893 | 893 | } |
894 | 894 | |
895 | - if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) { |
|
896 | - unset( $meta[ 'gateway' ] ); |
|
895 | + if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) { |
|
896 | + unset($meta['gateway']); |
|
897 | 897 | } |
898 | 898 | |
899 | 899 | // Only display the due date if due dates are enabled. |
900 | - if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) { |
|
901 | - unset( $meta[ 'due_date' ] ); |
|
900 | + if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) { |
|
901 | + unset($meta['due_date']); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | // Only display the vat number if taxes are enabled. |
905 | - if ( ! wpinv_use_taxes() ) { |
|
906 | - unset( $meta[ 'vat_number' ] ); |
|
905 | + if (!wpinv_use_taxes()) { |
|
906 | + unset($meta['vat_number']); |
|
907 | 907 | } |
908 | 908 | |
909 | - if ( $invoice->is_recurring() ) { |
|
909 | + if ($invoice->is_recurring()) { |
|
910 | 910 | |
911 | 911 | // Link to the parent invoice. |
912 | - if ( $invoice->is_renewal() ) { |
|
912 | + if ($invoice->is_renewal()) { |
|
913 | 913 | |
914 | - $meta[ 'parent' ] = array( |
|
914 | + $meta['parent'] = array( |
|
915 | 915 | |
916 | 916 | 'label' => sprintf( |
917 | - __( 'Parent %s', 'invoicing' ), |
|
918 | - ucfirst( $invoice->get_type() ) |
|
917 | + __('Parent %s', 'invoicing'), |
|
918 | + ucfirst($invoice->get_type()) |
|
919 | 919 | ), |
920 | 920 | |
921 | - 'value' => wpinv_invoice_link( $invoice->get_parent_id() ), |
|
921 | + 'value' => wpinv_invoice_link($invoice->get_parent_id()), |
|
922 | 922 | |
923 | 923 | ); |
924 | 924 | |
925 | 925 | } |
926 | 926 | |
927 | - $subscription = wpinv_get_subscription( $invoice ); |
|
927 | + $subscription = wpinv_get_subscription($invoice); |
|
928 | 928 | |
929 | - if ( ! empty ( $subscription ) ) { |
|
929 | + if (!empty ($subscription)) { |
|
930 | 930 | |
931 | 931 | // Display the renewal date. |
932 | - if ( $subscription->is_active() && 'cancelled' != $subscription->status ) { |
|
932 | + if ($subscription->is_active() && 'cancelled' != $subscription->status) { |
|
933 | 933 | |
934 | - $meta[ 'renewal_date' ] = array( |
|
934 | + $meta['renewal_date'] = array( |
|
935 | 935 | |
936 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
937 | - 'value' => getpaid_format_date( $subscription->expiration ), |
|
936 | + 'label' => __('Renews On', 'invoicing'), |
|
937 | + 'value' => getpaid_format_date($subscription->expiration), |
|
938 | 938 | |
939 | 939 | ); |
940 | 940 | |
941 | 941 | } |
942 | 942 | |
943 | - if ( $invoice->is_parent() ) { |
|
943 | + if ($invoice->is_parent()) { |
|
944 | 944 | |
945 | 945 | // Display the recurring amount. |
946 | - $meta[ 'recurring_total' ] = array( |
|
946 | + $meta['recurring_total'] = array( |
|
947 | 947 | |
948 | - 'label' => __( 'Recurring Amount', 'invoicing' ), |
|
949 | - 'value' => wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), $invoice->get_currency() ), |
|
948 | + 'label' => __('Recurring Amount', 'invoicing'), |
|
949 | + 'value' => wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()), |
|
950 | 950 | |
951 | 951 | ); |
952 | 952 | |
@@ -956,20 +956,20 @@ discard block |
||
956 | 956 | } |
957 | 957 | |
958 | 958 | // Add the invoice total to the meta. |
959 | - $meta[ 'invoice_total' ] = array( |
|
959 | + $meta['invoice_total'] = array( |
|
960 | 960 | |
961 | - 'label' => __( 'Total Amount', 'invoicing' ), |
|
962 | - 'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ), |
|
961 | + 'label' => __('Total Amount', 'invoicing'), |
|
962 | + 'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()), |
|
963 | 963 | |
964 | 964 | ); |
965 | 965 | |
966 | 966 | // Provide a way for third party plugins to filter the meta. |
967 | - $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice ); |
|
967 | + $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice); |
|
968 | 968 | |
969 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
969 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
970 | 970 | |
971 | 971 | } |
972 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
972 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
973 | 973 | |
974 | 974 | /** |
975 | 975 | * Retrieves the address markup to use on Invoices. |
@@ -981,29 +981,29 @@ discard block |
||
981 | 981 | * @param string $separator How to separate address lines. |
982 | 982 | * @return string |
983 | 983 | */ |
984 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
984 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
985 | 985 | |
986 | 986 | // Retrieve the address markup... |
987 | - $country= empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
988 | - $format = wpinv_get_full_address_format( $country ); |
|
987 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
988 | + $format = wpinv_get_full_address_format($country); |
|
989 | 989 | |
990 | 990 | // ... and the replacements. |
991 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
991 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
992 | 992 | |
993 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
993 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
994 | 994 | |
995 | 995 | // Remove unavailable tags. |
996 | - $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
|
996 | + $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address); |
|
997 | 997 | |
998 | 998 | // Clean up white space. |
999 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
1000 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
999 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
1000 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
1001 | 1001 | |
1002 | 1002 | // Break newlines apart and remove empty lines/trim commas and white space. |
1003 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
1003 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
1004 | 1004 | |
1005 | 1005 | // Add html breaks. |
1006 | - $formatted_address = implode( $separator, $formatted_address ); |
|
1006 | + $formatted_address = implode($separator, $formatted_address); |
|
1007 | 1007 | |
1008 | 1008 | // We're done! |
1009 | 1009 | return $formatted_address; |
@@ -1015,88 +1015,88 @@ discard block |
||
1015 | 1015 | * |
1016 | 1016 | * @param WPInv_Invoice $invoice |
1017 | 1017 | */ |
1018 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
1019 | - if ( ! empty( $invoice ) ) { |
|
1020 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
1018 | +function wpinv_display_to_address($invoice = 0) { |
|
1019 | + if (!empty($invoice)) { |
|
1020 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
1021 | 1021 | } |
1022 | 1022 | } |
1023 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
1023 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
1024 | 1024 | |
1025 | 1025 | |
1026 | 1026 | /** |
1027 | 1027 | * Displays invoice line items. |
1028 | 1028 | */ |
1029 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
1029 | +function wpinv_display_line_items($invoice_id = 0) { |
|
1030 | 1030 | |
1031 | 1031 | // Prepare the invoice. |
1032 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
1032 | + $invoice = new WPInv_Invoice($invoice_id); |
|
1033 | 1033 | |
1034 | 1034 | // Abort if there is no invoice. |
1035 | - if ( 0 == $invoice->get_id() ) { |
|
1035 | + if (0 == $invoice->get_id()) { |
|
1036 | 1036 | return; |
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | // Line item columns. |
1040 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
1041 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
1040 | + $columns = getpaid_invoice_item_columns($invoice); |
|
1041 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
1042 | 1042 | |
1043 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
1043 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
1044 | 1044 | } |
1045 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
1045 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
1046 | 1046 | |
1047 | 1047 | /** |
1048 | 1048 | * Displays invoice notices on invoices. |
1049 | 1049 | */ |
1050 | 1050 | function wpinv_display_invoice_notice() { |
1051 | 1051 | |
1052 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
1053 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
1052 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
1053 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
1054 | 1054 | |
1055 | - if ( empty( $label ) && empty( $notice ) ) { |
|
1055 | + if (empty($label) && empty($notice)) { |
|
1056 | 1056 | return; |
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
1060 | 1060 | |
1061 | - if ( ! empty( $label ) ) { |
|
1062 | - $label = sanitize_text_field( $label ); |
|
1061 | + if (!empty($label)) { |
|
1062 | + $label = sanitize_text_field($label); |
|
1063 | 1063 | echo "<h5>$label</h5>"; |
1064 | 1064 | } |
1065 | 1065 | |
1066 | - if ( ! empty( $notice ) ) { |
|
1067 | - echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>'; |
|
1066 | + if (!empty($notice)) { |
|
1067 | + echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>'; |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | echo '</div>'; |
1071 | 1071 | } |
1072 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
1072 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
1073 | 1073 | |
1074 | 1074 | /** |
1075 | 1075 | * @param WPInv_Invoice $invoice |
1076 | 1076 | */ |
1077 | -function wpinv_display_invoice_notes( $invoice ) { |
|
1077 | +function wpinv_display_invoice_notes($invoice) { |
|
1078 | 1078 | |
1079 | 1079 | // Retrieve the notes. |
1080 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
1080 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
1081 | 1081 | |
1082 | 1082 | // Abort if we have non. |
1083 | - if ( empty( $notes ) ) { |
|
1083 | + if (empty($notes)) { |
|
1084 | 1084 | return; |
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | // Echo the note. |
1088 | 1088 | echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">'; |
1089 | - echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>'; |
|
1089 | + echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>'; |
|
1090 | 1090 | echo '<ul class="getpaid-invoice-notes mt-4 p-0">'; |
1091 | 1091 | |
1092 | - foreach( $notes as $note ) { |
|
1093 | - wpinv_get_invoice_note_line_item( $note ); |
|
1092 | + foreach ($notes as $note) { |
|
1093 | + wpinv_get_invoice_note_line_item($note); |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | echo '</ul>'; |
1097 | 1097 | echo '</div>'; |
1098 | 1098 | } |
1099 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
1099 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
1100 | 1100 | |
1101 | 1101 | /** |
1102 | 1102 | * Loads scripts on our invoice templates. |
@@ -1104,32 +1104,32 @@ discard block |
||
1104 | 1104 | function wpinv_display_style() { |
1105 | 1105 | |
1106 | 1106 | // Make sure that all scripts have been loaded. |
1107 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
1108 | - do_action( 'wp_enqueue_scripts' ); |
|
1107 | + if (!did_action('wp_enqueue_scripts')) { |
|
1108 | + do_action('wp_enqueue_scripts'); |
|
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | // Register the invoices style. |
1112 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
1112 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
1113 | 1113 | |
1114 | 1114 | // Load required styles |
1115 | - wp_print_styles( 'open-sans' ); |
|
1116 | - wp_print_styles( 'wpinv-single-style' ); |
|
1117 | - wp_print_styles( 'ayecode-ui' ); |
|
1115 | + wp_print_styles('open-sans'); |
|
1116 | + wp_print_styles('wpinv-single-style'); |
|
1117 | + wp_print_styles('ayecode-ui'); |
|
1118 | 1118 | |
1119 | 1119 | // Maybe load custom css. |
1120 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
1120 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
1121 | 1121 | |
1122 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
1123 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
1124 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
1122 | + if (isset($custom_css) && !empty($custom_css)) { |
|
1123 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
1124 | + $custom_css = str_replace('>', '>', $custom_css); |
|
1125 | 1125 | echo '<style type="text/css">'; |
1126 | 1126 | echo $custom_css; |
1127 | 1127 | echo '</style>'; |
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | } |
1131 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
1132 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
1131 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
1132 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
1133 | 1133 | |
1134 | 1134 | |
1135 | 1135 | /** |
@@ -1141,41 +1141,41 @@ discard block |
||
1141 | 1141 | // Retrieve the current invoice. |
1142 | 1142 | $invoice_id = getpaid_get_current_invoice_id(); |
1143 | 1143 | |
1144 | - if ( empty( $invoice_id ) ) { |
|
1144 | + if (empty($invoice_id)) { |
|
1145 | 1145 | |
1146 | 1146 | return aui()->alert( |
1147 | 1147 | array( |
1148 | 1148 | 'type' => 'warning', |
1149 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
1149 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
1150 | 1150 | ) |
1151 | 1151 | ); |
1152 | 1152 | |
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | // Can the user view this invoice? |
1156 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
1156 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
1157 | 1157 | |
1158 | 1158 | return aui()->alert( |
1159 | 1159 | array( |
1160 | 1160 | 'type' => 'warning', |
1161 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
1161 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
1162 | 1162 | ) |
1163 | 1163 | ); |
1164 | 1164 | |
1165 | 1165 | } |
1166 | 1166 | |
1167 | 1167 | // Ensure that it is not yet paid for. |
1168 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
1168 | + $invoice = new WPInv_Invoice($invoice_id); |
|
1169 | 1169 | |
1170 | 1170 | // Maybe mark it as viewed. |
1171 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
1171 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
1172 | 1172 | |
1173 | - if ( $invoice->is_paid() ) { |
|
1173 | + if ($invoice->is_paid()) { |
|
1174 | 1174 | |
1175 | 1175 | return aui()->alert( |
1176 | 1176 | array( |
1177 | 1177 | 'type' => 'success', |
1178 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
1178 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
1179 | 1179 | ) |
1180 | 1180 | ); |
1181 | 1181 | |
@@ -1185,14 +1185,14 @@ discard block |
||
1185 | 1185 | $wpi_checkout_id = $invoice_id; |
1186 | 1186 | |
1187 | 1187 | // We'll display this invoice via the default form. |
1188 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1188 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1189 | 1189 | |
1190 | - if ( 0 == $form->get_id() ) { |
|
1190 | + if (0 == $form->get_id()) { |
|
1191 | 1191 | |
1192 | 1192 | return aui()->alert( |
1193 | 1193 | array( |
1194 | 1194 | 'type' => 'warning', |
1195 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
1195 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
1196 | 1196 | ) |
1197 | 1197 | ); |
1198 | 1198 | |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | |
1201 | 1201 | // Set the invoice. |
1202 | 1202 | $form->invoice = $invoice; |
1203 | - $form->set_items( $invoice->get_items() ); |
|
1203 | + $form->set_items($invoice->get_items()); |
|
1204 | 1204 | |
1205 | 1205 | // Generate the html. |
1206 | 1206 | return $form->get_html(); |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | function wpinv_empty_cart_message() { |
1211 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1211 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | /** |
@@ -1225,38 +1225,38 @@ discard block |
||
1225 | 1225 | ) |
1226 | 1226 | ); |
1227 | 1227 | } |
1228 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1228 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1229 | 1229 | |
1230 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
1231 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1230 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
1231 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1232 | 1232 | |
1233 | - if ( empty( $invoice ) ) { |
|
1233 | + if (empty($invoice)) { |
|
1234 | 1234 | return NULL; |
1235 | 1235 | } |
1236 | 1236 | |
1237 | 1237 | $billing_details = $invoice->get_user_info(); |
1238 | - $address_row = wpinv_get_invoice_address_markup( $billing_details ); |
|
1238 | + $address_row = wpinv_get_invoice_address_markup($billing_details); |
|
1239 | 1239 | |
1240 | 1240 | ob_start(); |
1241 | 1241 | ?> |
1242 | 1242 | <table class="table table-bordered table-sm wpi-billing-details"> |
1243 | 1243 | <tbody> |
1244 | 1244 | <tr class="wpi-receipt-name"> |
1245 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
1246 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
1245 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
1246 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
1247 | 1247 | </tr> |
1248 | 1248 | <tr class="wpi-receipt-email"> |
1249 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
1250 | - <td><?php echo $billing_details['email'] ;?></td> |
|
1249 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
1250 | + <td><?php echo $billing_details['email']; ?></td> |
|
1251 | 1251 | </tr> |
1252 | 1252 | <tr class="wpi-receipt-address"> |
1253 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
1254 | - <td><?php echo $address_row ;?></td> |
|
1253 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
1254 | + <td><?php echo $address_row; ?></td> |
|
1255 | 1255 | </tr> |
1256 | - <?php if ( $billing_details['phone'] ) { ?> |
|
1256 | + <?php if ($billing_details['phone']) { ?> |
|
1257 | 1257 | <tr class="wpi-receipt-phone"> |
1258 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
1259 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
1258 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
1259 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
1260 | 1260 | </tr> |
1261 | 1261 | <?php } ?> |
1262 | 1262 | </tbody> |
@@ -1264,7 +1264,7 @@ discard block |
||
1264 | 1264 | <?php |
1265 | 1265 | $output = ob_get_clean(); |
1266 | 1266 | |
1267 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
1267 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
1268 | 1268 | |
1269 | 1269 | echo $output; |
1270 | 1270 | } |
@@ -1272,88 +1272,88 @@ discard block |
||
1272 | 1272 | /** |
1273 | 1273 | * Filters the receipt page. |
1274 | 1274 | */ |
1275 | -function wpinv_filter_success_page_content( $content ) { |
|
1275 | +function wpinv_filter_success_page_content($content) { |
|
1276 | 1276 | |
1277 | 1277 | // Ensure this is our page. |
1278 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1278 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1279 | 1279 | |
1280 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
1281 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
1280 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
1281 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
1282 | 1282 | |
1283 | 1283 | } |
1284 | 1284 | |
1285 | 1285 | return $content; |
1286 | 1286 | } |
1287 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1287 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1288 | 1288 | |
1289 | -function wpinv_invoice_link( $invoice_id ) { |
|
1290 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1289 | +function wpinv_invoice_link($invoice_id) { |
|
1290 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1291 | 1291 | |
1292 | - if ( empty( $invoice ) ) { |
|
1292 | + if (empty($invoice)) { |
|
1293 | 1293 | return NULL; |
1294 | 1294 | } |
1295 | 1295 | |
1296 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1296 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1297 | 1297 | |
1298 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1298 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1299 | 1299 | } |
1300 | 1300 | |
1301 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
1302 | - if ( empty( $invoice ) ) { |
|
1301 | +function wpinv_cart_total_label($label, $invoice) { |
|
1302 | + if (empty($invoice)) { |
|
1303 | 1303 | return $label; |
1304 | 1304 | } |
1305 | 1305 | |
1306 | 1306 | $prefix_label = ''; |
1307 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
1308 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
1309 | - } else if ( $invoice->is_renewal() ) { |
|
1310 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
1307 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
1308 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
1309 | + } else if ($invoice->is_renewal()) { |
|
1310 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
1311 | 1311 | } |
1312 | 1312 | |
1313 | - if ( $prefix_label != '' ) { |
|
1314 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
1313 | + if ($prefix_label != '') { |
|
1314 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | return $label; |
1318 | 1318 | } |
1319 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
1320 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
1321 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
1319 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
1320 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
1321 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
1322 | 1322 | |
1323 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
1324 | - if ( empty( $note ) ) { |
|
1323 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
1324 | + if (empty($note)) { |
|
1325 | 1325 | return NULL; |
1326 | 1326 | } |
1327 | 1327 | |
1328 | - if ( is_int( $note ) ) { |
|
1329 | - $note = get_comment( $note ); |
|
1328 | + if (is_int($note)) { |
|
1329 | + $note = get_comment($note); |
|
1330 | 1330 | } |
1331 | 1331 | |
1332 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
1332 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
1333 | 1333 | return NULL; |
1334 | 1334 | } |
1335 | 1335 | |
1336 | - $note_classes = array( 'note' ); |
|
1337 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
1336 | + $note_classes = array('note'); |
|
1337 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
1338 | 1338 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
1339 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
1340 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
1339 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
1340 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
1341 | 1341 | |
1342 | 1342 | ob_start(); |
1343 | 1343 | ?> |
1344 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3"> |
|
1344 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3"> |
|
1345 | 1345 | <div class="note_content bg-light border position-relative p-4"> |
1346 | 1346 | |
1347 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
1347 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
1348 | 1348 | |
1349 | - <?php if ( ! is_admin() ) : ?> |
|
1349 | + <?php if (!is_admin()) : ?> |
|
1350 | 1350 | <em class="meta position-absolute form-text"> |
1351 | 1351 | <?php |
1352 | 1352 | printf( |
1353 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1353 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
1354 | 1354 | $note->comment_author, |
1355 | - getpaid_format_date_value( $note->comment_date ), |
|
1356 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
1355 | + getpaid_format_date_value($note->comment_date), |
|
1356 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
1357 | 1357 | ); |
1358 | 1358 | ?> |
1359 | 1359 | </em> |
@@ -1361,21 +1361,21 @@ discard block |
||
1361 | 1361 | |
1362 | 1362 | </div> |
1363 | 1363 | |
1364 | - <?php if ( is_admin() ) : ?> |
|
1364 | + <?php if (is_admin()) : ?> |
|
1365 | 1365 | |
1366 | 1366 | <p class="meta px-4 py-2"> |
1367 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
1367 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
1368 | 1368 | <?php |
1369 | 1369 | printf( |
1370 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1370 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
1371 | 1371 | $note->comment_author, |
1372 | - getpaid_format_date_value( $note->comment_date ), |
|
1373 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
1372 | + getpaid_format_date_value($note->comment_date), |
|
1373 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
1374 | 1374 | ); |
1375 | 1375 | ?> |
1376 | 1376 | </abbr> |
1377 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
1378 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
1377 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
1378 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
1379 | 1379 | <?php } ?> |
1380 | 1380 | </p> |
1381 | 1381 | |
@@ -1384,9 +1384,9 @@ discard block |
||
1384 | 1384 | </li> |
1385 | 1385 | <?php |
1386 | 1386 | $note_content = ob_get_clean(); |
1387 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
1387 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
1388 | 1388 | |
1389 | - if ( $echo ) { |
|
1389 | + if ($echo) { |
|
1390 | 1390 | echo $note_content; |
1391 | 1391 | } else { |
1392 | 1392 | return $note_content; |
@@ -1396,36 +1396,36 @@ discard block |
||
1396 | 1396 | function wpinv_invalid_invoice_content() { |
1397 | 1397 | global $post; |
1398 | 1398 | |
1399 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
1399 | + $invoice = wpinv_get_invoice($post->ID); |
|
1400 | 1400 | |
1401 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
1402 | - if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
1403 | - if ( is_user_logged_in() ) { |
|
1404 | - if ( wpinv_require_login_to_checkout() ) { |
|
1405 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
1406 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
1401 | + $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing'); |
|
1402 | + if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
1403 | + if (is_user_logged_in()) { |
|
1404 | + if (wpinv_require_login_to_checkout()) { |
|
1405 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
1406 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
1407 | 1407 | } |
1408 | 1408 | } |
1409 | 1409 | } else { |
1410 | - if ( wpinv_require_login_to_checkout() ) { |
|
1411 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
1412 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
1410 | + if (wpinv_require_login_to_checkout()) { |
|
1411 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
1412 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
1413 | 1413 | } |
1414 | 1414 | } |
1415 | 1415 | } |
1416 | 1416 | } else { |
1417 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
1417 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
1418 | 1418 | } |
1419 | 1419 | ?> |
1420 | 1420 | <div class="row wpinv-row-invalid"> |
1421 | 1421 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
1422 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
1422 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
1423 | 1423 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
1424 | 1424 | </div> |
1425 | 1425 | </div> |
1426 | 1426 | <?php |
1427 | 1427 | } |
1428 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
1428 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
1429 | 1429 | |
1430 | 1430 | /** |
1431 | 1431 | * Function to get privacy policy text. |
@@ -1434,21 +1434,21 @@ discard block |
||
1434 | 1434 | * @return string |
1435 | 1435 | */ |
1436 | 1436 | function wpinv_get_policy_text() { |
1437 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
1437 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
1438 | 1438 | |
1439 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
1439 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
1440 | 1440 | |
1441 | - if(!$privacy_page_id){ |
|
1442 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
1441 | + if (!$privacy_page_id) { |
|
1442 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
1443 | 1443 | } |
1444 | 1444 | |
1445 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
1445 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
1446 | 1446 | |
1447 | 1447 | $find_replace = array( |
1448 | 1448 | '[wpinv_privacy_policy]' => $privacy_link, |
1449 | 1449 | ); |
1450 | 1450 | |
1451 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
1451 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
1452 | 1452 | |
1453 | 1453 | return wp_kses_post(wpautop($privacy_text)); |
1454 | 1454 | } |
@@ -1456,21 +1456,21 @@ discard block |
||
1456 | 1456 | function wpinv_oxygen_fix_conflict() { |
1457 | 1457 | global $ct_ignore_post_types; |
1458 | 1458 | |
1459 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
1459 | + if (!is_array($ct_ignore_post_types)) { |
|
1460 | 1460 | $ct_ignore_post_types = array(); |
1461 | 1461 | } |
1462 | 1462 | |
1463 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' ); |
|
1463 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item'); |
|
1464 | 1464 | |
1465 | - foreach ( $post_types as $post_type ) { |
|
1465 | + foreach ($post_types as $post_type) { |
|
1466 | 1466 | $ct_ignore_post_types[] = $post_type; |
1467 | 1467 | |
1468 | 1468 | // Ignore post type |
1469 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
1469 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
1470 | 1470 | } |
1471 | 1471 | |
1472 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
1473 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
1472 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
1473 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | /** |
@@ -1478,10 +1478,10 @@ discard block |
||
1478 | 1478 | * |
1479 | 1479 | * @param GetPaid_Payment_Form $form |
1480 | 1480 | */ |
1481 | -function getpaid_display_payment_form( $form ) { |
|
1481 | +function getpaid_display_payment_form($form) { |
|
1482 | 1482 | |
1483 | - if ( is_numeric( $form ) ) { |
|
1484 | - $form = new GetPaid_Payment_Form( $form ); |
|
1483 | + if (is_numeric($form)) { |
|
1484 | + $form = new GetPaid_Payment_Form($form); |
|
1485 | 1485 | } |
1486 | 1486 | |
1487 | 1487 | $form->display(); |
@@ -1491,16 +1491,16 @@ discard block |
||
1491 | 1491 | /** |
1492 | 1492 | * Helper function to display a item payment form on the frontend. |
1493 | 1493 | */ |
1494 | -function getpaid_display_item_payment_form( $items ) { |
|
1494 | +function getpaid_display_item_payment_form($items) { |
|
1495 | 1495 | |
1496 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1497 | - $form->set_items( $items ); |
|
1496 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1497 | + $form->set_items($items); |
|
1498 | 1498 | |
1499 | - if ( 0 == count( $form->get_items() ) ) { |
|
1499 | + if (0 == count($form->get_items())) { |
|
1500 | 1500 | echo aui()->alert( |
1501 | 1501 | array( |
1502 | 1502 | 'type' => 'warning', |
1503 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1503 | + 'content' => __('No published items found', 'invoicing'), |
|
1504 | 1504 | ) |
1505 | 1505 | ); |
1506 | 1506 | return; |
@@ -1512,32 +1512,32 @@ discard block |
||
1512 | 1512 | /** |
1513 | 1513 | * Helper function to display an invoice payment form on the frontend. |
1514 | 1514 | */ |
1515 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
1515 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
1516 | 1516 | |
1517 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1517 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1518 | 1518 | |
1519 | - if ( empty( $invoice ) ) { |
|
1519 | + if (empty($invoice)) { |
|
1520 | 1520 | echo aui()->alert( |
1521 | 1521 | array( |
1522 | 1522 | 'type' => 'warning', |
1523 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1523 | + 'content' => __('Invoice not found', 'invoicing'), |
|
1524 | 1524 | ) |
1525 | 1525 | ); |
1526 | 1526 | return; |
1527 | 1527 | } |
1528 | 1528 | |
1529 | - if ( $invoice->is_paid() ) { |
|
1529 | + if ($invoice->is_paid()) { |
|
1530 | 1530 | echo aui()->alert( |
1531 | 1531 | array( |
1532 | 1532 | 'type' => 'warning', |
1533 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1533 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
1534 | 1534 | ) |
1535 | 1535 | ); |
1536 | 1536 | return; |
1537 | 1537 | } |
1538 | 1538 | |
1539 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1540 | - $form->set_items( $invoice->get_items() ); |
|
1539 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1540 | + $form->set_items($invoice->get_items()); |
|
1541 | 1541 | |
1542 | 1542 | $form->display(); |
1543 | 1543 | } |
@@ -1545,23 +1545,23 @@ discard block |
||
1545 | 1545 | /** |
1546 | 1546 | * Helper function to convert item string to array. |
1547 | 1547 | */ |
1548 | -function getpaid_convert_items_to_array( $items ) { |
|
1549 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
1548 | +function getpaid_convert_items_to_array($items) { |
|
1549 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
1550 | 1550 | $prepared = array(); |
1551 | 1551 | |
1552 | - foreach ( $items as $item ) { |
|
1553 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
1552 | + foreach ($items as $item) { |
|
1553 | + $data = array_map('trim', explode('|', $item)); |
|
1554 | 1554 | |
1555 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
1555 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
1556 | 1556 | continue; |
1557 | 1557 | } |
1558 | 1558 | |
1559 | 1559 | $quantity = 1; |
1560 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
1560 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
1561 | 1561 | $quantity = (int) $data[1]; |
1562 | 1562 | } |
1563 | 1563 | |
1564 | - $prepared[ $data[0] ] = $quantity; |
|
1564 | + $prepared[$data[0]] = $quantity; |
|
1565 | 1565 | |
1566 | 1566 | } |
1567 | 1567 | |
@@ -1571,13 +1571,13 @@ discard block |
||
1571 | 1571 | /** |
1572 | 1572 | * Helper function to convert item array to string. |
1573 | 1573 | */ |
1574 | -function getpaid_convert_items_to_string( $items ) { |
|
1574 | +function getpaid_convert_items_to_string($items) { |
|
1575 | 1575 | $prepared = array(); |
1576 | 1576 | |
1577 | - foreach ( $items as $item => $quantity ) { |
|
1577 | + foreach ($items as $item => $quantity) { |
|
1578 | 1578 | $prepared[] = "$item|$quantity"; |
1579 | 1579 | } |
1580 | - return implode( ',', $prepared ); |
|
1580 | + return implode(',', $prepared); |
|
1581 | 1581 | } |
1582 | 1582 | |
1583 | 1583 | /** |
@@ -1585,22 +1585,22 @@ discard block |
||
1585 | 1585 | * |
1586 | 1586 | * Provide a label and one of $form, $items or $invoice. |
1587 | 1587 | */ |
1588 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
1589 | - $label = sanitize_text_field( $label ); |
|
1588 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
1589 | + $label = sanitize_text_field($label); |
|
1590 | 1590 | $nonce = wp_create_nonce('getpaid_ajax_form'); |
1591 | 1591 | |
1592 | - if ( ! empty( $form ) ) { |
|
1593 | - $form = esc_attr( $form ); |
|
1592 | + if (!empty($form)) { |
|
1593 | + $form = esc_attr($form); |
|
1594 | 1594 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; |
1595 | 1595 | } |
1596 | 1596 | |
1597 | - if ( ! empty( $items ) ) { |
|
1598 | - $items = esc_attr( $items ); |
|
1597 | + if (!empty($items)) { |
|
1598 | + $items = esc_attr($items); |
|
1599 | 1599 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; |
1600 | 1600 | } |
1601 | 1601 | |
1602 | - if ( ! empty( $invoice ) ) { |
|
1603 | - $invoice = esc_attr( $invoice ); |
|
1602 | + if (!empty($invoice)) { |
|
1603 | + $invoice = esc_attr($invoice); |
|
1604 | 1604 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-invoice='$invoice'>$label</button>"; |
1605 | 1605 | } |
1606 | 1606 | |
@@ -1611,17 +1611,17 @@ discard block |
||
1611 | 1611 | * |
1612 | 1612 | * @param WPInv_Invoice $invoice |
1613 | 1613 | */ |
1614 | -function getpaid_the_invoice_description( $invoice ) { |
|
1614 | +function getpaid_the_invoice_description($invoice) { |
|
1615 | 1615 | $description = $invoice->get_description(); |
1616 | 1616 | |
1617 | - if ( empty( $description ) ) { |
|
1617 | + if (empty($description)) { |
|
1618 | 1618 | return; |
1619 | 1619 | } |
1620 | 1620 | |
1621 | - $description = wp_kses_post( $description ); |
|
1621 | + $description = wp_kses_post($description); |
|
1622 | 1622 | echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>"; |
1623 | 1623 | } |
1624 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
1624 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
1625 | 1625 | |
1626 | 1626 | /** |
1627 | 1627 | * Render element on a form. |
@@ -1629,60 +1629,60 @@ discard block |
||
1629 | 1629 | * @param array $element |
1630 | 1630 | * @param GetPaid_Payment_Form $form |
1631 | 1631 | */ |
1632 | -function getpaid_payment_form_element( $element, $form ) { |
|
1632 | +function getpaid_payment_form_element($element, $form) { |
|
1633 | 1633 | |
1634 | 1634 | // Set up the args. |
1635 | - $element_type = trim( $element['type'] ); |
|
1635 | + $element_type = trim($element['type']); |
|
1636 | 1636 | $element['form'] = $form; |
1637 | - extract( $element ); |
|
1637 | + extract($element); |
|
1638 | 1638 | |
1639 | 1639 | // Try to locate the appropriate template. |
1640 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
1640 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
1641 | 1641 | |
1642 | 1642 | // Abort if this is not our element. |
1643 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1643 | + if (empty($located) || !file_exists($located)) { |
|
1644 | 1644 | return; |
1645 | 1645 | } |
1646 | 1646 | |
1647 | 1647 | // Generate the class and id of the element. |
1648 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
1649 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
1648 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
1649 | + $id = isset($id) ? $id : uniqid('gp'); |
|
1650 | 1650 | |
1651 | 1651 | // Echo the opening wrapper. |
1652 | 1652 | echo "<div class='getpaid-payment-form-element $wrapper_class'>"; |
1653 | 1653 | |
1654 | 1654 | // Fires before displaying a given element type's content. |
1655 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
1655 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
1656 | 1656 | |
1657 | 1657 | // Include the template for the element. |
1658 | 1658 | include $located; |
1659 | 1659 | |
1660 | 1660 | // Fires after displaying a given element type's content. |
1661 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
1661 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
1662 | 1662 | |
1663 | 1663 | // Echo the closing wrapper. |
1664 | 1664 | echo '</div>'; |
1665 | 1665 | } |
1666 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
1666 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
1667 | 1667 | |
1668 | 1668 | /** |
1669 | 1669 | * Render an element's edit page. |
1670 | 1670 | * |
1671 | 1671 | * @param WP_Post $post |
1672 | 1672 | */ |
1673 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
1673 | +function getpaid_payment_form_edit_element_template($post) { |
|
1674 | 1674 | |
1675 | 1675 | // Retrieve all elements. |
1676 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1676 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1677 | 1677 | |
1678 | - foreach ( $all_elements as $element ) { |
|
1678 | + foreach ($all_elements as $element) { |
|
1679 | 1679 | |
1680 | 1680 | // Try to locate the appropriate template. |
1681 | - $element = sanitize_key( $element ); |
|
1682 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
1681 | + $element = sanitize_key($element); |
|
1682 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
1683 | 1683 | |
1684 | 1684 | // Continue if this is not our element. |
1685 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1685 | + if (empty($located) || !file_exists($located)) { |
|
1686 | 1686 | continue; |
1687 | 1687 | } |
1688 | 1688 | |
@@ -1693,7 +1693,7 @@ discard block |
||
1693 | 1693 | } |
1694 | 1694 | |
1695 | 1695 | } |
1696 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
1696 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
1697 | 1697 | |
1698 | 1698 | /** |
1699 | 1699 | * Render an element's preview. |
@@ -1702,16 +1702,16 @@ discard block |
||
1702 | 1702 | function getpaid_payment_form_render_element_preview_template() { |
1703 | 1703 | |
1704 | 1704 | // Retrieve all elements. |
1705 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1705 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1706 | 1706 | |
1707 | - foreach ( $all_elements as $element ) { |
|
1707 | + foreach ($all_elements as $element) { |
|
1708 | 1708 | |
1709 | 1709 | // Try to locate the appropriate template. |
1710 | - $element = sanitize_key( $element ); |
|
1711 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
1710 | + $element = sanitize_key($element); |
|
1711 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
1712 | 1712 | |
1713 | 1713 | // Continue if this is not our element. |
1714 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1714 | + if (empty($located) || !file_exists($located)) { |
|
1715 | 1715 | continue; |
1716 | 1716 | } |
1717 | 1717 | |
@@ -1722,7 +1722,7 @@ discard block |
||
1722 | 1722 | } |
1723 | 1723 | |
1724 | 1724 | } |
1725 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
1725 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
1726 | 1726 | |
1727 | 1727 | /** |
1728 | 1728 | * Shows a list of gateways that support recurring payments. |
@@ -1730,17 +1730,17 @@ discard block |
||
1730 | 1730 | function wpinv_get_recurring_gateways_text() { |
1731 | 1731 | $gateways = array(); |
1732 | 1732 | |
1733 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
1734 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
1735 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
1733 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
1734 | + if (wpinv_gateway_support_subscription($key)) { |
|
1735 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
1736 | 1736 | } |
1737 | 1737 | } |
1738 | 1738 | |
1739 | - if ( empty( $gateways ) ) { |
|
1740 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>"; |
|
1739 | + if (empty($gateways)) { |
|
1740 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>"; |
|
1741 | 1741 | } |
1742 | 1742 | |
1743 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>"; |
|
1743 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>"; |
|
1744 | 1744 | |
1745 | 1745 | } |
1746 | 1746 | |
@@ -1750,7 +1750,7 @@ discard block |
||
1750 | 1750 | * @return GetPaid_Template |
1751 | 1751 | */ |
1752 | 1752 | function getpaid_template() { |
1753 | - return getpaid()->get( 'template' ); |
|
1753 | + return getpaid()->get('template'); |
|
1754 | 1754 | } |
1755 | 1755 | |
1756 | 1756 | /** |
@@ -1759,23 +1759,23 @@ discard block |
||
1759 | 1759 | * @param array args |
1760 | 1760 | * @return string |
1761 | 1761 | */ |
1762 | -function getpaid_paginate_links( $args ) { |
|
1762 | +function getpaid_paginate_links($args) { |
|
1763 | 1763 | |
1764 | 1764 | $args['type'] = 'array'; |
1765 | 1765 | $args['mid_size'] = 1; |
1766 | - $pages = paginate_links( $args ); |
|
1766 | + $pages = paginate_links($args); |
|
1767 | 1767 | |
1768 | - if ( ! is_array( $pages ) ) { |
|
1768 | + if (!is_array($pages)) { |
|
1769 | 1769 | return ''; |
1770 | 1770 | } |
1771 | 1771 | |
1772 | 1772 | $_pages = array(); |
1773 | - foreach ( $pages as $page ) { |
|
1774 | - $_pages[] = str_replace( 'page-numbers', 'page-link text-decoration-none', $page ); |
|
1773 | + foreach ($pages as $page) { |
|
1774 | + $_pages[] = str_replace('page-numbers', 'page-link text-decoration-none', $page); |
|
1775 | 1775 | } |
1776 | 1776 | |
1777 | 1777 | $links = "<nav>\n\t<ul class='pagination justify-content-end m-0'>\n\t\t<li class='page-item'>"; |
1778 | - $links .= join( "</li>\n\t\t<li class='page-item'>", $_pages ); |
|
1778 | + $links .= join("</li>\n\t\t<li class='page-item'>", $_pages); |
|
1779 | 1779 | $links .= "</li>\n\t</ul>\n</nav>\n"; |
1780 | 1780 | |
1781 | 1781 | return $links; |
@@ -6,7 +6,7 @@ |
||
6 | 6 | * @package Invoicing/data |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | return array( |
12 | 12 | "AD" => "AD\d{3}", |