@@ -40,86 +40,86 @@ discard block |
||
40 | 40 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
41 | 41 | <?php |
42 | 42 | |
43 | - foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : |
|
43 | + foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : |
|
44 | 44 | |
45 | - $column_id = sanitize_html_class( $column_id ); |
|
46 | - $class = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] ); |
|
45 | + $column_id = sanitize_html_class( $column_id ); |
|
46 | + $class = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] ); |
|
47 | 47 | |
48 | - echo "<td class='$column_id $class'>"; |
|
49 | - switch ( $column_id ) { |
|
48 | + echo "<td class='$column_id $class'>"; |
|
49 | + switch ( $column_id ) { |
|
50 | 50 | |
51 | - case 'invoice-number': |
|
52 | - echo wpinv_invoice_link( $invoice ); |
|
53 | - break; |
|
51 | + case 'invoice-number': |
|
52 | + echo wpinv_invoice_link( $invoice ); |
|
53 | + break; |
|
54 | 54 | |
55 | - case 'created-date': |
|
56 | - echo getpaid_format_date_value( $invoice->get_date_created() ); |
|
57 | - break; |
|
55 | + case 'created-date': |
|
56 | + echo getpaid_format_date_value( $invoice->get_date_created() ); |
|
57 | + break; |
|
58 | 58 | |
59 | - case 'payment-date': |
|
59 | + case 'payment-date': |
|
60 | 60 | |
61 | - if ( $invoice->needs_payment() ) { |
|
62 | - echo "—"; |
|
63 | - } else { |
|
64 | - echo getpaid_format_date_value( $invoice->get_date_completed() ); |
|
65 | - } |
|
61 | + if ( $invoice->needs_payment() ) { |
|
62 | + echo "—"; |
|
63 | + } else { |
|
64 | + echo getpaid_format_date_value( $invoice->get_date_completed() ); |
|
65 | + } |
|
66 | 66 | |
67 | - break; |
|
67 | + break; |
|
68 | 68 | |
69 | - case 'invoice-status': |
|
70 | - echo $invoice->get_status_label_html(); |
|
69 | + case 'invoice-status': |
|
70 | + echo $invoice->get_status_label_html(); |
|
71 | 71 | |
72 | - break; |
|
72 | + break; |
|
73 | 73 | |
74 | - case 'invoice-total': |
|
75 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total() ) ); |
|
74 | + case 'invoice-total': |
|
75 | + echo wpinv_price( wpinv_format_amount( $invoice->get_total() ) ); |
|
76 | 76 | |
77 | - break; |
|
77 | + break; |
|
78 | 78 | |
79 | - case 'invoice-actions': |
|
79 | + case 'invoice-actions': |
|
80 | 80 | |
81 | - $actions = array( |
|
81 | + $actions = array( |
|
82 | 82 | |
83 | - 'pay' => array( |
|
84 | - 'url' => $invoice->get_checkout_payment_url(), |
|
85 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
83 | + 'pay' => array( |
|
84 | + 'url' => $invoice->get_checkout_payment_url(), |
|
85 | + 'name' => __( 'Pay Now', 'invoicing' ), |
|
86 | 86 | 'class' => 'btn-success' |
87 | - ), |
|
87 | + ), |
|
88 | 88 | |
89 | 89 | 'print' => array( |
90 | - 'url' => $invoice->get_view_url(), |
|
91 | - 'name' => __( 'View Invoice', 'invoicing' ), |
|
90 | + 'url' => $invoice->get_view_url(), |
|
91 | + 'name' => __( 'View Invoice', 'invoicing' ), |
|
92 | 92 | 'class' => 'btn-secondary', |
93 | 93 | 'attrs' => 'target="_blank"' |
94 | - ) |
|
95 | - ); |
|
94 | + ) |
|
95 | + ); |
|
96 | 96 | |
97 | - if ( ! $invoice->needs_payment() ) { |
|
98 | - unset( $actions['pay'] ); |
|
99 | - } |
|
97 | + if ( ! $invoice->needs_payment() ) { |
|
98 | + unset( $actions['pay'] ); |
|
99 | + } |
|
100 | 100 | |
101 | - $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ); |
|
101 | + $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ); |
|
102 | 102 | |
103 | - foreach ( $actions as $key => $action ) { |
|
104 | - $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
105 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
106 | - } |
|
103 | + foreach ( $actions as $key => $action ) { |
|
104 | + $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
105 | + echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
106 | + } |
|
107 | 107 | |
108 | - break; |
|
108 | + break; |
|
109 | 109 | |
110 | - default: |
|
111 | - do_action( "wpinv_user_invoices_column_$column_id", $invoice ); |
|
112 | - break; |
|
110 | + default: |
|
111 | + do_action( "wpinv_user_invoices_column_$column_id", $invoice ); |
|
112 | + break; |
|
113 | 113 | |
114 | 114 | |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | - do_action( "wpinv_user_invoices_column_after_$column_id", $invoice ); |
|
117 | + do_action( "wpinv_user_invoices_column_after_$column_id", $invoice ); |
|
118 | 118 | |
119 | - echo '</td>'; |
|
119 | + echo '</td>'; |
|
120 | 120 | |
121 | - endforeach; |
|
122 | - ?> |
|
121 | + endforeach; |
|
122 | + ?> |
|
123 | 123 | </tr> |
124 | 124 | |
125 | 125 | <?php endforeach; ?> |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | <?php if ( 1 < $invoices->max_num_pages ) : ?> |
133 | 133 | <div class="invoicing-Pagination"> |
134 | 134 | <?php |
135 | - $big = 999999; |
|
136 | - |
|
137 | - echo paginate_links( array( |
|
138 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
139 | - 'format' => '?paged=%#%', |
|
140 | - 'total' => $invoices->max_num_pages, |
|
141 | - ) ); |
|
142 | - ?> |
|
135 | + $big = 999999; |
|
136 | + |
|
137 | + echo paginate_links( array( |
|
138 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
139 | + 'format' => '?paged=%#%', |
|
140 | + 'total' => $invoices->max_num_pages, |
|
141 | + ) ); |
|
142 | + ?> |
|
143 | 143 | </div> |
144 | 144 | <?php endif; ?> |
145 | 145 |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Current page. |
13 | -$current_page = empty( $_GET[ 'page' ] ) ? 1 : absint( $_GET[ 'page' ] ); |
|
13 | +$current_page = empty($_GET['page']) ? 1 : absint($_GET['page']); |
|
14 | 14 | |
15 | 15 | // Fires before displaying user invoices. |
16 | -do_action( 'wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages ); |
|
16 | +do_action('wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages); |
|
17 | 17 | |
18 | 18 | ?> |
19 | 19 | |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | <thead> |
24 | 24 | <tr> |
25 | 25 | |
26 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
27 | - <th class="<?php echo sanitize_html_class( $column_id ); ?> <?php echo ( ! empty( $column_name['class'] ) ? sanitize_html_class( $column_name['class'] ) : '');?> border-bottom-0"> |
|
28 | - <span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span> |
|
26 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
27 | + <th class="<?php echo sanitize_html_class($column_id); ?> <?php echo (!empty($column_name['class']) ? sanitize_html_class($column_name['class']) : ''); ?> border-bottom-0"> |
|
28 | + <span class="nobr"><?php echo esc_html($column_name['title']); ?></span> |
|
29 | 29 | </th> |
30 | 30 | <?php endforeach; ?> |
31 | 31 | |
@@ -35,33 +35,33 @@ discard block |
||
35 | 35 | |
36 | 36 | |
37 | 37 | <tbody> |
38 | - <?php foreach ( $invoices->invoices as $invoice ) : ?> |
|
38 | + <?php foreach ($invoices->invoices as $invoice) : ?> |
|
39 | 39 | |
40 | 40 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
41 | 41 | <?php |
42 | 42 | |
43 | - foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : |
|
43 | + foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : |
|
44 | 44 | |
45 | - $column_id = sanitize_html_class( $column_id ); |
|
46 | - $class = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] ); |
|
45 | + $column_id = sanitize_html_class($column_id); |
|
46 | + $class = empty($column_name['class']) ? '' : sanitize_html_class($column_name['class']); |
|
47 | 47 | |
48 | 48 | echo "<td class='$column_id $class'>"; |
49 | - switch ( $column_id ) { |
|
49 | + switch ($column_id) { |
|
50 | 50 | |
51 | 51 | case 'invoice-number': |
52 | - echo wpinv_invoice_link( $invoice ); |
|
52 | + echo wpinv_invoice_link($invoice); |
|
53 | 53 | break; |
54 | 54 | |
55 | 55 | case 'created-date': |
56 | - echo getpaid_format_date_value( $invoice->get_date_created() ); |
|
56 | + echo getpaid_format_date_value($invoice->get_date_created()); |
|
57 | 57 | break; |
58 | 58 | |
59 | 59 | case 'payment-date': |
60 | 60 | |
61 | - if ( $invoice->needs_payment() ) { |
|
61 | + if ($invoice->needs_payment()) { |
|
62 | 62 | echo "—"; |
63 | 63 | } else { |
64 | - echo getpaid_format_date_value( $invoice->get_date_completed() ); |
|
64 | + echo getpaid_format_date_value($invoice->get_date_completed()); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | break; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | break; |
73 | 73 | |
74 | 74 | case 'invoice-total': |
75 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total() ) ); |
|
75 | + echo wpinv_price(wpinv_format_amount($invoice->get_total())); |
|
76 | 76 | |
77 | 77 | break; |
78 | 78 | |
@@ -82,39 +82,39 @@ discard block |
||
82 | 82 | |
83 | 83 | 'pay' => array( |
84 | 84 | 'url' => $invoice->get_checkout_payment_url(), |
85 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
85 | + 'name' => __('Pay Now', 'invoicing'), |
|
86 | 86 | 'class' => 'btn-success' |
87 | 87 | ), |
88 | 88 | |
89 | 89 | 'print' => array( |
90 | 90 | 'url' => $invoice->get_view_url(), |
91 | - 'name' => __( 'View Invoice', 'invoicing' ), |
|
91 | + 'name' => __('View Invoice', 'invoicing'), |
|
92 | 92 | 'class' => 'btn-secondary', |
93 | 93 | 'attrs' => 'target="_blank"' |
94 | 94 | ) |
95 | 95 | ); |
96 | 96 | |
97 | - if ( ! $invoice->needs_payment() ) { |
|
98 | - unset( $actions['pay'] ); |
|
97 | + if (!$invoice->needs_payment()) { |
|
98 | + unset($actions['pay']); |
|
99 | 99 | } |
100 | 100 | |
101 | - $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ); |
|
101 | + $actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice); |
|
102 | 102 | |
103 | - foreach ( $actions as $key => $action ) { |
|
103 | + foreach ($actions as $key => $action) { |
|
104 | 104 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
105 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
105 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | break; |
109 | 109 | |
110 | 110 | default: |
111 | - do_action( "wpinv_user_invoices_column_$column_id", $invoice ); |
|
111 | + do_action("wpinv_user_invoices_column_$column_id", $invoice); |
|
112 | 112 | break; |
113 | 113 | |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | - do_action( "wpinv_user_invoices_column_after_$column_id", $invoice ); |
|
117 | + do_action("wpinv_user_invoices_column_after_$column_id", $invoice); |
|
118 | 118 | |
119 | 119 | echo '</td>'; |
120 | 120 | |
@@ -127,20 +127,20 @@ discard block |
||
127 | 127 | </tbody> |
128 | 128 | </table> |
129 | 129 | |
130 | - <?php do_action( 'wpinv_before_user_invoices_pagination' ); ?> |
|
130 | + <?php do_action('wpinv_before_user_invoices_pagination'); ?> |
|
131 | 131 | |
132 | - <?php if ( 1 < $invoices->max_num_pages ) : ?> |
|
132 | + <?php if (1 < $invoices->max_num_pages) : ?> |
|
133 | 133 | <div class="invoicing-Pagination"> |
134 | 134 | <?php |
135 | 135 | $big = 999999; |
136 | 136 | |
137 | - echo paginate_links( array( |
|
138 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
137 | + echo paginate_links(array( |
|
138 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
139 | 139 | 'format' => '?paged=%#%', |
140 | 140 | 'total' => $invoices->max_num_pages, |
141 | - ) ); |
|
141 | + )); |
|
142 | 142 | ?> |
143 | 143 | </div> |
144 | 144 | <?php endif; ?> |
145 | 145 | |
146 | -<?php do_action( 'wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages ); ?> |
|
146 | +<?php do_action('wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages); ?> |
@@ -7,54 +7,54 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Fetch the invoice. |
13 | -$invoice = new WPInv_Invoice( $invoice ); |
|
13 | +$invoice = new WPInv_Invoice($invoice); |
|
14 | 14 | |
15 | 15 | // @deprecated |
16 | -do_action( 'wpinv_success_content_before', $invoice ); |
|
17 | -do_action( 'wpinv_before_receipt', $invoice ); |
|
16 | +do_action('wpinv_success_content_before', $invoice); |
|
17 | +do_action('wpinv_before_receipt', $invoice); |
|
18 | 18 | |
19 | 19 | |
20 | 20 | // Prepare header text. |
21 | -if ( $invoice->is_paid() ) { |
|
21 | +if ($invoice->is_paid()) { |
|
22 | 22 | |
23 | 23 | $alert = aui()->alert( |
24 | 24 | array( |
25 | 25 | 'type' => 'success', |
26 | - 'content' => __( 'Thank you for your payment!', 'invoicing' ), |
|
26 | + 'content' => __('Thank you for your payment!', 'invoicing'), |
|
27 | 27 | ) |
28 | 28 | ); |
29 | 29 | |
30 | -} else if ( $invoice->is_refunded() ) { |
|
30 | +} else if ($invoice->is_refunded()) { |
|
31 | 31 | |
32 | 32 | $alert = aui()->alert( |
33 | 33 | array( |
34 | 34 | 'type' => 'info', |
35 | - 'content' => __( 'This invoice was refunded.', 'invoicing' ), |
|
35 | + 'content' => __('This invoice was refunded.', 'invoicing'), |
|
36 | 36 | ) |
37 | 37 | ); |
38 | 38 | |
39 | -} else if ( $invoice->is_held() ) { |
|
39 | +} else if ($invoice->is_held()) { |
|
40 | 40 | |
41 | 41 | $alert = aui()->alert( |
42 | 42 | array( |
43 | 43 | 'type' => 'info', |
44 | - 'content' => __( 'This invoice will be processed as soon we verify your payment.', 'invoicing' ), |
|
44 | + 'content' => __('This invoice will be processed as soon we verify your payment.', 'invoicing'), |
|
45 | 45 | ) |
46 | 46 | ); |
47 | 47 | |
48 | -} else if ( $invoice->needs_payment() ) { |
|
48 | +} else if ($invoice->needs_payment()) { |
|
49 | 49 | |
50 | - if ( $invoice->is_due() ) { |
|
50 | + if ($invoice->is_due()) { |
|
51 | 51 | |
52 | 52 | $alert = aui()->alert( |
53 | 53 | array( |
54 | 54 | 'type' => 'danger', |
55 | 55 | 'content' => sprintf( |
56 | - __( 'This invoice was due on %.', 'invoicing' ), |
|
57 | - getpaid_format_date_value( $invoice->get_due_date() ) |
|
56 | + __('This invoice was due on %.', 'invoicing'), |
|
57 | + getpaid_format_date_value($invoice->get_due_date()) |
|
58 | 58 | ), |
59 | 59 | ) |
60 | 60 | ); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $alert = aui()->alert( |
65 | 65 | array( |
66 | 66 | 'type' => 'warning', |
67 | - 'content' => __( 'This invoice needs payment.', 'invoicing' ), |
|
67 | + 'content' => __('This invoice needs payment.', 'invoicing'), |
|
68 | 68 | ) |
69 | 69 | ); |
70 | 70 | |
@@ -79,19 +79,19 @@ discard block |
||
79 | 79 | |
80 | 80 | 'pay' => array( |
81 | 81 | 'url' => $invoice->get_checkout_payment_url(), |
82 | - 'name' => __( 'Pay For Invoice', 'invoicing' ), |
|
82 | + 'name' => __('Pay For Invoice', 'invoicing'), |
|
83 | 83 | 'class' => 'btn-success', |
84 | 84 | ), |
85 | 85 | |
86 | 86 | 'view' => array( |
87 | 87 | 'url' => $invoice->get_view_url(), |
88 | - 'name' => __( 'View Invoice', 'invoicing' ), |
|
88 | + 'name' => __('View Invoice', 'invoicing'), |
|
89 | 89 | 'class' => 'btn-primary', |
90 | 90 | ), |
91 | 91 | |
92 | 92 | 'history' => array( |
93 | 93 | 'url' => wpinv_get_history_page_uri(), |
94 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
94 | + 'name' => __('Invoice History', 'invoicing'), |
|
95 | 95 | 'class' => 'btn-warning', |
96 | 96 | ), |
97 | 97 | |
@@ -100,12 +100,12 @@ discard block |
||
100 | 100 | |
101 | 101 | ); |
102 | 102 | |
103 | -if ( ( ! $invoice->needs_payment() || $invoice->is_held() ) && isset( $actions['pay'] ) ) { |
|
104 | - unset( $actions['pay'] ); |
|
103 | +if ((!$invoice->needs_payment() || $invoice->is_held()) && isset($actions['pay'])) { |
|
104 | + unset($actions['pay']); |
|
105 | 105 | } |
106 | 106 | |
107 | -if ( ! is_user_logged_in() && isset( $actions['history'] ) ) { |
|
108 | - unset( $actions['history'] ); |
|
107 | +if (!is_user_logged_in() && isset($actions['history'])) { |
|
108 | + unset($actions['history']); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | ?> |
@@ -114,19 +114,19 @@ discard block |
||
114 | 114 | |
115 | 115 | <?php |
116 | 116 | |
117 | - do_action( 'wpinv_receipt_start', $invoice ); |
|
117 | + do_action('wpinv_receipt_start', $invoice); |
|
118 | 118 | |
119 | - if ( ! empty( $actions ) ) { |
|
119 | + if (!empty($actions)) { |
|
120 | 120 | |
121 | 121 | echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">'; |
122 | 122 | |
123 | - foreach ( $actions as $key => $action ) { |
|
123 | + foreach ($actions as $key => $action) { |
|
124 | 124 | |
125 | - $key = sanitize_html_class( $key ); |
|
126 | - $class = empty( $action['class'] ) ? 'btn-dark' : sanitize_html_class( $action['class'] ); |
|
127 | - $url = empty( $action['url'] ) ? '#' : esc_url( $action['url'] ); |
|
128 | - $attrs = empty( $action['attrs'] ) ? '' : $action['attrs']; |
|
129 | - $anchor = sanitize_text_field( $action['name'] ); |
|
125 | + $key = sanitize_html_class($key); |
|
126 | + $class = empty($action['class']) ? 'btn-dark' : sanitize_html_class($action['class']); |
|
127 | + $url = empty($action['url']) ? '#' : esc_url($action['url']); |
|
128 | + $attrs = empty($action['attrs']) ? '' : $action['attrs']; |
|
129 | + $anchor = sanitize_text_field($action['name']); |
|
130 | 130 | |
131 | 131 | echo "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>"; |
132 | 132 | } |
@@ -142,20 +142,20 @@ discard block |
||
142 | 142 | <div class="wpinv-receipt-details"> |
143 | 143 | |
144 | 144 | <h4 class="wpinv-details-t mb-3 mt-3"> |
145 | - <?php echo apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?> |
|
145 | + <?php echo apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing'), $invoice); ?> |
|
146 | 146 | </h4> |
147 | 147 | |
148 | - <?php getpaid_invoice_meta( $invoice ); ?> |
|
148 | + <?php getpaid_invoice_meta($invoice); ?> |
|
149 | 149 | |
150 | 150 | </div> |
151 | 151 | |
152 | 152 | |
153 | - <?php do_action( 'wpinv_receipt_end', $invoice ); ?> |
|
153 | + <?php do_action('wpinv_receipt_end', $invoice); ?> |
|
154 | 154 | |
155 | 155 | </div> |
156 | 156 | |
157 | 157 | <?php |
158 | 158 | |
159 | 159 | // @deprecated |
160 | -do_action( 'wpinv_success_content_after', $invoice ); |
|
161 | -do_action( 'wpinv_after_receipt', $invoice ); |
|
160 | +do_action('wpinv_success_content_after', $invoice); |
|
161 | +do_action('wpinv_after_receipt', $invoice); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Represents a single email type. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param string $id Email Type. |
33 | 33 | * @param mixed $object Optional. Associated object. |
34 | 34 | */ |
35 | - public function __construct( $id, $object = false ) { |
|
35 | + public function __construct($id, $object = false) { |
|
36 | 36 | $this->id = $id; |
37 | 37 | $this->object = $object; |
38 | 38 | } |
@@ -42,19 +42,19 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return mixed |
44 | 44 | */ |
45 | - public function get_option( $key ) { |
|
45 | + public function get_option($key) { |
|
46 | 46 | |
47 | 47 | $key = "email_{$this->id}_$key"; |
48 | - $value = wpinv_get_option( $key, null ); |
|
48 | + $value = wpinv_get_option($key, null); |
|
49 | 49 | |
50 | - if ( is_null( $value ) ) { |
|
50 | + if (is_null($value)) { |
|
51 | 51 | $options = wpinv_get_emails(); |
52 | 52 | |
53 | - if ( ! isset( $options[ $this->id ] ) || ! isset( $options[ $this->id ][ $key ] ) ) { |
|
53 | + if (!isset($options[$this->id]) || !isset($options[$this->id][$key])) { |
|
54 | 54 | return ''; |
55 | 55 | } |
56 | 56 | |
57 | - $value = isset( $options[ $this->id ][ $key ]['std'] ) ? $options[ $this->id ][ $key ]['std'] : ''; |
|
57 | + $value = isset($options[$this->id][$key]['std']) ? $options[$this->id][$key]['std'] : ''; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return $value; |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @return string |
67 | 67 | */ |
68 | 68 | public function get_body() { |
69 | - $body = $this->get_option( 'body' ); |
|
70 | - return apply_filters( 'getpaid_get_email_body', $body, $this->id, $this->object ); |
|
69 | + $body = $this->get_option('body'); |
|
70 | + return apply_filters('getpaid_get_email_body', $body, $this->id, $this->object); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @return string |
77 | 77 | */ |
78 | 78 | public function get_subject() { |
79 | - $subject = $this->get_option( 'subject' ); |
|
80 | - return apply_filters( 'getpaid_get_email_subject', $subject, $this->id, $this->object ); |
|
79 | + $subject = $this->get_option('subject'); |
|
80 | + return apply_filters('getpaid_get_email_subject', $subject, $this->id, $this->object); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @return string |
87 | 87 | */ |
88 | 88 | public function get_heading() { |
89 | - $heading = $this->get_option( 'heading' ); |
|
90 | - return apply_filters( 'getpaid_get_email_heading', $heading, $this->id, $this->object ); |
|
89 | + $heading = $this->get_option('heading'); |
|
90 | + return apply_filters('getpaid_get_email_heading', $heading, $this->id, $this->object); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | * @return bool |
97 | 97 | */ |
98 | 98 | public function is_active() { |
99 | - $is_active = ! empty( $this->get_option( 'is_active' ) ); |
|
100 | - return apply_filters( 'getpaid_email_type_is_active', $is_active, $this->id, $this->object ); |
|
99 | + $is_active = !empty($this->get_option('is_active')); |
|
100 | + return apply_filters('getpaid_email_type_is_active', $is_active, $this->id, $this->object); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | * @return bool |
107 | 107 | */ |
108 | 108 | public function include_admin_bcc() { |
109 | - $include_admin_bcc = ! empty( $this->get_option( 'admin_bcc' ) ); |
|
110 | - return apply_filters( 'getpaid_email_type_include_admin_bcc', $include_admin_bcc, $this->id, $this->object ); |
|
109 | + $include_admin_bcc = !empty($this->get_option('admin_bcc')); |
|
110 | + return apply_filters('getpaid_email_type_include_admin_bcc', $include_admin_bcc, $this->id, $this->object); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * @return bool |
117 | 117 | */ |
118 | 118 | public function is_admin_email() { |
119 | - $is_admin_email = in_array( $this->id, array( 'new_invoice', 'cancelled_invoice', 'failed_invoice' ) ); |
|
120 | - return apply_filters( 'getpaid_email_type_is_admin_email', $is_admin_email, $this->id, $this->object ); |
|
119 | + $is_admin_email = in_array($this->id, array('new_invoice', 'cancelled_invoice', 'failed_invoice')); |
|
120 | + return apply_filters('getpaid_email_type_is_admin_email', $is_admin_email, $this->id, $this->object); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @return array |
127 | 127 | */ |
128 | 128 | public function get_attachments() { |
129 | - return apply_filters( 'getpaid_get_email_attachments', array(), $this->id, $this->object ); |
|
129 | + return apply_filters('getpaid_get_email_attachments', array(), $this->id, $this->object); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | |
139 | 139 | $merge_tags = array( |
140 | 140 | '{site_title}' => wpinv_get_blogname(), |
141 | - '{date}' => getpaid_format_date_value( current_time( 'mysql' ) ), |
|
141 | + '{date}' => getpaid_format_date_value(current_time('mysql')), |
|
142 | 142 | ); |
143 | 143 | |
144 | - return apply_filters( 'getpaid_get_email_merge_tags', $merge_tags, $this->object, $this->id ); |
|
144 | + return apply_filters('getpaid_get_email_merge_tags', $merge_tags, $this->object, $this->id); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | * @param array $merge_tags |
152 | 152 | * @return string |
153 | 153 | */ |
154 | - public function add_merge_tags( $text, $merge_tags = array() ) { |
|
154 | + public function add_merge_tags($text, $merge_tags = array()) { |
|
155 | 155 | |
156 | - foreach ( $merge_tags as $key => $value ) { |
|
157 | - $text = str_replace( $key, $value, $text ); |
|
156 | + foreach ($merge_tags as $key => $value) { |
|
157 | + $text = str_replace($key, $value, $text); |
|
158 | 158 | } |
159 | 159 | |
160 | - return wptexturize( $text ); |
|
160 | + return wptexturize($text); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param array $extra_args Extra template args |
168 | 168 | * @return string |
169 | 169 | */ |
170 | - public function get_content( $merge_tags = array(), $extra_args = array() ) { |
|
170 | + public function get_content($merge_tags = array(), $extra_args = array()) { |
|
171 | 171 | |
172 | 172 | $content = wpinv_get_template_html( |
173 | 173 | "emails/wpinv-email-{$this->id}.php", |
@@ -177,15 +177,15 @@ discard block |
||
177 | 177 | 'invoice' => $this->object, // Backwards compat. |
178 | 178 | 'object' => $this->object, |
179 | 179 | 'email_type' => $this->id, |
180 | - 'email_heading' => $this->add_merge_tags( $this->get_heading(), $merge_tags ), |
|
180 | + 'email_heading' => $this->add_merge_tags($this->get_heading(), $merge_tags), |
|
181 | 181 | 'sent_to_admin' => $this->is_admin_email(), |
182 | 182 | 'plain_text' => false, |
183 | - 'message_body' => wpautop( $this->add_merge_tags( $this->get_body(), $merge_tags ) ), |
|
183 | + 'message_body' => wpautop($this->add_merge_tags($this->get_body(), $merge_tags)), |
|
184 | 184 | ) |
185 | 185 | ) |
186 | 186 | ); |
187 | 187 | |
188 | - return wpinv_email_style_body( $content ); |
|
188 | + return wpinv_email_style_body($content); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Personal data exporters. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * WPInv_Privacy_Exporters Class. |
@@ -17,38 +17,38 @@ discard block |
||
17 | 17 | * @param int $page Page. |
18 | 18 | * @return array An array of invoice data in name value pairs |
19 | 19 | */ |
20 | - public static function customer_invoice_data_exporter( $email_address, $page ) { |
|
20 | + public static function customer_invoice_data_exporter($email_address, $page) { |
|
21 | 21 | $done = false; |
22 | 22 | $page = (int) $page; |
23 | 23 | $data_to_export = array(); |
24 | 24 | |
25 | - $user = get_user_by( 'email', $email_address ); |
|
26 | - if ( ! $user instanceof WP_User ) { |
|
25 | + $user = get_user_by('email', $email_address); |
|
26 | + if (!$user instanceof WP_User) { |
|
27 | 27 | return array( |
28 | 28 | 'data' => $data_to_export, |
29 | 29 | 'done' => true, |
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
33 | - $args = array( |
|
33 | + $args = array( |
|
34 | 34 | 'limit' => 30, |
35 | 35 | 'page' => $page, |
36 | 36 | 'user' => $user->ID, |
37 | 37 | ); |
38 | 38 | |
39 | - $invoices = wpinv_get_invoices( $args ); |
|
39 | + $invoices = wpinv_get_invoices($args); |
|
40 | 40 | |
41 | - if ( 0 < count( $invoices ) ) { |
|
42 | - foreach ( $invoices as $invoice ) { |
|
41 | + if (0 < count($invoices)) { |
|
42 | + foreach ($invoices as $invoice) { |
|
43 | 43 | $data_to_export[] = array( |
44 | 44 | 'group_id' => 'customer_invoices', |
45 | - 'group_label' => __( 'Invoicing Data', 'invoicing' ), |
|
46 | - 'group_description' => __( 'Customer invoicing data.', 'invoicing' ), |
|
45 | + 'group_label' => __('Invoicing Data', 'invoicing'), |
|
46 | + 'group_description' => __('Customer invoicing data.', 'invoicing'), |
|
47 | 47 | 'item_id' => "wpinv-{$invoice->ID}", |
48 | - 'data' => self::get_customer_invoice_data( $invoice ), |
|
48 | + 'data' => self::get_customer_invoice_data($invoice), |
|
49 | 49 | ); |
50 | 50 | } |
51 | - $done = 30 > count( $invoices ); |
|
51 | + $done = 30 > count($invoices); |
|
52 | 52 | } else { |
53 | 53 | $done = true; |
54 | 54 | } |
@@ -66,59 +66,59 @@ discard block |
||
66 | 66 | * @param WPInv_Invoice $invoice invoice object. |
67 | 67 | * @return array |
68 | 68 | */ |
69 | - public static function get_customer_invoice_data( $invoice ) { |
|
69 | + public static function get_customer_invoice_data($invoice) { |
|
70 | 70 | $personal_data = array(); |
71 | 71 | |
72 | 72 | $props_to_export = array( |
73 | - 'number' => __( 'Invoice Number', 'invoicing' ), |
|
74 | - 'created_date' => __( 'Invoice Date', 'invoicing' ), |
|
75 | - 'status' => __( 'Invoice Status', 'invoicing' ), |
|
76 | - 'total' => __( 'Invoice Total', 'invoicing' ), |
|
77 | - 'items' => __( 'Invoice Items', 'invoicing' ), |
|
78 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
79 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
80 | - 'email' => __( 'Email Address', 'invoicing' ), |
|
81 | - '_wpinv_company' => __( 'Company', 'invoicing' ), |
|
82 | - 'phone' => __( 'Phone Number', 'invoicing' ), |
|
83 | - 'address' => __( 'Address', 'invoicing' ), |
|
84 | - '_wpinv_city' => __( 'City', 'invoicing' ), |
|
85 | - '_wpinv_country' => __( 'Country', 'invoicing' ), |
|
86 | - '_wpinv_state' => __( 'State', 'invoicing' ), |
|
87 | - '_wpinv_zip' => __( 'Zip Code', 'invoicing' ), |
|
73 | + 'number' => __('Invoice Number', 'invoicing'), |
|
74 | + 'created_date' => __('Invoice Date', 'invoicing'), |
|
75 | + 'status' => __('Invoice Status', 'invoicing'), |
|
76 | + 'total' => __('Invoice Total', 'invoicing'), |
|
77 | + 'items' => __('Invoice Items', 'invoicing'), |
|
78 | + 'first_name' => __('First Name', 'invoicing'), |
|
79 | + 'last_name' => __('Last Name', 'invoicing'), |
|
80 | + 'email' => __('Email Address', 'invoicing'), |
|
81 | + '_wpinv_company' => __('Company', 'invoicing'), |
|
82 | + 'phone' => __('Phone Number', 'invoicing'), |
|
83 | + 'address' => __('Address', 'invoicing'), |
|
84 | + '_wpinv_city' => __('City', 'invoicing'), |
|
85 | + '_wpinv_country' => __('Country', 'invoicing'), |
|
86 | + '_wpinv_state' => __('State', 'invoicing'), |
|
87 | + '_wpinv_zip' => __('Zip Code', 'invoicing'), |
|
88 | 88 | ); |
89 | 89 | |
90 | - $subscription = wpinv_get_subscription( $invoice ); |
|
90 | + $subscription = wpinv_get_subscription($invoice); |
|
91 | 91 | $period = $initial_amt = $bill_times = $billed = $renewal_date = ''; |
92 | 92 | |
93 | - if ( $invoice->is_recurring() && !empty( $subscription ) ) { |
|
94 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->get_period(),$subscription->get_frequency() ); |
|
95 | - $period = wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $subscription->get_parent_payment()->get_currency() ) . ' / ' . $frequency; |
|
96 | - $initial_amt = wpinv_price( wpinv_format_amount( $subscription->get_initial_amount() ), $subscription->get_parent_payment()->get_currency() ); |
|
97 | - $bill_times = $subscription->get_times_billed() . ' / ' . ( ( $subscription->get_bill_times() == 0 ) ? __( 'Until Cancelled', 'invoicing' ) : $subscription->get_bill_times() ); |
|
98 | - $renewal_date = ! empty( $subscription->expiration ) ? getpaid_format_date( $subscription->expiration ) : __( 'N/A', 'invoicing' ); |
|
99 | - |
|
100 | - $props_to_export['period'] = __( 'Billing Cycle', 'invoicing' ); |
|
101 | - $props_to_export['initial_amount'] = __( 'Initial Amount', 'invoicing' ); |
|
102 | - $props_to_export['bill_times'] = __( 'Times Billed', 'invoicing' ); |
|
103 | - $props_to_export['renewal_date'] = __( 'Renewal Date', 'invoicing' ); |
|
93 | + if ($invoice->is_recurring() && !empty($subscription)) { |
|
94 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->get_period(), $subscription->get_frequency()); |
|
95 | + $period = wpinv_price(wpinv_format_amount($subscription->get_recurring_amount()), $subscription->get_parent_payment()->get_currency()) . ' / ' . $frequency; |
|
96 | + $initial_amt = wpinv_price(wpinv_format_amount($subscription->get_initial_amount()), $subscription->get_parent_payment()->get_currency()); |
|
97 | + $bill_times = $subscription->get_times_billed() . ' / ' . (($subscription->get_bill_times() == 0) ? __('Until Cancelled', 'invoicing') : $subscription->get_bill_times()); |
|
98 | + $renewal_date = !empty($subscription->expiration) ? getpaid_format_date($subscription->expiration) : __('N/A', 'invoicing'); |
|
99 | + |
|
100 | + $props_to_export['period'] = __('Billing Cycle', 'invoicing'); |
|
101 | + $props_to_export['initial_amount'] = __('Initial Amount', 'invoicing'); |
|
102 | + $props_to_export['bill_times'] = __('Times Billed', 'invoicing'); |
|
103 | + $props_to_export['renewal_date'] = __('Renewal Date', 'invoicing'); |
|
104 | 104 | } |
105 | 105 | |
106 | - $props_to_export['ip'] = __( 'IP Address', 'invoicing' ); |
|
107 | - $props_to_export['view_url'] = __( 'Invoice Link', 'invoicing' ); |
|
106 | + $props_to_export['ip'] = __('IP Address', 'invoicing'); |
|
107 | + $props_to_export['view_url'] = __('Invoice Link', 'invoicing'); |
|
108 | 108 | |
109 | - $props_to_export = apply_filters( 'wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription); |
|
109 | + $props_to_export = apply_filters('wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription); |
|
110 | 110 | |
111 | - foreach ( $props_to_export as $prop => $name ) { |
|
111 | + foreach ($props_to_export as $prop => $name) { |
|
112 | 112 | $value = ''; |
113 | 113 | |
114 | - switch ( $prop ) { |
|
114 | + switch ($prop) { |
|
115 | 115 | case 'items': |
116 | 116 | $item_names = array(); |
117 | - foreach ( $invoice->get_cart_details() as $key => $cart_item ) { |
|
118 | - $item_quantity = $cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
117 | + foreach ($invoice->get_cart_details() as $key => $cart_item) { |
|
118 | + $item_quantity = $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
119 | 119 | $item_names[] = $cart_item['name'] . ' x ' . $item_quantity; |
120 | 120 | } |
121 | - $value = implode( ', ', $item_names ); |
|
121 | + $value = implode(', ', $item_names); |
|
122 | 122 | break; |
123 | 123 | case 'status': |
124 | 124 | $value = $invoice->get_status(true); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $value = $renewal_date; |
140 | 140 | break; |
141 | 141 | default: |
142 | - if ( is_callable( array( $invoice, 'get_' . $prop ) ) ) { |
|
142 | + if (is_callable(array($invoice, 'get_' . $prop))) { |
|
143 | 143 | $value = $invoice->{"get_$prop"}(); |
144 | 144 | } else { |
145 | 145 | $value = $invoice->get_meta($prop); |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | break; |
148 | 148 | } |
149 | 149 | |
150 | - $value = apply_filters( 'wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice ); |
|
150 | + $value = apply_filters('wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice); |
|
151 | 151 | |
152 | - if ( $value ) { |
|
152 | + if ($value) { |
|
153 | 153 | $personal_data[] = array( |
154 | 154 | 'name' => $name, |
155 | 155 | 'value' => $value, |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | } |
160 | 160 | |
161 | - $personal_data = apply_filters( 'wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice ); |
|
161 | + $personal_data = apply_filters('wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice); |
|
162 | 162 | |
163 | 163 | return $personal_data; |
164 | 164 |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | final class WPInv_Legacy_Invoice { |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * Invoice id. |
18 | 18 | */ |
19 | - public $ID = 0; |
|
19 | + public $ID = 0; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * The title of the invoice. Usually the invoice number. |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | /** |
133 | 133 | * The invoice status. |
134 | 134 | */ |
135 | - public $status = 'wpi-pending'; |
|
135 | + public $status = 'wpi-pending'; |
|
136 | 136 | |
137 | 137 | /** |
138 | 138 | * Same as self::$status. |
@@ -259,17 +259,17 @@ discard block |
||
259 | 259 | */ |
260 | 260 | public $parent_invoice = 0; |
261 | 261 | |
262 | - public function __construct( $invoice_id = false ) { |
|
263 | - if( empty( $invoice_id ) ) { |
|
262 | + public function __construct($invoice_id = false) { |
|
263 | + if (empty($invoice_id)) { |
|
264 | 264 | return false; |
265 | 265 | } |
266 | 266 | |
267 | - $this->setup_invoice( $invoice_id ); |
|
267 | + $this->setup_invoice($invoice_id); |
|
268 | 268 | } |
269 | 269 | |
270 | - public function get( $key ) { |
|
271 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
272 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
270 | + public function get($key) { |
|
271 | + if (method_exists($this, 'get_' . $key)) { |
|
272 | + $value = call_user_func(array($this, 'get_' . $key)); |
|
273 | 273 | } else { |
274 | 274 | $value = $this->$key; |
275 | 275 | } |
@@ -277,51 +277,51 @@ discard block |
||
277 | 277 | return $value; |
278 | 278 | } |
279 | 279 | |
280 | - public function set( $key, $value ) { |
|
281 | - $ignore = array( 'items', 'cart_details', 'fees', '_ID' ); |
|
280 | + public function set($key, $value) { |
|
281 | + $ignore = array('items', 'cart_details', 'fees', '_ID'); |
|
282 | 282 | |
283 | - if ( $key === 'status' ) { |
|
283 | + if ($key === 'status') { |
|
284 | 284 | $this->old_status = $this->status; |
285 | 285 | } |
286 | 286 | |
287 | - if ( ! in_array( $key, $ignore ) ) { |
|
288 | - $this->pending[ $key ] = $value; |
|
287 | + if (!in_array($key, $ignore)) { |
|
288 | + $this->pending[$key] = $value; |
|
289 | 289 | } |
290 | 290 | |
291 | - if( '_ID' !== $key ) { |
|
291 | + if ('_ID' !== $key) { |
|
292 | 292 | $this->$key = $value; |
293 | 293 | } |
294 | 294 | } |
295 | 295 | |
296 | - public function _isset( $name ) { |
|
297 | - if ( property_exists( $this, $name) ) { |
|
298 | - return false === empty( $this->$name ); |
|
296 | + public function _isset($name) { |
|
297 | + if (property_exists($this, $name)) { |
|
298 | + return false === empty($this->$name); |
|
299 | 299 | } else { |
300 | 300 | return null; |
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
304 | - private function setup_invoice( $invoice_id ) { |
|
304 | + private function setup_invoice($invoice_id) { |
|
305 | 305 | $this->pending = array(); |
306 | 306 | |
307 | - if ( empty( $invoice_id ) ) { |
|
307 | + if (empty($invoice_id)) { |
|
308 | 308 | return false; |
309 | 309 | } |
310 | 310 | |
311 | - $invoice = get_post( $invoice_id ); |
|
311 | + $invoice = get_post($invoice_id); |
|
312 | 312 | |
313 | - if( !$invoice || is_wp_error( $invoice ) ) { |
|
313 | + if (!$invoice || is_wp_error($invoice)) { |
|
314 | 314 | return false; |
315 | 315 | } |
316 | 316 | |
317 | - if( !('wpi_invoice' == $invoice->post_type OR 'wpi_quote' == $invoice->post_type) ) { |
|
317 | + if (!('wpi_invoice' == $invoice->post_type OR 'wpi_quote' == $invoice->post_type)) { |
|
318 | 318 | return false; |
319 | 319 | } |
320 | 320 | |
321 | - do_action( 'wpinv_pre_setup_invoice', $this, $invoice_id ); |
|
321 | + do_action('wpinv_pre_setup_invoice', $this, $invoice_id); |
|
322 | 322 | |
323 | 323 | // Primary Identifier |
324 | - $this->ID = absint( $invoice_id ); |
|
324 | + $this->ID = absint($invoice_id); |
|
325 | 325 | $this->post_type = $invoice->post_type; |
326 | 326 | |
327 | 327 | // We have a payment, get the generic payment_meta item to reduce calls to it |
@@ -331,14 +331,14 @@ discard block |
||
331 | 331 | $this->completed_date = $this->setup_completed_date(); |
332 | 332 | $this->status = $invoice->post_status; |
333 | 333 | |
334 | - if ( 'future' == $this->status ) { |
|
334 | + if ('future' == $this->status) { |
|
335 | 335 | $this->status = 'publish'; |
336 | 336 | } |
337 | 337 | |
338 | 338 | $this->post_status = $this->status; |
339 | 339 | $this->mode = $this->setup_mode(); |
340 | 340 | $this->parent_invoice = $invoice->post_parent; |
341 | - $this->post_name = $this->setup_post_name( $invoice ); |
|
341 | + $this->post_name = $this->setup_post_name($invoice); |
|
342 | 342 | $this->status_nicename = $this->setup_status_nicename($invoice->post_status); |
343 | 343 | |
344 | 344 | // Items |
@@ -361,8 +361,8 @@ discard block |
||
361 | 361 | |
362 | 362 | // User based |
363 | 363 | $this->ip = $this->setup_ip(); |
364 | - $this->user_id = !empty( $invoice->post_author ) ? $invoice->post_author : get_current_user_id();///$this->setup_user_id(); |
|
365 | - $this->email = get_the_author_meta( 'email', $this->user_id ); |
|
364 | + $this->user_id = !empty($invoice->post_author) ? $invoice->post_author : get_current_user_id(); ///$this->setup_user_id(); |
|
365 | + $this->email = get_the_author_meta('email', $this->user_id); |
|
366 | 366 | |
367 | 367 | $this->user_info = $this->setup_user_info(); |
368 | 368 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | $this->company = $this->user_info['company']; |
372 | 372 | $this->vat_number = $this->user_info['vat_number']; |
373 | 373 | $this->vat_rate = $this->user_info['vat_rate']; |
374 | - $this->adddress_confirmed = $this->user_info['adddress_confirmed']; |
|
374 | + $this->adddress_confirmed = $this->user_info['adddress_confirmed']; |
|
375 | 375 | $this->address = $this->user_info['address']; |
376 | 376 | $this->city = $this->user_info['city']; |
377 | 377 | $this->country = $this->user_info['country']; |
@@ -386,39 +386,39 @@ discard block |
||
386 | 386 | // Other Identifiers |
387 | 387 | $this->key = $this->setup_invoice_key(); |
388 | 388 | $this->number = $this->setup_invoice_number(); |
389 | - $this->title = !empty( $invoice->post_title ) ? $invoice->post_title : $this->number; |
|
389 | + $this->title = !empty($invoice->post_title) ? $invoice->post_title : $this->number; |
|
390 | 390 | |
391 | - $this->full_name = trim( $this->first_name . ' '. $this->last_name ); |
|
391 | + $this->full_name = trim($this->first_name . ' ' . $this->last_name); |
|
392 | 392 | |
393 | 393 | // Allow extensions to add items to this object via hook |
394 | - do_action( 'wpinv_setup_invoice', $this, $invoice_id ); |
|
394 | + do_action('wpinv_setup_invoice', $this, $invoice_id); |
|
395 | 395 | |
396 | 396 | return true; |
397 | 397 | } |
398 | 398 | |
399 | - private function setup_status_nicename( $status ) { |
|
400 | - $all_invoice_statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
399 | + private function setup_status_nicename($status) { |
|
400 | + $all_invoice_statuses = wpinv_get_invoice_statuses(true, true, $this); |
|
401 | 401 | |
402 | - if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
403 | - $all_invoice_statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses(); |
|
402 | + if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) { |
|
403 | + $all_invoice_statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses(); |
|
404 | 404 | } |
405 | - $status = isset( $all_invoice_statuses[$status] ) ? $all_invoice_statuses[$status] : __( $status, 'invoicing' ); |
|
405 | + $status = isset($all_invoice_statuses[$status]) ? $all_invoice_statuses[$status] : __($status, 'invoicing'); |
|
406 | 406 | |
407 | - return apply_filters( 'setup_status_nicename', $status ); |
|
407 | + return apply_filters('setup_status_nicename', $status); |
|
408 | 408 | } |
409 | 409 | |
410 | - private function setup_post_name( $post = NULL ) { |
|
410 | + private function setup_post_name($post = NULL) { |
|
411 | 411 | global $wpdb; |
412 | 412 | |
413 | 413 | $post_name = ''; |
414 | 414 | |
415 | - if ( !empty( $post ) ) { |
|
416 | - if( !empty( $post->post_name ) ) { |
|
415 | + if (!empty($post)) { |
|
416 | + if (!empty($post->post_name)) { |
|
417 | 417 | $post_name = $post->post_name; |
418 | - } else if ( !empty( $post->ID ) ) { |
|
419 | - $post_name = wpinv_generate_post_name( $post->ID ); |
|
418 | + } else if (!empty($post->ID)) { |
|
419 | + $post_name = wpinv_generate_post_name($post->ID); |
|
420 | 420 | |
421 | - $wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), array( 'ID' => $post->ID ) ); |
|
421 | + $wpdb->update($wpdb->posts, array('post_name' => $post_name), array('ID' => $post->ID)); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
@@ -426,12 +426,12 @@ discard block |
||
426 | 426 | } |
427 | 427 | |
428 | 428 | private function setup_due_date() { |
429 | - $due_date = $this->get_meta( '_wpinv_due_date' ); |
|
429 | + $due_date = $this->get_meta('_wpinv_due_date'); |
|
430 | 430 | |
431 | - if ( empty( $due_date ) ) { |
|
432 | - $overdue_time = strtotime( $this->date ) + ( DAY_IN_SECONDS * absint( wpinv_get_option( 'overdue_days' ) ) ); |
|
433 | - $due_date = date_i18n( 'Y-m-d', $overdue_time ); |
|
434 | - } else if ( $due_date == 'none' ) { |
|
431 | + if (empty($due_date)) { |
|
432 | + $overdue_time = strtotime($this->date) + (DAY_IN_SECONDS * absint(wpinv_get_option('overdue_days'))); |
|
433 | + $due_date = date_i18n('Y-m-d', $overdue_time); |
|
434 | + } else if ($due_date == 'none') { |
|
435 | 435 | $due_date = ''; |
436 | 436 | } |
437 | 437 | |
@@ -439,67 +439,67 @@ discard block |
||
439 | 439 | } |
440 | 440 | |
441 | 441 | private function setup_completed_date() { |
442 | - $invoice = get_post( $this->ID ); |
|
442 | + $invoice = get_post($this->ID); |
|
443 | 443 | |
444 | - if ( 'wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status ) { |
|
444 | + if ('wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status) { |
|
445 | 445 | return false; // This invoice was never paid |
446 | 446 | } |
447 | 447 | |
448 | - $date = ( $date = $this->get_meta( '_wpinv_completed_date', true ) ) ? $date : $invoice->modified_date; |
|
448 | + $date = ($date = $this->get_meta('_wpinv_completed_date', true)) ? $date : $invoice->modified_date; |
|
449 | 449 | |
450 | 450 | return $date; |
451 | 451 | } |
452 | 452 | |
453 | 453 | private function setup_cart_details() { |
454 | - $cart_details = isset( $this->payment_meta['cart_details'] ) ? maybe_unserialize( $this->payment_meta['cart_details'] ) : array(); |
|
454 | + $cart_details = isset($this->payment_meta['cart_details']) ? maybe_unserialize($this->payment_meta['cart_details']) : array(); |
|
455 | 455 | return $cart_details; |
456 | 456 | } |
457 | 457 | |
458 | 458 | public function array_convert() { |
459 | - return get_object_vars( $this ); |
|
459 | + return get_object_vars($this); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | private function setup_items() { |
463 | - $items = isset( $this->payment_meta['items'] ) ? maybe_unserialize( $this->payment_meta['items'] ) : array(); |
|
463 | + $items = isset($this->payment_meta['items']) ? maybe_unserialize($this->payment_meta['items']) : array(); |
|
464 | 464 | return $items; |
465 | 465 | } |
466 | 466 | |
467 | 467 | private function setup_fees() { |
468 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
468 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
469 | 469 | return $payment_fees; |
470 | 470 | } |
471 | 471 | |
472 | 472 | private function setup_currency() { |
473 | - $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'wpinv_currency_default', wpinv_get_currency(), $this ); |
|
473 | + $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('wpinv_currency_default', wpinv_get_currency(), $this); |
|
474 | 474 | return $currency; |
475 | 475 | } |
476 | 476 | |
477 | 477 | private function setup_discount() { |
478 | 478 | //$discount = $this->get_meta( '_wpinv_discount', true ); |
479 | - $discount = (float)$this->subtotal - ( (float)$this->total - (float)$this->tax - (float)$this->fees_total ); |
|
480 | - if ( $discount < 0 ) { |
|
479 | + $discount = (float) $this->subtotal - ((float) $this->total - (float) $this->tax - (float) $this->fees_total); |
|
480 | + if ($discount < 0) { |
|
481 | 481 | $discount = 0; |
482 | 482 | } |
483 | - $discount = wpinv_round_amount( $discount ); |
|
483 | + $discount = wpinv_round_amount($discount); |
|
484 | 484 | |
485 | 485 | return $discount; |
486 | 486 | } |
487 | 487 | |
488 | 488 | private function setup_discount_code() { |
489 | - $discount_code = !empty( $this->discounts ) ? $this->discounts : $this->get_meta( '_wpinv_discount_code', true ); |
|
489 | + $discount_code = !empty($this->discounts) ? $this->discounts : $this->get_meta('_wpinv_discount_code', true); |
|
490 | 490 | return $discount_code; |
491 | 491 | } |
492 | 492 | |
493 | 493 | private function setup_tax() { |
494 | 494 | |
495 | - $tax = $this->get_meta( '_wpinv_tax', true ); |
|
495 | + $tax = $this->get_meta('_wpinv_tax', true); |
|
496 | 496 | |
497 | 497 | // We don't have tax as it's own meta and no meta was passed |
498 | - if ( '' === $tax ) { |
|
499 | - $tax = isset( $this->payment_meta['tax'] ) ? $this->payment_meta['tax'] : 0; |
|
498 | + if ('' === $tax) { |
|
499 | + $tax = isset($this->payment_meta['tax']) ? $this->payment_meta['tax'] : 0; |
|
500 | 500 | } |
501 | 501 | |
502 | - if ( $tax < 0 || ! $this->is_taxable() ) { |
|
502 | + if ($tax < 0 || !$this->is_taxable()) { |
|
503 | 503 | $tax = 0; |
504 | 504 | } |
505 | 505 | |
@@ -510,16 +510,16 @@ discard block |
||
510 | 510 | * If taxes are enabled, allow users to enable/disable taxes per invoice. |
511 | 511 | */ |
512 | 512 | private function setup_is_taxable() { |
513 | - return (int) $this->get_meta( '_wpinv_disable_taxes', true ); |
|
513 | + return (int) $this->get_meta('_wpinv_disable_taxes', true); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | private function setup_subtotal() { |
517 | 517 | $subtotal = 0; |
518 | 518 | $cart_details = $this->cart_details; |
519 | 519 | |
520 | - if ( is_array( $cart_details ) ) { |
|
521 | - foreach ( $cart_details as $item ) { |
|
522 | - if ( isset( $item['subtotal'] ) ) { |
|
520 | + if (is_array($cart_details)) { |
|
521 | + foreach ($cart_details as $item) { |
|
522 | + if (isset($item['subtotal'])) { |
|
523 | 523 | $subtotal += $item['subtotal']; |
524 | 524 | } |
525 | 525 | } |
@@ -533,23 +533,23 @@ discard block |
||
533 | 533 | } |
534 | 534 | |
535 | 535 | private function setup_discounts() { |
536 | - $discounts = ! empty( $this->payment_meta['user_info']['discount'] ) ? $this->payment_meta['user_info']['discount'] : array(); |
|
536 | + $discounts = !empty($this->payment_meta['user_info']['discount']) ? $this->payment_meta['user_info']['discount'] : array(); |
|
537 | 537 | return $discounts; |
538 | 538 | } |
539 | 539 | |
540 | 540 | private function setup_total() { |
541 | - $amount = $this->get_meta( '_wpinv_total', true ); |
|
541 | + $amount = $this->get_meta('_wpinv_total', true); |
|
542 | 542 | |
543 | - if ( empty( $amount ) && '0.00' != $amount ) { |
|
544 | - $meta = $this->get_meta( '_wpinv_payment_meta', true ); |
|
545 | - $meta = maybe_unserialize( $meta ); |
|
543 | + if (empty($amount) && '0.00' != $amount) { |
|
544 | + $meta = $this->get_meta('_wpinv_payment_meta', true); |
|
545 | + $meta = maybe_unserialize($meta); |
|
546 | 546 | |
547 | - if ( isset( $meta['amount'] ) ) { |
|
547 | + if (isset($meta['amount'])) { |
|
548 | 548 | $amount = $meta['amount']; |
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | - if($amount < 0){ |
|
552 | + if ($amount < 0) { |
|
553 | 553 | $amount = 0; |
554 | 554 | } |
555 | 555 | |
@@ -557,13 +557,13 @@ discard block |
||
557 | 557 | } |
558 | 558 | |
559 | 559 | private function setup_mode() { |
560 | - return $this->get_meta( '_wpinv_mode' ); |
|
560 | + return $this->get_meta('_wpinv_mode'); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | private function setup_gateway() { |
564 | - $gateway = $this->get_meta( '_wpinv_gateway' ); |
|
564 | + $gateway = $this->get_meta('_wpinv_gateway'); |
|
565 | 565 | |
566 | - if ( empty( $gateway ) && 'publish' === $this->status ) { |
|
566 | + if (empty($gateway) && 'publish' === $this->status) { |
|
567 | 567 | $gateway = 'manual'; |
568 | 568 | } |
569 | 569 | |
@@ -571,23 +571,23 @@ discard block |
||
571 | 571 | } |
572 | 572 | |
573 | 573 | private function setup_gateway_title() { |
574 | - $gateway_title = wpinv_get_gateway_checkout_label( $this->gateway ); |
|
574 | + $gateway_title = wpinv_get_gateway_checkout_label($this->gateway); |
|
575 | 575 | return $gateway_title; |
576 | 576 | } |
577 | 577 | |
578 | 578 | private function setup_transaction_id() { |
579 | - $transaction_id = $this->get_meta( '_wpinv_transaction_id' ); |
|
579 | + $transaction_id = $this->get_meta('_wpinv_transaction_id'); |
|
580 | 580 | |
581 | - if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) { |
|
581 | + if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) { |
|
582 | 582 | $gateway = $this->gateway; |
583 | - $transaction_id = apply_filters( 'wpinv_get_invoice_transaction_id-' . $gateway, $this->ID ); |
|
583 | + $transaction_id = apply_filters('wpinv_get_invoice_transaction_id-' . $gateway, $this->ID); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | return $transaction_id; |
587 | 587 | } |
588 | 588 | |
589 | 589 | private function setup_ip() { |
590 | - $ip = $this->get_meta( '_wpinv_user_ip' ); |
|
590 | + $ip = $this->get_meta('_wpinv_user_ip'); |
|
591 | 591 | return $ip; |
592 | 592 | } |
593 | 593 | |
@@ -597,62 +597,62 @@ discard block |
||
597 | 597 | ///} |
598 | 598 | |
599 | 599 | private function setup_first_name() { |
600 | - $first_name = $this->get_meta( '_wpinv_first_name' ); |
|
600 | + $first_name = $this->get_meta('_wpinv_first_name'); |
|
601 | 601 | return $first_name; |
602 | 602 | } |
603 | 603 | |
604 | 604 | private function setup_last_name() { |
605 | - $last_name = $this->get_meta( '_wpinv_last_name' ); |
|
605 | + $last_name = $this->get_meta('_wpinv_last_name'); |
|
606 | 606 | return $last_name; |
607 | 607 | } |
608 | 608 | |
609 | 609 | private function setup_company() { |
610 | - $company = $this->get_meta( '_wpinv_company' ); |
|
610 | + $company = $this->get_meta('_wpinv_company'); |
|
611 | 611 | return $company; |
612 | 612 | } |
613 | 613 | |
614 | 614 | private function setup_vat_number() { |
615 | - $vat_number = $this->get_meta( '_wpinv_vat_number' ); |
|
615 | + $vat_number = $this->get_meta('_wpinv_vat_number'); |
|
616 | 616 | return $vat_number; |
617 | 617 | } |
618 | 618 | |
619 | 619 | private function setup_vat_rate() { |
620 | - $vat_rate = $this->get_meta( '_wpinv_vat_rate' ); |
|
620 | + $vat_rate = $this->get_meta('_wpinv_vat_rate'); |
|
621 | 621 | return $vat_rate; |
622 | 622 | } |
623 | 623 | |
624 | 624 | private function setup_adddress_confirmed() { |
625 | - $adddress_confirmed = $this->get_meta( '_wpinv_adddress_confirmed' ); |
|
625 | + $adddress_confirmed = $this->get_meta('_wpinv_adddress_confirmed'); |
|
626 | 626 | return $adddress_confirmed; |
627 | 627 | } |
628 | 628 | |
629 | 629 | private function setup_phone() { |
630 | - $phone = $this->get_meta( '_wpinv_phone' ); |
|
630 | + $phone = $this->get_meta('_wpinv_phone'); |
|
631 | 631 | return $phone; |
632 | 632 | } |
633 | 633 | |
634 | 634 | private function setup_address() { |
635 | - $address = $this->get_meta( '_wpinv_address', true ); |
|
635 | + $address = $this->get_meta('_wpinv_address', true); |
|
636 | 636 | return $address; |
637 | 637 | } |
638 | 638 | |
639 | 639 | private function setup_city() { |
640 | - $city = $this->get_meta( '_wpinv_city', true ); |
|
640 | + $city = $this->get_meta('_wpinv_city', true); |
|
641 | 641 | return $city; |
642 | 642 | } |
643 | 643 | |
644 | 644 | private function setup_country() { |
645 | - $country = $this->get_meta( '_wpinv_country', true ); |
|
645 | + $country = $this->get_meta('_wpinv_country', true); |
|
646 | 646 | return $country; |
647 | 647 | } |
648 | 648 | |
649 | 649 | private function setup_state() { |
650 | - $state = $this->get_meta( '_wpinv_state', true ); |
|
650 | + $state = $this->get_meta('_wpinv_state', true); |
|
651 | 651 | return $state; |
652 | 652 | } |
653 | 653 | |
654 | 654 | private function setup_zip() { |
655 | - $zip = $this->get_meta( '_wpinv_zip', true ); |
|
655 | + $zip = $this->get_meta('_wpinv_zip', true); |
|
656 | 656 | return $zip; |
657 | 657 | } |
658 | 658 | |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | 'user_id' => $this->user_id, |
662 | 662 | 'first_name' => $this->first_name, |
663 | 663 | 'last_name' => $this->last_name, |
664 | - 'email' => get_the_author_meta( 'email', $this->user_id ), |
|
664 | + 'email' => get_the_author_meta('email', $this->user_id), |
|
665 | 665 | 'phone' => $this->phone, |
666 | 666 | 'address' => $this->address, |
667 | 667 | 'city' => $this->city, |
@@ -676,12 +676,12 @@ discard block |
||
676 | 676 | ); |
677 | 677 | |
678 | 678 | $user_info = array(); |
679 | - if ( isset( $this->payment_meta['user_info'] ) ) { |
|
680 | - $user_info = maybe_unserialize( $this->payment_meta['user_info'] ); |
|
679 | + if (isset($this->payment_meta['user_info'])) { |
|
680 | + $user_info = maybe_unserialize($this->payment_meta['user_info']); |
|
681 | 681 | |
682 | - if ( !empty( $user_info ) && isset( $user_info['user_id'] ) && $post = get_post( $this->ID ) ) { |
|
682 | + if (!empty($user_info) && isset($user_info['user_id']) && $post = get_post($this->ID)) { |
|
683 | 683 | $this->user_id = $post->post_author; |
684 | - $this->email = get_the_author_meta( 'email', $this->user_id ); |
|
684 | + $this->email = get_the_author_meta('email', $this->user_id); |
|
685 | 685 | |
686 | 686 | $user_info['user_id'] = $this->user_id; |
687 | 687 | $user_info['email'] = $this->email; |
@@ -690,13 +690,13 @@ discard block |
||
690 | 690 | } |
691 | 691 | } |
692 | 692 | |
693 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
693 | + $user_info = wp_parse_args($user_info, $defaults); |
|
694 | 694 | |
695 | 695 | // Get the user, but only if it's been created |
696 | - $user = get_userdata( $this->user_id ); |
|
696 | + $user = get_userdata($this->user_id); |
|
697 | 697 | |
698 | - if ( !empty( $user ) && $user->ID > 0 ) { |
|
699 | - if ( empty( $user_info ) ) { |
|
698 | + if (!empty($user) && $user->ID > 0) { |
|
699 | + if (empty($user_info)) { |
|
700 | 700 | $user_info = array( |
701 | 701 | 'user_id' => $user->ID, |
702 | 702 | 'first_name' => $user->first_name, |
@@ -705,23 +705,23 @@ discard block |
||
705 | 705 | 'discount' => '', |
706 | 706 | ); |
707 | 707 | } else { |
708 | - foreach ( $user_info as $key => $value ) { |
|
709 | - if ( ! empty( $value ) ) { |
|
708 | + foreach ($user_info as $key => $value) { |
|
709 | + if (!empty($value)) { |
|
710 | 710 | continue; |
711 | 711 | } |
712 | 712 | |
713 | - switch( $key ) { |
|
713 | + switch ($key) { |
|
714 | 714 | case 'user_id': |
715 | - $user_info[ $key ] = $user->ID; |
|
715 | + $user_info[$key] = $user->ID; |
|
716 | 716 | break; |
717 | 717 | case 'first_name': |
718 | - $user_info[ $key ] = $user->first_name; |
|
718 | + $user_info[$key] = $user->first_name; |
|
719 | 719 | break; |
720 | 720 | case 'last_name': |
721 | - $user_info[ $key ] = $user->last_name; |
|
721 | + $user_info[$key] = $user->last_name; |
|
722 | 722 | break; |
723 | 723 | case 'email': |
724 | - $user_info[ $key ] = $user->user_email; |
|
724 | + $user_info[$key] = $user->user_email; |
|
725 | 725 | break; |
726 | 726 | } |
727 | 727 | } |
@@ -732,25 +732,25 @@ discard block |
||
732 | 732 | } |
733 | 733 | |
734 | 734 | private function setup_invoice_key() { |
735 | - $key = $this->get_meta( '_wpinv_key', true ); |
|
735 | + $key = $this->get_meta('_wpinv_key', true); |
|
736 | 736 | |
737 | 737 | return $key; |
738 | 738 | } |
739 | 739 | |
740 | 740 | private function setup_invoice_number() { |
741 | - $number = $this->get_meta( '_wpinv_number', true ); |
|
741 | + $number = $this->get_meta('_wpinv_number', true); |
|
742 | 742 | |
743 | - if ( !$number ) { |
|
743 | + if (!$number) { |
|
744 | 744 | $number = $this->ID; |
745 | 745 | |
746 | - if ( $this->status == 'auto-draft' ) { |
|
747 | - if ( wpinv_sequential_number_active( $this->post_type ) ) { |
|
748 | - $next_number = wpinv_get_next_invoice_number( $this->post_type ); |
|
746 | + if ($this->status == 'auto-draft') { |
|
747 | + if (wpinv_sequential_number_active($this->post_type)) { |
|
748 | + $next_number = wpinv_get_next_invoice_number($this->post_type); |
|
749 | 749 | $number = $next_number; |
750 | 750 | } |
751 | 751 | } |
752 | 752 | |
753 | - $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
753 | + $number = wpinv_format_invoice_number($number, $this->post_type); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | return $number; |
@@ -759,10 +759,10 @@ discard block |
||
759 | 759 | private function insert_invoice() { |
760 | 760 | global $wpdb; |
761 | 761 | |
762 | - if ( empty( $this->post_type ) ) { |
|
763 | - if ( !empty( $this->ID ) && $post_type = get_post_type( $this->ID ) ) { |
|
762 | + if (empty($this->post_type)) { |
|
763 | + if (!empty($this->ID) && $post_type = get_post_type($this->ID)) { |
|
764 | 764 | $this->post_type = $post_type; |
765 | - } else if ( !empty( $this->parent_invoice ) && $post_type = get_post_type( $this->parent_invoice ) ) { |
|
765 | + } else if (!empty($this->parent_invoice) && $post_type = get_post_type($this->parent_invoice)) { |
|
766 | 766 | $this->post_type = $post_type; |
767 | 767 | } else { |
768 | 768 | $this->post_type = 'wpi_invoice'; |
@@ -770,16 +770,16 @@ discard block |
||
770 | 770 | } |
771 | 771 | |
772 | 772 | $invoice_number = $this->ID; |
773 | - if ( $number = $this->get_meta( '_wpinv_number', true ) ) { |
|
773 | + if ($number = $this->get_meta('_wpinv_number', true)) { |
|
774 | 774 | $invoice_number = $number; |
775 | 775 | } |
776 | 776 | |
777 | - if ( empty( $this->key ) ) { |
|
777 | + if (empty($this->key)) { |
|
778 | 778 | $this->key = self::generate_key(); |
779 | 779 | $this->pending['key'] = $this->key; |
780 | 780 | } |
781 | 781 | |
782 | - if ( empty( $this->ip ) ) { |
|
782 | + if (empty($this->ip)) { |
|
783 | 783 | $this->ip = wpinv_get_ip(); |
784 | 784 | $this->pending['ip'] = $this->ip; |
785 | 785 | } |
@@ -816,60 +816,60 @@ discard block |
||
816 | 816 | 'post_status' => $this->status, |
817 | 817 | 'post_author' => $this->user_id, |
818 | 818 | 'post_type' => $this->post_type, |
819 | - 'post_date' => ! empty( $this->date ) && $this->date != '0000-00-00 00:00:00' ? $this->date : current_time( 'mysql' ), |
|
820 | - 'post_date_gmt' => ! empty( $this->date ) && $this->date != '0000-00-00 00:00:00' ? get_gmt_from_date( $this->date ) : current_time( 'mysql', 1 ), |
|
819 | + 'post_date' => !empty($this->date) && $this->date != '0000-00-00 00:00:00' ? $this->date : current_time('mysql'), |
|
820 | + 'post_date_gmt' => !empty($this->date) && $this->date != '0000-00-00 00:00:00' ? get_gmt_from_date($this->date) : current_time('mysql', 1), |
|
821 | 821 | 'post_parent' => $this->parent_invoice, |
822 | 822 | ); |
823 | - $args = apply_filters( 'wpinv_insert_invoice_args', $post_data, $this ); |
|
823 | + $args = apply_filters('wpinv_insert_invoice_args', $post_data, $this); |
|
824 | 824 | |
825 | 825 | // Create a blank invoice |
826 | - if ( !empty( $this->ID ) ) { |
|
827 | - $args['ID'] = $this->ID; |
|
826 | + if (!empty($this->ID)) { |
|
827 | + $args['ID'] = $this->ID; |
|
828 | 828 | |
829 | - $invoice_id = wp_update_post( $args, true ); |
|
829 | + $invoice_id = wp_update_post($args, true); |
|
830 | 830 | } else { |
831 | - $invoice_id = wp_insert_post( $args, true ); |
|
831 | + $invoice_id = wp_insert_post($args, true); |
|
832 | 832 | } |
833 | 833 | |
834 | - if ( is_wp_error( $invoice_id ) ) { |
|
834 | + if (is_wp_error($invoice_id)) { |
|
835 | 835 | return false; |
836 | 836 | } |
837 | 837 | |
838 | - if ( !empty( $invoice_id ) ) { |
|
838 | + if (!empty($invoice_id)) { |
|
839 | 839 | $this->ID = $invoice_id; |
840 | 840 | $this->_ID = $invoice_id; |
841 | 841 | |
842 | - $this->payment_meta = apply_filters( 'wpinv_payment_meta', $this->payment_meta, $payment_data ); |
|
843 | - if ( ! empty( $this->payment_meta['fees'] ) ) { |
|
844 | - $this->fees = array_merge( $this->fees, $this->payment_meta['fees'] ); |
|
845 | - foreach( $this->fees as $fee ) { |
|
846 | - $this->increase_fees( $fee['amount'] ); |
|
842 | + $this->payment_meta = apply_filters('wpinv_payment_meta', $this->payment_meta, $payment_data); |
|
843 | + if (!empty($this->payment_meta['fees'])) { |
|
844 | + $this->fees = array_merge($this->fees, $this->payment_meta['fees']); |
|
845 | + foreach ($this->fees as $fee) { |
|
846 | + $this->increase_fees($fee['amount']); |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | |
850 | - $this->update_meta( '_wpinv_payment_meta', $this->payment_meta ); |
|
850 | + $this->update_meta('_wpinv_payment_meta', $this->payment_meta); |
|
851 | 851 | $this->new = true; |
852 | 852 | } |
853 | 853 | |
854 | 854 | return $this->ID; |
855 | 855 | } |
856 | 856 | |
857 | - public function save( $setup = false ) { |
|
857 | + public function save($setup = false) { |
|
858 | 858 | |
859 | 859 | $saved = false; |
860 | - if ( empty( $this->items ) ) { |
|
860 | + if (empty($this->items)) { |
|
861 | 861 | return $saved; // Don't save empty invoice. |
862 | 862 | } |
863 | 863 | |
864 | - if ( empty( $this->key ) ) { |
|
864 | + if (empty($this->key)) { |
|
865 | 865 | $this->key = self::generate_key(); |
866 | 866 | $this->pending['key'] = $this->key; |
867 | 867 | } |
868 | 868 | |
869 | - if ( empty( $this->ID ) ) { |
|
869 | + if (empty($this->ID)) { |
|
870 | 870 | $invoice_id = $this->insert_invoice(); |
871 | 871 | |
872 | - if ( false === $invoice_id ) { |
|
872 | + if (false === $invoice_id) { |
|
873 | 873 | $saved = false; |
874 | 874 | } else { |
875 | 875 | $this->ID = $invoice_id; |
@@ -877,27 +877,27 @@ discard block |
||
877 | 877 | } |
878 | 878 | |
879 | 879 | // If we have something pending, let's save it |
880 | - if ( !empty( $this->pending ) ) { |
|
880 | + if (!empty($this->pending)) { |
|
881 | 881 | $total_increase = 0; |
882 | 882 | $total_decrease = 0; |
883 | 883 | |
884 | - foreach ( $this->pending as $key => $value ) { |
|
885 | - switch( $key ) { |
|
884 | + foreach ($this->pending as $key => $value) { |
|
885 | + switch ($key) { |
|
886 | 886 | case 'items': |
887 | 887 | // Update totals for pending items |
888 | - foreach ( $this->pending[ $key ] as $item ) { |
|
889 | - switch( $item['action'] ) { |
|
888 | + foreach ($this->pending[$key] as $item) { |
|
889 | + switch ($item['action']) { |
|
890 | 890 | case 'add': |
891 | 891 | $price = $item['price']; |
892 | 892 | $taxes = $item['tax']; |
893 | 893 | |
894 | - if ( 'publish' === $this->status ) { |
|
894 | + if ('publish' === $this->status) { |
|
895 | 895 | $total_increase += $price; |
896 | 896 | } |
897 | 897 | break; |
898 | 898 | |
899 | 899 | case 'remove': |
900 | - if ( 'publish' === $this->status ) { |
|
900 | + if ('publish' === $this->status) { |
|
901 | 901 | $total_decrease += $item['price']; |
902 | 902 | } |
903 | 903 | break; |
@@ -905,16 +905,16 @@ discard block |
||
905 | 905 | } |
906 | 906 | break; |
907 | 907 | case 'fees': |
908 | - if ( 'publish' !== $this->status ) { |
|
908 | + if ('publish' !== $this->status) { |
|
909 | 909 | break; |
910 | 910 | } |
911 | 911 | |
912 | - if ( empty( $this->pending[ $key ] ) ) { |
|
912 | + if (empty($this->pending[$key])) { |
|
913 | 913 | break; |
914 | 914 | } |
915 | 915 | |
916 | - foreach ( $this->pending[ $key ] as $fee ) { |
|
917 | - switch( $fee['action'] ) { |
|
916 | + foreach ($this->pending[$key] as $fee) { |
|
917 | + switch ($fee['action']) { |
|
918 | 918 | case 'add': |
919 | 919 | $total_increase += $fee['amount']; |
920 | 920 | break; |
@@ -926,86 +926,86 @@ discard block |
||
926 | 926 | } |
927 | 927 | break; |
928 | 928 | case 'status': |
929 | - $this->update_status( $this->status ); |
|
929 | + $this->update_status($this->status); |
|
930 | 930 | break; |
931 | 931 | case 'gateway': |
932 | - $this->update_meta( '_wpinv_gateway', $this->gateway ); |
|
932 | + $this->update_meta('_wpinv_gateway', $this->gateway); |
|
933 | 933 | break; |
934 | 934 | case 'mode': |
935 | - $this->update_meta( '_wpinv_mode', $this->mode ); |
|
935 | + $this->update_meta('_wpinv_mode', $this->mode); |
|
936 | 936 | break; |
937 | 937 | case 'transaction_id': |
938 | - $this->update_meta( '_wpinv_transaction_id', $this->transaction_id ); |
|
938 | + $this->update_meta('_wpinv_transaction_id', $this->transaction_id); |
|
939 | 939 | break; |
940 | 940 | case 'ip': |
941 | - $this->update_meta( '_wpinv_user_ip', $this->ip ); |
|
941 | + $this->update_meta('_wpinv_user_ip', $this->ip); |
|
942 | 942 | break; |
943 | 943 | ///case 'user_id': |
944 | 944 | ///$this->update_meta( '_wpinv_user_id', $this->user_id ); |
945 | 945 | ///$this->user_info['user_id'] = $this->user_id; |
946 | 946 | ///break; |
947 | 947 | case 'first_name': |
948 | - $this->update_meta( '_wpinv_first_name', $this->first_name ); |
|
948 | + $this->update_meta('_wpinv_first_name', $this->first_name); |
|
949 | 949 | $this->user_info['first_name'] = $this->first_name; |
950 | 950 | break; |
951 | 951 | case 'last_name': |
952 | - $this->update_meta( '_wpinv_last_name', $this->last_name ); |
|
952 | + $this->update_meta('_wpinv_last_name', $this->last_name); |
|
953 | 953 | $this->user_info['last_name'] = $this->last_name; |
954 | 954 | break; |
955 | 955 | case 'phone': |
956 | - $this->update_meta( '_wpinv_phone', $this->phone ); |
|
956 | + $this->update_meta('_wpinv_phone', $this->phone); |
|
957 | 957 | $this->user_info['phone'] = $this->phone; |
958 | 958 | break; |
959 | 959 | case 'address': |
960 | - $this->update_meta( '_wpinv_address', $this->address ); |
|
960 | + $this->update_meta('_wpinv_address', $this->address); |
|
961 | 961 | $this->user_info['address'] = $this->address; |
962 | 962 | break; |
963 | 963 | case 'city': |
964 | - $this->update_meta( '_wpinv_city', $this->city ); |
|
964 | + $this->update_meta('_wpinv_city', $this->city); |
|
965 | 965 | $this->user_info['city'] = $this->city; |
966 | 966 | break; |
967 | 967 | case 'country': |
968 | - $this->update_meta( '_wpinv_country', $this->country ); |
|
968 | + $this->update_meta('_wpinv_country', $this->country); |
|
969 | 969 | $this->user_info['country'] = $this->country; |
970 | 970 | break; |
971 | 971 | case 'state': |
972 | - $this->update_meta( '_wpinv_state', $this->state ); |
|
972 | + $this->update_meta('_wpinv_state', $this->state); |
|
973 | 973 | $this->user_info['state'] = $this->state; |
974 | 974 | break; |
975 | 975 | case 'zip': |
976 | - $this->update_meta( '_wpinv_zip', $this->zip ); |
|
976 | + $this->update_meta('_wpinv_zip', $this->zip); |
|
977 | 977 | $this->user_info['zip'] = $this->zip; |
978 | 978 | break; |
979 | 979 | case 'company': |
980 | - $this->update_meta( '_wpinv_company', $this->company ); |
|
980 | + $this->update_meta('_wpinv_company', $this->company); |
|
981 | 981 | $this->user_info['company'] = $this->company; |
982 | 982 | break; |
983 | 983 | case 'vat_number': |
984 | - $this->update_meta( '_wpinv_vat_number', $this->vat_number ); |
|
984 | + $this->update_meta('_wpinv_vat_number', $this->vat_number); |
|
985 | 985 | $this->user_info['vat_number'] = $this->vat_number; |
986 | 986 | |
987 | - $vat_info = getpaid_session()->get( 'user_vat_data' ); |
|
988 | - if ( $this->vat_number && !empty( $vat_info ) && isset( $vat_info['number'] ) && isset( $vat_info['valid'] ) && $vat_info['number'] == $this->vat_number ) { |
|
989 | - $adddress_confirmed = isset( $vat_info['adddress_confirmed'] ) ? $vat_info['adddress_confirmed'] : false; |
|
990 | - $this->update_meta( '_wpinv_adddress_confirmed', (bool)$adddress_confirmed ); |
|
991 | - $this->user_info['adddress_confirmed'] = (bool)$adddress_confirmed; |
|
987 | + $vat_info = getpaid_session()->get('user_vat_data'); |
|
988 | + if ($this->vat_number && !empty($vat_info) && isset($vat_info['number']) && isset($vat_info['valid']) && $vat_info['number'] == $this->vat_number) { |
|
989 | + $adddress_confirmed = isset($vat_info['adddress_confirmed']) ? $vat_info['adddress_confirmed'] : false; |
|
990 | + $this->update_meta('_wpinv_adddress_confirmed', (bool) $adddress_confirmed); |
|
991 | + $this->user_info['adddress_confirmed'] = (bool) $adddress_confirmed; |
|
992 | 992 | } |
993 | 993 | |
994 | 994 | break; |
995 | 995 | case 'vat_rate': |
996 | - $this->update_meta( '_wpinv_vat_rate', $this->vat_rate ); |
|
996 | + $this->update_meta('_wpinv_vat_rate', $this->vat_rate); |
|
997 | 997 | $this->user_info['vat_rate'] = $this->vat_rate; |
998 | 998 | break; |
999 | 999 | case 'adddress_confirmed': |
1000 | - $this->update_meta( '_wpinv_adddress_confirmed', $this->adddress_confirmed ); |
|
1000 | + $this->update_meta('_wpinv_adddress_confirmed', $this->adddress_confirmed); |
|
1001 | 1001 | $this->user_info['adddress_confirmed'] = $this->adddress_confirmed; |
1002 | 1002 | break; |
1003 | 1003 | |
1004 | 1004 | case 'key': |
1005 | - $this->update_meta( '_wpinv_key', $this->key ); |
|
1005 | + $this->update_meta('_wpinv_key', $this->key); |
|
1006 | 1006 | break; |
1007 | 1007 | case 'disable_taxes': |
1008 | - $this->update_meta( '_wpinv_disable_taxes', $this->disable_taxes ); |
|
1008 | + $this->update_meta('_wpinv_disable_taxes', $this->disable_taxes); |
|
1009 | 1009 | break; |
1010 | 1010 | case 'date': |
1011 | 1011 | $args = array( |
@@ -1014,49 +1014,49 @@ discard block |
||
1014 | 1014 | 'edit_date' => true, |
1015 | 1015 | ); |
1016 | 1016 | |
1017 | - wp_update_post( $args ); |
|
1017 | + wp_update_post($args); |
|
1018 | 1018 | break; |
1019 | 1019 | case 'due_date': |
1020 | - if ( empty( $this->due_date ) ) { |
|
1020 | + if (empty($this->due_date)) { |
|
1021 | 1021 | $this->due_date = 'none'; |
1022 | 1022 | } |
1023 | 1023 | |
1024 | - $this->update_meta( '_wpinv_due_date', $this->due_date ); |
|
1024 | + $this->update_meta('_wpinv_due_date', $this->due_date); |
|
1025 | 1025 | break; |
1026 | 1026 | case 'completed_date': |
1027 | - $this->update_meta( '_wpinv_completed_date', $this->completed_date ); |
|
1027 | + $this->update_meta('_wpinv_completed_date', $this->completed_date); |
|
1028 | 1028 | break; |
1029 | 1029 | case 'discounts': |
1030 | - if ( ! is_array( $this->discounts ) ) { |
|
1031 | - $this->discounts = explode( ',', $this->discounts ); |
|
1030 | + if (!is_array($this->discounts)) { |
|
1031 | + $this->discounts = explode(',', $this->discounts); |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | - $this->user_info['discount'] = implode( ',', $this->discounts ); |
|
1034 | + $this->user_info['discount'] = implode(',', $this->discounts); |
|
1035 | 1035 | break; |
1036 | 1036 | case 'discount': |
1037 | - $this->update_meta( '_wpinv_discount', wpinv_round_amount( $this->discount ) ); |
|
1037 | + $this->update_meta('_wpinv_discount', wpinv_round_amount($this->discount)); |
|
1038 | 1038 | break; |
1039 | 1039 | case 'discount_code': |
1040 | - $this->update_meta( '_wpinv_discount_code', $this->discount_code ); |
|
1040 | + $this->update_meta('_wpinv_discount_code', $this->discount_code); |
|
1041 | 1041 | break; |
1042 | 1042 | case 'parent_invoice': |
1043 | 1043 | $args = array( |
1044 | 1044 | 'ID' => $this->ID, |
1045 | 1045 | 'post_parent' => $this->parent_invoice, |
1046 | 1046 | ); |
1047 | - wp_update_post( $args ); |
|
1047 | + wp_update_post($args); |
|
1048 | 1048 | break; |
1049 | 1049 | default: |
1050 | - do_action( 'wpinv_save', $this, $key ); |
|
1050 | + do_action('wpinv_save', $this, $key); |
|
1051 | 1051 | break; |
1052 | 1052 | } |
1053 | 1053 | } |
1054 | 1054 | |
1055 | - $this->update_meta( '_wpinv_subtotal', wpinv_round_amount( $this->subtotal ) ); |
|
1056 | - $this->update_meta( '_wpinv_total', wpinv_round_amount( $this->total ) ); |
|
1057 | - $this->update_meta( '_wpinv_tax', wpinv_round_amount( $this->tax ) ); |
|
1055 | + $this->update_meta('_wpinv_subtotal', wpinv_round_amount($this->subtotal)); |
|
1056 | + $this->update_meta('_wpinv_total', wpinv_round_amount($this->total)); |
|
1057 | + $this->update_meta('_wpinv_tax', wpinv_round_amount($this->tax)); |
|
1058 | 1058 | |
1059 | - $this->items = array_values( $this->items ); |
|
1059 | + $this->items = array_values($this->items); |
|
1060 | 1060 | |
1061 | 1061 | $new_meta = array( |
1062 | 1062 | 'items' => $this->items, |
@@ -1067,12 +1067,12 @@ discard block |
||
1067 | 1067 | ); |
1068 | 1068 | |
1069 | 1069 | $meta = $this->get_meta(); |
1070 | - $merged_meta = array_merge( $meta, $new_meta ); |
|
1070 | + $merged_meta = array_merge($meta, $new_meta); |
|
1071 | 1071 | |
1072 | 1072 | // Only save the payment meta if it's changed |
1073 | - if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta) ) ) { |
|
1074 | - $updated = $this->update_meta( '_wpinv_payment_meta', $merged_meta ); |
|
1075 | - if ( false !== $updated ) { |
|
1073 | + if (md5(serialize($meta)) !== md5(serialize($merged_meta))) { |
|
1074 | + $updated = $this->update_meta('_wpinv_payment_meta', $merged_meta); |
|
1075 | + if (false !== $updated) { |
|
1076 | 1076 | $saved = true; |
1077 | 1077 | } |
1078 | 1078 | } |
@@ -1080,15 +1080,15 @@ discard block |
||
1080 | 1080 | $this->pending = array(); |
1081 | 1081 | $saved = true; |
1082 | 1082 | } else { |
1083 | - $this->update_meta( '_wpinv_subtotal', wpinv_round_amount( $this->subtotal ) ); |
|
1084 | - $this->update_meta( '_wpinv_total', wpinv_round_amount( $this->total ) ); |
|
1085 | - $this->update_meta( '_wpinv_tax', wpinv_round_amount( $this->tax ) ); |
|
1083 | + $this->update_meta('_wpinv_subtotal', wpinv_round_amount($this->subtotal)); |
|
1084 | + $this->update_meta('_wpinv_total', wpinv_round_amount($this->total)); |
|
1085 | + $this->update_meta('_wpinv_tax', wpinv_round_amount($this->tax)); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | - do_action( 'wpinv_invoice_save', $this, $saved ); |
|
1088 | + do_action('wpinv_invoice_save', $this, $saved); |
|
1089 | 1089 | |
1090 | - if ( true === $saved || $setup ) { |
|
1091 | - $this->setup_invoice( $this->ID ); |
|
1090 | + if (true === $saved || $setup) { |
|
1091 | + $this->setup_invoice($this->ID); |
|
1092 | 1092 | } |
1093 | 1093 | |
1094 | 1094 | $this->refresh_item_ids(); |
@@ -1096,7 +1096,7 @@ discard block |
||
1096 | 1096 | return $saved; |
1097 | 1097 | } |
1098 | 1098 | |
1099 | - public function add_fee( $args, $global = true ) { |
|
1099 | + public function add_fee($args, $global = true) { |
|
1100 | 1100 | $default_args = array( |
1101 | 1101 | 'label' => '', |
1102 | 1102 | 'amount' => 0, |
@@ -1106,75 +1106,75 @@ discard block |
||
1106 | 1106 | 'item_id' => 0, |
1107 | 1107 | ); |
1108 | 1108 | |
1109 | - $fee = wp_parse_args( $args, $default_args ); |
|
1109 | + $fee = wp_parse_args($args, $default_args); |
|
1110 | 1110 | |
1111 | - if ( empty( $fee['label'] ) ) { |
|
1111 | + if (empty($fee['label'])) { |
|
1112 | 1112 | return false; |
1113 | 1113 | } |
1114 | 1114 | |
1115 | - $fee['id'] = sanitize_title( $fee['label'] ); |
|
1115 | + $fee['id'] = sanitize_title($fee['label']); |
|
1116 | 1116 | |
1117 | - $this->fees[] = $fee; |
|
1117 | + $this->fees[] = $fee; |
|
1118 | 1118 | |
1119 | 1119 | $added_fee = $fee; |
1120 | 1120 | $added_fee['action'] = 'add'; |
1121 | 1121 | $this->pending['fees'][] = $added_fee; |
1122 | - reset( $this->fees ); |
|
1122 | + reset($this->fees); |
|
1123 | 1123 | |
1124 | - $this->increase_fees( $fee['amount'] ); |
|
1124 | + $this->increase_fees($fee['amount']); |
|
1125 | 1125 | return true; |
1126 | 1126 | } |
1127 | 1127 | |
1128 | - public function remove_fee( $key ) { |
|
1128 | + public function remove_fee($key) { |
|
1129 | 1129 | $removed = false; |
1130 | 1130 | |
1131 | - if ( is_numeric( $key ) ) { |
|
1132 | - $removed = $this->remove_fee_by( 'index', $key ); |
|
1131 | + if (is_numeric($key)) { |
|
1132 | + $removed = $this->remove_fee_by('index', $key); |
|
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | return $removed; |
1136 | 1136 | } |
1137 | 1137 | |
1138 | - public function remove_fee_by( $key, $value, $global = false ) { |
|
1139 | - $allowed_fee_keys = apply_filters( 'wpinv_fee_keys', array( |
|
1138 | + public function remove_fee_by($key, $value, $global = false) { |
|
1139 | + $allowed_fee_keys = apply_filters('wpinv_fee_keys', array( |
|
1140 | 1140 | 'index', 'label', 'amount', 'type', |
1141 | - ) ); |
|
1141 | + )); |
|
1142 | 1142 | |
1143 | - if ( ! in_array( $key, $allowed_fee_keys ) ) { |
|
1143 | + if (!in_array($key, $allowed_fee_keys)) { |
|
1144 | 1144 | return false; |
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | $removed = false; |
1148 | - if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) { |
|
1149 | - $removed_fee = $this->fees[ $value ]; |
|
1148 | + if ('index' === $key && array_key_exists($value, $this->fees)) { |
|
1149 | + $removed_fee = $this->fees[$value]; |
|
1150 | 1150 | $removed_fee['action'] = 'remove'; |
1151 | 1151 | $this->pending['fees'][] = $removed_fee; |
1152 | 1152 | |
1153 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
1153 | + $this->decrease_fees($removed_fee['amount']); |
|
1154 | 1154 | |
1155 | - unset( $this->fees[ $value ] ); |
|
1155 | + unset($this->fees[$value]); |
|
1156 | 1156 | $removed = true; |
1157 | - } else if ( 'index' !== $key ) { |
|
1158 | - foreach ( $this->fees as $index => $fee ) { |
|
1159 | - if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) { |
|
1157 | + } else if ('index' !== $key) { |
|
1158 | + foreach ($this->fees as $index => $fee) { |
|
1159 | + if (isset($fee[$key]) && $fee[$key] == $value) { |
|
1160 | 1160 | $removed_fee = $fee; |
1161 | 1161 | $removed_fee['action'] = 'remove'; |
1162 | 1162 | $this->pending['fees'][] = $removed_fee; |
1163 | 1163 | |
1164 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
1164 | + $this->decrease_fees($removed_fee['amount']); |
|
1165 | 1165 | |
1166 | - unset( $this->fees[ $index ] ); |
|
1166 | + unset($this->fees[$index]); |
|
1167 | 1167 | $removed = true; |
1168 | 1168 | |
1169 | - if ( false === $global ) { |
|
1169 | + if (false === $global) { |
|
1170 | 1170 | break; |
1171 | 1171 | } |
1172 | 1172 | } |
1173 | 1173 | } |
1174 | 1174 | } |
1175 | 1175 | |
1176 | - if ( true === $removed ) { |
|
1177 | - $this->fees = array_values( $this->fees ); |
|
1176 | + if (true === $removed) { |
|
1177 | + $this->fees = array_values($this->fees); |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | return $removed; |
@@ -1182,35 +1182,35 @@ discard block |
||
1182 | 1182 | |
1183 | 1183 | |
1184 | 1184 | |
1185 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
1185 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
1186 | 1186 | // Bail if no note specified |
1187 | - if( !$note ) { |
|
1187 | + if (!$note) { |
|
1188 | 1188 | return false; |
1189 | 1189 | } |
1190 | 1190 | |
1191 | - if ( empty( $this->ID ) ) |
|
1191 | + if (empty($this->ID)) |
|
1192 | 1192 | return false; |
1193 | 1193 | |
1194 | - if ( ( ( is_user_logged_in() && wpinv_current_user_can_manage_invoicing() ) || $added_by_user ) && !$system ) { |
|
1195 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
1194 | + if (((is_user_logged_in() && wpinv_current_user_can_manage_invoicing()) || $added_by_user) && !$system) { |
|
1195 | + $user = get_user_by('id', get_current_user_id()); |
|
1196 | 1196 | $comment_author = $user->display_name; |
1197 | 1197 | $comment_author_email = $user->user_email; |
1198 | 1198 | } else { |
1199 | 1199 | $comment_author = 'System'; |
1200 | 1200 | $comment_author_email = 'system@'; |
1201 | - $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) : 'noreply.com'; |
|
1202 | - $comment_author_email = sanitize_email( $comment_author_email ); |
|
1201 | + $comment_author_email .= isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : 'noreply.com'; |
|
1202 | + $comment_author_email = sanitize_email($comment_author_email); |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | - do_action( 'wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type ); |
|
1205 | + do_action('wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type); |
|
1206 | 1206 | |
1207 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
1207 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
1208 | 1208 | 'comment_post_ID' => $this->ID, |
1209 | 1209 | 'comment_content' => $note, |
1210 | 1210 | 'comment_agent' => 'WPInvoicing', |
1211 | 1211 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
1212 | - 'comment_date' => current_time( 'mysql' ), |
|
1213 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
1212 | + 'comment_date' => current_time('mysql'), |
|
1213 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
1214 | 1214 | 'comment_approved' => 1, |
1215 | 1215 | 'comment_parent' => 0, |
1216 | 1216 | 'comment_author' => $comment_author, |
@@ -1218,53 +1218,53 @@ discard block |
||
1218 | 1218 | 'comment_author_url' => '', |
1219 | 1219 | 'comment_author_email' => $comment_author_email, |
1220 | 1220 | 'comment_type' => 'wpinv_note' |
1221 | - ) ) ); |
|
1221 | + ))); |
|
1222 | 1222 | |
1223 | - do_action( 'wpinv_insert_payment_note', $note_id, $this->ID, $note ); |
|
1223 | + do_action('wpinv_insert_payment_note', $note_id, $this->ID, $note); |
|
1224 | 1224 | |
1225 | - if ( $customer_type ) { |
|
1226 | - add_comment_meta( $note_id, '_wpi_customer_note', 1 ); |
|
1225 | + if ($customer_type) { |
|
1226 | + add_comment_meta($note_id, '_wpi_customer_note', 1); |
|
1227 | 1227 | |
1228 | - do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $this->ID, 'user_note' => $note ) ); |
|
1228 | + do_action('wpinv_new_customer_note', array('invoice_id' => $this->ID, 'user_note' => $note)); |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | return $note_id; |
1232 | 1232 | } |
1233 | 1233 | |
1234 | - private function increase_subtotal( $amount = 0.00 ) { |
|
1234 | + private function increase_subtotal($amount = 0.00) { |
|
1235 | 1235 | $amount = (float) $amount; |
1236 | 1236 | $this->subtotal += $amount; |
1237 | - $this->subtotal = wpinv_round_amount( $this->subtotal ); |
|
1237 | + $this->subtotal = wpinv_round_amount($this->subtotal); |
|
1238 | 1238 | |
1239 | 1239 | $this->recalculate_total(); |
1240 | 1240 | } |
1241 | 1241 | |
1242 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
1242 | + private function decrease_subtotal($amount = 0.00) { |
|
1243 | 1243 | $amount = (float) $amount; |
1244 | 1244 | $this->subtotal -= $amount; |
1245 | - $this->subtotal = wpinv_round_amount( $this->subtotal ); |
|
1245 | + $this->subtotal = wpinv_round_amount($this->subtotal); |
|
1246 | 1246 | |
1247 | - if ( $this->subtotal < 0 ) { |
|
1247 | + if ($this->subtotal < 0) { |
|
1248 | 1248 | $this->subtotal = 0; |
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | $this->recalculate_total(); |
1252 | 1252 | } |
1253 | 1253 | |
1254 | - private function increase_fees( $amount = 0.00 ) { |
|
1255 | - $amount = (float)$amount; |
|
1254 | + private function increase_fees($amount = 0.00) { |
|
1255 | + $amount = (float) $amount; |
|
1256 | 1256 | $this->fees_total += $amount; |
1257 | - $this->fees_total = wpinv_round_amount( $this->fees_total ); |
|
1257 | + $this->fees_total = wpinv_round_amount($this->fees_total); |
|
1258 | 1258 | |
1259 | 1259 | $this->recalculate_total(); |
1260 | 1260 | } |
1261 | 1261 | |
1262 | - private function decrease_fees( $amount = 0.00 ) { |
|
1262 | + private function decrease_fees($amount = 0.00) { |
|
1263 | 1263 | $amount = (float) $amount; |
1264 | 1264 | $this->fees_total -= $amount; |
1265 | - $this->fees_total = wpinv_round_amount( $this->fees_total ); |
|
1265 | + $this->fees_total = wpinv_round_amount($this->fees_total); |
|
1266 | 1266 | |
1267 | - if ( $this->fees_total < 0 ) { |
|
1267 | + if ($this->fees_total < 0) { |
|
1268 | 1268 | $this->fees_total = 0; |
1269 | 1269 | } |
1270 | 1270 | |
@@ -1275,54 +1275,54 @@ discard block |
||
1275 | 1275 | global $wpi_nosave; |
1276 | 1276 | |
1277 | 1277 | $this->total = $this->subtotal + $this->tax + $this->fees_total; |
1278 | - $this->total = wpinv_round_amount( $this->total ); |
|
1278 | + $this->total = wpinv_round_amount($this->total); |
|
1279 | 1279 | |
1280 | - do_action( 'wpinv_invoice_recalculate_total', $this, $wpi_nosave ); |
|
1280 | + do_action('wpinv_invoice_recalculate_total', $this, $wpi_nosave); |
|
1281 | 1281 | } |
1282 | 1282 | |
1283 | - public function increase_tax( $amount = 0.00 ) { |
|
1283 | + public function increase_tax($amount = 0.00) { |
|
1284 | 1284 | $amount = (float) $amount; |
1285 | 1285 | $this->tax += $amount; |
1286 | 1286 | |
1287 | 1287 | $this->recalculate_total(); |
1288 | 1288 | } |
1289 | 1289 | |
1290 | - public function decrease_tax( $amount = 0.00 ) { |
|
1290 | + public function decrease_tax($amount = 0.00) { |
|
1291 | 1291 | $amount = (float) $amount; |
1292 | 1292 | $this->tax -= $amount; |
1293 | 1293 | |
1294 | - if ( $this->tax < 0 ) { |
|
1294 | + if ($this->tax < 0) { |
|
1295 | 1295 | $this->tax = 0; |
1296 | 1296 | } |
1297 | 1297 | |
1298 | 1298 | $this->recalculate_total(); |
1299 | 1299 | } |
1300 | 1300 | |
1301 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
1302 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : get_post_status( $this->ID ); |
|
1301 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
1302 | + $old_status = !empty($this->old_status) ? $this->old_status : get_post_status($this->ID); |
|
1303 | 1303 | |
1304 | - if ( $old_status === $new_status && in_array( $new_status, array_keys( wpinv_get_invoice_statuses( true ) ) ) ) { |
|
1304 | + if ($old_status === $new_status && in_array($new_status, array_keys(wpinv_get_invoice_statuses(true)))) { |
|
1305 | 1305 | return false; // Don't permit status changes that aren't changes |
1306 | 1306 | } |
1307 | 1307 | |
1308 | - $do_change = apply_filters( 'wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status ); |
|
1308 | + $do_change = apply_filters('wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status); |
|
1309 | 1309 | $updated = false; |
1310 | 1310 | |
1311 | - if ( $do_change ) { |
|
1312 | - do_action( 'wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status ); |
|
1311 | + if ($do_change) { |
|
1312 | + do_action('wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status); |
|
1313 | 1313 | |
1314 | 1314 | $update_post_data = array(); |
1315 | 1315 | $update_post_data['ID'] = $this->ID; |
1316 | 1316 | $update_post_data['post_status'] = $new_status; |
1317 | - $update_post_data['edit_date'] = current_time( 'mysql', 0 ); |
|
1318 | - $update_post_data['edit_date_gmt'] = current_time( 'mysql', 1 ); |
|
1317 | + $update_post_data['edit_date'] = current_time('mysql', 0); |
|
1318 | + $update_post_data['edit_date_gmt'] = current_time('mysql', 1); |
|
1319 | 1319 | |
1320 | - $update_post_data = apply_filters( 'wpinv_update_invoice_status_fields', $update_post_data, $this->ID ); |
|
1320 | + $update_post_data = apply_filters('wpinv_update_invoice_status_fields', $update_post_data, $this->ID); |
|
1321 | 1321 | |
1322 | - $updated = wp_update_post( $update_post_data ); |
|
1322 | + $updated = wp_update_post($update_post_data); |
|
1323 | 1323 | |
1324 | 1324 | // Process any specific status functions |
1325 | - switch( $new_status ) { |
|
1325 | + switch ($new_status) { |
|
1326 | 1326 | case 'wpi-refunded': |
1327 | 1327 | $this->process_refund(); |
1328 | 1328 | break; |
@@ -1335,9 +1335,9 @@ discard block |
||
1335 | 1335 | } |
1336 | 1336 | |
1337 | 1337 | // Status was changed. |
1338 | - do_action( 'wpinv_status_' . $new_status, $this->ID, $old_status ); |
|
1339 | - do_action( 'wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status ); |
|
1340 | - do_action( 'wpinv_update_status', $this->ID, $new_status, $old_status ); |
|
1338 | + do_action('wpinv_status_' . $new_status, $this->ID, $old_status); |
|
1339 | + do_action('wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status); |
|
1340 | + do_action('wpinv_update_status', $this->ID, $new_status, $old_status); |
|
1341 | 1341 | } |
1342 | 1342 | |
1343 | 1343 | return $updated; |
@@ -1351,20 +1351,20 @@ discard block |
||
1351 | 1351 | $this->save(); |
1352 | 1352 | } |
1353 | 1353 | |
1354 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
1355 | - if ( empty( $meta_key ) ) { |
|
1354 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
1355 | + if (empty($meta_key)) { |
|
1356 | 1356 | return false; |
1357 | 1357 | } |
1358 | 1358 | |
1359 | - if ( $meta_key == 'key' || $meta_key == 'date' ) { |
|
1359 | + if ($meta_key == 'key' || $meta_key == 'date') { |
|
1360 | 1360 | $current_meta = $this->get_meta(); |
1361 | - $current_meta[ $meta_key ] = $meta_value; |
|
1361 | + $current_meta[$meta_key] = $meta_value; |
|
1362 | 1362 | |
1363 | 1363 | $meta_key = '_wpinv_payment_meta'; |
1364 | 1364 | $meta_value = $current_meta; |
1365 | 1365 | } |
1366 | 1366 | |
1367 | - $meta_value = apply_filters( 'wpinv_update_payment_meta_' . $meta_key, $meta_value, $this->ID ); |
|
1367 | + $meta_value = apply_filters('wpinv_update_payment_meta_' . $meta_key, $meta_value, $this->ID); |
|
1368 | 1368 | |
1369 | 1369 | // Do not update created date on invoice marked as paid. |
1370 | 1370 | /*if ( $meta_key == '_wpinv_completed_date' && !empty( $meta_value ) ) { |
@@ -1379,45 +1379,45 @@ discard block |
||
1379 | 1379 | wp_update_post( $args ); |
1380 | 1380 | }*/ |
1381 | 1381 | |
1382 | - return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
1382 | + return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
1383 | 1383 | } |
1384 | 1384 | |
1385 | 1385 | private function process_refund() { |
1386 | 1386 | $process_refund = true; |
1387 | 1387 | |
1388 | 1388 | // If the payment was not in publish, don't decrement stats as they were never incremented |
1389 | - if ( 'publish' != $this->old_status || 'wpi-refunded' != $this->status ) { |
|
1389 | + if ('publish' != $this->old_status || 'wpi-refunded' != $this->status) { |
|
1390 | 1390 | $process_refund = false; |
1391 | 1391 | } |
1392 | 1392 | |
1393 | 1393 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
1394 | - $process_refund = apply_filters( 'wpinv_should_process_refund', $process_refund, $this ); |
|
1394 | + $process_refund = apply_filters('wpinv_should_process_refund', $process_refund, $this); |
|
1395 | 1395 | |
1396 | - if ( false === $process_refund ) { |
|
1396 | + if (false === $process_refund) { |
|
1397 | 1397 | return; |
1398 | 1398 | } |
1399 | 1399 | |
1400 | - do_action( 'wpinv_pre_refund_invoice', $this ); |
|
1400 | + do_action('wpinv_pre_refund_invoice', $this); |
|
1401 | 1401 | |
1402 | - $decrease_store_earnings = apply_filters( 'wpinv_decrease_store_earnings_on_refund', true, $this ); |
|
1403 | - $decrease_customer_value = apply_filters( 'wpinv_decrease_customer_value_on_refund', true, $this ); |
|
1404 | - $decrease_purchase_count = apply_filters( 'wpinv_decrease_customer_purchase_count_on_refund', true, $this ); |
|
1402 | + $decrease_store_earnings = apply_filters('wpinv_decrease_store_earnings_on_refund', true, $this); |
|
1403 | + $decrease_customer_value = apply_filters('wpinv_decrease_customer_value_on_refund', true, $this); |
|
1404 | + $decrease_purchase_count = apply_filters('wpinv_decrease_customer_purchase_count_on_refund', true, $this); |
|
1405 | 1405 | |
1406 | - do_action( 'wpinv_post_refund_invoice', $this ); |
|
1406 | + do_action('wpinv_post_refund_invoice', $this); |
|
1407 | 1407 | } |
1408 | 1408 | |
1409 | 1409 | private function process_failure() { |
1410 | 1410 | $discounts = $this->discounts; |
1411 | - if ( empty( $discounts ) ) { |
|
1411 | + if (empty($discounts)) { |
|
1412 | 1412 | return; |
1413 | 1413 | } |
1414 | 1414 | |
1415 | - if ( ! is_array( $discounts ) ) { |
|
1416 | - $discounts = array_map( 'trim', explode( ',', $discounts ) ); |
|
1415 | + if (!is_array($discounts)) { |
|
1416 | + $discounts = array_map('trim', explode(',', $discounts)); |
|
1417 | 1417 | } |
1418 | 1418 | |
1419 | - foreach ( $discounts as $discount ) { |
|
1420 | - wpinv_decrease_discount_usage( $discount ); |
|
1419 | + foreach ($discounts as $discount) { |
|
1420 | + wpinv_decrease_discount_usage($discount); |
|
1421 | 1421 | } |
1422 | 1422 | } |
1423 | 1423 | |
@@ -1425,92 +1425,92 @@ discard block |
||
1425 | 1425 | $process_pending = true; |
1426 | 1426 | |
1427 | 1427 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
1428 | - if ( ( 'publish' != $this->old_status && 'revoked' != $this->old_status ) || 'wpi-pending' != $this->status ) { |
|
1428 | + if (('publish' != $this->old_status && 'revoked' != $this->old_status) || 'wpi-pending' != $this->status) { |
|
1429 | 1429 | $process_pending = false; |
1430 | 1430 | } |
1431 | 1431 | |
1432 | 1432 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
1433 | - $process_pending = apply_filters( 'wpinv_should_process_pending', $process_pending, $this ); |
|
1433 | + $process_pending = apply_filters('wpinv_should_process_pending', $process_pending, $this); |
|
1434 | 1434 | |
1435 | - if ( false === $process_pending ) { |
|
1435 | + if (false === $process_pending) { |
|
1436 | 1436 | return; |
1437 | 1437 | } |
1438 | 1438 | |
1439 | - $decrease_store_earnings = apply_filters( 'wpinv_decrease_store_earnings_on_pending', true, $this ); |
|
1440 | - $decrease_customer_value = apply_filters( 'wpinv_decrease_customer_value_on_pending', true, $this ); |
|
1441 | - $decrease_purchase_count = apply_filters( 'wpinv_decrease_customer_purchase_count_on_pending', true, $this ); |
|
1439 | + $decrease_store_earnings = apply_filters('wpinv_decrease_store_earnings_on_pending', true, $this); |
|
1440 | + $decrease_customer_value = apply_filters('wpinv_decrease_customer_value_on_pending', true, $this); |
|
1441 | + $decrease_purchase_count = apply_filters('wpinv_decrease_customer_purchase_count_on_pending', true, $this); |
|
1442 | 1442 | |
1443 | 1443 | $this->completed_date = ''; |
1444 | - $this->update_meta( '_wpinv_completed_date', '' ); |
|
1444 | + $this->update_meta('_wpinv_completed_date', ''); |
|
1445 | 1445 | } |
1446 | 1446 | |
1447 | 1447 | // get data |
1448 | - public function get_meta( $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
1449 | - $meta = get_post_meta( $this->ID, $meta_key, $single ); |
|
1448 | + public function get_meta($meta_key = '_wpinv_payment_meta', $single = true) { |
|
1449 | + $meta = get_post_meta($this->ID, $meta_key, $single); |
|
1450 | 1450 | |
1451 | - if ( $meta_key === '_wpinv_payment_meta' ) { |
|
1451 | + if ($meta_key === '_wpinv_payment_meta') { |
|
1452 | 1452 | |
1453 | - if(!is_array($meta)){$meta = array();} // we need this to be an array so make sure it is. |
|
1453 | + if (!is_array($meta)) {$meta = array(); } // we need this to be an array so make sure it is. |
|
1454 | 1454 | |
1455 | - if ( empty( $meta['key'] ) ) { |
|
1455 | + if (empty($meta['key'])) { |
|
1456 | 1456 | $meta['key'] = $this->setup_invoice_key(); |
1457 | 1457 | } |
1458 | 1458 | |
1459 | - if ( empty( $meta['date'] ) ) { |
|
1460 | - $meta['date'] = get_post_field( 'post_date', $this->ID ); |
|
1459 | + if (empty($meta['date'])) { |
|
1460 | + $meta['date'] = get_post_field('post_date', $this->ID); |
|
1461 | 1461 | } |
1462 | 1462 | } |
1463 | 1463 | |
1464 | - $meta = apply_filters( 'wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID ); |
|
1464 | + $meta = apply_filters('wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID); |
|
1465 | 1465 | |
1466 | - return apply_filters( 'wpinv_get_invoice_meta', $meta, $this->ID, $meta_key ); |
|
1466 | + return apply_filters('wpinv_get_invoice_meta', $meta, $this->ID, $meta_key); |
|
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | public function get_description() { |
1470 | - $post = get_post( $this->ID ); |
|
1470 | + $post = get_post($this->ID); |
|
1471 | 1471 | |
1472 | - $description = !empty( $post ) ? $post->post_content : ''; |
|
1473 | - return apply_filters( 'wpinv_get_description', $description, $this->ID, $this ); |
|
1472 | + $description = !empty($post) ? $post->post_content : ''; |
|
1473 | + return apply_filters('wpinv_get_description', $description, $this->ID, $this); |
|
1474 | 1474 | } |
1475 | 1475 | |
1476 | - public function get_status( $nicename = false ) { |
|
1477 | - if ( !$nicename ) { |
|
1476 | + public function get_status($nicename = false) { |
|
1477 | + if (!$nicename) { |
|
1478 | 1478 | $status = $this->status; |
1479 | 1479 | } else { |
1480 | 1480 | $status = $this->status_nicename; |
1481 | 1481 | } |
1482 | 1482 | |
1483 | - return apply_filters( 'wpinv_get_status', $status, $nicename, $this->ID, $this ); |
|
1483 | + return apply_filters('wpinv_get_status', $status, $nicename, $this->ID, $this); |
|
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | public function get_cart_details() { |
1487 | - return apply_filters( 'wpinv_cart_details', $this->cart_details, $this->ID, $this ); |
|
1487 | + return apply_filters('wpinv_cart_details', $this->cart_details, $this->ID, $this); |
|
1488 | 1488 | } |
1489 | 1489 | |
1490 | - public function get_subtotal( $currency = false ) { |
|
1491 | - $subtotal = wpinv_round_amount( $this->subtotal ); |
|
1490 | + public function get_subtotal($currency = false) { |
|
1491 | + $subtotal = wpinv_round_amount($this->subtotal); |
|
1492 | 1492 | |
1493 | - if ( $currency ) { |
|
1494 | - $subtotal = wpinv_price( wpinv_format_amount( $subtotal, NULL, !$currency ), $this->get_currency() ); |
|
1493 | + if ($currency) { |
|
1494 | + $subtotal = wpinv_price(wpinv_format_amount($subtotal, NULL, !$currency), $this->get_currency()); |
|
1495 | 1495 | } |
1496 | 1496 | |
1497 | - return apply_filters( 'wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency ); |
|
1497 | + return apply_filters('wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency); |
|
1498 | 1498 | } |
1499 | 1499 | |
1500 | - public function get_total( $currency = false ) { |
|
1501 | - if ( $this->is_free_trial() ) { |
|
1502 | - $total = wpinv_round_amount( 0 ); |
|
1500 | + public function get_total($currency = false) { |
|
1501 | + if ($this->is_free_trial()) { |
|
1502 | + $total = wpinv_round_amount(0); |
|
1503 | 1503 | } else { |
1504 | - $total = wpinv_round_amount( $this->total ); |
|
1504 | + $total = wpinv_round_amount($this->total); |
|
1505 | 1505 | } |
1506 | - if ( $currency ) { |
|
1507 | - $total = wpinv_price( wpinv_format_amount( $total, NULL, !$currency ), $this->get_currency() ); |
|
1506 | + if ($currency) { |
|
1507 | + $total = wpinv_price(wpinv_format_amount($total, NULL, !$currency), $this->get_currency()); |
|
1508 | 1508 | } |
1509 | 1509 | |
1510 | - return apply_filters( 'wpinv_get_invoice_total', $total, $this->ID, $this, $currency ); |
|
1510 | + return apply_filters('wpinv_get_invoice_total', $total, $this->ID, $this, $currency); |
|
1511 | 1511 | } |
1512 | 1512 | |
1513 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
1513 | + public function get_recurring_details($field = '', $currency = false) { |
|
1514 | 1514 | $data = array(); |
1515 | 1515 | $data['cart_details'] = $this->cart_details; |
1516 | 1516 | $data['subtotal'] = $this->get_subtotal(); |
@@ -1518,119 +1518,119 @@ discard block |
||
1518 | 1518 | $data['tax'] = $this->get_tax(); |
1519 | 1519 | $data['total'] = $this->get_total(); |
1520 | 1520 | |
1521 | - if ( !empty( $this->cart_details ) && ( $this->is_parent() || $this->is_renewal() ) ) { |
|
1521 | + if (!empty($this->cart_details) && ($this->is_parent() || $this->is_renewal())) { |
|
1522 | 1522 | $is_free_trial = $this->is_free_trial(); |
1523 | - $discounts = $this->get_discounts( true ); |
|
1523 | + $discounts = $this->get_discounts(true); |
|
1524 | 1524 | |
1525 | - if ( $is_free_trial || !empty( $discounts ) ) { |
|
1525 | + if ($is_free_trial || !empty($discounts)) { |
|
1526 | 1526 | $first_use_only = false; |
1527 | 1527 | |
1528 | - if ( !empty( $discounts ) ) { |
|
1529 | - foreach ( $discounts as $key => $code ) { |
|
1530 | - if ( wpinv_discount_is_recurring( $code, true ) && !$this->is_renewal() ) { |
|
1528 | + if (!empty($discounts)) { |
|
1529 | + foreach ($discounts as $key => $code) { |
|
1530 | + if (wpinv_discount_is_recurring($code, true) && !$this->is_renewal()) { |
|
1531 | 1531 | $first_use_only = true; |
1532 | 1532 | break; |
1533 | 1533 | } |
1534 | 1534 | } |
1535 | 1535 | } |
1536 | 1536 | |
1537 | - if ( !$first_use_only ) { |
|
1538 | - $data['subtotal'] = wpinv_round_amount( $this->subtotal ); |
|
1539 | - $data['discount'] = wpinv_round_amount( $this->discount ); |
|
1540 | - $data['tax'] = wpinv_round_amount( $this->tax ); |
|
1541 | - $data['total'] = wpinv_round_amount( $this->total ); |
|
1537 | + if (!$first_use_only) { |
|
1538 | + $data['subtotal'] = wpinv_round_amount($this->subtotal); |
|
1539 | + $data['discount'] = wpinv_round_amount($this->discount); |
|
1540 | + $data['tax'] = wpinv_round_amount($this->tax); |
|
1541 | + $data['total'] = wpinv_round_amount($this->total); |
|
1542 | 1542 | } else { |
1543 | 1543 | $cart_subtotal = 0; |
1544 | 1544 | $cart_discount = $this->discount; |
1545 | 1545 | $cart_tax = 0; |
1546 | 1546 | |
1547 | - foreach ( $this->cart_details as $key => $item ) { |
|
1548 | - $item_quantity = $item['quantity'] > 0 ? absint( $item['quantity'] ) : 1; |
|
1549 | - $item_subtotal = !empty( $item['subtotal'] ) ? $item['subtotal'] : $item['item_price'] * $item_quantity; |
|
1547 | + foreach ($this->cart_details as $key => $item) { |
|
1548 | + $item_quantity = $item['quantity'] > 0 ? absint($item['quantity']) : 1; |
|
1549 | + $item_subtotal = !empty($item['subtotal']) ? $item['subtotal'] : $item['item_price'] * $item_quantity; |
|
1550 | 1550 | $item_discount = 0; |
1551 | - $item_tax = $item_subtotal > 0 && !empty( $item['vat_rate'] ) ? ( $item_subtotal * 0.01 * (float)$item['vat_rate'] ) : 0; |
|
1551 | + $item_tax = $item_subtotal > 0 && !empty($item['vat_rate']) ? ($item_subtotal * 0.01 * (float) $item['vat_rate']) : 0; |
|
1552 | 1552 | |
1553 | - if ( wpinv_prices_include_tax() ) { |
|
1554 | - $item_subtotal -= wpinv_round_amount( $item_tax ); |
|
1553 | + if (wpinv_prices_include_tax()) { |
|
1554 | + $item_subtotal -= wpinv_round_amount($item_tax); |
|
1555 | 1555 | } |
1556 | 1556 | |
1557 | 1557 | $item_total = $item_subtotal - $item_discount + $item_tax; |
1558 | 1558 | // Do not allow totals to go negative |
1559 | - if ( $item_total < 0 ) { |
|
1559 | + if ($item_total < 0) { |
|
1560 | 1560 | $item_total = 0; |
1561 | 1561 | } |
1562 | 1562 | |
1563 | - $cart_subtotal += (float)($item_subtotal); |
|
1564 | - $cart_discount += (float)($item_discount); |
|
1565 | - $cart_tax += (float)($item_tax); |
|
1563 | + $cart_subtotal += (float) ($item_subtotal); |
|
1564 | + $cart_discount += (float) ($item_discount); |
|
1565 | + $cart_tax += (float) ($item_tax); |
|
1566 | 1566 | |
1567 | - $data['cart_details'][$key]['discount'] = wpinv_round_amount( $item_discount ); |
|
1568 | - $data['cart_details'][$key]['tax'] = wpinv_round_amount( $item_tax ); |
|
1569 | - $data['cart_details'][$key]['price'] = wpinv_round_amount( $item_total ); |
|
1567 | + $data['cart_details'][$key]['discount'] = wpinv_round_amount($item_discount); |
|
1568 | + $data['cart_details'][$key]['tax'] = wpinv_round_amount($item_tax); |
|
1569 | + $data['cart_details'][$key]['price'] = wpinv_round_amount($item_total); |
|
1570 | 1570 | } |
1571 | 1571 | |
1572 | 1572 | $total = $data['subtotal'] - $data['discount'] + $data['tax']; |
1573 | - if ( $total < 0 ) { |
|
1573 | + if ($total < 0) { |
|
1574 | 1574 | $total = 0; |
1575 | 1575 | } |
1576 | 1576 | |
1577 | - $data['subtotal'] = wpinv_round_amount( $cart_subtotal ); |
|
1578 | - $data['discount'] = wpinv_round_amount( $cart_discount ); |
|
1579 | - $data['tax'] = wpinv_round_amount( $cart_tax ); |
|
1580 | - $data['total'] = wpinv_round_amount( $total ); |
|
1577 | + $data['subtotal'] = wpinv_round_amount($cart_subtotal); |
|
1578 | + $data['discount'] = wpinv_round_amount($cart_discount); |
|
1579 | + $data['tax'] = wpinv_round_amount($cart_tax); |
|
1580 | + $data['total'] = wpinv_round_amount($total); |
|
1581 | 1581 | } |
1582 | 1582 | } |
1583 | 1583 | } |
1584 | 1584 | |
1585 | - $data = apply_filters( 'wpinv_get_invoice_recurring_details', $data, $this, $field, $currency ); |
|
1585 | + $data = apply_filters('wpinv_get_invoice_recurring_details', $data, $this, $field, $currency); |
|
1586 | 1586 | |
1587 | - if ( isset( $data[$field] ) ) { |
|
1588 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
1587 | + if (isset($data[$field])) { |
|
1588 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
1589 | 1589 | } |
1590 | 1590 | |
1591 | 1591 | return $data; |
1592 | 1592 | } |
1593 | 1593 | |
1594 | - public function get_final_tax( $currency = false ) { |
|
1595 | - $final_total = wpinv_round_amount( $this->tax ); |
|
1596 | - if ( $currency ) { |
|
1597 | - $final_total = wpinv_price( wpinv_format_amount( $final_total, NULL, !$currency ), $this->get_currency() ); |
|
1594 | + public function get_final_tax($currency = false) { |
|
1595 | + $final_total = wpinv_round_amount($this->tax); |
|
1596 | + if ($currency) { |
|
1597 | + $final_total = wpinv_price(wpinv_format_amount($final_total, NULL, !$currency), $this->get_currency()); |
|
1598 | 1598 | } |
1599 | 1599 | |
1600 | - return apply_filters( 'wpinv_get_invoice_final_total', $final_total, $this, $currency ); |
|
1600 | + return apply_filters('wpinv_get_invoice_final_total', $final_total, $this, $currency); |
|
1601 | 1601 | } |
1602 | 1602 | |
1603 | - public function get_discounts( $array = false ) { |
|
1603 | + public function get_discounts($array = false) { |
|
1604 | 1604 | $discounts = $this->discounts; |
1605 | - if ( $array && $discounts ) { |
|
1606 | - $discounts = explode( ',', $discounts ); |
|
1605 | + if ($array && $discounts) { |
|
1606 | + $discounts = explode(',', $discounts); |
|
1607 | 1607 | } |
1608 | - return apply_filters( 'wpinv_payment_discounts', $discounts, $this->ID, $this, $array ); |
|
1608 | + return apply_filters('wpinv_payment_discounts', $discounts, $this->ID, $this, $array); |
|
1609 | 1609 | } |
1610 | 1610 | |
1611 | - public function get_discount( $currency = false, $dash = false ) { |
|
1612 | - if ( !empty( $this->discounts ) ) { |
|
1611 | + public function get_discount($currency = false, $dash = false) { |
|
1612 | + if (!empty($this->discounts)) { |
|
1613 | 1613 | global $ajax_cart_details; |
1614 | 1614 | $ajax_cart_details = $this->get_cart_details(); |
1615 | 1615 | |
1616 | - if ( !empty( $ajax_cart_details ) && count( $ajax_cart_details ) == count( $this->items ) ) { |
|
1616 | + if (!empty($ajax_cart_details) && count($ajax_cart_details) == count($this->items)) { |
|
1617 | 1617 | $cart_items = $ajax_cart_details; |
1618 | 1618 | } else { |
1619 | 1619 | $cart_items = $this->items; |
1620 | 1620 | } |
1621 | 1621 | |
1622 | - $this->discount = wpinv_get_cart_items_discount_amount( $cart_items , $this->discounts ); |
|
1622 | + $this->discount = wpinv_get_cart_items_discount_amount($cart_items, $this->discounts); |
|
1623 | 1623 | } |
1624 | - $discount = wpinv_round_amount( $this->discount ); |
|
1624 | + $discount = wpinv_round_amount($this->discount); |
|
1625 | 1625 | $dash = $dash && $discount > 0 ? '–' : ''; |
1626 | 1626 | |
1627 | - if ( $currency ) { |
|
1628 | - $discount = wpinv_price( wpinv_format_amount( $discount, NULL, !$currency ), $this->get_currency() ); |
|
1627 | + if ($currency) { |
|
1628 | + $discount = wpinv_price(wpinv_format_amount($discount, NULL, !$currency), $this->get_currency()); |
|
1629 | 1629 | } |
1630 | 1630 | |
1631 | - $discount = $dash . $discount; |
|
1631 | + $discount = $dash . $discount; |
|
1632 | 1632 | |
1633 | - return apply_filters( 'wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash ); |
|
1633 | + return apply_filters('wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash); |
|
1634 | 1634 | } |
1635 | 1635 | |
1636 | 1636 | public function get_discount_code() { |
@@ -1642,49 +1642,49 @@ discard block |
||
1642 | 1642 | return (int) $this->disable_taxes === 0; |
1643 | 1643 | } |
1644 | 1644 | |
1645 | - public function get_tax( $currency = false ) { |
|
1646 | - $tax = wpinv_round_amount( $this->tax ); |
|
1645 | + public function get_tax($currency = false) { |
|
1646 | + $tax = wpinv_round_amount($this->tax); |
|
1647 | 1647 | |
1648 | - if ( $currency ) { |
|
1649 | - $tax = wpinv_price( wpinv_format_amount( $tax, NULL, !$currency ), $this->get_currency() ); |
|
1648 | + if ($currency) { |
|
1649 | + $tax = wpinv_price(wpinv_format_amount($tax, NULL, !$currency), $this->get_currency()); |
|
1650 | 1650 | } |
1651 | 1651 | |
1652 | - if ( ! $this->is_taxable() ) { |
|
1653 | - $tax = wpinv_round_amount( 0.00 ); |
|
1652 | + if (!$this->is_taxable()) { |
|
1653 | + $tax = wpinv_round_amount(0.00); |
|
1654 | 1654 | } |
1655 | 1655 | |
1656 | - return apply_filters( 'wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency ); |
|
1656 | + return apply_filters('wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency); |
|
1657 | 1657 | } |
1658 | 1658 | |
1659 | - public function get_fees( $type = 'all' ) { |
|
1660 | - $fees = array(); |
|
1659 | + public function get_fees($type = 'all') { |
|
1660 | + $fees = array(); |
|
1661 | 1661 | |
1662 | - if ( ! empty( $this->fees ) && is_array( $this->fees ) ) { |
|
1663 | - foreach ( $this->fees as $fee ) { |
|
1664 | - if( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
1662 | + if (!empty($this->fees) && is_array($this->fees)) { |
|
1663 | + foreach ($this->fees as $fee) { |
|
1664 | + if ('all' != $type && !empty($fee['type']) && $type != $fee['type']) { |
|
1665 | 1665 | continue; |
1666 | 1666 | } |
1667 | 1667 | |
1668 | - $fee['label'] = stripslashes( $fee['label'] ); |
|
1669 | - $fee['amount_display'] = wpinv_price( $fee['amount'], $this->get_currency() ); |
|
1670 | - $fees[] = $fee; |
|
1668 | + $fee['label'] = stripslashes($fee['label']); |
|
1669 | + $fee['amount_display'] = wpinv_price($fee['amount'], $this->get_currency()); |
|
1670 | + $fees[] = $fee; |
|
1671 | 1671 | } |
1672 | 1672 | } |
1673 | 1673 | |
1674 | - return apply_filters( 'wpinv_get_invoice_fees', $fees, $this->ID, $this ); |
|
1674 | + return apply_filters('wpinv_get_invoice_fees', $fees, $this->ID, $this); |
|
1675 | 1675 | } |
1676 | 1676 | |
1677 | - public function get_fees_total( $type = 'all' ) { |
|
1677 | + public function get_fees_total($type = 'all') { |
|
1678 | 1678 | $fees_total = (float) 0.00; |
1679 | 1679 | |
1680 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
1681 | - if ( ! empty( $payment_fees ) ) { |
|
1682 | - foreach ( $payment_fees as $fee ) { |
|
1680 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
1681 | + if (!empty($payment_fees)) { |
|
1682 | + foreach ($payment_fees as $fee) { |
|
1683 | 1683 | $fees_total += (float) $fee['amount']; |
1684 | 1684 | } |
1685 | 1685 | } |
1686 | 1686 | |
1687 | - return apply_filters( 'wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this ); |
|
1687 | + return apply_filters('wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this); |
|
1688 | 1688 | /* |
1689 | 1689 | $fees = $this->get_fees( $type ); |
1690 | 1690 | |
@@ -1704,116 +1704,116 @@ discard block |
||
1704 | 1704 | } |
1705 | 1705 | |
1706 | 1706 | public function get_user_id() { |
1707 | - return apply_filters( 'wpinv_user_id', $this->user_id, $this->ID, $this ); |
|
1707 | + return apply_filters('wpinv_user_id', $this->user_id, $this->ID, $this); |
|
1708 | 1708 | } |
1709 | 1709 | |
1710 | 1710 | public function get_first_name() { |
1711 | - return apply_filters( 'wpinv_first_name', $this->first_name, $this->ID, $this ); |
|
1711 | + return apply_filters('wpinv_first_name', $this->first_name, $this->ID, $this); |
|
1712 | 1712 | } |
1713 | 1713 | |
1714 | 1714 | public function get_last_name() { |
1715 | - return apply_filters( 'wpinv_last_name', $this->last_name, $this->ID, $this ); |
|
1715 | + return apply_filters('wpinv_last_name', $this->last_name, $this->ID, $this); |
|
1716 | 1716 | } |
1717 | 1717 | |
1718 | 1718 | public function get_user_full_name() { |
1719 | - return apply_filters( 'wpinv_user_full_name', $this->full_name, $this->ID, $this ); |
|
1719 | + return apply_filters('wpinv_user_full_name', $this->full_name, $this->ID, $this); |
|
1720 | 1720 | } |
1721 | 1721 | |
1722 | 1722 | public function get_user_info() { |
1723 | - return apply_filters( 'wpinv_user_info', $this->user_info, $this->ID, $this ); |
|
1723 | + return apply_filters('wpinv_user_info', $this->user_info, $this->ID, $this); |
|
1724 | 1724 | } |
1725 | 1725 | |
1726 | 1726 | public function get_email() { |
1727 | - return apply_filters( 'wpinv_user_email', $this->email, $this->ID, $this ); |
|
1727 | + return apply_filters('wpinv_user_email', $this->email, $this->ID, $this); |
|
1728 | 1728 | } |
1729 | 1729 | |
1730 | 1730 | public function get_address() { |
1731 | - return apply_filters( 'wpinv_address', $this->address, $this->ID, $this ); |
|
1731 | + return apply_filters('wpinv_address', $this->address, $this->ID, $this); |
|
1732 | 1732 | } |
1733 | 1733 | |
1734 | 1734 | public function get_phone() { |
1735 | - return apply_filters( 'wpinv_phone', $this->phone, $this->ID, $this ); |
|
1735 | + return apply_filters('wpinv_phone', $this->phone, $this->ID, $this); |
|
1736 | 1736 | } |
1737 | 1737 | |
1738 | 1738 | public function get_number() { |
1739 | - return apply_filters( 'wpinv_number', $this->number, $this->ID, $this ); |
|
1739 | + return apply_filters('wpinv_number', $this->number, $this->ID, $this); |
|
1740 | 1740 | } |
1741 | 1741 | |
1742 | 1742 | public function get_items() { |
1743 | - return apply_filters( 'wpinv_payment_meta_items', $this->items, $this->ID, $this ); |
|
1743 | + return apply_filters('wpinv_payment_meta_items', $this->items, $this->ID, $this); |
|
1744 | 1744 | } |
1745 | 1745 | |
1746 | 1746 | public function get_key() { |
1747 | - return apply_filters( 'wpinv_key', $this->key, $this->ID, $this ); |
|
1747 | + return apply_filters('wpinv_key', $this->key, $this->ID, $this); |
|
1748 | 1748 | } |
1749 | 1749 | |
1750 | 1750 | public function get_transaction_id() { |
1751 | - return apply_filters( 'wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
1751 | + return apply_filters('wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this); |
|
1752 | 1752 | } |
1753 | 1753 | |
1754 | 1754 | public function get_gateway() { |
1755 | - return apply_filters( 'wpinv_gateway', $this->gateway, $this->ID, $this ); |
|
1755 | + return apply_filters('wpinv_gateway', $this->gateway, $this->ID, $this); |
|
1756 | 1756 | } |
1757 | 1757 | |
1758 | 1758 | public function get_gateway_title() { |
1759 | - $this->gateway_title = !empty( $this->gateway_title ) ? $this->gateway_title : wpinv_get_gateway_checkout_label( $this->gateway ); |
|
1759 | + $this->gateway_title = !empty($this->gateway_title) ? $this->gateway_title : wpinv_get_gateway_checkout_label($this->gateway); |
|
1760 | 1760 | |
1761 | - return apply_filters( 'wpinv_gateway_title', $this->gateway_title, $this->ID, $this ); |
|
1761 | + return apply_filters('wpinv_gateway_title', $this->gateway_title, $this->ID, $this); |
|
1762 | 1762 | } |
1763 | 1763 | |
1764 | 1764 | public function get_currency() { |
1765 | - return apply_filters( 'wpinv_currency_code', $this->currency, $this->ID, $this ); |
|
1765 | + return apply_filters('wpinv_currency_code', $this->currency, $this->ID, $this); |
|
1766 | 1766 | } |
1767 | 1767 | |
1768 | 1768 | public function get_created_date() { |
1769 | - return apply_filters( 'wpinv_created_date', $this->date, $this->ID, $this ); |
|
1769 | + return apply_filters('wpinv_created_date', $this->date, $this->ID, $this); |
|
1770 | 1770 | } |
1771 | 1771 | |
1772 | - public function get_due_date( $display = false ) { |
|
1773 | - $due_date = apply_filters( 'wpinv_due_date', $this->due_date, $this->ID, $this ); |
|
1772 | + public function get_due_date($display = false) { |
|
1773 | + $due_date = apply_filters('wpinv_due_date', $this->due_date, $this->ID, $this); |
|
1774 | 1774 | |
1775 | - if ( ! $display ) { |
|
1775 | + if (!$display) { |
|
1776 | 1776 | return $due_date; |
1777 | 1777 | } |
1778 | 1778 | |
1779 | - return getpaid_format_date( $this->due_date ); |
|
1779 | + return getpaid_format_date($this->due_date); |
|
1780 | 1780 | } |
1781 | 1781 | |
1782 | 1782 | public function get_completed_date() { |
1783 | - return apply_filters( 'wpinv_completed_date', $this->completed_date, $this->ID, $this ); |
|
1783 | + return apply_filters('wpinv_completed_date', $this->completed_date, $this->ID, $this); |
|
1784 | 1784 | } |
1785 | 1785 | |
1786 | - public function get_invoice_date( $formatted = true ) { |
|
1786 | + public function get_invoice_date($formatted = true) { |
|
1787 | 1787 | $date_completed = $this->completed_date; |
1788 | 1788 | $invoice_date = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? $date_completed : ''; |
1789 | 1789 | |
1790 | - if ( $invoice_date == '' ) { |
|
1790 | + if ($invoice_date == '') { |
|
1791 | 1791 | $date_created = $this->date; |
1792 | 1792 | $invoice_date = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? $date_created : ''; |
1793 | 1793 | } |
1794 | 1794 | |
1795 | - if ( $formatted && $invoice_date ) { |
|
1796 | - $invoice_date = getpaid_format_date( $invoice_date ); |
|
1795 | + if ($formatted && $invoice_date) { |
|
1796 | + $invoice_date = getpaid_format_date($invoice_date); |
|
1797 | 1797 | } |
1798 | 1798 | |
1799 | - return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this ); |
|
1799 | + return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this); |
|
1800 | 1800 | } |
1801 | 1801 | |
1802 | 1802 | public function get_ip() { |
1803 | - return apply_filters( 'wpinv_user_ip', $this->ip, $this->ID, $this ); |
|
1803 | + return apply_filters('wpinv_user_ip', $this->ip, $this->ID, $this); |
|
1804 | 1804 | } |
1805 | 1805 | |
1806 | - public function has_status( $status ) { |
|
1807 | - return apply_filters( 'wpinv_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status ) ) || $this->get_status() === $status ? true : false, $this, $status ); |
|
1806 | + public function has_status($status) { |
|
1807 | + return apply_filters('wpinv_has_status', (is_array($status) && in_array($this->get_status(), $status)) || $this->get_status() === $status ? true : false, $this, $status); |
|
1808 | 1808 | } |
1809 | 1809 | |
1810 | - public function add_item( $item_id = 0, $args = array() ) { |
|
1810 | + public function add_item($item_id = 0, $args = array()) { |
|
1811 | 1811 | global $wpi_current_id, $wpi_item_id; |
1812 | 1812 | |
1813 | - $item = new WPInv_Item( $item_id ); |
|
1813 | + $item = new WPInv_Item($item_id); |
|
1814 | 1814 | |
1815 | 1815 | // Bail if this post isn't a item |
1816 | - if( !$item || $item->post_type !== 'wpi_item' ) { |
|
1816 | + if (!$item || $item->post_type !== 'wpi_item') { |
|
1817 | 1817 | return false; |
1818 | 1818 | } |
1819 | 1819 | |
@@ -1832,8 +1832,8 @@ discard block |
||
1832 | 1832 | 'fees' => array() |
1833 | 1833 | ); |
1834 | 1834 | |
1835 | - $args = wp_parse_args( apply_filters( 'wpinv_add_item_args', $args, $item->ID ), $defaults ); |
|
1836 | - $args['quantity'] = $has_quantities && $args['quantity'] > 0 ? absint( $args['quantity'] ) : 1; |
|
1835 | + $args = wp_parse_args(apply_filters('wpinv_add_item_args', $args, $item->ID), $defaults); |
|
1836 | + $args['quantity'] = $has_quantities && $args['quantity'] > 0 ? absint($args['quantity']) : 1; |
|
1837 | 1837 | |
1838 | 1838 | $wpi_current_id = $this->ID; |
1839 | 1839 | $wpi_item_id = $item->ID; |
@@ -1845,19 +1845,19 @@ discard block |
||
1845 | 1845 | $found_cart_key = false; |
1846 | 1846 | |
1847 | 1847 | if ($has_quantities) { |
1848 | - $this->cart_details = !empty( $this->cart_details ) ? array_values( $this->cart_details ) : $this->cart_details; |
|
1848 | + $this->cart_details = !empty($this->cart_details) ? array_values($this->cart_details) : $this->cart_details; |
|
1849 | 1849 | |
1850 | - foreach ( $this->items as $key => $cart_item ) { |
|
1851 | - if ( (int)$item_id !== (int)$cart_item['id'] ) { |
|
1850 | + foreach ($this->items as $key => $cart_item) { |
|
1851 | + if ((int) $item_id !== (int) $cart_item['id']) { |
|
1852 | 1852 | continue; |
1853 | 1853 | } |
1854 | 1854 | |
1855 | - $this->items[ $key ]['quantity'] += $args['quantity']; |
|
1855 | + $this->items[$key]['quantity'] += $args['quantity']; |
|
1856 | 1856 | break; |
1857 | 1857 | } |
1858 | 1858 | |
1859 | - foreach ( $this->cart_details as $cart_key => $cart_item ) { |
|
1860 | - if ( $item_id != $cart_item['id'] ) { |
|
1859 | + foreach ($this->cart_details as $cart_key => $cart_item) { |
|
1860 | + if ($item_id != $cart_item['id']) { |
|
1861 | 1861 | continue; |
1862 | 1862 | } |
1863 | 1863 | |
@@ -1869,29 +1869,29 @@ discard block |
||
1869 | 1869 | if ($has_quantities && $found_cart_key !== false) { |
1870 | 1870 | $cart_item = $this->cart_details[$found_cart_key]; |
1871 | 1871 | $item_price = $cart_item['item_price']; |
1872 | - $quantity = !empty( $cart_item['quantity'] ) ? $cart_item['quantity'] : 1; |
|
1873 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : 0; |
|
1872 | + $quantity = !empty($cart_item['quantity']) ? $cart_item['quantity'] : 1; |
|
1873 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : 0; |
|
1874 | 1874 | |
1875 | 1875 | $new_quantity = $quantity + $args['quantity']; |
1876 | 1876 | $subtotal = $item_price * $new_quantity; |
1877 | 1877 | |
1878 | 1878 | $args['quantity'] = $new_quantity; |
1879 | - $discount = !empty( $args['discount'] ) ? $args['discount'] : 0; |
|
1880 | - $tax = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0; |
|
1879 | + $discount = !empty($args['discount']) ? $args['discount'] : 0; |
|
1880 | + $tax = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0; |
|
1881 | 1881 | |
1882 | - $discount_increased = $discount > 0 && $subtotal > 0 && $discount > (float)$cart_item['discount'] ? $discount - (float)$cart_item['discount'] : 0; |
|
1883 | - $tax_increased = $tax > 0 && $subtotal > 0 && $tax > (float)$cart_item['tax'] ? $tax - (float)$cart_item['tax'] : 0; |
|
1882 | + $discount_increased = $discount > 0 && $subtotal > 0 && $discount > (float) $cart_item['discount'] ? $discount - (float) $cart_item['discount'] : 0; |
|
1883 | + $tax_increased = $tax > 0 && $subtotal > 0 && $tax > (float) $cart_item['tax'] ? $tax - (float) $cart_item['tax'] : 0; |
|
1884 | 1884 | // The total increase equals the number removed * the item_price |
1885 | - $total_increased = wpinv_round_amount( $item_price ); |
|
1885 | + $total_increased = wpinv_round_amount($item_price); |
|
1886 | 1886 | |
1887 | - if ( wpinv_prices_include_tax() ) { |
|
1888 | - $subtotal -= wpinv_round_amount( $tax ); |
|
1887 | + if (wpinv_prices_include_tax()) { |
|
1888 | + $subtotal -= wpinv_round_amount($tax); |
|
1889 | 1889 | } |
1890 | 1890 | |
1891 | - $total = $subtotal - $discount + $tax; |
|
1891 | + $total = $subtotal - $discount + $tax; |
|
1892 | 1892 | |
1893 | 1893 | // Do not allow totals to go negative |
1894 | - if( $total < 0 ) { |
|
1894 | + if ($total < 0) { |
|
1895 | 1895 | $total = 0; |
1896 | 1896 | } |
1897 | 1897 | |
@@ -1907,25 +1907,25 @@ discard block |
||
1907 | 1907 | $this->cart_details[$found_cart_key] = $cart_item; |
1908 | 1908 | } else { |
1909 | 1909 | // Set custom price. |
1910 | - if ( $args['custom_price'] !== '' ) { |
|
1910 | + if ($args['custom_price'] !== '') { |
|
1911 | 1911 | $item_price = $args['custom_price']; |
1912 | 1912 | } else { |
1913 | 1913 | // Allow overriding the price |
1914 | - if ( false !== $args['item_price'] ) { |
|
1914 | + if (false !== $args['item_price']) { |
|
1915 | 1915 | $item_price = $args['item_price']; |
1916 | 1916 | } else { |
1917 | - $item_price = wpinv_get_item_price( $item->ID ); |
|
1917 | + $item_price = wpinv_get_item_price($item->ID); |
|
1918 | 1918 | } |
1919 | 1919 | } |
1920 | 1920 | |
1921 | 1921 | // Sanitizing the price here so we don't have a dozen calls later |
1922 | - $item_price = wpinv_sanitize_amount( $item_price ); |
|
1923 | - $subtotal = wpinv_round_amount( $item_price * $args['quantity'] ); |
|
1922 | + $item_price = wpinv_sanitize_amount($item_price); |
|
1923 | + $subtotal = wpinv_round_amount($item_price * $args['quantity']); |
|
1924 | 1924 | |
1925 | - $discount = !empty( $args['discount'] ) ? $args['discount'] : 0; |
|
1926 | - $tax_class = !empty( $args['vat_class'] ) ? $args['vat_class'] : ''; |
|
1927 | - $tax_rate = !empty( $args['vat_rate'] ) ? $args['vat_rate'] : 0; |
|
1928 | - $tax = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0; |
|
1925 | + $discount = !empty($args['discount']) ? $args['discount'] : 0; |
|
1926 | + $tax_class = !empty($args['vat_class']) ? $args['vat_class'] : ''; |
|
1927 | + $tax_rate = !empty($args['vat_rate']) ? $args['vat_rate'] : 0; |
|
1928 | + $tax = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0; |
|
1929 | 1929 | |
1930 | 1930 | // Setup the items meta item |
1931 | 1931 | $new_item = array( |
@@ -1933,29 +1933,29 @@ discard block |
||
1933 | 1933 | 'quantity' => $args['quantity'], |
1934 | 1934 | ); |
1935 | 1935 | |
1936 | - $this->items[] = $new_item; |
|
1936 | + $this->items[] = $new_item; |
|
1937 | 1937 | |
1938 | - if ( wpinv_prices_include_tax() ) { |
|
1939 | - $subtotal -= wpinv_round_amount( $tax ); |
|
1938 | + if (wpinv_prices_include_tax()) { |
|
1939 | + $subtotal -= wpinv_round_amount($tax); |
|
1940 | 1940 | } |
1941 | 1941 | |
1942 | - $total = $subtotal - $discount + $tax; |
|
1942 | + $total = $subtotal - $discount + $tax; |
|
1943 | 1943 | |
1944 | 1944 | // Do not allow totals to go negative |
1945 | - if( $total < 0 ) { |
|
1945 | + if ($total < 0) { |
|
1946 | 1946 | $total = 0; |
1947 | 1947 | } |
1948 | 1948 | |
1949 | 1949 | $this->cart_details[] = array( |
1950 | 1950 | 'name' => !empty($args['name']) ? $args['name'] : $item->get_name(), |
1951 | 1951 | 'id' => $item->ID, |
1952 | - 'item_price' => wpinv_round_amount( $item_price ), |
|
1953 | - 'custom_price' => ( $args['custom_price'] !== '' ? wpinv_round_amount( $args['custom_price'] ) : '' ), |
|
1952 | + 'item_price' => wpinv_round_amount($item_price), |
|
1953 | + 'custom_price' => ($args['custom_price'] !== '' ? wpinv_round_amount($args['custom_price']) : ''), |
|
1954 | 1954 | 'quantity' => $args['quantity'], |
1955 | 1955 | 'discount' => $discount, |
1956 | - 'subtotal' => wpinv_round_amount( $subtotal ), |
|
1957 | - 'tax' => wpinv_round_amount( $tax ), |
|
1958 | - 'price' => wpinv_round_amount( $total ), |
|
1956 | + 'subtotal' => wpinv_round_amount($subtotal), |
|
1957 | + 'tax' => wpinv_round_amount($tax), |
|
1958 | + 'price' => wpinv_round_amount($total), |
|
1959 | 1959 | 'vat_rate' => $tax_rate, |
1960 | 1960 | 'vat_class' => $tax_class, |
1961 | 1961 | 'meta' => $args['meta'], |
@@ -1965,18 +1965,18 @@ discard block |
||
1965 | 1965 | $subtotal = $subtotal - $discount; |
1966 | 1966 | } |
1967 | 1967 | |
1968 | - $added_item = end( $this->cart_details ); |
|
1969 | - $added_item['action'] = 'add'; |
|
1968 | + $added_item = end($this->cart_details); |
|
1969 | + $added_item['action'] = 'add'; |
|
1970 | 1970 | |
1971 | 1971 | $this->pending['items'][] = $added_item; |
1972 | 1972 | |
1973 | - $this->increase_subtotal( $subtotal ); |
|
1974 | - $this->increase_tax( $tax ); |
|
1973 | + $this->increase_subtotal($subtotal); |
|
1974 | + $this->increase_tax($tax); |
|
1975 | 1975 | |
1976 | 1976 | return true; |
1977 | 1977 | } |
1978 | 1978 | |
1979 | - public function remove_item( $item_id, $args = array() ) { |
|
1979 | + public function remove_item($item_id, $args = array()) { |
|
1980 | 1980 | // Set some defaults |
1981 | 1981 | $defaults = array( |
1982 | 1982 | 'quantity' => 1, |
@@ -1984,51 +1984,51 @@ discard block |
||
1984 | 1984 | 'custom_price' => '', |
1985 | 1985 | 'cart_index' => false, |
1986 | 1986 | ); |
1987 | - $args = wp_parse_args( $args, $defaults ); |
|
1987 | + $args = wp_parse_args($args, $defaults); |
|
1988 | 1988 | |
1989 | 1989 | // Bail if this post isn't a item |
1990 | - if ( get_post_type( $item_id ) !== 'wpi_item' ) { |
|
1990 | + if (get_post_type($item_id) !== 'wpi_item') { |
|
1991 | 1991 | return false; |
1992 | 1992 | } |
1993 | 1993 | |
1994 | - $this->cart_details = !empty( $this->cart_details ) ? array_values( $this->cart_details ) : $this->cart_details; |
|
1994 | + $this->cart_details = !empty($this->cart_details) ? array_values($this->cart_details) : $this->cart_details; |
|
1995 | 1995 | |
1996 | - foreach ( $this->items as $key => $item ) { |
|
1997 | - if ( !empty($item['id']) && (int)$item_id !== (int)$item['id'] ) { |
|
1996 | + foreach ($this->items as $key => $item) { |
|
1997 | + if (!empty($item['id']) && (int) $item_id !== (int) $item['id']) { |
|
1998 | 1998 | continue; |
1999 | 1999 | } |
2000 | 2000 | |
2001 | - if ( false !== $args['cart_index'] ) { |
|
2002 | - $cart_index = absint( $args['cart_index'] ); |
|
2003 | - $cart_item = ! empty( $this->cart_details[ $cart_index ] ) ? $this->cart_details[ $cart_index ] : false; |
|
2001 | + if (false !== $args['cart_index']) { |
|
2002 | + $cart_index = absint($args['cart_index']); |
|
2003 | + $cart_item = !empty($this->cart_details[$cart_index]) ? $this->cart_details[$cart_index] : false; |
|
2004 | 2004 | |
2005 | - if ( ! empty( $cart_item ) ) { |
|
2005 | + if (!empty($cart_item)) { |
|
2006 | 2006 | // If the cart index item isn't the same item ID, don't remove it |
2007 | - if ( !empty($cart_item['id']) && $cart_item['id'] != $item['id'] ) { |
|
2007 | + if (!empty($cart_item['id']) && $cart_item['id'] != $item['id']) { |
|
2008 | 2008 | continue; |
2009 | 2009 | } |
2010 | 2010 | } |
2011 | 2011 | } |
2012 | 2012 | |
2013 | - $item_quantity = $this->items[ $key ]['quantity']; |
|
2014 | - if ( $item_quantity > $args['quantity'] ) { |
|
2015 | - $this->items[ $key ]['quantity'] -= $args['quantity']; |
|
2013 | + $item_quantity = $this->items[$key]['quantity']; |
|
2014 | + if ($item_quantity > $args['quantity']) { |
|
2015 | + $this->items[$key]['quantity'] -= $args['quantity']; |
|
2016 | 2016 | break; |
2017 | 2017 | } else { |
2018 | - unset( $this->items[ $key ] ); |
|
2018 | + unset($this->items[$key]); |
|
2019 | 2019 | break; |
2020 | 2020 | } |
2021 | 2021 | } |
2022 | 2022 | |
2023 | 2023 | $found_cart_key = false; |
2024 | - if ( false === $args['cart_index'] ) { |
|
2025 | - foreach ( $this->cart_details as $cart_key => $item ) { |
|
2026 | - if ( $item_id != $item['id'] ) { |
|
2024 | + if (false === $args['cart_index']) { |
|
2025 | + foreach ($this->cart_details as $cart_key => $item) { |
|
2026 | + if ($item_id != $item['id']) { |
|
2027 | 2027 | continue; |
2028 | 2028 | } |
2029 | 2029 | |
2030 | - if ( false !== $args['item_price'] ) { |
|
2031 | - if ( isset( $item['item_price'] ) && (float) $args['item_price'] != (float) $item['item_price'] ) { |
|
2030 | + if (false !== $args['item_price']) { |
|
2031 | + if (isset($item['item_price']) && (float) $args['item_price'] != (float) $item['item_price']) { |
|
2032 | 2032 | continue; |
2033 | 2033 | } |
2034 | 2034 | } |
@@ -2037,13 +2037,13 @@ discard block |
||
2037 | 2037 | break; |
2038 | 2038 | } |
2039 | 2039 | } else { |
2040 | - $cart_index = absint( $args['cart_index'] ); |
|
2040 | + $cart_index = absint($args['cart_index']); |
|
2041 | 2041 | |
2042 | - if ( ! array_key_exists( $cart_index, $this->cart_details ) ) { |
|
2042 | + if (!array_key_exists($cart_index, $this->cart_details)) { |
|
2043 | 2043 | return false; // Invalid cart index passed. |
2044 | 2044 | } |
2045 | 2045 | |
2046 | - if ( (int) $this->cart_details[ $cart_index ]['id'] > 0 && (int) $this->cart_details[ $cart_index ]['id'] !== (int) $item_id ) { |
|
2046 | + if ((int) $this->cart_details[$cart_index]['id'] > 0 && (int) $this->cart_details[$cart_index]['id'] !== (int) $item_id) { |
|
2047 | 2047 | return false; // We still need the proper Item ID to be sure. |
2048 | 2048 | } |
2049 | 2049 | |
@@ -2051,41 +2051,41 @@ discard block |
||
2051 | 2051 | } |
2052 | 2052 | |
2053 | 2053 | $cart_item = $this->cart_details[$found_cart_key]; |
2054 | - $quantity = !empty( $cart_item['quantity'] ) ? $cart_item['quantity'] : 1; |
|
2054 | + $quantity = !empty($cart_item['quantity']) ? $cart_item['quantity'] : 1; |
|
2055 | 2055 | |
2056 | - if ( count( $this->cart_details ) == 1 && ( $quantity - $args['quantity'] ) < 1 ) { |
|
2056 | + if (count($this->cart_details) == 1 && ($quantity - $args['quantity']) < 1) { |
|
2057 | 2057 | //return false; // Invoice must contain at least one item. |
2058 | 2058 | } |
2059 | 2059 | |
2060 | - $discounts = $this->get_discounts(); |
|
2060 | + $discounts = $this->get_discounts(); |
|
2061 | 2061 | |
2062 | - if ( $quantity > $args['quantity'] ) { |
|
2062 | + if ($quantity > $args['quantity']) { |
|
2063 | 2063 | $item_price = $cart_item['item_price']; |
2064 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : 0; |
|
2064 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : 0; |
|
2065 | 2065 | |
2066 | - $new_quantity = max( $quantity - $args['quantity'], 1); |
|
2066 | + $new_quantity = max($quantity - $args['quantity'], 1); |
|
2067 | 2067 | $subtotal = $item_price * $new_quantity; |
2068 | 2068 | |
2069 | 2069 | $args['quantity'] = $new_quantity; |
2070 | - $discount = !empty( $cart_item['discount'] ) ? $cart_item['discount'] : 0; |
|
2071 | - $tax = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0; |
|
2070 | + $discount = !empty($cart_item['discount']) ? $cart_item['discount'] : 0; |
|
2071 | + $tax = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0; |
|
2072 | 2072 | |
2073 | - $discount_decrease = (float)$cart_item['discount'] > 0 && $quantity > 0 ? wpinv_round_amount( ( (float)$cart_item['discount'] / $quantity ) ) : 0; |
|
2074 | - $discount_decrease = $discount > 0 && $subtotal > 0 && (float)$cart_item['discount'] > $discount ? (float)$cart_item['discount'] - $discount : $discount_decrease; |
|
2075 | - $tax_decrease = (float)$cart_item['tax'] > 0 && $quantity > 0 ? wpinv_round_amount( ( (float)$cart_item['tax'] / $quantity ) ) : 0; |
|
2076 | - $tax_decrease = $tax > 0 && $subtotal > 0 && (float)$cart_item['tax'] > $tax ? (float)$cart_item['tax'] - $tax : $tax_decrease; |
|
2073 | + $discount_decrease = (float) $cart_item['discount'] > 0 && $quantity > 0 ? wpinv_round_amount(((float) $cart_item['discount'] / $quantity)) : 0; |
|
2074 | + $discount_decrease = $discount > 0 && $subtotal > 0 && (float) $cart_item['discount'] > $discount ? (float) $cart_item['discount'] - $discount : $discount_decrease; |
|
2075 | + $tax_decrease = (float) $cart_item['tax'] > 0 && $quantity > 0 ? wpinv_round_amount(((float) $cart_item['tax'] / $quantity)) : 0; |
|
2076 | + $tax_decrease = $tax > 0 && $subtotal > 0 && (float) $cart_item['tax'] > $tax ? (float) $cart_item['tax'] - $tax : $tax_decrease; |
|
2077 | 2077 | |
2078 | 2078 | // The total increase equals the number removed * the item_price |
2079 | - $total_decrease = wpinv_round_amount( $item_price ); |
|
2079 | + $total_decrease = wpinv_round_amount($item_price); |
|
2080 | 2080 | |
2081 | - if ( wpinv_prices_include_tax() ) { |
|
2082 | - $subtotal -= wpinv_round_amount( $tax ); |
|
2081 | + if (wpinv_prices_include_tax()) { |
|
2082 | + $subtotal -= wpinv_round_amount($tax); |
|
2083 | 2083 | } |
2084 | 2084 | |
2085 | - $total = $subtotal - $discount + $tax; |
|
2085 | + $total = $subtotal - $discount + $tax; |
|
2086 | 2086 | |
2087 | 2087 | // Do not allow totals to go negative |
2088 | - if( $total < 0 ) { |
|
2088 | + if ($total < 0) { |
|
2089 | 2089 | $total = 0; |
2090 | 2090 | } |
2091 | 2091 | |
@@ -2104,16 +2104,16 @@ discard block |
||
2104 | 2104 | |
2105 | 2105 | $this->cart_details[$found_cart_key] = $cart_item; |
2106 | 2106 | |
2107 | - $remove_item = end( $this->cart_details ); |
|
2107 | + $remove_item = end($this->cart_details); |
|
2108 | 2108 | } else { |
2109 | 2109 | $item_price = $cart_item['item_price']; |
2110 | - $discount = !empty( $cart_item['discount'] ) ? $cart_item['discount'] : 0; |
|
2111 | - $tax = !empty( $cart_item['tax'] ) ? $cart_item['tax'] : 0; |
|
2110 | + $discount = !empty($cart_item['discount']) ? $cart_item['discount'] : 0; |
|
2111 | + $tax = !empty($cart_item['tax']) ? $cart_item['tax'] : 0; |
|
2112 | 2112 | |
2113 | - $subtotal_decrease = ( $item_price * $quantity ) - $discount; |
|
2113 | + $subtotal_decrease = ($item_price * $quantity) - $discount; |
|
2114 | 2114 | $tax_decrease = $tax; |
2115 | 2115 | |
2116 | - unset( $this->cart_details[$found_cart_key] ); |
|
2116 | + unset($this->cart_details[$found_cart_key]); |
|
2117 | 2117 | |
2118 | 2118 | $remove_item = $args; |
2119 | 2119 | $remove_item['id'] = $item_id; |
@@ -2124,8 +2124,8 @@ discard block |
||
2124 | 2124 | $remove_item['action'] = 'remove'; |
2125 | 2125 | $this->pending['items'][] = $remove_item; |
2126 | 2126 | |
2127 | - $this->decrease_subtotal( $subtotal_decrease ); |
|
2128 | - $this->decrease_tax( $tax_decrease ); |
|
2127 | + $this->decrease_subtotal($subtotal_decrease); |
|
2128 | + $this->decrease_tax($tax_decrease); |
|
2129 | 2129 | |
2130 | 2130 | return true; |
2131 | 2131 | } |
@@ -2133,7 +2133,7 @@ discard block |
||
2133 | 2133 | public function update_items($temp = false) { |
2134 | 2134 | global $wpinv_euvat, $wpi_current_id, $wpi_item_id, $wpi_nosave; |
2135 | 2135 | |
2136 | - if ( !empty( $this->cart_details ) ) { |
|
2136 | + if (!empty($this->cart_details)) { |
|
2137 | 2137 | $wpi_nosave = $temp; |
2138 | 2138 | $cart_subtotal = 0; |
2139 | 2139 | $cart_discount = 0; |
@@ -2143,65 +2143,65 @@ discard block |
||
2143 | 2143 | $_POST['wpinv_country'] = $this->country; |
2144 | 2144 | $_POST['wpinv_state'] = $this->state; |
2145 | 2145 | |
2146 | - foreach ( $this->cart_details as $key => $item ) { |
|
2146 | + foreach ($this->cart_details as $key => $item) { |
|
2147 | 2147 | $item_price = $item['item_price']; |
2148 | - $quantity = wpinv_item_quantities_enabled() && $item['quantity'] > 0 ? absint( $item['quantity'] ) : 1; |
|
2149 | - $amount = wpinv_round_amount( $item_price * $quantity ); |
|
2148 | + $quantity = wpinv_item_quantities_enabled() && $item['quantity'] > 0 ? absint($item['quantity']) : 1; |
|
2149 | + $amount = wpinv_round_amount($item_price * $quantity); |
|
2150 | 2150 | $subtotal = $item_price * $quantity; |
2151 | 2151 | |
2152 | 2152 | $wpi_current_id = $this->ID; |
2153 | 2153 | $wpi_item_id = $item['id']; |
2154 | 2154 | |
2155 | - $discount = wpinv_get_cart_item_discount_amount( $item, $this->get_discounts() ); |
|
2155 | + $discount = wpinv_get_cart_item_discount_amount($item, $this->get_discounts()); |
|
2156 | 2156 | |
2157 | - $tax_rate = wpinv_get_tax_rate( $this->country, $this->state, $wpi_item_id ); |
|
2158 | - $tax_class = $wpinv_euvat->get_item_class( $wpi_item_id ); |
|
2159 | - $tax = $item_price > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0; |
|
2157 | + $tax_rate = wpinv_get_tax_rate($this->country, $this->state, $wpi_item_id); |
|
2158 | + $tax_class = $wpinv_euvat->get_item_class($wpi_item_id); |
|
2159 | + $tax = $item_price > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0; |
|
2160 | 2160 | |
2161 | - if ( ! $this->is_taxable() ) { |
|
2161 | + if (!$this->is_taxable()) { |
|
2162 | 2162 | $tax = 0; |
2163 | 2163 | } |
2164 | 2164 | |
2165 | - if ( wpinv_prices_include_tax() ) { |
|
2166 | - $subtotal -= wpinv_round_amount( $tax ); |
|
2165 | + if (wpinv_prices_include_tax()) { |
|
2166 | + $subtotal -= wpinv_round_amount($tax); |
|
2167 | 2167 | } |
2168 | 2168 | |
2169 | - $total = $subtotal - $discount + $tax; |
|
2169 | + $total = $subtotal - $discount + $tax; |
|
2170 | 2170 | |
2171 | 2171 | // Do not allow totals to go negative |
2172 | - if( $total < 0 ) { |
|
2172 | + if ($total < 0) { |
|
2173 | 2173 | $total = 0; |
2174 | 2174 | } |
2175 | 2175 | |
2176 | 2176 | $cart_details[] = array( |
2177 | 2177 | 'id' => $item['id'], |
2178 | 2178 | 'name' => $item['name'], |
2179 | - 'item_price' => wpinv_round_amount( $item_price ), |
|
2180 | - 'custom_price'=> ( isset( $item['custom_price'] ) ? $item['custom_price'] : '' ), |
|
2179 | + 'item_price' => wpinv_round_amount($item_price), |
|
2180 | + 'custom_price'=> (isset($item['custom_price']) ? $item['custom_price'] : ''), |
|
2181 | 2181 | 'quantity' => $quantity, |
2182 | 2182 | 'discount' => $discount, |
2183 | - 'subtotal' => wpinv_round_amount( $subtotal ), |
|
2184 | - 'tax' => wpinv_round_amount( $tax ), |
|
2185 | - 'price' => wpinv_round_amount( $total ), |
|
2183 | + 'subtotal' => wpinv_round_amount($subtotal), |
|
2184 | + 'tax' => wpinv_round_amount($tax), |
|
2185 | + 'price' => wpinv_round_amount($total), |
|
2186 | 2186 | 'vat_rate' => $tax_rate, |
2187 | 2187 | 'vat_class' => $tax_class, |
2188 | 2188 | 'meta' => isset($item['meta']) ? $item['meta'] : array(), |
2189 | 2189 | 'fees' => isset($item['fees']) ? $item['fees'] : array(), |
2190 | 2190 | ); |
2191 | 2191 | |
2192 | - $cart_subtotal += (float)($subtotal - $discount); // TODO |
|
2193 | - $cart_discount += (float)($discount); |
|
2194 | - $cart_tax += (float)($tax); |
|
2192 | + $cart_subtotal += (float) ($subtotal - $discount); // TODO |
|
2193 | + $cart_discount += (float) ($discount); |
|
2194 | + $cart_tax += (float) ($tax); |
|
2195 | 2195 | } |
2196 | - if ( $cart_subtotal < 0 ) { |
|
2196 | + if ($cart_subtotal < 0) { |
|
2197 | 2197 | $cart_subtotal = 0; |
2198 | 2198 | } |
2199 | - if ( $cart_tax < 0 ) { |
|
2199 | + if ($cart_tax < 0) { |
|
2200 | 2200 | $cart_tax = 0; |
2201 | 2201 | } |
2202 | - $this->subtotal = wpinv_round_amount( $cart_subtotal ); |
|
2203 | - $this->tax = wpinv_round_amount( $cart_tax ); |
|
2204 | - $this->discount = wpinv_round_amount( $cart_discount ); |
|
2202 | + $this->subtotal = wpinv_round_amount($cart_subtotal); |
|
2203 | + $this->tax = wpinv_round_amount($cart_tax); |
|
2204 | + $this->discount = wpinv_round_amount($cart_discount); |
|
2205 | 2205 | |
2206 | 2206 | $this->recalculate_total(); |
2207 | 2207 | |
@@ -2213,177 +2213,177 @@ discard block |
||
2213 | 2213 | |
2214 | 2214 | public function recalculate_totals($temp = false) { |
2215 | 2215 | $this->update_items($temp); |
2216 | - $this->save( true ); |
|
2216 | + $this->save(true); |
|
2217 | 2217 | |
2218 | 2218 | return $this; |
2219 | 2219 | } |
2220 | 2220 | |
2221 | 2221 | public function needs_payment() { |
2222 | - $valid_invoice_statuses = apply_filters( 'wpinv_valid_invoice_statuses_for_payment', array( 'wpi-pending' ), $this ); |
|
2222 | + $valid_invoice_statuses = apply_filters('wpinv_valid_invoice_statuses_for_payment', array('wpi-pending'), $this); |
|
2223 | 2223 | |
2224 | - if ( $this->has_status( $valid_invoice_statuses ) && ( $this->get_total() > 0 || $this->is_free_trial() || $this->is_free() || $this->is_initial_free() ) ) { |
|
2224 | + if ($this->has_status($valid_invoice_statuses) && ($this->get_total() > 0 || $this->is_free_trial() || $this->is_free() || $this->is_initial_free())) { |
|
2225 | 2225 | $needs_payment = true; |
2226 | 2226 | } else { |
2227 | 2227 | $needs_payment = false; |
2228 | 2228 | } |
2229 | 2229 | |
2230 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this, $valid_invoice_statuses ); |
|
2230 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this, $valid_invoice_statuses); |
|
2231 | 2231 | } |
2232 | 2232 | |
2233 | - public function get_checkout_payment_url( $with_key = false, $secret = false ) { |
|
2233 | + public function get_checkout_payment_url($with_key = false, $secret = false) { |
|
2234 | 2234 | $pay_url = wpinv_get_checkout_uri(); |
2235 | 2235 | |
2236 | - if ( is_ssl() ) { |
|
2237 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
2236 | + if (is_ssl()) { |
|
2237 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
2238 | 2238 | } |
2239 | 2239 | |
2240 | 2240 | $key = $this->get_key(); |
2241 | 2241 | |
2242 | - if ( $with_key ) { |
|
2243 | - $pay_url = add_query_arg( 'invoice_key', $key, $pay_url ); |
|
2242 | + if ($with_key) { |
|
2243 | + $pay_url = add_query_arg('invoice_key', $key, $pay_url); |
|
2244 | 2244 | } else { |
2245 | - $pay_url = add_query_arg( array( 'wpi_action' => 'pay_for_invoice', 'invoice_key' => $key ), $pay_url ); |
|
2245 | + $pay_url = add_query_arg(array('wpi_action' => 'pay_for_invoice', 'invoice_key' => $key), $pay_url); |
|
2246 | 2246 | } |
2247 | 2247 | |
2248 | - if ( $secret ) { |
|
2249 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $key ) ), $pay_url ); |
|
2248 | + if ($secret) { |
|
2249 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $key)), $pay_url); |
|
2250 | 2250 | } |
2251 | 2251 | |
2252 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $with_key, $secret ); |
|
2252 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $with_key, $secret); |
|
2253 | 2253 | } |
2254 | 2254 | |
2255 | - public function get_view_url( $with_key = false ) { |
|
2256 | - $invoice_url = get_permalink( $this->ID ); |
|
2255 | + public function get_view_url($with_key = false) { |
|
2256 | + $invoice_url = get_permalink($this->ID); |
|
2257 | 2257 | |
2258 | - if ( $with_key ) { |
|
2259 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
2258 | + if ($with_key) { |
|
2259 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
2260 | 2260 | } |
2261 | 2261 | |
2262 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this, $with_key ); |
|
2262 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this, $with_key); |
|
2263 | 2263 | } |
2264 | 2264 | |
2265 | - public function generate_key( $string = '' ) { |
|
2266 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
2267 | - return strtolower( md5( $string . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) ); // Unique key |
|
2265 | + public function generate_key($string = '') { |
|
2266 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
2267 | + return strtolower(md5($string . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))); // Unique key |
|
2268 | 2268 | } |
2269 | 2269 | |
2270 | 2270 | public function is_recurring() { |
2271 | - if ( empty( $this->cart_details ) ) { |
|
2271 | + if (empty($this->cart_details)) { |
|
2272 | 2272 | return false; |
2273 | 2273 | } |
2274 | 2274 | |
2275 | 2275 | $has_subscription = false; |
2276 | - foreach( $this->cart_details as $cart_item ) { |
|
2277 | - if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] ) ) { |
|
2276 | + foreach ($this->cart_details as $cart_item) { |
|
2277 | + if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) { |
|
2278 | 2278 | $has_subscription = true; |
2279 | 2279 | break; |
2280 | 2280 | } |
2281 | 2281 | } |
2282 | 2282 | |
2283 | - if ( count( $this->cart_details ) > 1 ) { |
|
2283 | + if (count($this->cart_details) > 1) { |
|
2284 | 2284 | $has_subscription = false; |
2285 | 2285 | } |
2286 | 2286 | |
2287 | - return apply_filters( 'wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details ); |
|
2287 | + return apply_filters('wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details); |
|
2288 | 2288 | } |
2289 | 2289 | |
2290 | 2290 | public function is_free_trial() { |
2291 | 2291 | $is_free_trial = false; |
2292 | 2292 | |
2293 | - if ( $this->is_parent() && $item = $this->get_recurring( true ) ) { |
|
2294 | - if ( !empty( $item ) && $item->has_free_trial() ) { |
|
2293 | + if ($this->is_parent() && $item = $this->get_recurring(true)) { |
|
2294 | + if (!empty($item) && $item->has_free_trial()) { |
|
2295 | 2295 | $is_free_trial = true; |
2296 | 2296 | } |
2297 | 2297 | } |
2298 | 2298 | |
2299 | - return apply_filters( 'wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this ); |
|
2299 | + return apply_filters('wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this); |
|
2300 | 2300 | } |
2301 | 2301 | |
2302 | 2302 | public function is_initial_free() { |
2303 | 2303 | $is_initial_free = false; |
2304 | 2304 | |
2305 | - if ( ! ( (float)wpinv_round_amount( $this->get_total() ) > 0 ) && $this->is_parent() && $this->is_recurring() && ! $this->is_free_trial() && ! $this->is_free() ) { |
|
2305 | + if (!((float) wpinv_round_amount($this->get_total()) > 0) && $this->is_parent() && $this->is_recurring() && !$this->is_free_trial() && !$this->is_free()) { |
|
2306 | 2306 | $is_initial_free = true; |
2307 | 2307 | } |
2308 | 2308 | |
2309 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->cart_details ); |
|
2309 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->cart_details); |
|
2310 | 2310 | } |
2311 | 2311 | |
2312 | - public function get_recurring( $object = false ) { |
|
2312 | + public function get_recurring($object = false) { |
|
2313 | 2313 | $item = NULL; |
2314 | 2314 | |
2315 | - if ( empty( $this->cart_details ) ) { |
|
2315 | + if (empty($this->cart_details)) { |
|
2316 | 2316 | return $item; |
2317 | 2317 | } |
2318 | 2318 | |
2319 | - foreach( $this->cart_details as $cart_item ) { |
|
2320 | - if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] ) ) { |
|
2319 | + foreach ($this->cart_details as $cart_item) { |
|
2320 | + if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) { |
|
2321 | 2321 | $item = $cart_item['id']; |
2322 | 2322 | break; |
2323 | 2323 | } |
2324 | 2324 | } |
2325 | 2325 | |
2326 | - if ( $object ) { |
|
2327 | - $item = $item ? new WPInv_Item( $item ) : NULL; |
|
2326 | + if ($object) { |
|
2327 | + $item = $item ? new WPInv_Item($item) : NULL; |
|
2328 | 2328 | |
2329 | - apply_filters( 'wpinv_invoice_get_recurring_item', $item, $this ); |
|
2329 | + apply_filters('wpinv_invoice_get_recurring_item', $item, $this); |
|
2330 | 2330 | } |
2331 | 2331 | |
2332 | - return apply_filters( 'wpinv_invoice_get_recurring_item_id', $item, $this ); |
|
2332 | + return apply_filters('wpinv_invoice_get_recurring_item_id', $item, $this); |
|
2333 | 2333 | } |
2334 | 2334 | |
2335 | 2335 | public function get_subscription_name() { |
2336 | - $item = $this->get_recurring( true ); |
|
2336 | + $item = $this->get_recurring(true); |
|
2337 | 2337 | |
2338 | - if ( empty( $item ) ) { |
|
2338 | + if (empty($item)) { |
|
2339 | 2339 | return NULL; |
2340 | 2340 | } |
2341 | 2341 | |
2342 | - if ( !($name = $item->get_name()) ) { |
|
2342 | + if (!($name = $item->get_name())) { |
|
2343 | 2343 | $name = $item->post_name; |
2344 | 2344 | } |
2345 | 2345 | |
2346 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $name, $this ); |
|
2346 | + return apply_filters('wpinv_invoice_get_subscription_name', $name, $this); |
|
2347 | 2347 | } |
2348 | 2348 | |
2349 | 2349 | public function get_subscription_id() { |
2350 | - $subscription_id = $this->get_meta( '_wpinv_subscr_profile_id', true ); |
|
2350 | + $subscription_id = $this->get_meta('_wpinv_subscr_profile_id', true); |
|
2351 | 2351 | |
2352 | - if ( empty( $subscription_id ) && !empty( $this->parent_invoice ) ) { |
|
2353 | - $parent_invoice = wpinv_get_invoice( $this->parent_invoice ); |
|
2352 | + if (empty($subscription_id) && !empty($this->parent_invoice)) { |
|
2353 | + $parent_invoice = wpinv_get_invoice($this->parent_invoice); |
|
2354 | 2354 | |
2355 | - $subscription_id = $parent_invoice->get_meta( '_wpinv_subscr_profile_id', true ); |
|
2355 | + $subscription_id = $parent_invoice->get_meta('_wpinv_subscr_profile_id', true); |
|
2356 | 2356 | } |
2357 | 2357 | |
2358 | 2358 | return $subscription_id; |
2359 | 2359 | } |
2360 | 2360 | |
2361 | 2361 | public function is_parent() { |
2362 | - $is_parent = empty( $this->parent_invoice ) ? true : false; |
|
2362 | + $is_parent = empty($this->parent_invoice) ? true : false; |
|
2363 | 2363 | |
2364 | - return apply_filters( 'wpinv_invoice_is_parent', $is_parent, $this ); |
|
2364 | + return apply_filters('wpinv_invoice_is_parent', $is_parent, $this); |
|
2365 | 2365 | } |
2366 | 2366 | |
2367 | 2367 | public function is_renewal() { |
2368 | 2368 | $is_renewal = $this->parent_invoice && $this->parent_invoice != $this->ID ? true : false; |
2369 | 2369 | |
2370 | - return apply_filters( 'wpinv_invoice_is_renewal', $is_renewal, $this ); |
|
2370 | + return apply_filters('wpinv_invoice_is_renewal', $is_renewal, $this); |
|
2371 | 2371 | } |
2372 | 2372 | |
2373 | 2373 | public function get_parent_payment() { |
2374 | 2374 | $parent_payment = NULL; |
2375 | 2375 | |
2376 | - if ( $this->is_renewal() ) { |
|
2377 | - $parent_payment = wpinv_get_invoice( $this->parent_invoice ); |
|
2376 | + if ($this->is_renewal()) { |
|
2377 | + $parent_payment = wpinv_get_invoice($this->parent_invoice); |
|
2378 | 2378 | } |
2379 | 2379 | |
2380 | 2380 | return $parent_payment; |
2381 | 2381 | } |
2382 | 2382 | |
2383 | 2383 | public function is_paid() { |
2384 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
2384 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
2385 | 2385 | |
2386 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
2386 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
2387 | 2387 | } |
2388 | 2388 | |
2389 | 2389 | /** |
@@ -2396,23 +2396,23 @@ discard block |
||
2396 | 2396 | } |
2397 | 2397 | |
2398 | 2398 | public function is_refunded() { |
2399 | - $is_refunded = $this->has_status( array( 'wpi-refunded' ) ); |
|
2399 | + $is_refunded = $this->has_status(array('wpi-refunded')); |
|
2400 | 2400 | |
2401 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
2401 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
2402 | 2402 | } |
2403 | 2403 | |
2404 | 2404 | public function is_free() { |
2405 | 2405 | $is_free = false; |
2406 | 2406 | |
2407 | - if ( !( (float)wpinv_round_amount( $this->get_total() ) > 0 ) ) { |
|
2408 | - if ( $this->is_parent() && $this->is_recurring() ) { |
|
2409 | - $is_free = (float)wpinv_round_amount( $this->get_recurring_details( 'total' ) ) > 0 ? false : true; |
|
2407 | + if (!((float) wpinv_round_amount($this->get_total()) > 0)) { |
|
2408 | + if ($this->is_parent() && $this->is_recurring()) { |
|
2409 | + $is_free = (float) wpinv_round_amount($this->get_recurring_details('total')) > 0 ? false : true; |
|
2410 | 2410 | } else { |
2411 | 2411 | $is_free = true; |
2412 | 2412 | } |
2413 | 2413 | } |
2414 | 2414 | |
2415 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
2415 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
2416 | 2416 | } |
2417 | 2417 | |
2418 | 2418 | public function has_vat() { |
@@ -2420,41 +2420,41 @@ discard block |
||
2420 | 2420 | |
2421 | 2421 | $requires_vat = false; |
2422 | 2422 | |
2423 | - if ( $this->country ) { |
|
2423 | + if ($this->country) { |
|
2424 | 2424 | $wpi_country = $this->country; |
2425 | 2425 | |
2426 | - $requires_vat = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) ); |
|
2426 | + $requires_vat = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this)); |
|
2427 | 2427 | } |
2428 | 2428 | |
2429 | - return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
|
2429 | + return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this); |
|
2430 | 2430 | } |
2431 | 2431 | |
2432 | 2432 | public function refresh_item_ids() { |
2433 | 2433 | $item_ids = array(); |
2434 | 2434 | |
2435 | - if ( !empty( $this->cart_details ) ) { |
|
2436 | - foreach ( $this->cart_details as $key => $item ) { |
|
2437 | - if ( !empty( $item['id'] ) ) { |
|
2435 | + if (!empty($this->cart_details)) { |
|
2436 | + foreach ($this->cart_details as $key => $item) { |
|
2437 | + if (!empty($item['id'])) { |
|
2438 | 2438 | $item_ids[] = $item['id']; |
2439 | 2439 | } |
2440 | 2440 | } |
2441 | 2441 | } |
2442 | 2442 | |
2443 | - $item_ids = !empty( $item_ids ) ? implode( ',', array_unique( $item_ids ) ) : ''; |
|
2443 | + $item_ids = !empty($item_ids) ? implode(',', array_unique($item_ids)) : ''; |
|
2444 | 2444 | |
2445 | - update_post_meta( $this->ID, '_wpinv_item_ids', $item_ids ); |
|
2445 | + update_post_meta($this->ID, '_wpinv_item_ids', $item_ids); |
|
2446 | 2446 | } |
2447 | 2447 | |
2448 | - public function get_invoice_quote_type( $post_id ) { |
|
2449 | - if ( empty( $post_id ) ) { |
|
2448 | + public function get_invoice_quote_type($post_id) { |
|
2449 | + if (empty($post_id)) { |
|
2450 | 2450 | return ''; |
2451 | 2451 | } |
2452 | 2452 | |
2453 | - $type = get_post_type( $post_id ); |
|
2453 | + $type = get_post_type($post_id); |
|
2454 | 2454 | |
2455 | - if ( 'wpi_invoice' === $type ) { |
|
2455 | + if ('wpi_invoice' === $type) { |
|
2456 | 2456 | $post_type = __('Invoice', 'invoicing'); |
2457 | - } else{ |
|
2457 | + } else { |
|
2458 | 2458 | $post_type = __('Quote', 'invoicing'); |
2459 | 2459 | } |
2460 | 2460 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | global $wpinv_options; |
44 | 44 | |
45 | 45 | // Try fetching the saved options. |
46 | - if ( ! is_array( $wpinv_options ) ) { |
|
47 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
46 | + if (!is_array($wpinv_options)) { |
|
47 | + $wpinv_options = get_option('wpinv_settings'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // If that fails, don't fetch the default settings to prevent a loop. |
51 | - if ( ! is_array( $wpinv_options ) ) { |
|
51 | + if (!is_array($wpinv_options)) { |
|
52 | 52 | $wpinv_options = array(); |
53 | 53 | } |
54 | 54 | |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | * @param mixed $default The default value to use if the setting has not been set. |
63 | 63 | * @return mixed |
64 | 64 | */ |
65 | -function wpinv_get_option( $key = '', $default = false ) { |
|
65 | +function wpinv_get_option($key = '', $default = false) { |
|
66 | 66 | |
67 | 67 | $options = wpinv_get_options(); |
68 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
69 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
68 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
69 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
70 | 70 | |
71 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
71 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param array $options the new options. |
78 | 78 | * @return bool |
79 | 79 | */ |
80 | -function wpinv_update_options( $options ) { |
|
80 | +function wpinv_update_options($options) { |
|
81 | 81 | global $wpinv_options; |
82 | 82 | |
83 | 83 | // update the option. |
84 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
84 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
85 | 85 | $wpinv_options = $options; |
86 | 86 | return true; |
87 | 87 | } |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | * @param mixed $value The setting value. |
97 | 97 | * @return bool |
98 | 98 | */ |
99 | -function wpinv_update_option( $key = '', $value = false ) { |
|
99 | +function wpinv_update_option($key = '', $value = false) { |
|
100 | 100 | |
101 | 101 | // If no key, exit. |
102 | - if ( empty( $key ) ) { |
|
102 | + if (empty($key)) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Maybe delete the option instead. |
107 | - if ( is_null( $value ) ) { |
|
108 | - return wpinv_delete_option( $key ); |
|
107 | + if (is_null($value)) { |
|
108 | + return wpinv_delete_option($key); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // Prepare the new options. |
112 | 112 | $options = wpinv_get_options(); |
113 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
113 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
114 | 114 | |
115 | 115 | // Save the new options. |
116 | - return wpinv_update_options( $options ); |
|
116 | + return wpinv_update_options($options); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
@@ -123,18 +123,18 @@ discard block |
||
123 | 123 | * @param string $key the setting key. |
124 | 124 | * @return bool |
125 | 125 | */ |
126 | -function wpinv_delete_option( $key = '' ) { |
|
126 | +function wpinv_delete_option($key = '') { |
|
127 | 127 | |
128 | 128 | // If no key, exit |
129 | - if ( empty( $key ) ) { |
|
129 | + if (empty($key)) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $options = wpinv_get_options(); |
134 | 134 | |
135 | - if ( isset( $options[ $key ] ) ) { |
|
136 | - unset( $options[ $key ] ); |
|
137 | - return wpinv_update_options( $options ); |
|
135 | + if (isset($options[$key])) { |
|
136 | + unset($options[$key]); |
|
137 | + return wpinv_update_options($options); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return true; |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | function wpinv_register_settings() { |
149 | 149 | |
150 | 150 | // Loop through all tabs. |
151 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
151 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
152 | 152 | |
153 | 153 | // In each tab, loop through sections. |
154 | - foreach ( $sections as $section => $settings ) { |
|
154 | + foreach ($sections as $section => $settings) { |
|
155 | 155 | |
156 | 156 | // Check for backwards compatibility |
157 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
158 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
157 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
158 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
159 | 159 | $section = 'main'; |
160 | 160 | $settings = $sections; |
161 | 161 | } |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | 'wpinv_settings_' . $tab . '_' . $section |
169 | 169 | ); |
170 | 170 | |
171 | - foreach ( $settings as $option ) { |
|
172 | - if ( ! empty( $option['id'] ) ) { |
|
173 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
171 | + foreach ($settings as $option) { |
|
172 | + if (!empty($option['id'])) { |
|
173 | + wpinv_register_settings_option($tab, $section, $option); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | } |
179 | 179 | |
180 | 180 | // Creates our settings in the options table. |
181 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
181 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
182 | 182 | } |
183 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
183 | +add_action('admin_init', 'wpinv_register_settings'); |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Register a single settings option. |
@@ -190,46 +190,46 @@ discard block |
||
190 | 190 | * @param string $option |
191 | 191 | * |
192 | 192 | */ |
193 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
193 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
194 | 194 | |
195 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
195 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
198 | 198 | |
199 | - if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
200 | - $tip = esc_attr( $option['desc'] ); |
|
199 | + if (isset($option['desc']) && !empty($option['help-tip'])) { |
|
200 | + $tip = esc_attr($option['desc']); |
|
201 | 201 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
202 | - unset( $option['desc'] ); |
|
202 | + unset($option['desc']); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // Loop through all tabs. |
206 | 206 | add_settings_field( |
207 | 207 | 'wpinv_settings[' . $option['id'] . ']', |
208 | 208 | $name, |
209 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
209 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
210 | 210 | $section, |
211 | 211 | $section, |
212 | 212 | array( |
213 | 213 | 'section' => $section, |
214 | - 'id' => isset( $option['id'] ) ? $option['id'] : null, |
|
215 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
214 | + 'id' => isset($option['id']) ? $option['id'] : null, |
|
215 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
216 | 216 | 'name' => $name, |
217 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
218 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
219 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
220 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
221 | - 'min' => isset( $option['min'] ) ? $option['min'] : null, |
|
222 | - 'max' => isset( $option['max'] ) ? $option['max'] : null, |
|
223 | - 'step' => isset( $option['step'] ) ? $option['step'] : null, |
|
224 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
225 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
226 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
227 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
228 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
229 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
230 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
231 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
217 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
218 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
219 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
220 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
221 | + 'min' => isset($option['min']) ? $option['min'] : null, |
|
222 | + 'max' => isset($option['max']) ? $option['max'] : null, |
|
223 | + 'step' => isset($option['step']) ? $option['step'] : null, |
|
224 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
225 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
226 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
227 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
228 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
229 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
230 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
231 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
233 | 233 | ) |
234 | 234 | ); |
235 | 235 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return array |
242 | 242 | */ |
243 | 243 | function wpinv_get_registered_settings() { |
244 | - return apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ); |
|
244 | + return apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -249,134 +249,134 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @return array |
251 | 251 | */ |
252 | -function wpinv_settings_sanitize( $input = array() ) { |
|
252 | +function wpinv_settings_sanitize($input = array()) { |
|
253 | 253 | |
254 | 254 | $wpinv_options = wpinv_get_options(); |
255 | 255 | |
256 | - if ( empty( wp_get_raw_referer() ) ) { |
|
256 | + if (empty(wp_get_raw_referer())) { |
|
257 | 257 | return $input; |
258 | 258 | } |
259 | 259 | |
260 | - wp_parse_str( wp_get_raw_referer(), $referrer ); |
|
260 | + wp_parse_str(wp_get_raw_referer(), $referrer); |
|
261 | 261 | |
262 | 262 | $settings = wpinv_get_registered_settings(); |
263 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
264 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
263 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
264 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
265 | 265 | |
266 | 266 | $input = $input ? $input : array(); |
267 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
268 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
267 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
268 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
269 | 269 | |
270 | 270 | // Loop through each setting being saved and pass it through a sanitization filter |
271 | - foreach ( $input as $key => $value ) { |
|
271 | + foreach ($input as $key => $value) { |
|
272 | 272 | |
273 | 273 | // Get the setting type (checkbox, select, etc) |
274 | - $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false; |
|
274 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
275 | 275 | |
276 | - if ( $type ) { |
|
276 | + if ($type) { |
|
277 | 277 | // Field type specific filter |
278 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
278 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | // General filter |
282 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
282 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | // Loop through the whitelist and unset any that are empty for the tab being saved |
286 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
287 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
286 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
287 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
288 | 288 | |
289 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
289 | + $found_settings = array_merge($main_settings, $section_settings); |
|
290 | 290 | |
291 | - if ( ! empty( $found_settings ) ) { |
|
292 | - foreach ( $found_settings as $key => $value ) { |
|
291 | + if (!empty($found_settings)) { |
|
292 | + foreach ($found_settings as $key => $value) { |
|
293 | 293 | |
294 | 294 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
295 | - if ( is_numeric( $key ) ) { |
|
295 | + if (is_numeric($key)) { |
|
296 | 296 | $key = $value['id']; |
297 | 297 | } |
298 | 298 | |
299 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
300 | - unset( $wpinv_options[ $key ] ); |
|
299 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
300 | + unset($wpinv_options[$key]); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | } |
304 | 304 | |
305 | 305 | // Merge our new settings with the existing |
306 | - $output = array_merge( $wpinv_options, $input ); |
|
306 | + $output = array_merge($wpinv_options, $input); |
|
307 | 307 | |
308 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
308 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
309 | 309 | |
310 | 310 | return $output; |
311 | 311 | } |
312 | 312 | |
313 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
313 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
314 | 314 | |
315 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
315 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
316 | 316 | return $input; |
317 | 317 | } |
318 | 318 | |
319 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
319 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
320 | 320 | // Shows an admin notice about upgrading previous order numbers |
321 | - getpaid_session()->set( 'upgrade_sequential', '1' ); |
|
321 | + getpaid_session()->set('upgrade_sequential', '1'); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | return $input; |
325 | 325 | } |
326 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
326 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
327 | 327 | |
328 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
329 | - if( ! wpinv_current_user_can_manage_invoicing() ) { |
|
328 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
329 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
330 | 330 | return $input; |
331 | 331 | } |
332 | 332 | |
333 | - $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
333 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
334 | 334 | |
335 | 335 | $tax_rates = array(); |
336 | 336 | |
337 | - if ( !empty( $new_rates ) ) { |
|
338 | - foreach ( $new_rates as $rate ) { |
|
339 | - if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) { |
|
337 | + if (!empty($new_rates)) { |
|
338 | + foreach ($new_rates as $rate) { |
|
339 | + if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) { |
|
340 | 340 | continue; |
341 | 341 | } |
342 | 342 | |
343 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 ); |
|
343 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4); |
|
344 | 344 | |
345 | 345 | $tax_rates[] = $rate; |
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
349 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
349 | + update_option('wpinv_tax_rates', $tax_rates); |
|
350 | 350 | |
351 | 351 | return $input; |
352 | 352 | } |
353 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
353 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
354 | 354 | |
355 | -function wpinv_sanitize_text_field( $input ) { |
|
356 | - return trim( $input ); |
|
355 | +function wpinv_sanitize_text_field($input) { |
|
356 | + return trim($input); |
|
357 | 357 | } |
358 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
358 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
359 | 359 | |
360 | 360 | function wpinv_get_settings_tabs() { |
361 | 361 | $tabs = array(); |
362 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
363 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
364 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
365 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
366 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
367 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
368 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
369 | - |
|
370 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
362 | + $tabs['general'] = __('General', 'invoicing'); |
|
363 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
364 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
365 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
366 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
367 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
368 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
369 | + |
|
370 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
371 | 371 | } |
372 | 372 | |
373 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
373 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
374 | 374 | $tabs = false; |
375 | 375 | $sections = wpinv_get_registered_settings_sections(); |
376 | 376 | |
377 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
378 | - $tabs = $sections[ $tab ]; |
|
379 | - } else if ( $tab ) { |
|
377 | + if ($tab && !empty($sections[$tab])) { |
|
378 | + $tabs = $sections[$tab]; |
|
379 | + } else if ($tab) { |
|
380 | 380 | $tabs = false; |
381 | 381 | } |
382 | 382 | |
@@ -386,150 +386,150 @@ discard block |
||
386 | 386 | function wpinv_get_registered_settings_sections() { |
387 | 387 | static $sections = false; |
388 | 388 | |
389 | - if ( false !== $sections ) { |
|
389 | + if (false !== $sections) { |
|
390 | 390 | return $sections; |
391 | 391 | } |
392 | 392 | |
393 | 393 | $sections = array( |
394 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
395 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
396 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
397 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
398 | - ) ), |
|
399 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
400 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
401 | - ) ), |
|
402 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
403 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
404 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
405 | - ) ), |
|
406 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
407 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
408 | - ) ), |
|
409 | - 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
|
410 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
411 | - ) ), |
|
412 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
413 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
414 | - 'fields' => __( 'Fields Settings', 'invoicing' ), |
|
415 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
416 | - ) ), |
|
417 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
418 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
419 | - ) ), |
|
394 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
395 | + 'main' => __('General Settings', 'invoicing'), |
|
396 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
397 | + 'labels' => __('Label Texts', 'invoicing'), |
|
398 | + )), |
|
399 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
400 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
401 | + )), |
|
402 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
403 | + 'main' => __('Tax Settings', 'invoicing'), |
|
404 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
405 | + )), |
|
406 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
407 | + 'main' => __('Email Settings', 'invoicing'), |
|
408 | + )), |
|
409 | + 'privacy' => apply_filters('wpinv_settings_sections_privacy', array( |
|
410 | + 'main' => __('Privacy policy', 'invoicing'), |
|
411 | + )), |
|
412 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
413 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
414 | + 'fields' => __('Fields Settings', 'invoicing'), |
|
415 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
416 | + )), |
|
417 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
418 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
419 | + )), |
|
420 | 420 | ); |
421 | 421 | |
422 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
422 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
423 | 423 | |
424 | 424 | return $sections; |
425 | 425 | } |
426 | 426 | |
427 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
427 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
428 | 428 | $pages_options = array(); |
429 | 429 | |
430 | - if( $default_label !== NULL && $default_label !== false ) { |
|
431 | - $pages_options = array( '' => $default_label ); // Blank option |
|
430 | + if ($default_label !== NULL && $default_label !== false) { |
|
431 | + $pages_options = array('' => $default_label); // Blank option |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | $pages = get_pages(); |
435 | - if ( $pages ) { |
|
436 | - foreach ( $pages as $page ) { |
|
435 | + if ($pages) { |
|
436 | + foreach ($pages as $page) { |
|
437 | 437 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
438 | - $pages_options[ $page->ID ] = $title; |
|
438 | + $pages_options[$page->ID] = $title; |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | |
442 | 442 | return $pages_options; |
443 | 443 | } |
444 | 444 | |
445 | -function wpinv_header_callback( $args ) { |
|
446 | - if ( !empty( $args['desc'] ) ) { |
|
445 | +function wpinv_header_callback($args) { |
|
446 | + if (!empty($args['desc'])) { |
|
447 | 447 | echo $args['desc']; |
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
451 | -function wpinv_hidden_callback( $args ) { |
|
451 | +function wpinv_hidden_callback($args) { |
|
452 | 452 | global $wpinv_options; |
453 | 453 | |
454 | - if ( isset( $args['set_value'] ) ) { |
|
454 | + if (isset($args['set_value'])) { |
|
455 | 455 | $value = $args['set_value']; |
456 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
457 | - $value = $wpinv_options[ $args['id'] ]; |
|
456 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
457 | + $value = $wpinv_options[$args['id']]; |
|
458 | 458 | } else { |
459 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
459 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
460 | 460 | } |
461 | 461 | |
462 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
462 | + if (isset($args['faux']) && true === $args['faux']) { |
|
463 | 463 | $args['readonly'] = true; |
464 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
464 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
465 | 465 | $name = ''; |
466 | 466 | } else { |
467 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
467 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
468 | 468 | } |
469 | 469 | |
470 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
470 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
471 | 471 | |
472 | 472 | echo $html; |
473 | 473 | } |
474 | 474 | |
475 | -function wpinv_checkbox_callback( $args ) { |
|
475 | +function wpinv_checkbox_callback($args) { |
|
476 | 476 | global $wpinv_options; |
477 | 477 | |
478 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
478 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
479 | 479 | |
480 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
480 | + if (isset($args['faux']) && true === $args['faux']) { |
|
481 | 481 | $name = ''; |
482 | 482 | } else { |
483 | 483 | $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
484 | 484 | } |
485 | 485 | |
486 | - $std = isset( $args['std'] ) ? $args['std'] : 0; |
|
487 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
488 | - $checked = checked( empty( $value ), false, false ); |
|
486 | + $std = isset($args['std']) ? $args['std'] : 0; |
|
487 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std; |
|
488 | + $checked = checked(empty($value), false, false); |
|
489 | 489 | |
490 | 490 | $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
491 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
491 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
492 | 492 | |
493 | 493 | echo $html; |
494 | 494 | } |
495 | 495 | |
496 | -function wpinv_multicheck_callback( $args ) { |
|
496 | +function wpinv_multicheck_callback($args) { |
|
497 | 497 | global $wpinv_options; |
498 | 498 | |
499 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
500 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
499 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
500 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
501 | 501 | |
502 | - if ( ! empty( $args['options'] ) ) { |
|
502 | + if (!empty($args['options'])) { |
|
503 | 503 | |
504 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
505 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
504 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
505 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std; |
|
506 | 506 | |
507 | 507 | echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
508 | - foreach( $args['options'] as $key => $option ): |
|
509 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
510 | - if ( in_array( $sanitize_key, $value ) ) { |
|
508 | + foreach ($args['options'] as $key => $option): |
|
509 | + $sanitize_key = wpinv_sanitize_key($key); |
|
510 | + if (in_array($sanitize_key, $value)) { |
|
511 | 511 | $enabled = $sanitize_key; |
512 | 512 | } else { |
513 | 513 | $enabled = NULL; |
514 | 514 | } |
515 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
516 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
515 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
516 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>'; |
|
517 | 517 | endforeach; |
518 | 518 | echo '</div>'; |
519 | 519 | echo '<p class="description">' . $args['desc'] . '</p>'; |
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
523 | -function wpinv_payment_icons_callback( $args ) { |
|
523 | +function wpinv_payment_icons_callback($args) { |
|
524 | 524 | global $wpinv_options; |
525 | 525 | |
526 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
526 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
527 | 527 | |
528 | - if ( ! empty( $args['options'] ) ) { |
|
529 | - foreach( $args['options'] as $key => $option ) { |
|
530 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
528 | + if (!empty($args['options'])) { |
|
529 | + foreach ($args['options'] as $key => $option) { |
|
530 | + $sanitize_key = wpinv_sanitize_key($key); |
|
531 | 531 | |
532 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
532 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
533 | 533 | $enabled = $option; |
534 | 534 | } else { |
535 | 535 | $enabled = NULL; |
@@ -537,197 +537,197 @@ discard block |
||
537 | 537 | |
538 | 538 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
539 | 539 | |
540 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
540 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
541 | 541 | |
542 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
543 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
542 | + if (wpinv_string_is_image_url($key)) { |
|
543 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
544 | 544 | } else { |
545 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
545 | + $card = strtolower(str_replace(' ', '', $option)); |
|
546 | 546 | |
547 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
548 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
547 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
548 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
549 | 549 | } else { |
550 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
550 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
551 | 551 | $content_dir = WP_CONTENT_DIR; |
552 | 552 | |
553 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
553 | + if (function_exists('wp_normalize_path')) { |
|
554 | 554 | // Replaces backslashes with forward slashes for Windows systems |
555 | - $image = wp_normalize_path( $image ); |
|
556 | - $content_dir = wp_normalize_path( $content_dir ); |
|
555 | + $image = wp_normalize_path($image); |
|
556 | + $content_dir = wp_normalize_path($content_dir); |
|
557 | 557 | } |
558 | 558 | |
559 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
559 | + $image = str_replace($content_dir, content_url(), $image); |
|
560 | 560 | } |
561 | 561 | |
562 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
562 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
563 | 563 | } |
564 | 564 | echo $option . '</label>'; |
565 | 565 | } |
566 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
566 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
567 | 567 | } |
568 | 568 | } |
569 | 569 | |
570 | -function wpinv_radio_callback( $args ) { |
|
570 | +function wpinv_radio_callback($args) { |
|
571 | 571 | global $wpinv_options; |
572 | 572 | |
573 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
573 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
574 | 574 | |
575 | - foreach ( $args['options'] as $key => $option ) : |
|
576 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
575 | + foreach ($args['options'] as $key => $option) : |
|
576 | + $sanitize_key = wpinv_sanitize_key($key); |
|
577 | 577 | |
578 | 578 | $checked = false; |
579 | 579 | |
580 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
580 | + if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key) |
|
581 | 581 | $checked = true; |
582 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
582 | + elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']])) |
|
583 | 583 | $checked = true; |
584 | 584 | |
585 | 585 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
586 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
586 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>'; |
|
587 | 587 | endforeach; |
588 | 588 | |
589 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
589 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
590 | 590 | } |
591 | 591 | |
592 | -function wpinv_gateways_callback( $args ) { |
|
592 | +function wpinv_gateways_callback($args) { |
|
593 | 593 | global $wpinv_options; |
594 | 594 | |
595 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
595 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
596 | 596 | |
597 | - foreach ( $args['options'] as $key => $option ) : |
|
598 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
597 | + foreach ($args['options'] as $key => $option) : |
|
598 | + $sanitize_key = wpinv_sanitize_key($key); |
|
599 | 599 | |
600 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
600 | + if (isset($wpinv_options['gateways'][$key])) |
|
601 | 601 | $enabled = '1'; |
602 | 602 | else |
603 | 603 | $enabled = null; |
604 | 604 | |
605 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
606 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
605 | + echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
606 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
607 | 607 | endforeach; |
608 | 608 | } |
609 | 609 | |
610 | 610 | function wpinv_gateway_select_callback($args) { |
611 | 611 | global $wpinv_options; |
612 | 612 | |
613 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
614 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
613 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
614 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
615 | 615 | |
616 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
616 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
|
617 | 617 | |
618 | - foreach ( $args['options'] as $key => $option ) : |
|
619 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
620 | - $selected = selected( $key, $args['selected'], false ); |
|
618 | + foreach ($args['options'] as $key => $option) : |
|
619 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
620 | + $selected = selected($key, $args['selected'], false); |
|
621 | 621 | } else { |
622 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
622 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
623 | 623 | } |
624 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
624 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
625 | 625 | endforeach; |
626 | 626 | |
627 | 627 | echo '</select>'; |
628 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
628 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
629 | 629 | } |
630 | 630 | |
631 | -function wpinv_text_callback( $args ) { |
|
631 | +function wpinv_text_callback($args) { |
|
632 | 632 | global $wpinv_options; |
633 | 633 | |
634 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
634 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
635 | 635 | |
636 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
637 | - $value = $wpinv_options[ $args['id'] ]; |
|
636 | + if (isset($wpinv_options[$args['id']])) { |
|
637 | + $value = $wpinv_options[$args['id']]; |
|
638 | 638 | } else { |
639 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
639 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
640 | 640 | } |
641 | 641 | |
642 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
642 | + if (isset($args['faux']) && true === $args['faux']) { |
|
643 | 643 | $args['readonly'] = true; |
644 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
644 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
645 | 645 | $name = ''; |
646 | 646 | } else { |
647 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
647 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
648 | 648 | } |
649 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
649 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
650 | 650 | |
651 | 651 | $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
652 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
653 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
654 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
652 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
653 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>'; |
|
654 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
655 | 655 | |
656 | 656 | echo $html; |
657 | 657 | } |
658 | 658 | |
659 | -function wpinv_number_callback( $args ) { |
|
659 | +function wpinv_number_callback($args) { |
|
660 | 660 | global $wpinv_options; |
661 | 661 | |
662 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
662 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
663 | 663 | |
664 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
665 | - $value = $wpinv_options[ $args['id'] ]; |
|
664 | + if (isset($wpinv_options[$args['id']])) { |
|
665 | + $value = $wpinv_options[$args['id']]; |
|
666 | 666 | } else { |
667 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
667 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
668 | 668 | } |
669 | 669 | |
670 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
670 | + if (isset($args['faux']) && true === $args['faux']) { |
|
671 | 671 | $args['readonly'] = true; |
672 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
672 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
673 | 673 | $name = ''; |
674 | 674 | } else { |
675 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
675 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
676 | 676 | } |
677 | 677 | |
678 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
679 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
680 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
681 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
678 | + $max = isset($args['max']) ? $args['max'] : 999999; |
|
679 | + $min = isset($args['min']) ? $args['min'] : 0; |
|
680 | + $step = isset($args['step']) ? $args['step'] : 1; |
|
681 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
682 | 682 | |
683 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
684 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
685 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
683 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
684 | + $html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
685 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
686 | 686 | |
687 | 687 | echo $html; |
688 | 688 | } |
689 | 689 | |
690 | -function wpinv_textarea_callback( $args ) { |
|
690 | +function wpinv_textarea_callback($args) { |
|
691 | 691 | global $wpinv_options; |
692 | 692 | |
693 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
693 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
694 | 694 | |
695 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
696 | - $value = $wpinv_options[ $args['id'] ]; |
|
695 | + if (isset($wpinv_options[$args['id']])) { |
|
696 | + $value = $wpinv_options[$args['id']]; |
|
697 | 697 | } else { |
698 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
698 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
699 | 699 | } |
700 | 700 | |
701 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
702 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
701 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
702 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
703 | 703 | |
704 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
705 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
704 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
705 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
706 | 706 | |
707 | 707 | echo $html; |
708 | 708 | } |
709 | 709 | |
710 | -function wpinv_password_callback( $args ) { |
|
710 | +function wpinv_password_callback($args) { |
|
711 | 711 | global $wpinv_options; |
712 | 712 | |
713 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
713 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
714 | 714 | |
715 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
716 | - $value = $wpinv_options[ $args['id'] ]; |
|
715 | + if (isset($wpinv_options[$args['id']])) { |
|
716 | + $value = $wpinv_options[$args['id']]; |
|
717 | 717 | } else { |
718 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
718 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
719 | 719 | } |
720 | 720 | |
721 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
722 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
723 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
721 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
722 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
723 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
724 | 724 | |
725 | 725 | echo $html; |
726 | 726 | } |
727 | 727 | |
728 | 728 | function wpinv_missing_callback($args) { |
729 | 729 | printf( |
730 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
730 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
731 | 731 | '<strong>' . $args['id'] . '</strong>' |
732 | 732 | ); |
733 | 733 | } |
@@ -735,134 +735,134 @@ discard block |
||
735 | 735 | function wpinv_select_callback($args) { |
736 | 736 | global $wpinv_options; |
737 | 737 | |
738 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
738 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
739 | 739 | |
740 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
741 | - $value = $wpinv_options[ $args['id'] ]; |
|
740 | + if (isset($wpinv_options[$args['id']])) { |
|
741 | + $value = $wpinv_options[$args['id']]; |
|
742 | 742 | } else { |
743 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
743 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
744 | 744 | } |
745 | 745 | |
746 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
746 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
747 | 747 | $value = $args['selected']; |
748 | 748 | } |
749 | 749 | |
750 | - if ( isset( $args['placeholder'] ) ) { |
|
750 | + if (isset($args['placeholder'])) { |
|
751 | 751 | $placeholder = $args['placeholder']; |
752 | 752 | } else { |
753 | 753 | $placeholder = ''; |
754 | 754 | } |
755 | 755 | |
756 | - if( !empty( $args['onchange'] ) ) { |
|
757 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
756 | + if (!empty($args['onchange'])) { |
|
757 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
758 | 758 | } else { |
759 | 759 | $onchange = ''; |
760 | 760 | } |
761 | 761 | |
762 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
762 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
763 | 763 | |
764 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
764 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" name="wpinv_settings[' . esc_attr($args['id']) . ']" data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />'; |
|
765 | 765 | |
766 | - foreach ( $args['options'] as $option => $name ) { |
|
767 | - $selected = selected( $option, $value, false ); |
|
768 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
766 | + foreach ($args['options'] as $option => $name) { |
|
767 | + $selected = selected($option, $value, false); |
|
768 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | $html .= '</select>'; |
772 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
772 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
773 | 773 | |
774 | 774 | echo $html; |
775 | 775 | } |
776 | 776 | |
777 | -function wpinv_color_select_callback( $args ) { |
|
777 | +function wpinv_color_select_callback($args) { |
|
778 | 778 | global $wpinv_options; |
779 | 779 | |
780 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
780 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
781 | 781 | |
782 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
783 | - $value = $wpinv_options[ $args['id'] ]; |
|
782 | + if (isset($wpinv_options[$args['id']])) { |
|
783 | + $value = $wpinv_options[$args['id']]; |
|
784 | 784 | } else { |
785 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
785 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
786 | 786 | } |
787 | 787 | |
788 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
788 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
789 | 789 | |
790 | - foreach ( $args['options'] as $option => $color ) { |
|
791 | - $selected = selected( $option, $value, false ); |
|
792 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
790 | + foreach ($args['options'] as $option => $color) { |
|
791 | + $selected = selected($option, $value, false); |
|
792 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | $html .= '</select>'; |
796 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
796 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
797 | 797 | |
798 | 798 | echo $html; |
799 | 799 | } |
800 | 800 | |
801 | -function wpinv_rich_editor_callback( $args ) { |
|
801 | +function wpinv_rich_editor_callback($args) { |
|
802 | 802 | global $wpinv_options, $wp_version; |
803 | 803 | |
804 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
804 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
805 | 805 | |
806 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
807 | - $value = $wpinv_options[ $args['id'] ]; |
|
806 | + if (isset($wpinv_options[$args['id']])) { |
|
807 | + $value = $wpinv_options[$args['id']]; |
|
808 | 808 | |
809 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
810 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
809 | + if (empty($args['allow_blank']) && empty($value)) { |
|
810 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
811 | 811 | } |
812 | 812 | } else { |
813 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
813 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
814 | 814 | } |
815 | 815 | |
816 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
816 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
817 | 817 | |
818 | 818 | $html = '<div class="getpaid-settings-editor-input">'; |
819 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
819 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
820 | 820 | ob_start(); |
821 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
821 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false)); |
|
822 | 822 | $html .= ob_get_clean(); |
823 | 823 | } else { |
824 | - $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
824 | + $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
825 | 825 | } |
826 | 826 | |
827 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
827 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
828 | 828 | |
829 | 829 | echo $html; |
830 | 830 | } |
831 | 831 | |
832 | -function wpinv_upload_callback( $args ) { |
|
832 | +function wpinv_upload_callback($args) { |
|
833 | 833 | global $wpinv_options; |
834 | 834 | |
835 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
835 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
836 | 836 | |
837 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
837 | + if (isset($wpinv_options[$args['id']])) { |
|
838 | 838 | $value = $wpinv_options[$args['id']]; |
839 | 839 | } else { |
840 | 840 | $value = isset($args['std']) ? $args['std'] : ''; |
841 | 841 | } |
842 | 842 | |
843 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
844 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
845 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
846 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
843 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
844 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
845 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
846 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
847 | 847 | |
848 | 848 | echo $html; |
849 | 849 | } |
850 | 850 | |
851 | -function wpinv_color_callback( $args ) { |
|
851 | +function wpinv_color_callback($args) { |
|
852 | 852 | global $wpinv_options; |
853 | 853 | |
854 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
854 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
855 | 855 | |
856 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
857 | - $value = $wpinv_options[ $args['id'] ]; |
|
856 | + if (isset($wpinv_options[$args['id']])) { |
|
857 | + $value = $wpinv_options[$args['id']]; |
|
858 | 858 | } else { |
859 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
859 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
860 | 860 | } |
861 | 861 | |
862 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
862 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
863 | 863 | |
864 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
865 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
864 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
865 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
866 | 866 | |
867 | 867 | echo $html; |
868 | 868 | } |
@@ -870,9 +870,9 @@ discard block |
||
870 | 870 | function wpinv_country_states_callback($args) { |
871 | 871 | global $wpinv_options; |
872 | 872 | |
873 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
873 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
874 | 874 | |
875 | - if ( isset( $args['placeholder'] ) ) { |
|
875 | + if (isset($args['placeholder'])) { |
|
876 | 876 | $placeholder = $args['placeholder']; |
877 | 877 | } else { |
878 | 878 | $placeholder = ''; |
@@ -880,16 +880,16 @@ discard block |
||
880 | 880 | |
881 | 881 | $states = wpinv_get_country_states(); |
882 | 882 | |
883 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
884 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
883 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
884 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
885 | 885 | |
886 | - foreach ( $states as $option => $name ) { |
|
887 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
888 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
886 | + foreach ($states as $option => $name) { |
|
887 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
888 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | $html .= '</select>'; |
892 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
892 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
893 | 893 | |
894 | 894 | echo $html; |
895 | 895 | } |
@@ -904,96 +904,96 @@ discard block |
||
904 | 904 | <table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts"> |
905 | 905 | <thead> |
906 | 906 | <tr> |
907 | - <th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
908 | - <th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th> |
|
909 | - <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
910 | - <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
911 | - <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th> |
|
912 | - <th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th> |
|
907 | + <th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th> |
|
908 | + <th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th> |
|
909 | + <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
910 | + <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
911 | + <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th> |
|
912 | + <th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th> |
|
913 | 913 | </tr> |
914 | 914 | </thead> |
915 | 915 | <tbody> |
916 | - <?php if( !empty( $rates ) ) : ?> |
|
917 | - <?php foreach( $rates as $key => $rate ) : ?> |
|
916 | + <?php if (!empty($rates)) : ?> |
|
917 | + <?php foreach ($rates as $key => $rate) : ?> |
|
918 | 918 | <?php |
919 | - $sanitized_key = wpinv_sanitize_key( $key ); |
|
919 | + $sanitized_key = wpinv_sanitize_key($key); |
|
920 | 920 | ?> |
921 | 921 | <tr> |
922 | 922 | <td class="wpinv_tax_country"> |
923 | 923 | <?php |
924 | - echo wpinv_html_select( array( |
|
925 | - 'options' => wpinv_get_country_list( true ), |
|
924 | + echo wpinv_html_select(array( |
|
925 | + 'options' => wpinv_get_country_list(true), |
|
926 | 926 | 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
927 | 927 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
928 | 928 | 'selected' => $rate['country'], |
929 | 929 | 'show_option_all' => false, |
930 | 930 | 'show_option_none' => false, |
931 | 931 | 'class' => 'wpinv-tax-country wpi_select2', |
932 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
933 | - ) ); |
|
932 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
933 | + )); |
|
934 | 934 | ?> |
935 | 935 | </td> |
936 | 936 | <td class="wpinv_tax_state"> |
937 | 937 | <?php |
938 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
939 | - if( !empty( $states ) ) { |
|
940 | - echo wpinv_html_select( array( |
|
941 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
938 | + $states = wpinv_get_country_states($rate['country']); |
|
939 | + if (!empty($states)) { |
|
940 | + echo wpinv_html_select(array( |
|
941 | + 'options' => array_merge(array('' => ''), $states), |
|
942 | 942 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
943 | 943 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
944 | 944 | 'selected' => $rate['state'], |
945 | 945 | 'show_option_all' => false, |
946 | 946 | 'show_option_none' => false, |
947 | 947 | 'class' => 'wpi_select2', |
948 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
949 | - ) ); |
|
948 | + 'placeholder' => __('Choose a state', 'invoicing') |
|
949 | + )); |
|
950 | 950 | } else { |
951 | - echo wpinv_html_text( array( |
|
951 | + echo wpinv_html_text(array( |
|
952 | 952 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
953 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
953 | + 'value' => !empty($rate['state']) ? $rate['state'] : '', |
|
954 | 954 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
955 | - ) ); |
|
955 | + )); |
|
956 | 956 | } |
957 | 957 | ?> |
958 | 958 | </td> |
959 | 959 | <td class="wpinv_tax_global"> |
960 | - <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
|
961 | - <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
960 | + <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/> |
|
961 | + <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
962 | 962 | </td> |
963 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td> |
|
964 | - <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td> |
|
965 | - <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
963 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td> |
|
964 | + <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td> |
|
965 | + <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
966 | 966 | </tr> |
967 | 967 | <?php endforeach; ?> |
968 | 968 | <?php else : ?> |
969 | 969 | <tr> |
970 | 970 | <td class="wpinv_tax_country"> |
971 | 971 | <?php |
972 | - echo wpinv_html_select( array( |
|
973 | - 'options' => wpinv_get_country_list( true ), |
|
972 | + echo wpinv_html_select(array( |
|
973 | + 'options' => wpinv_get_country_list(true), |
|
974 | 974 | 'name' => 'tax_rates[0][country]', |
975 | 975 | 'show_option_all' => false, |
976 | 976 | 'show_option_none' => false, |
977 | 977 | 'class' => 'wpinv-tax-country wpi_select2', |
978 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
979 | - ) ); ?> |
|
978 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
979 | + )); ?> |
|
980 | 980 | </td> |
981 | 981 | <td class="wpinv_tax_state"> |
982 | - <?php echo wpinv_html_text( array( |
|
982 | + <?php echo wpinv_html_text(array( |
|
983 | 983 | 'name' => 'tax_rates[0][state]' |
984 | - ) ); ?> |
|
984 | + )); ?> |
|
985 | 985 | </td> |
986 | 986 | <td class="wpinv_tax_global"> |
987 | 987 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
988 | - <label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
988 | + <label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
989 | 989 | </td> |
990 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td> |
|
990 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float) wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float) wpinv_get_option('tax_rate', 0); ?>"/></td> |
|
991 | 991 | <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td> |
992 | - <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
992 | + <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
993 | 993 | </tr> |
994 | 994 | <?php endif; ?> |
995 | 995 | </tbody> |
996 | - <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
|
996 | + <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot> |
|
997 | 997 | </table> |
998 | 998 | <?php |
999 | 999 | echo ob_get_clean(); |
@@ -1004,76 +1004,76 @@ discard block |
||
1004 | 1004 | ob_start(); ?> |
1005 | 1005 | </td><tr> |
1006 | 1006 | <td colspan="2" class="wpinv_tools_tdbox"> |
1007 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
1008 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
1007 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
1008 | + <?php do_action('wpinv_tools_before'); ?> |
|
1009 | 1009 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
1010 | 1010 | <thead> |
1011 | 1011 | <tr> |
1012 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
1013 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
1014 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
1012 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
1013 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
1014 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
1015 | 1015 | </tr> |
1016 | 1016 | </thead> |
1017 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1017 | + <?php do_action('wpinv_tools_row'); ?> |
|
1018 | 1018 | <tbody> |
1019 | 1019 | </tbody> |
1020 | 1020 | </table> |
1021 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1021 | + <?php do_action('wpinv_tools_after'); ?> |
|
1022 | 1022 | <?php |
1023 | 1023 | echo ob_get_clean(); |
1024 | 1024 | } |
1025 | 1025 | |
1026 | -function wpinv_descriptive_text_callback( $args ) { |
|
1027 | - echo wp_kses_post( $args['desc'] ); |
|
1026 | +function wpinv_descriptive_text_callback($args) { |
|
1027 | + echo wp_kses_post($args['desc']); |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | -function wpinv_hook_callback( $args ) { |
|
1031 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1030 | +function wpinv_hook_callback($args) { |
|
1031 | + do_action('wpinv_' . $args['id'], $args); |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | function wpinv_set_settings_cap() { |
1035 | 1035 | return wpinv_get_capability(); |
1036 | 1036 | } |
1037 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1037 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1038 | 1038 | |
1039 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
1040 | - if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) { |
|
1041 | - $value = wpinv_sanitize_amount( $value, 4 ); |
|
1039 | +function wpinv_settings_sanitize_input($value, $key) { |
|
1040 | + if ($key == 'tax_rate' || $key == 'eu_fallback_rate') { |
|
1041 | + $value = wpinv_sanitize_amount($value, 4); |
|
1042 | 1042 | $value = $value >= 100 ? 99 : $value; |
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | return $value; |
1046 | 1046 | } |
1047 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
1047 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
1048 | 1048 | |
1049 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1050 | - $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1051 | - $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1049 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1050 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1051 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1052 | 1052 | |
1053 | - if ( $old != $new ) { |
|
1054 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1053 | + if ($old != $new) { |
|
1054 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1055 | 1055 | } |
1056 | 1056 | } |
1057 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1058 | -add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1059 | -add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1060 | -add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1061 | -add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1062 | -add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1063 | -add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1064 | -add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1065 | -add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1066 | -add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1067 | -add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1068 | - |
|
1069 | -function wpinv_settings_tab_bottom_emails( $active_tab, $section ) { |
|
1057 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1058 | +add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1059 | +add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1060 | +add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1061 | +add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1062 | +add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1063 | +add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1064 | +add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1065 | +add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1066 | +add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1067 | +add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1068 | + |
|
1069 | +function wpinv_settings_tab_bottom_emails($active_tab, $section) { |
|
1070 | 1070 | ?> |
1071 | 1071 | <div class="wpinv-email-wc-row "> |
1072 | 1072 | <div class="wpinv-email-wc-td"> |
1073 | - <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3> |
|
1073 | + <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3> |
|
1074 | 1074 | <p class="wpinv-email-wc-description"> |
1075 | 1075 | <?php |
1076 | - $description = __( 'The following wildcards can be used in email subjects, heading and content:<br> |
|
1076 | + $description = __('The following wildcards can be used in email subjects, heading and content:<br> |
|
1077 | 1077 | <strong>{site_title} :</strong> Site Title<br> |
1078 | 1078 | <strong>{name} :</strong> Customer\'s full name<br> |
1079 | 1079 | <strong>{first_name} :</strong> Customer\'s first name<br> |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | <strong>{invoice_due_date} :</strong> The date the invoice is due<br> |
1088 | 1088 | <strong>{date} :</strong> Today\'s date.<br> |
1089 | 1089 | <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br> |
1090 | - <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' ); |
|
1090 | + <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing'); |
|
1091 | 1091 | echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section); |
1092 | 1092 | ?> |
1093 | 1093 | </p> |
@@ -13,616 +13,616 @@ discard block |
||
13 | 13 | class GetPaid_Post_Types_Admin { |
14 | 14 | |
15 | 15 | /** |
16 | - * Hook in methods. |
|
17 | - */ |
|
18 | - public static function init() { |
|
19 | - |
|
20 | - // Init metaboxes. |
|
21 | - GetPaid_Metaboxes::init(); |
|
22 | - |
|
23 | - // Filter the post updated messages. |
|
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
25 | - |
|
26 | - // Filter post actions. |
|
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - |
|
29 | - // Invoice table columns. |
|
30 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
31 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
32 | - |
|
33 | - // Items table columns. |
|
34 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
35 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
36 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
37 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
38 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
39 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
40 | - |
|
41 | - // Payment forms columns. |
|
42 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
43 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
44 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
45 | - |
|
46 | - // Discount table columns. |
|
47 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
48 | - |
|
49 | - // Deleting posts. |
|
50 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
51 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Post updated messages. |
|
56 | - */ |
|
57 | - public static function post_updated_messages( $messages ) { |
|
58 | - global $post; |
|
59 | - |
|
60 | - $messages['wpi_discount'] = array( |
|
61 | - 0 => '', |
|
62 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
63 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
64 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
65 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
66 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
67 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
68 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
69 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
70 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
71 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
72 | - ); |
|
73 | - |
|
74 | - $messages['wpi_payment_form'] = array( |
|
75 | - 0 => '', |
|
76 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
77 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
78 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
79 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
80 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
81 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
83 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
84 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
85 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
86 | - ); |
|
87 | - |
|
88 | - return $messages; |
|
89 | - |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Post row actions. |
|
94 | - */ |
|
95 | - public static function post_row_actions( $actions, $post ) { |
|
96 | - |
|
97 | - $post = get_post( $post ); |
|
98 | - |
|
99 | - // We do not want to edit the default payment form. |
|
100 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
101 | - unset( $actions['trash'] ); |
|
102 | - unset( $actions['inline hide-if-no-js'] ); |
|
103 | - } |
|
104 | - |
|
105 | - return $actions; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Returns an array of invoice table columns. |
|
110 | - */ |
|
111 | - public static function invoice_columns( $columns ) { |
|
112 | - |
|
113 | - $columns = array( |
|
114 | - 'cb' => $columns['cb'], |
|
115 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
116 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
117 | - 'invoice_date' => __( 'Date', 'invoicing' ), |
|
118 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
119 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
120 | - 'status' => __( 'Status', 'invoicing' ), |
|
121 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
122 | - ); |
|
123 | - |
|
124 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * Displays invoice table columns. |
|
129 | - */ |
|
130 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
131 | - |
|
132 | - $invoice = new WPInv_Invoice( $post_id ); |
|
133 | - |
|
134 | - switch ( $column_name ) { |
|
135 | - |
|
136 | - case 'invoice_date' : |
|
137 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
138 | - $date = getpaid_format_date_value( $date_time ); |
|
139 | - echo "<span title='$date_time'>$date</span>"; |
|
140 | - break; |
|
141 | - |
|
142 | - case 'amount' : |
|
143 | - |
|
144 | - $amount = $invoice->get_total(); |
|
145 | - $formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() ); |
|
146 | - |
|
147 | - if ( $invoice->is_refunded() ) { |
|
148 | - $refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() ); |
|
149 | - echo "<del>$formated_amount</del><ins>$refunded_amount</ins>"; |
|
150 | - } else { |
|
151 | - |
|
152 | - $discount = $invoice->get_total_discount(); |
|
153 | - |
|
154 | - if ( ! empty( $discount ) ) { |
|
155 | - $new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() ); |
|
156 | - echo "<del>$new_amount</del><ins>$formated_amount</ins>"; |
|
157 | - } else { |
|
158 | - echo $formated_amount; |
|
159 | - } |
|
160 | - |
|
161 | - } |
|
162 | - |
|
163 | - break; |
|
164 | - |
|
165 | - case 'status' : |
|
166 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
167 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
168 | - |
|
169 | - // If it is paid, show the gateway title. |
|
170 | - if ( $invoice->is_paid() ) { |
|
171 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
172 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
16 | + * Hook in methods. |
|
17 | + */ |
|
18 | + public static function init() { |
|
173 | 19 | |
174 | - echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
175 | - } else { |
|
176 | - echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
177 | - } |
|
20 | + // Init metaboxes. |
|
21 | + GetPaid_Metaboxes::init(); |
|
178 | 22 | |
179 | - // If it is not paid, display the overdue and view status. |
|
180 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
23 | + // Filter the post updated messages. |
|
24 | + add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
181 | 25 | |
182 | - // Invoice view status. |
|
183 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
184 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
185 | - } else { |
|
186 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
187 | - } |
|
26 | + // Filter post actions. |
|
27 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
188 | 28 | |
189 | - // Display the overview status. |
|
190 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
191 | - $due_date = $invoice->get_due_date(); |
|
192 | - $fomatted = getpaid_format_date( $due_date ); |
|
29 | + // Invoice table columns. |
|
30 | + add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
31 | + add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
193 | 32 | |
194 | - if ( ! empty( $fomatted ) ) { |
|
195 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
196 | - echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
197 | - } |
|
198 | - } |
|
33 | + // Items table columns. |
|
34 | + add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
35 | + add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
36 | + add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
37 | + add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
38 | + add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
39 | + add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
199 | 40 | |
200 | - } |
|
41 | + // Payment forms columns. |
|
42 | + add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
43 | + add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
44 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
201 | 45 | |
202 | - break; |
|
46 | + // Discount table columns. |
|
47 | + add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
203 | 48 | |
204 | - case 'recurring': |
|
49 | + // Deleting posts. |
|
50 | + add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
51 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
52 | + } |
|
205 | 53 | |
206 | - if ( $invoice->is_recurring() ) { |
|
207 | - echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
208 | - } else { |
|
209 | - echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
210 | - } |
|
211 | - break; |
|
54 | + /** |
|
55 | + * Post updated messages. |
|
56 | + */ |
|
57 | + public static function post_updated_messages( $messages ) { |
|
58 | + global $post; |
|
59 | + |
|
60 | + $messages['wpi_discount'] = array( |
|
61 | + 0 => '', |
|
62 | + 1 => __( 'Discount updated.', 'invoicing' ), |
|
63 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
64 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
65 | + 4 => __( 'Discount updated.', 'invoicing' ), |
|
66 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
67 | + 6 => __( 'Discount updated.', 'invoicing' ), |
|
68 | + 7 => __( 'Discount saved.', 'invoicing' ), |
|
69 | + 8 => __( 'Discount submitted.', 'invoicing' ), |
|
70 | + 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
71 | + 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
72 | + ); |
|
73 | + |
|
74 | + $messages['wpi_payment_form'] = array( |
|
75 | + 0 => '', |
|
76 | + 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
77 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
78 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
79 | + 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
80 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
81 | + 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | + 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
83 | + 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
84 | + 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
85 | + 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
86 | + ); |
|
87 | + |
|
88 | + return $messages; |
|
89 | + |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Post row actions. |
|
94 | + */ |
|
95 | + public static function post_row_actions( $actions, $post ) { |
|
96 | + |
|
97 | + $post = get_post( $post ); |
|
98 | + |
|
99 | + // We do not want to edit the default payment form. |
|
100 | + if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
101 | + unset( $actions['trash'] ); |
|
102 | + unset( $actions['inline hide-if-no-js'] ); |
|
103 | + } |
|
104 | + |
|
105 | + return $actions; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Returns an array of invoice table columns. |
|
110 | + */ |
|
111 | + public static function invoice_columns( $columns ) { |
|
112 | + |
|
113 | + $columns = array( |
|
114 | + 'cb' => $columns['cb'], |
|
115 | + 'number' => __( 'Invoice', 'invoicing' ), |
|
116 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
117 | + 'invoice_date' => __( 'Date', 'invoicing' ), |
|
118 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
119 | + 'recurring' => __( 'Recurring', 'invoicing' ), |
|
120 | + 'status' => __( 'Status', 'invoicing' ), |
|
121 | + 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
122 | + ); |
|
123 | + |
|
124 | + return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * Displays invoice table columns. |
|
129 | + */ |
|
130 | + public static function display_invoice_columns( $column_name, $post_id ) { |
|
131 | + |
|
132 | + $invoice = new WPInv_Invoice( $post_id ); |
|
133 | + |
|
134 | + switch ( $column_name ) { |
|
135 | + |
|
136 | + case 'invoice_date' : |
|
137 | + $date_time = esc_attr( $invoice->get_created_date() ); |
|
138 | + $date = getpaid_format_date_value( $date_time ); |
|
139 | + echo "<span title='$date_time'>$date</span>"; |
|
140 | + break; |
|
141 | + |
|
142 | + case 'amount' : |
|
143 | + |
|
144 | + $amount = $invoice->get_total(); |
|
145 | + $formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() ); |
|
146 | + |
|
147 | + if ( $invoice->is_refunded() ) { |
|
148 | + $refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() ); |
|
149 | + echo "<del>$formated_amount</del><ins>$refunded_amount</ins>"; |
|
150 | + } else { |
|
151 | + |
|
152 | + $discount = $invoice->get_total_discount(); |
|
153 | + |
|
154 | + if ( ! empty( $discount ) ) { |
|
155 | + $new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() ); |
|
156 | + echo "<del>$new_amount</del><ins>$formated_amount</ins>"; |
|
157 | + } else { |
|
158 | + echo $formated_amount; |
|
159 | + } |
|
160 | + |
|
161 | + } |
|
162 | + |
|
163 | + break; |
|
164 | + |
|
165 | + case 'status' : |
|
166 | + $status = sanitize_text_field( $invoice->get_status() ); |
|
167 | + $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
168 | + |
|
169 | + // If it is paid, show the gateway title. |
|
170 | + if ( $invoice->is_paid() ) { |
|
171 | + $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
172 | + $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
212 | 173 | |
213 | - case 'number' : |
|
174 | + echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
175 | + } else { |
|
176 | + echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
177 | + } |
|
214 | 178 | |
215 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
216 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
217 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
179 | + // If it is not paid, display the overdue and view status. |
|
180 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
218 | 181 | |
219 | - echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
182 | + // Invoice view status. |
|
183 | + if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
184 | + echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
185 | + } else { |
|
186 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
187 | + } |
|
220 | 188 | |
221 | - break; |
|
189 | + // Display the overview status. |
|
190 | + if ( wpinv_get_option( 'overdue_active' ) ) { |
|
191 | + $due_date = $invoice->get_due_date(); |
|
192 | + $fomatted = getpaid_format_date( $due_date ); |
|
222 | 193 | |
223 | - case 'customer' : |
|
194 | + if ( ! empty( $fomatted ) ) { |
|
195 | + $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
196 | + echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
197 | + } |
|
198 | + } |
|
199 | + |
|
200 | + } |
|
201 | + |
|
202 | + break; |
|
203 | + |
|
204 | + case 'recurring': |
|
205 | + |
|
206 | + if ( $invoice->is_recurring() ) { |
|
207 | + echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
208 | + } else { |
|
209 | + echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
210 | + } |
|
211 | + break; |
|
212 | + |
|
213 | + case 'number' : |
|
214 | + |
|
215 | + $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
216 | + $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
217 | + $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
218 | + |
|
219 | + echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
220 | + |
|
221 | + break; |
|
222 | + |
|
223 | + case 'customer' : |
|
224 | 224 | |
225 | - $customer_name = $invoice->get_user_full_name(); |
|
225 | + $customer_name = $invoice->get_user_full_name(); |
|
226 | 226 | |
227 | - if ( empty( $customer_name ) ) { |
|
228 | - $customer_name = $invoice->get_email(); |
|
229 | - } |
|
227 | + if ( empty( $customer_name ) ) { |
|
228 | + $customer_name = $invoice->get_email(); |
|
229 | + } |
|
230 | 230 | |
231 | - if ( ! empty( $customer_name ) ) { |
|
232 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
233 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
234 | - echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
235 | - } else { |
|
236 | - echo '<div>—</div>'; |
|
237 | - } |
|
231 | + if ( ! empty( $customer_name ) ) { |
|
232 | + $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
233 | + $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
234 | + echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
235 | + } else { |
|
236 | + echo '<div>—</div>'; |
|
237 | + } |
|
238 | + |
|
239 | + break; |
|
240 | + |
|
241 | + case 'wpi_actions' : |
|
242 | + |
|
243 | + if ( $invoice->is_draft() ) { |
|
244 | + return; |
|
245 | + } |
|
246 | + |
|
247 | + $url = esc_url( $invoice->get_view_url() ); |
|
248 | + $print = esc_attr__( 'Print invoice', 'invoicing' ); |
|
249 | + echo " <a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>"; |
|
250 | + |
|
251 | + $url = esc_url( |
|
252 | + wp_nonce_url( |
|
253 | + add_query_arg( |
|
254 | + array( |
|
255 | + 'getpaid-admin-action' => 'send_invoice', |
|
256 | + 'invoice_id' => $invoice->get_id() |
|
257 | + ) |
|
258 | + ), |
|
259 | + 'getpaid-nonce', |
|
260 | + 'getpaid-nonce' |
|
261 | + ) |
|
262 | + ); |
|
263 | + |
|
264 | + $send = esc_attr__( 'Send invoice to customer', 'invoicing' ); |
|
265 | + echo " <a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>"; |
|
266 | + |
|
267 | + break; |
|
268 | + } |
|
238 | 269 | |
239 | - break; |
|
270 | + } |
|
240 | 271 | |
241 | - case 'wpi_actions' : |
|
242 | - |
|
243 | - if ( $invoice->is_draft() ) { |
|
244 | - return; |
|
245 | - } |
|
246 | - |
|
247 | - $url = esc_url( $invoice->get_view_url() ); |
|
248 | - $print = esc_attr__( 'Print invoice', 'invoicing' ); |
|
249 | - echo " <a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>"; |
|
272 | + /** |
|
273 | + * Returns an array of payment forms table columns. |
|
274 | + */ |
|
275 | + public static function payment_form_columns( $columns ) { |
|
250 | 276 | |
251 | - $url = esc_url( |
|
252 | - wp_nonce_url( |
|
253 | - add_query_arg( |
|
254 | - array( |
|
255 | - 'getpaid-admin-action' => 'send_invoice', |
|
256 | - 'invoice_id' => $invoice->get_id() |
|
257 | - ) |
|
258 | - ), |
|
259 | - 'getpaid-nonce', |
|
260 | - 'getpaid-nonce' |
|
261 | - ) |
|
262 | - ); |
|
277 | + $columns = array( |
|
278 | + 'cb' => $columns['cb'], |
|
279 | + 'title' => __( 'Name', 'invoicing' ), |
|
280 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
281 | + 'earnings' => __( 'Revenue', 'invoicing' ), |
|
282 | + 'refunds' => __( 'Refunded', 'invoicing' ), |
|
283 | + 'items' => __( 'Items', 'invoicing' ), |
|
284 | + 'date' => __( 'Date', 'invoicing' ), |
|
285 | + ); |
|
263 | 286 | |
264 | - $send = esc_attr__( 'Send invoice to customer', 'invoicing' ); |
|
265 | - echo " <a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>"; |
|
287 | + return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
266 | 288 | |
267 | - break; |
|
268 | - } |
|
289 | + } |
|
269 | 290 | |
270 | - } |
|
291 | + /** |
|
292 | + * Displays payment form table columns. |
|
293 | + */ |
|
294 | + public static function display_payment_form_columns( $column_name, $post_id ) { |
|
271 | 295 | |
272 | - /** |
|
273 | - * Returns an array of payment forms table columns. |
|
274 | - */ |
|
275 | - public static function payment_form_columns( $columns ) { |
|
296 | + // Retrieve the payment form. |
|
297 | + $form = new GetPaid_Payment_Form( $post_id ); |
|
276 | 298 | |
277 | - $columns = array( |
|
278 | - 'cb' => $columns['cb'], |
|
279 | - 'title' => __( 'Name', 'invoicing' ), |
|
280 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
281 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
282 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
283 | - 'items' => __( 'Items', 'invoicing' ), |
|
284 | - 'date' => __( 'Date', 'invoicing' ), |
|
285 | - ); |
|
299 | + switch ( $column_name ) { |
|
286 | 300 | |
287 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
301 | + case 'earnings' : |
|
302 | + echo wpinv_price( wpinv_format_amount( $form->get_earned() ) ); |
|
303 | + break; |
|
288 | 304 | |
289 | - } |
|
305 | + case 'refunds' : |
|
306 | + echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
307 | + break; |
|
290 | 308 | |
291 | - /** |
|
292 | - * Displays payment form table columns. |
|
293 | - */ |
|
294 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
309 | + case 'refunds' : |
|
310 | + echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
311 | + break; |
|
295 | 312 | |
296 | - // Retrieve the payment form. |
|
297 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
313 | + case 'shortcode' : |
|
298 | 314 | |
299 | - switch ( $column_name ) { |
|
315 | + if ( $form->is_default() ) { |
|
316 | + echo '—'; |
|
317 | + } else { |
|
318 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
319 | + } |
|
300 | 320 | |
301 | - case 'earnings' : |
|
302 | - echo wpinv_price( wpinv_format_amount( $form->get_earned() ) ); |
|
303 | - break; |
|
321 | + break; |
|
304 | 322 | |
305 | - case 'refunds' : |
|
306 | - echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
307 | - break; |
|
323 | + case 'items' : |
|
308 | 324 | |
309 | - case 'refunds' : |
|
310 | - echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
311 | - break; |
|
325 | + $items = $form->get_items(); |
|
312 | 326 | |
313 | - case 'shortcode' : |
|
327 | + if ( $form->is_default() || empty( $items ) ) { |
|
328 | + echo '—'; |
|
329 | + return; |
|
330 | + } |
|
314 | 331 | |
315 | - if ( $form->is_default() ) { |
|
316 | - echo '—'; |
|
317 | - } else { |
|
318 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
319 | - } |
|
332 | + $_items = array(); |
|
320 | 333 | |
321 | - break; |
|
334 | + foreach ( $items as $item ) { |
|
335 | + $url = $item->get_edit_url(); |
|
322 | 336 | |
323 | - case 'items' : |
|
337 | + if ( empty( $url ) ) { |
|
338 | + $_items[] = sanitize_text_field( $item->get_name() ); |
|
339 | + } else { |
|
340 | + $_items[] = sprintf( |
|
341 | + '<a href="%s">%s</a>', |
|
342 | + esc_url( $url ), |
|
343 | + sanitize_text_field( $item->get_name() ) |
|
344 | + ); |
|
345 | + } |
|
324 | 346 | |
325 | - $items = $form->get_items(); |
|
347 | + } |
|
326 | 348 | |
327 | - if ( $form->is_default() || empty( $items ) ) { |
|
328 | - echo '—'; |
|
329 | - return; |
|
330 | - } |
|
349 | + echo implode( '<br>', $_items ); |
|
331 | 350 | |
332 | - $_items = array(); |
|
351 | + break; |
|
333 | 352 | |
334 | - foreach ( $items as $item ) { |
|
335 | - $url = $item->get_edit_url(); |
|
353 | + } |
|
336 | 354 | |
337 | - if ( empty( $url ) ) { |
|
338 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
339 | - } else { |
|
340 | - $_items[] = sprintf( |
|
341 | - '<a href="%s">%s</a>', |
|
342 | - esc_url( $url ), |
|
343 | - sanitize_text_field( $item->get_name() ) |
|
344 | - ); |
|
345 | - } |
|
355 | + } |
|
346 | 356 | |
347 | - } |
|
357 | + /** |
|
358 | + * Filters post states. |
|
359 | + */ |
|
360 | + public static function filter_payment_form_state( $post_states, $post ) { |
|
348 | 361 | |
349 | - echo implode( '<br>', $_items ); |
|
362 | + if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
363 | + $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
364 | + } |
|
365 | + |
|
366 | + return $post_states; |
|
350 | 367 | |
351 | - break; |
|
368 | + } |
|
352 | 369 | |
353 | - } |
|
370 | + /** |
|
371 | + * Returns an array of coupon table columns. |
|
372 | + */ |
|
373 | + public static function discount_columns( $columns ) { |
|
374 | + |
|
375 | + $columns = array( |
|
376 | + 'cb' => $columns['cb'], |
|
377 | + 'title' => __( 'Name', 'invoicing' ), |
|
378 | + 'code' => __( 'Code', 'invoicing' ), |
|
379 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
380 | + 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
381 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
382 | + 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
383 | + ); |
|
384 | + |
|
385 | + return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
386 | + } |
|
354 | 387 | |
355 | - } |
|
388 | + /** |
|
389 | + * Filters post states. |
|
390 | + */ |
|
391 | + public static function filter_discount_state( $post_states, $post ) { |
|
356 | 392 | |
357 | - /** |
|
358 | - * Filters post states. |
|
359 | - */ |
|
360 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
393 | + if ( 'wpi_discount' == $post->post_type ) { |
|
361 | 394 | |
362 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
363 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
364 | - } |
|
365 | - |
|
366 | - return $post_states; |
|
395 | + $discount = new WPInv_Discount( $post ); |
|
367 | 396 | |
368 | - } |
|
397 | + $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
369 | 398 | |
370 | - /** |
|
371 | - * Returns an array of coupon table columns. |
|
372 | - */ |
|
373 | - public static function discount_columns( $columns ) { |
|
399 | + if ( $status != 'publish' ) { |
|
400 | + return array( |
|
401 | + 'discount_status' => wpinv_discount_status( $status ), |
|
402 | + ); |
|
403 | + } |
|
374 | 404 | |
375 | - $columns = array( |
|
376 | - 'cb' => $columns['cb'], |
|
377 | - 'title' => __( 'Name', 'invoicing' ), |
|
378 | - 'code' => __( 'Code', 'invoicing' ), |
|
379 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
380 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
381 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
382 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
383 | - ); |
|
405 | + return array(); |
|
384 | 406 | |
385 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
386 | - } |
|
407 | + } |
|
387 | 408 | |
388 | - /** |
|
389 | - * Filters post states. |
|
390 | - */ |
|
391 | - public static function filter_discount_state( $post_states, $post ) { |
|
409 | + return $post_states; |
|
392 | 410 | |
393 | - if ( 'wpi_discount' == $post->post_type ) { |
|
411 | + } |
|
394 | 412 | |
395 | - $discount = new WPInv_Discount( $post ); |
|
413 | + /** |
|
414 | + * Returns an array of items table columns. |
|
415 | + */ |
|
416 | + public static function item_columns( $columns ) { |
|
417 | + global $wpinv_euvat; |
|
418 | + |
|
419 | + $columns = array( |
|
420 | + 'cb' => $columns['cb'], |
|
421 | + 'title' => __( 'Name', 'invoicing' ), |
|
422 | + 'price' => __( 'Price', 'invoicing' ), |
|
423 | + 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
424 | + 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
425 | + 'type' => __( 'Type', 'invoicing' ), |
|
426 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
427 | + ); |
|
428 | + |
|
429 | + if ( ! $wpinv_euvat->allow_vat_rules() ) { |
|
430 | + unset( $columns['vat_rule'] ); |
|
431 | + } |
|
396 | 432 | |
397 | - $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
433 | + if ( ! $wpinv_euvat->allow_vat_classes() ) { |
|
434 | + unset( $columns['vat_class'] ); |
|
435 | + } |
|
398 | 436 | |
399 | - if ( $status != 'publish' ) { |
|
400 | - return array( |
|
401 | - 'discount_status' => wpinv_discount_status( $status ), |
|
402 | - ); |
|
403 | - } |
|
437 | + return apply_filters( 'wpi_item_table_columns', $columns ); |
|
438 | + } |
|
404 | 439 | |
405 | - return array(); |
|
440 | + /** |
|
441 | + * Returns an array of sortable items table columns. |
|
442 | + */ |
|
443 | + public static function sortable_item_columns( $columns ) { |
|
444 | + |
|
445 | + return array_merge( |
|
446 | + $columns, |
|
447 | + array( |
|
448 | + 'price' => 'price', |
|
449 | + 'vat_rule' => 'vat_rule', |
|
450 | + 'vat_class' => 'vat_class', |
|
451 | + 'type' => 'type', |
|
452 | + ) |
|
453 | + ); |
|
454 | + |
|
455 | + } |
|
406 | 456 | |
407 | - } |
|
457 | + /** |
|
458 | + * Displays items table columns. |
|
459 | + */ |
|
460 | + public static function display_item_columns( $column_name, $post_id ) { |
|
461 | + global $wpinv_euvat; |
|
408 | 462 | |
409 | - return $post_states; |
|
463 | + $item = new WPInv_Item( $post_id ); |
|
410 | 464 | |
411 | - } |
|
465 | + switch ( $column_name ) { |
|
412 | 466 | |
413 | - /** |
|
414 | - * Returns an array of items table columns. |
|
415 | - */ |
|
416 | - public static function item_columns( $columns ) { |
|
417 | - global $wpinv_euvat; |
|
467 | + case 'price' : |
|
418 | 468 | |
419 | - $columns = array( |
|
420 | - 'cb' => $columns['cb'], |
|
421 | - 'title' => __( 'Name', 'invoicing' ), |
|
422 | - 'price' => __( 'Price', 'invoicing' ), |
|
423 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
424 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
425 | - 'type' => __( 'Type', 'invoicing' ), |
|
426 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
427 | - ); |
|
469 | + if ( ! $item->is_recurring() ) { |
|
470 | + echo $item->get_the_price(); |
|
471 | + break; |
|
472 | + } |
|
428 | 473 | |
429 | - if ( ! $wpinv_euvat->allow_vat_rules() ) { |
|
430 | - unset( $columns['vat_rule'] ); |
|
431 | - } |
|
474 | + $price = wp_sprintf( |
|
475 | + __( '%s / %s', 'invoicing' ), |
|
476 | + $item->get_the_price(), |
|
477 | + WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->get_recurring_period(), $item->get_recurring_interval() ) |
|
478 | + ); |
|
432 | 479 | |
433 | - if ( ! $wpinv_euvat->allow_vat_classes() ) { |
|
434 | - unset( $columns['vat_class'] ); |
|
435 | - } |
|
480 | + if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
481 | + echo $price; |
|
482 | + break; |
|
483 | + } |
|
436 | 484 | |
437 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
438 | - } |
|
485 | + echo $item->get_the_initial_price(); |
|
439 | 486 | |
440 | - /** |
|
441 | - * Returns an array of sortable items table columns. |
|
442 | - */ |
|
443 | - public static function sortable_item_columns( $columns ) { |
|
487 | + echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
488 | + break; |
|
444 | 489 | |
445 | - return array_merge( |
|
446 | - $columns, |
|
447 | - array( |
|
448 | - 'price' => 'price', |
|
449 | - 'vat_rule' => 'vat_rule', |
|
450 | - 'vat_class' => 'vat_class', |
|
451 | - 'type' => 'type', |
|
452 | - ) |
|
453 | - ); |
|
490 | + case 'vat_rule' : |
|
491 | + echo $wpinv_euvat->item_rule_label( $item->get_id() ); |
|
492 | + break; |
|
454 | 493 | |
455 | - } |
|
494 | + case 'vat_class' : |
|
495 | + echo $wpinv_euvat->item_class_label( $item->get_id() ); |
|
496 | + break; |
|
456 | 497 | |
457 | - /** |
|
458 | - * Displays items table columns. |
|
459 | - */ |
|
460 | - public static function display_item_columns( $column_name, $post_id ) { |
|
461 | - global $wpinv_euvat; |
|
498 | + case 'shortcode' : |
|
499 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
500 | + break; |
|
462 | 501 | |
463 | - $item = new WPInv_Item( $post_id ); |
|
502 | + case 'type' : |
|
503 | + echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
504 | + break; |
|
464 | 505 | |
465 | - switch ( $column_name ) { |
|
506 | + } |
|
466 | 507 | |
467 | - case 'price' : |
|
508 | + } |
|
468 | 509 | |
469 | - if ( ! $item->is_recurring() ) { |
|
470 | - echo $item->get_the_price(); |
|
471 | - break; |
|
472 | - } |
|
510 | + /** |
|
511 | + * Lets users filter items using taxes. |
|
512 | + */ |
|
513 | + public static function add_item_filters( $post_type ) { |
|
514 | + $wpinv_euvat = getpaid_tax(); |
|
515 | + |
|
516 | + // Abort if we're not dealing with items. |
|
517 | + if ( $post_type != 'wpi_item' ) { |
|
518 | + return; |
|
519 | + } |
|
520 | + |
|
521 | + // Filter by vat rules. |
|
522 | + if ( $wpinv_euvat->allow_vat_rules() ) { |
|
523 | + |
|
524 | + // Sanitize selected vat rule. |
|
525 | + $vat_rule = ''; |
|
526 | + $vat_rules = $wpinv_euvat->get_rules(); |
|
527 | + if ( isset( $_GET['vat_rule'] ) ) { |
|
528 | + $vat_rule = $_GET['vat_rule']; |
|
529 | + } |
|
530 | + |
|
531 | + // Filter by VAT rule. |
|
532 | + echo wpinv_html_select( |
|
533 | + array( |
|
534 | + 'options' => array_merge( |
|
535 | + array( |
|
536 | + '' => __( 'All VAT rules', 'invoicing' ) |
|
537 | + ), |
|
538 | + $vat_rules |
|
539 | + ), |
|
540 | + 'name' => 'vat_rule', |
|
541 | + 'id' => 'vat_rule', |
|
542 | + 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
543 | + 'show_option_all' => false, |
|
544 | + 'show_option_none' => false, |
|
545 | + 'class' => 'gdmbx2-text-medium', |
|
546 | + ) |
|
547 | + ); |
|
548 | + |
|
549 | + // Filter by VAT class. |
|
550 | + } |
|
473 | 551 | |
474 | - $price = wp_sprintf( |
|
475 | - __( '%s / %s', 'invoicing' ), |
|
476 | - $item->get_the_price(), |
|
477 | - WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->get_recurring_period(), $item->get_recurring_interval() ) |
|
478 | - ); |
|
552 | + // Filter by vat class. |
|
553 | + if ( $wpinv_euvat->allow_vat_classes() ) { |
|
554 | + |
|
555 | + // Sanitize selected vat rule. |
|
556 | + $vat_class = ''; |
|
557 | + $vat_classes = $wpinv_euvat->get_all_classes(); |
|
558 | + if ( isset( $_GET['vat_class'] ) ) { |
|
559 | + $vat_class = $_GET['vat_class']; |
|
560 | + } |
|
561 | + |
|
562 | + echo wpinv_html_select( |
|
563 | + array( |
|
564 | + 'options' => array_merge( |
|
565 | + array( |
|
566 | + '' => __( 'All VAT classes', 'invoicing' ) |
|
567 | + ), |
|
568 | + $vat_classes |
|
569 | + ), |
|
570 | + 'name' => 'vat_class', |
|
571 | + 'id' => 'vat_class', |
|
572 | + 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
573 | + 'show_option_all' => false, |
|
574 | + 'show_option_none' => false, |
|
575 | + 'class' => 'gdmbx2-text-medium', |
|
576 | + ) |
|
577 | + ); |
|
479 | 578 | |
480 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
481 | - echo $price; |
|
482 | - break; |
|
483 | - } |
|
579 | + } |
|
484 | 580 | |
485 | - echo $item->get_the_initial_price(); |
|
581 | + // Filter by item type. |
|
582 | + $type = ''; |
|
583 | + if ( isset( $_GET['type'] ) ) { |
|
584 | + $type = $_GET['type']; |
|
585 | + } |
|
486 | 586 | |
487 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
488 | - break; |
|
587 | + echo wpinv_html_select( |
|
588 | + array( |
|
589 | + 'options' => array_merge( |
|
590 | + array( |
|
591 | + '' => __( 'All item types', 'invoicing' ) |
|
592 | + ), |
|
593 | + wpinv_get_item_types() |
|
594 | + ), |
|
595 | + 'name' => 'type', |
|
596 | + 'id' => 'type', |
|
597 | + 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
598 | + 'show_option_all' => false, |
|
599 | + 'show_option_none' => false, |
|
600 | + 'class' => 'gdmbx2-text-medium', |
|
601 | + ) |
|
602 | + ); |
|
603 | + |
|
604 | + } |
|
489 | 605 | |
490 | - case 'vat_rule' : |
|
491 | - echo $wpinv_euvat->item_rule_label( $item->get_id() ); |
|
492 | - break; |
|
606 | + /** |
|
607 | + * Filters the item query. |
|
608 | + */ |
|
609 | + public static function filter_item_query( $query ) { |
|
493 | 610 | |
494 | - case 'vat_class' : |
|
495 | - echo $wpinv_euvat->item_class_label( $item->get_id() ); |
|
496 | - break; |
|
611 | + // modify the query only if it admin and main query. |
|
612 | + if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
613 | + return $query; |
|
614 | + } |
|
497 | 615 | |
498 | - case 'shortcode' : |
|
499 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
500 | - break; |
|
616 | + // we want to modify the query for our items. |
|
617 | + if ( 'wpi_item' != $query->query['post_type'] ){ |
|
618 | + return $query; |
|
619 | + } |
|
501 | 620 | |
502 | - case 'type' : |
|
503 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
504 | - break; |
|
621 | + if ( empty( $query->query_vars['meta_query'] ) ) { |
|
622 | + $query->query_vars['meta_query'] = array(); |
|
623 | + } |
|
505 | 624 | |
506 | - } |
|
507 | - |
|
508 | - } |
|
509 | - |
|
510 | - /** |
|
511 | - * Lets users filter items using taxes. |
|
512 | - */ |
|
513 | - public static function add_item_filters( $post_type ) { |
|
514 | - $wpinv_euvat = getpaid_tax(); |
|
515 | - |
|
516 | - // Abort if we're not dealing with items. |
|
517 | - if ( $post_type != 'wpi_item' ) { |
|
518 | - return; |
|
519 | - } |
|
520 | - |
|
521 | - // Filter by vat rules. |
|
522 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
523 | - |
|
524 | - // Sanitize selected vat rule. |
|
525 | - $vat_rule = ''; |
|
526 | - $vat_rules = $wpinv_euvat->get_rules(); |
|
527 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
528 | - $vat_rule = $_GET['vat_rule']; |
|
529 | - } |
|
530 | - |
|
531 | - // Filter by VAT rule. |
|
532 | - echo wpinv_html_select( |
|
533 | - array( |
|
534 | - 'options' => array_merge( |
|
535 | - array( |
|
536 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
537 | - ), |
|
538 | - $vat_rules |
|
539 | - ), |
|
540 | - 'name' => 'vat_rule', |
|
541 | - 'id' => 'vat_rule', |
|
542 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
543 | - 'show_option_all' => false, |
|
544 | - 'show_option_none' => false, |
|
545 | - 'class' => 'gdmbx2-text-medium', |
|
546 | - ) |
|
547 | - ); |
|
548 | - |
|
549 | - // Filter by VAT class. |
|
550 | - } |
|
551 | - |
|
552 | - // Filter by vat class. |
|
553 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
554 | - |
|
555 | - // Sanitize selected vat rule. |
|
556 | - $vat_class = ''; |
|
557 | - $vat_classes = $wpinv_euvat->get_all_classes(); |
|
558 | - if ( isset( $_GET['vat_class'] ) ) { |
|
559 | - $vat_class = $_GET['vat_class']; |
|
560 | - } |
|
561 | - |
|
562 | - echo wpinv_html_select( |
|
563 | - array( |
|
564 | - 'options' => array_merge( |
|
565 | - array( |
|
566 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
567 | - ), |
|
568 | - $vat_classes |
|
569 | - ), |
|
570 | - 'name' => 'vat_class', |
|
571 | - 'id' => 'vat_class', |
|
572 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
573 | - 'show_option_all' => false, |
|
574 | - 'show_option_none' => false, |
|
575 | - 'class' => 'gdmbx2-text-medium', |
|
576 | - ) |
|
577 | - ); |
|
578 | - |
|
579 | - } |
|
580 | - |
|
581 | - // Filter by item type. |
|
582 | - $type = ''; |
|
583 | - if ( isset( $_GET['type'] ) ) { |
|
584 | - $type = $_GET['type']; |
|
585 | - } |
|
586 | - |
|
587 | - echo wpinv_html_select( |
|
588 | - array( |
|
589 | - 'options' => array_merge( |
|
590 | - array( |
|
591 | - '' => __( 'All item types', 'invoicing' ) |
|
592 | - ), |
|
593 | - wpinv_get_item_types() |
|
594 | - ), |
|
595 | - 'name' => 'type', |
|
596 | - 'id' => 'type', |
|
597 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
598 | - 'show_option_all' => false, |
|
599 | - 'show_option_none' => false, |
|
600 | - 'class' => 'gdmbx2-text-medium', |
|
601 | - ) |
|
602 | - ); |
|
603 | - |
|
604 | - } |
|
605 | - |
|
606 | - /** |
|
607 | - * Filters the item query. |
|
608 | - */ |
|
609 | - public static function filter_item_query( $query ) { |
|
610 | - |
|
611 | - // modify the query only if it admin and main query. |
|
612 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
613 | - return $query; |
|
614 | - } |
|
615 | - |
|
616 | - // we want to modify the query for our items. |
|
617 | - if ( 'wpi_item' != $query->query['post_type'] ){ |
|
618 | - return $query; |
|
619 | - } |
|
620 | - |
|
621 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
622 | - $query->query_vars['meta_query'] = array(); |
|
623 | - } |
|
624 | - |
|
625 | - // Filter vat rule type |
|
625 | + // Filter vat rule type |
|
626 | 626 | if ( ! empty( $_GET['vat_rule'] ) ) { |
627 | 627 | $query->query_vars['meta_query'][] = array( |
628 | 628 | 'key' => '_wpinv_vat_rule', |
@@ -647,94 +647,94 @@ discard block |
||
647 | 647 | 'value' => sanitize_text_field( $_GET['type'] ), |
648 | 648 | 'compare' => '=' |
649 | 649 | ); |
650 | - } |
|
651 | - |
|
652 | - } |
|
653 | - |
|
654 | - /** |
|
655 | - * Reorders items. |
|
656 | - */ |
|
657 | - public static function reorder_items( $vars ) { |
|
658 | - global $typenow; |
|
659 | - |
|
660 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
661 | - return $vars; |
|
662 | - } |
|
663 | - |
|
664 | - // By item type. |
|
665 | - if ( 'type' == $vars['orderby'] ) { |
|
666 | - return array_merge( |
|
667 | - $vars, |
|
668 | - array( |
|
669 | - 'meta_key' => '_wpinv_type', |
|
670 | - 'orderby' => 'meta_value' |
|
671 | - ) |
|
672 | - ); |
|
673 | - } |
|
674 | - |
|
675 | - // By vat class. |
|
676 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
677 | - return array_merge( |
|
678 | - $vars, |
|
679 | - array( |
|
680 | - 'meta_key' => '_wpinv_vat_class', |
|
681 | - 'orderby' => 'meta_value' |
|
682 | - ) |
|
683 | - ); |
|
684 | - } |
|
685 | - |
|
686 | - // By vat rule. |
|
687 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
688 | - return array_merge( |
|
689 | - $vars, |
|
690 | - array( |
|
691 | - 'meta_key' => '_wpinv_vat_rule', |
|
692 | - 'orderby' => 'meta_value' |
|
693 | - ) |
|
694 | - ); |
|
695 | - } |
|
696 | - |
|
697 | - // By price. |
|
698 | - if ( 'price' == $vars['orderby'] ) { |
|
699 | - return array_merge( |
|
700 | - $vars, |
|
701 | - array( |
|
702 | - 'meta_key' => '_wpinv_price', |
|
703 | - 'orderby' => 'meta_value_num' |
|
704 | - ) |
|
705 | - ); |
|
706 | - } |
|
707 | - |
|
708 | - return $vars; |
|
709 | - |
|
710 | - } |
|
711 | - |
|
712 | - /** |
|
713 | - * Fired when deleting a post. |
|
714 | - */ |
|
715 | - public static function delete_post( $post_id ) { |
|
716 | - |
|
717 | - switch ( get_post_type( $post_id ) ) { |
|
718 | - |
|
719 | - case 'wpi_item' : |
|
720 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
721 | - break; |
|
722 | - |
|
723 | - case 'wpi_payment_form' : |
|
724 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
725 | - break; |
|
726 | - |
|
727 | - case 'wpi_discount' : |
|
728 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
729 | - break; |
|
730 | - |
|
731 | - case 'wpi_invoice' : |
|
732 | - $invoice = new WPInv_Invoice( $post_id ); |
|
733 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
734 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
735 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
736 | - break; |
|
737 | - } |
|
738 | - } |
|
650 | + } |
|
651 | + |
|
652 | + } |
|
653 | + |
|
654 | + /** |
|
655 | + * Reorders items. |
|
656 | + */ |
|
657 | + public static function reorder_items( $vars ) { |
|
658 | + global $typenow; |
|
659 | + |
|
660 | + if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
661 | + return $vars; |
|
662 | + } |
|
663 | + |
|
664 | + // By item type. |
|
665 | + if ( 'type' == $vars['orderby'] ) { |
|
666 | + return array_merge( |
|
667 | + $vars, |
|
668 | + array( |
|
669 | + 'meta_key' => '_wpinv_type', |
|
670 | + 'orderby' => 'meta_value' |
|
671 | + ) |
|
672 | + ); |
|
673 | + } |
|
674 | + |
|
675 | + // By vat class. |
|
676 | + if ( 'vat_class' == $vars['orderby'] ) { |
|
677 | + return array_merge( |
|
678 | + $vars, |
|
679 | + array( |
|
680 | + 'meta_key' => '_wpinv_vat_class', |
|
681 | + 'orderby' => 'meta_value' |
|
682 | + ) |
|
683 | + ); |
|
684 | + } |
|
685 | + |
|
686 | + // By vat rule. |
|
687 | + if ( 'vat_rule' == $vars['orderby'] ) { |
|
688 | + return array_merge( |
|
689 | + $vars, |
|
690 | + array( |
|
691 | + 'meta_key' => '_wpinv_vat_rule', |
|
692 | + 'orderby' => 'meta_value' |
|
693 | + ) |
|
694 | + ); |
|
695 | + } |
|
696 | + |
|
697 | + // By price. |
|
698 | + if ( 'price' == $vars['orderby'] ) { |
|
699 | + return array_merge( |
|
700 | + $vars, |
|
701 | + array( |
|
702 | + 'meta_key' => '_wpinv_price', |
|
703 | + 'orderby' => 'meta_value_num' |
|
704 | + ) |
|
705 | + ); |
|
706 | + } |
|
707 | + |
|
708 | + return $vars; |
|
709 | + |
|
710 | + } |
|
711 | + |
|
712 | + /** |
|
713 | + * Fired when deleting a post. |
|
714 | + */ |
|
715 | + public static function delete_post( $post_id ) { |
|
716 | + |
|
717 | + switch ( get_post_type( $post_id ) ) { |
|
718 | + |
|
719 | + case 'wpi_item' : |
|
720 | + do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
721 | + break; |
|
722 | + |
|
723 | + case 'wpi_payment_form' : |
|
724 | + do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
725 | + break; |
|
726 | + |
|
727 | + case 'wpi_discount' : |
|
728 | + do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
729 | + break; |
|
730 | + |
|
731 | + case 'wpi_invoice' : |
|
732 | + $invoice = new WPInv_Invoice( $post_id ); |
|
733 | + do_action( "getpaid_before_delete_invoice", $invoice ); |
|
734 | + $invoice->get_data_store()->delete_items( $invoice ); |
|
735 | + $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
736 | + break; |
|
737 | + } |
|
738 | + } |
|
739 | 739 | |
740 | 740 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Post types Admin Class |
@@ -21,68 +21,68 @@ discard block |
||
21 | 21 | GetPaid_Metaboxes::init(); |
22 | 22 | |
23 | 23 | // Filter the post updated messages. |
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
24 | + add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages'); |
|
25 | 25 | |
26 | 26 | // Filter post actions. |
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
28 | 28 | |
29 | 29 | // Invoice table columns. |
30 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
31 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
30 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
31 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
32 | 32 | |
33 | 33 | // Items table columns. |
34 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
35 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
36 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
37 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
38 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
39 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
34 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
35 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
36 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
37 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
38 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
39 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
40 | 40 | |
41 | 41 | // Payment forms columns. |
42 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
43 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
44 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
42 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
43 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
44 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
45 | 45 | |
46 | 46 | // Discount table columns. |
47 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
47 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
48 | 48 | |
49 | 49 | // Deleting posts. |
50 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
51 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
50 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
51 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Post updated messages. |
56 | 56 | */ |
57 | - public static function post_updated_messages( $messages ) { |
|
57 | + public static function post_updated_messages($messages) { |
|
58 | 58 | global $post; |
59 | 59 | |
60 | 60 | $messages['wpi_discount'] = array( |
61 | 61 | 0 => '', |
62 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
63 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
64 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
65 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
66 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
67 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
68 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
69 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
70 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
71 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
62 | + 1 => __('Discount updated.', 'invoicing'), |
|
63 | + 2 => __('Custom field updated.', 'invoicing'), |
|
64 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
65 | + 4 => __('Discount updated.', 'invoicing'), |
|
66 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
67 | + 6 => __('Discount updated.', 'invoicing'), |
|
68 | + 7 => __('Discount saved.', 'invoicing'), |
|
69 | + 8 => __('Discount submitted.', 'invoicing'), |
|
70 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
71 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
72 | 72 | ); |
73 | 73 | |
74 | 74 | $messages['wpi_payment_form'] = array( |
75 | 75 | 0 => '', |
76 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
77 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
78 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
79 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
80 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
81 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
83 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
84 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
85 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
76 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
77 | + 2 => __('Custom field updated.', 'invoicing'), |
|
78 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
79 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
80 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
81 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
82 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
83 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
84 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
85 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
86 | 86 | ); |
87 | 87 | |
88 | 88 | return $messages; |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | /** |
93 | 93 | * Post row actions. |
94 | 94 | */ |
95 | - public static function post_row_actions( $actions, $post ) { |
|
95 | + public static function post_row_actions($actions, $post) { |
|
96 | 96 | |
97 | - $post = get_post( $post ); |
|
97 | + $post = get_post($post); |
|
98 | 98 | |
99 | 99 | // We do not want to edit the default payment form. |
100 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
101 | - unset( $actions['trash'] ); |
|
102 | - unset( $actions['inline hide-if-no-js'] ); |
|
100 | + if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) { |
|
101 | + unset($actions['trash']); |
|
102 | + unset($actions['inline hide-if-no-js']); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $actions; |
@@ -108,51 +108,51 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * Returns an array of invoice table columns. |
110 | 110 | */ |
111 | - public static function invoice_columns( $columns ) { |
|
111 | + public static function invoice_columns($columns) { |
|
112 | 112 | |
113 | 113 | $columns = array( |
114 | 114 | 'cb' => $columns['cb'], |
115 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
116 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
117 | - 'invoice_date' => __( 'Date', 'invoicing' ), |
|
118 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
119 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
120 | - 'status' => __( 'Status', 'invoicing' ), |
|
121 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
115 | + 'number' => __('Invoice', 'invoicing'), |
|
116 | + 'customer' => __('Customer', 'invoicing'), |
|
117 | + 'invoice_date' => __('Date', 'invoicing'), |
|
118 | + 'amount' => __('Amount', 'invoicing'), |
|
119 | + 'recurring' => __('Recurring', 'invoicing'), |
|
120 | + 'status' => __('Status', 'invoicing'), |
|
121 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
122 | 122 | ); |
123 | 123 | |
124 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
124 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Displays invoice table columns. |
129 | 129 | */ |
130 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
130 | + public static function display_invoice_columns($column_name, $post_id) { |
|
131 | 131 | |
132 | - $invoice = new WPInv_Invoice( $post_id ); |
|
132 | + $invoice = new WPInv_Invoice($post_id); |
|
133 | 133 | |
134 | - switch ( $column_name ) { |
|
134 | + switch ($column_name) { |
|
135 | 135 | |
136 | 136 | case 'invoice_date' : |
137 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
138 | - $date = getpaid_format_date_value( $date_time ); |
|
137 | + $date_time = esc_attr($invoice->get_created_date()); |
|
138 | + $date = getpaid_format_date_value($date_time); |
|
139 | 139 | echo "<span title='$date_time'>$date</span>"; |
140 | 140 | break; |
141 | 141 | |
142 | 142 | case 'amount' : |
143 | 143 | |
144 | 144 | $amount = $invoice->get_total(); |
145 | - $formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() ); |
|
145 | + $formated_amount = wpinv_price(wpinv_format_amount($amount), $invoice->get_currency()); |
|
146 | 146 | |
147 | - if ( $invoice->is_refunded() ) { |
|
148 | - $refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() ); |
|
147 | + if ($invoice->is_refunded()) { |
|
148 | + $refunded_amount = wpinv_price(wpinv_format_amount(0), $invoice->get_currency()); |
|
149 | 149 | echo "<del>$formated_amount</del><ins>$refunded_amount</ins>"; |
150 | 150 | } else { |
151 | 151 | |
152 | 152 | $discount = $invoice->get_total_discount(); |
153 | 153 | |
154 | - if ( ! empty( $discount ) ) { |
|
155 | - $new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() ); |
|
154 | + if (!empty($discount)) { |
|
155 | + $new_amount = wpinv_price(wpinv_format_amount($amount + $discount), $invoice->get_currency()); |
|
156 | 156 | echo "<del>$new_amount</del><ins>$formated_amount</ins>"; |
157 | 157 | } else { |
158 | 158 | echo $formated_amount; |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | break; |
164 | 164 | |
165 | 165 | case 'status' : |
166 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
167 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
166 | + $status = sanitize_text_field($invoice->get_status()); |
|
167 | + $status_label = sanitize_text_field($invoice->get_status_nicename()); |
|
168 | 168 | |
169 | 169 | // If it is paid, show the gateway title. |
170 | - if ( $invoice->is_paid() ) { |
|
171 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
172 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
170 | + if ($invoice->is_paid()) { |
|
171 | + $gateway = sanitize_text_field($invoice->get_gateway_title()); |
|
172 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway); |
|
173 | 173 | |
174 | 174 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
175 | 175 | } else { |
@@ -177,22 +177,22 @@ discard block |
||
177 | 177 | } |
178 | 178 | |
179 | 179 | // If it is not paid, display the overdue and view status. |
180 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
180 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
181 | 181 | |
182 | 182 | // Invoice view status. |
183 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
184 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
183 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
184 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
185 | 185 | } else { |
186 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
186 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Display the overview status. |
190 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
190 | + if (wpinv_get_option('overdue_active')) { |
|
191 | 191 | $due_date = $invoice->get_due_date(); |
192 | - $fomatted = getpaid_format_date( $due_date ); |
|
192 | + $fomatted = getpaid_format_date($due_date); |
|
193 | 193 | |
194 | - if ( ! empty( $fomatted ) ) { |
|
195 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
194 | + if (!empty($fomatted)) { |
|
195 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
196 | 196 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
197 | 197 | } |
198 | 198 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | case 'recurring': |
205 | 205 | |
206 | - if ( $invoice->is_recurring() ) { |
|
206 | + if ($invoice->is_recurring()) { |
|
207 | 207 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
208 | 208 | } else { |
209 | 209 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | |
213 | 213 | case 'number' : |
214 | 214 | |
215 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
216 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
217 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
215 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
216 | + $invoice_number = sanitize_text_field($invoice->get_number()); |
|
217 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
218 | 218 | |
219 | 219 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
220 | 220 | |
@@ -224,13 +224,13 @@ discard block |
||
224 | 224 | |
225 | 225 | $customer_name = $invoice->get_user_full_name(); |
226 | 226 | |
227 | - if ( empty( $customer_name ) ) { |
|
227 | + if (empty($customer_name)) { |
|
228 | 228 | $customer_name = $invoice->get_email(); |
229 | 229 | } |
230 | 230 | |
231 | - if ( ! empty( $customer_name ) ) { |
|
232 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
233 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
231 | + if (!empty($customer_name)) { |
|
232 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
233 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
234 | 234 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
235 | 235 | } else { |
236 | 236 | echo '<div>—</div>'; |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | |
241 | 241 | case 'wpi_actions' : |
242 | 242 | |
243 | - if ( $invoice->is_draft() ) { |
|
243 | + if ($invoice->is_draft()) { |
|
244 | 244 | return; |
245 | 245 | } |
246 | 246 | |
247 | - $url = esc_url( $invoice->get_view_url() ); |
|
248 | - $print = esc_attr__( 'Print invoice', 'invoicing' ); |
|
247 | + $url = esc_url($invoice->get_view_url()); |
|
248 | + $print = esc_attr__('Print invoice', 'invoicing'); |
|
249 | 249 | echo " <a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>"; |
250 | 250 | |
251 | 251 | $url = esc_url( |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | ) |
262 | 262 | ); |
263 | 263 | |
264 | - $send = esc_attr__( 'Send invoice to customer', 'invoicing' ); |
|
264 | + $send = esc_attr__('Send invoice to customer', 'invoicing'); |
|
265 | 265 | echo " <a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>"; |
266 | 266 | |
267 | 267 | break; |
@@ -272,50 +272,50 @@ discard block |
||
272 | 272 | /** |
273 | 273 | * Returns an array of payment forms table columns. |
274 | 274 | */ |
275 | - public static function payment_form_columns( $columns ) { |
|
275 | + public static function payment_form_columns($columns) { |
|
276 | 276 | |
277 | 277 | $columns = array( |
278 | 278 | 'cb' => $columns['cb'], |
279 | - 'title' => __( 'Name', 'invoicing' ), |
|
280 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
281 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
282 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
283 | - 'items' => __( 'Items', 'invoicing' ), |
|
284 | - 'date' => __( 'Date', 'invoicing' ), |
|
279 | + 'title' => __('Name', 'invoicing'), |
|
280 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
281 | + 'earnings' => __('Revenue', 'invoicing'), |
|
282 | + 'refunds' => __('Refunded', 'invoicing'), |
|
283 | + 'items' => __('Items', 'invoicing'), |
|
284 | + 'date' => __('Date', 'invoicing'), |
|
285 | 285 | ); |
286 | 286 | |
287 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
287 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
288 | 288 | |
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
292 | 292 | * Displays payment form table columns. |
293 | 293 | */ |
294 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
294 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
295 | 295 | |
296 | 296 | // Retrieve the payment form. |
297 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
297 | + $form = new GetPaid_Payment_Form($post_id); |
|
298 | 298 | |
299 | - switch ( $column_name ) { |
|
299 | + switch ($column_name) { |
|
300 | 300 | |
301 | 301 | case 'earnings' : |
302 | - echo wpinv_price( wpinv_format_amount( $form->get_earned() ) ); |
|
302 | + echo wpinv_price(wpinv_format_amount($form->get_earned())); |
|
303 | 303 | break; |
304 | 304 | |
305 | 305 | case 'refunds' : |
306 | - echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
306 | + echo wpinv_price(wpinv_format_amount($form->get_refunded())); |
|
307 | 307 | break; |
308 | 308 | |
309 | 309 | case 'refunds' : |
310 | - echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
310 | + echo wpinv_price(wpinv_format_amount($form->get_refunded())); |
|
311 | 311 | break; |
312 | 312 | |
313 | 313 | case 'shortcode' : |
314 | 314 | |
315 | - if ( $form->is_default() ) { |
|
315 | + if ($form->is_default()) { |
|
316 | 316 | echo '—'; |
317 | 317 | } else { |
318 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
318 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | break; |
@@ -324,29 +324,29 @@ discard block |
||
324 | 324 | |
325 | 325 | $items = $form->get_items(); |
326 | 326 | |
327 | - if ( $form->is_default() || empty( $items ) ) { |
|
327 | + if ($form->is_default() || empty($items)) { |
|
328 | 328 | echo '—'; |
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | 332 | $_items = array(); |
333 | 333 | |
334 | - foreach ( $items as $item ) { |
|
334 | + foreach ($items as $item) { |
|
335 | 335 | $url = $item->get_edit_url(); |
336 | 336 | |
337 | - if ( empty( $url ) ) { |
|
338 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
337 | + if (empty($url)) { |
|
338 | + $_items[] = sanitize_text_field($item->get_name()); |
|
339 | 339 | } else { |
340 | 340 | $_items[] = sprintf( |
341 | 341 | '<a href="%s">%s</a>', |
342 | - esc_url( $url ), |
|
343 | - sanitize_text_field( $item->get_name() ) |
|
342 | + esc_url($url), |
|
343 | + sanitize_text_field($item->get_name()) |
|
344 | 344 | ); |
345 | 345 | } |
346 | 346 | |
347 | 347 | } |
348 | 348 | |
349 | - echo implode( '<br>', $_items ); |
|
349 | + echo implode('<br>', $_items); |
|
350 | 350 | |
351 | 351 | break; |
352 | 352 | |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | /** |
358 | 358 | * Filters post states. |
359 | 359 | */ |
360 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
360 | + public static function filter_payment_form_state($post_states, $post) { |
|
361 | 361 | |
362 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
363 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
362 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
363 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | return $post_states; |
@@ -370,35 +370,35 @@ discard block |
||
370 | 370 | /** |
371 | 371 | * Returns an array of coupon table columns. |
372 | 372 | */ |
373 | - public static function discount_columns( $columns ) { |
|
373 | + public static function discount_columns($columns) { |
|
374 | 374 | |
375 | 375 | $columns = array( |
376 | 376 | 'cb' => $columns['cb'], |
377 | - 'title' => __( 'Name', 'invoicing' ), |
|
378 | - 'code' => __( 'Code', 'invoicing' ), |
|
379 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
380 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
381 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
382 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
377 | + 'title' => __('Name', 'invoicing'), |
|
378 | + 'code' => __('Code', 'invoicing'), |
|
379 | + 'amount' => __('Amount', 'invoicing'), |
|
380 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
381 | + 'start_date' => __('Start Date', 'invoicing'), |
|
382 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
383 | 383 | ); |
384 | 384 | |
385 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
385 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
389 | 389 | * Filters post states. |
390 | 390 | */ |
391 | - public static function filter_discount_state( $post_states, $post ) { |
|
391 | + public static function filter_discount_state($post_states, $post) { |
|
392 | 392 | |
393 | - if ( 'wpi_discount' == $post->post_type ) { |
|
393 | + if ('wpi_discount' == $post->post_type) { |
|
394 | 394 | |
395 | - $discount = new WPInv_Discount( $post ); |
|
395 | + $discount = new WPInv_Discount($post); |
|
396 | 396 | |
397 | 397 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
398 | 398 | |
399 | - if ( $status != 'publish' ) { |
|
399 | + if ($status != 'publish') { |
|
400 | 400 | return array( |
401 | - 'discount_status' => wpinv_discount_status( $status ), |
|
401 | + 'discount_status' => wpinv_discount_status($status), |
|
402 | 402 | ); |
403 | 403 | } |
404 | 404 | |
@@ -413,34 +413,34 @@ discard block |
||
413 | 413 | /** |
414 | 414 | * Returns an array of items table columns. |
415 | 415 | */ |
416 | - public static function item_columns( $columns ) { |
|
416 | + public static function item_columns($columns) { |
|
417 | 417 | global $wpinv_euvat; |
418 | 418 | |
419 | 419 | $columns = array( |
420 | 420 | 'cb' => $columns['cb'], |
421 | - 'title' => __( 'Name', 'invoicing' ), |
|
422 | - 'price' => __( 'Price', 'invoicing' ), |
|
423 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
424 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
425 | - 'type' => __( 'Type', 'invoicing' ), |
|
426 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
421 | + 'title' => __('Name', 'invoicing'), |
|
422 | + 'price' => __('Price', 'invoicing'), |
|
423 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
424 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
425 | + 'type' => __('Type', 'invoicing'), |
|
426 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
427 | 427 | ); |
428 | 428 | |
429 | - if ( ! $wpinv_euvat->allow_vat_rules() ) { |
|
430 | - unset( $columns['vat_rule'] ); |
|
429 | + if (!$wpinv_euvat->allow_vat_rules()) { |
|
430 | + unset($columns['vat_rule']); |
|
431 | 431 | } |
432 | 432 | |
433 | - if ( ! $wpinv_euvat->allow_vat_classes() ) { |
|
434 | - unset( $columns['vat_class'] ); |
|
433 | + if (!$wpinv_euvat->allow_vat_classes()) { |
|
434 | + unset($columns['vat_class']); |
|
435 | 435 | } |
436 | 436 | |
437 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
437 | + return apply_filters('wpi_item_table_columns', $columns); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
441 | 441 | * Returns an array of sortable items table columns. |
442 | 442 | */ |
443 | - public static function sortable_item_columns( $columns ) { |
|
443 | + public static function sortable_item_columns($columns) { |
|
444 | 444 | |
445 | 445 | return array_merge( |
446 | 446 | $columns, |
@@ -457,50 +457,50 @@ discard block |
||
457 | 457 | /** |
458 | 458 | * Displays items table columns. |
459 | 459 | */ |
460 | - public static function display_item_columns( $column_name, $post_id ) { |
|
460 | + public static function display_item_columns($column_name, $post_id) { |
|
461 | 461 | global $wpinv_euvat; |
462 | 462 | |
463 | - $item = new WPInv_Item( $post_id ); |
|
463 | + $item = new WPInv_Item($post_id); |
|
464 | 464 | |
465 | - switch ( $column_name ) { |
|
465 | + switch ($column_name) { |
|
466 | 466 | |
467 | 467 | case 'price' : |
468 | 468 | |
469 | - if ( ! $item->is_recurring() ) { |
|
469 | + if (!$item->is_recurring()) { |
|
470 | 470 | echo $item->get_the_price(); |
471 | 471 | break; |
472 | 472 | } |
473 | 473 | |
474 | 474 | $price = wp_sprintf( |
475 | - __( '%s / %s', 'invoicing' ), |
|
475 | + __('%s / %s', 'invoicing'), |
|
476 | 476 | $item->get_the_price(), |
477 | - WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->get_recurring_period(), $item->get_recurring_interval() ) |
|
477 | + WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($item->get_recurring_period(), $item->get_recurring_interval()) |
|
478 | 478 | ); |
479 | 479 | |
480 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
480 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
481 | 481 | echo $price; |
482 | 482 | break; |
483 | 483 | } |
484 | 484 | |
485 | 485 | echo $item->get_the_initial_price(); |
486 | 486 | |
487 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
487 | + echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>'; |
|
488 | 488 | break; |
489 | 489 | |
490 | 490 | case 'vat_rule' : |
491 | - echo $wpinv_euvat->item_rule_label( $item->get_id() ); |
|
491 | + echo $wpinv_euvat->item_rule_label($item->get_id()); |
|
492 | 492 | break; |
493 | 493 | |
494 | 494 | case 'vat_class' : |
495 | - echo $wpinv_euvat->item_class_label( $item->get_id() ); |
|
495 | + echo $wpinv_euvat->item_class_label($item->get_id()); |
|
496 | 496 | break; |
497 | 497 | |
498 | 498 | case 'shortcode' : |
499 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
499 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
500 | 500 | break; |
501 | 501 | |
502 | 502 | case 'type' : |
503 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
503 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
504 | 504 | break; |
505 | 505 | |
506 | 506 | } |
@@ -510,22 +510,22 @@ discard block |
||
510 | 510 | /** |
511 | 511 | * Lets users filter items using taxes. |
512 | 512 | */ |
513 | - public static function add_item_filters( $post_type ) { |
|
513 | + public static function add_item_filters($post_type) { |
|
514 | 514 | $wpinv_euvat = getpaid_tax(); |
515 | 515 | |
516 | 516 | // Abort if we're not dealing with items. |
517 | - if ( $post_type != 'wpi_item' ) { |
|
517 | + if ($post_type != 'wpi_item') { |
|
518 | 518 | return; |
519 | 519 | } |
520 | 520 | |
521 | 521 | // Filter by vat rules. |
522 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
522 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
523 | 523 | |
524 | 524 | // Sanitize selected vat rule. |
525 | 525 | $vat_rule = ''; |
526 | 526 | $vat_rules = $wpinv_euvat->get_rules(); |
527 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
528 | - $vat_rule = $_GET['vat_rule']; |
|
527 | + if (isset($_GET['vat_rule'])) { |
|
528 | + $vat_rule = $_GET['vat_rule']; |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | // Filter by VAT rule. |
@@ -533,13 +533,13 @@ discard block |
||
533 | 533 | array( |
534 | 534 | 'options' => array_merge( |
535 | 535 | array( |
536 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
536 | + '' => __('All VAT rules', 'invoicing') |
|
537 | 537 | ), |
538 | 538 | $vat_rules |
539 | 539 | ), |
540 | 540 | 'name' => 'vat_rule', |
541 | 541 | 'id' => 'vat_rule', |
542 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
542 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
543 | 543 | 'show_option_all' => false, |
544 | 544 | 'show_option_none' => false, |
545 | 545 | 'class' => 'gdmbx2-text-medium', |
@@ -550,26 +550,26 @@ discard block |
||
550 | 550 | } |
551 | 551 | |
552 | 552 | // Filter by vat class. |
553 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
553 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
554 | 554 | |
555 | 555 | // Sanitize selected vat rule. |
556 | 556 | $vat_class = ''; |
557 | 557 | $vat_classes = $wpinv_euvat->get_all_classes(); |
558 | - if ( isset( $_GET['vat_class'] ) ) { |
|
559 | - $vat_class = $_GET['vat_class']; |
|
558 | + if (isset($_GET['vat_class'])) { |
|
559 | + $vat_class = $_GET['vat_class']; |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | echo wpinv_html_select( |
563 | 563 | array( |
564 | 564 | 'options' => array_merge( |
565 | 565 | array( |
566 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
566 | + '' => __('All VAT classes', 'invoicing') |
|
567 | 567 | ), |
568 | 568 | $vat_classes |
569 | 569 | ), |
570 | 570 | 'name' => 'vat_class', |
571 | 571 | 'id' => 'vat_class', |
572 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
572 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
573 | 573 | 'show_option_all' => false, |
574 | 574 | 'show_option_none' => false, |
575 | 575 | 'class' => 'gdmbx2-text-medium', |
@@ -579,22 +579,22 @@ discard block |
||
579 | 579 | } |
580 | 580 | |
581 | 581 | // Filter by item type. |
582 | - $type = ''; |
|
583 | - if ( isset( $_GET['type'] ) ) { |
|
584 | - $type = $_GET['type']; |
|
582 | + $type = ''; |
|
583 | + if (isset($_GET['type'])) { |
|
584 | + $type = $_GET['type']; |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | echo wpinv_html_select( |
588 | 588 | array( |
589 | 589 | 'options' => array_merge( |
590 | 590 | array( |
591 | - '' => __( 'All item types', 'invoicing' ) |
|
591 | + '' => __('All item types', 'invoicing') |
|
592 | 592 | ), |
593 | 593 | wpinv_get_item_types() |
594 | 594 | ), |
595 | 595 | 'name' => 'type', |
596 | 596 | 'id' => 'type', |
597 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
597 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
598 | 598 | 'show_option_all' => false, |
599 | 599 | 'show_option_none' => false, |
600 | 600 | 'class' => 'gdmbx2-text-medium', |
@@ -606,45 +606,45 @@ discard block |
||
606 | 606 | /** |
607 | 607 | * Filters the item query. |
608 | 608 | */ |
609 | - public static function filter_item_query( $query ) { |
|
609 | + public static function filter_item_query($query) { |
|
610 | 610 | |
611 | 611 | // modify the query only if it admin and main query. |
612 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
612 | + if (!(is_admin() && $query->is_main_query())) { |
|
613 | 613 | return $query; |
614 | 614 | } |
615 | 615 | |
616 | 616 | // we want to modify the query for our items. |
617 | - if ( 'wpi_item' != $query->query['post_type'] ){ |
|
617 | + if ('wpi_item' != $query->query['post_type']) { |
|
618 | 618 | return $query; |
619 | 619 | } |
620 | 620 | |
621 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
621 | + if (empty($query->query_vars['meta_query'])) { |
|
622 | 622 | $query->query_vars['meta_query'] = array(); |
623 | 623 | } |
624 | 624 | |
625 | 625 | // Filter vat rule type |
626 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
626 | + if (!empty($_GET['vat_rule'])) { |
|
627 | 627 | $query->query_vars['meta_query'][] = array( |
628 | 628 | 'key' => '_wpinv_vat_rule', |
629 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
629 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
630 | 630 | 'compare' => '=' |
631 | 631 | ); |
632 | 632 | } |
633 | 633 | |
634 | 634 | // Filter vat class |
635 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
635 | + if (!empty($_GET['vat_class'])) { |
|
636 | 636 | $query->query_vars['meta_query'][] = array( |
637 | 637 | 'key' => '_wpinv_vat_class', |
638 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
638 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
639 | 639 | 'compare' => '=' |
640 | 640 | ); |
641 | 641 | } |
642 | 642 | |
643 | 643 | // Filter item type |
644 | - if ( ! empty( $_GET['type'] ) ) { |
|
644 | + if (!empty($_GET['type'])) { |
|
645 | 645 | $query->query_vars['meta_query'][] = array( |
646 | 646 | 'key' => '_wpinv_type', |
647 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
647 | + 'value' => sanitize_text_field($_GET['type']), |
|
648 | 648 | 'compare' => '=' |
649 | 649 | ); |
650 | 650 | } |
@@ -654,15 +654,15 @@ discard block |
||
654 | 654 | /** |
655 | 655 | * Reorders items. |
656 | 656 | */ |
657 | - public static function reorder_items( $vars ) { |
|
657 | + public static function reorder_items($vars) { |
|
658 | 658 | global $typenow; |
659 | 659 | |
660 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
660 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
661 | 661 | return $vars; |
662 | 662 | } |
663 | 663 | |
664 | 664 | // By item type. |
665 | - if ( 'type' == $vars['orderby'] ) { |
|
665 | + if ('type' == $vars['orderby']) { |
|
666 | 666 | return array_merge( |
667 | 667 | $vars, |
668 | 668 | array( |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | } |
674 | 674 | |
675 | 675 | // By vat class. |
676 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
676 | + if ('vat_class' == $vars['orderby']) { |
|
677 | 677 | return array_merge( |
678 | 678 | $vars, |
679 | 679 | array( |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | } |
685 | 685 | |
686 | 686 | // By vat rule. |
687 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
687 | + if ('vat_rule' == $vars['orderby']) { |
|
688 | 688 | return array_merge( |
689 | 689 | $vars, |
690 | 690 | array( |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | } |
696 | 696 | |
697 | 697 | // By price. |
698 | - if ( 'price' == $vars['orderby'] ) { |
|
698 | + if ('price' == $vars['orderby']) { |
|
699 | 699 | return array_merge( |
700 | 700 | $vars, |
701 | 701 | array( |
@@ -712,27 +712,27 @@ discard block |
||
712 | 712 | /** |
713 | 713 | * Fired when deleting a post. |
714 | 714 | */ |
715 | - public static function delete_post( $post_id ) { |
|
715 | + public static function delete_post($post_id) { |
|
716 | 716 | |
717 | - switch ( get_post_type( $post_id ) ) { |
|
717 | + switch (get_post_type($post_id)) { |
|
718 | 718 | |
719 | 719 | case 'wpi_item' : |
720 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
720 | + do_action("getpaid_before_delete_item", new WPInv_Item($post_id)); |
|
721 | 721 | break; |
722 | 722 | |
723 | 723 | case 'wpi_payment_form' : |
724 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
724 | + do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id)); |
|
725 | 725 | break; |
726 | 726 | |
727 | 727 | case 'wpi_discount' : |
728 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
728 | + do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id)); |
|
729 | 729 | break; |
730 | 730 | |
731 | 731 | case 'wpi_invoice' : |
732 | - $invoice = new WPInv_Invoice( $post_id ); |
|
733 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
734 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
735 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
732 | + $invoice = new WPInv_Invoice($post_id); |
|
733 | + do_action("getpaid_before_delete_invoice", $invoice); |
|
734 | + $invoice->get_data_store()->delete_items($invoice); |
|
735 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
736 | 736 | break; |
737 | 737 | } |
738 | 738 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function wpinv_subscriptions_page() { |
16 | 16 | |
17 | - ?> |
|
17 | + ?> |
|
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,27 +22,27 @@ discard block |
||
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | - // Verify user permissions. |
|
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
25 | + // Verify user permissions. |
|
26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
27 | 27 | |
28 | - echo aui()->alert( |
|
29 | - array( |
|
30 | - 'type' => 'danger', |
|
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | - ) |
|
33 | - ); |
|
28 | + echo aui()->alert( |
|
29 | + array( |
|
30 | + 'type' => 'danger', |
|
31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | + ) |
|
33 | + ); |
|
34 | 34 | |
35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
36 | 36 | |
37 | - // Display a single subscription. |
|
38 | - wpinv_recurring_subscription_details(); |
|
39 | - } else { |
|
37 | + // Display a single subscription. |
|
38 | + wpinv_recurring_subscription_details(); |
|
39 | + } else { |
|
40 | 40 | |
41 | - // Display a list of available subscriptions. |
|
42 | - getpaid_print_subscriptions_list(); |
|
43 | - } |
|
41 | + // Display a list of available subscriptions. |
|
42 | + getpaid_print_subscriptions_list(); |
|
43 | + } |
|
44 | 44 | |
45 | - ?> |
|
45 | + ?> |
|
46 | 46 | |
47 | 47 | </div> |
48 | 48 | </div> |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function getpaid_print_subscriptions_list() { |
61 | 61 | |
62 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
63 | - $subscribers_table->prepare_items(); |
|
62 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
63 | + $subscribers_table->prepare_items(); |
|
64 | 64 | |
65 | - ?> |
|
65 | + ?> |
|
66 | 66 | <form id="subscribers-filter" class="bsui" method="get"> |
67 | 67 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
68 | 68 | <?php $subscribers_table->views(); ?> |
@@ -80,27 +80,27 @@ discard block |
||
80 | 80 | */ |
81 | 81 | function wpinv_recurring_subscription_details() { |
82 | 82 | |
83 | - // Fetch the subscription. |
|
84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | - if ( ! $sub->get_id() ) { |
|
83 | + // Fetch the subscription. |
|
84 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | + if ( ! $sub->get_id() ) { |
|
86 | 86 | |
87 | - echo aui()->alert( |
|
88 | - array( |
|
89 | - 'type' => 'danger', |
|
90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
91 | - ) |
|
92 | - ); |
|
87 | + echo aui()->alert( |
|
88 | + array( |
|
89 | + 'type' => 'danger', |
|
90 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
91 | + ) |
|
92 | + ); |
|
93 | 93 | |
94 | - return; |
|
95 | - } |
|
94 | + return; |
|
95 | + } |
|
96 | 96 | |
97 | - // Use metaboxes to display the subscription details. |
|
98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' ); |
|
99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
101 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
97 | + // Use metaboxes to display the subscription details. |
|
98 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' ); |
|
99 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
101 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
102 | 102 | |
103 | - ?> |
|
103 | + ?> |
|
104 | 104 | |
105 | 105 | <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
106 | 106 | |
@@ -140,41 +140,41 @@ discard block |
||
140 | 140 | */ |
141 | 141 | function getpaid_admin_subscription_details_metabox( $sub ) { |
142 | 142 | |
143 | - // Prepare subscription detail columns. |
|
144 | - $fields = apply_filters( |
|
145 | - 'getpaid_subscription_admin_page_fields', |
|
146 | - array( |
|
147 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
148 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
149 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
150 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
151 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
152 | - 'renewals' => __( 'Renewals', 'invoicing' ), |
|
153 | - 'item' => __( 'Item', 'invoicing' ), |
|
154 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
155 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
156 | - 'status' => __( 'Status', 'invoicing' ), |
|
157 | - ) |
|
158 | - ); |
|
159 | - |
|
160 | - if ( ! $sub->is_active() ) { |
|
161 | - |
|
162 | - if ( isset( $fields['renews_on'] ) ) { |
|
163 | - unset( $fields['renews_on'] ); |
|
164 | - } |
|
165 | - |
|
166 | - if ( isset( $fields['gateway'] ) ) { |
|
167 | - unset( $fields['gateway'] ); |
|
168 | - } |
|
143 | + // Prepare subscription detail columns. |
|
144 | + $fields = apply_filters( |
|
145 | + 'getpaid_subscription_admin_page_fields', |
|
146 | + array( |
|
147 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
148 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
149 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
150 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
151 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
152 | + 'renewals' => __( 'Renewals', 'invoicing' ), |
|
153 | + 'item' => __( 'Item', 'invoicing' ), |
|
154 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
155 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
156 | + 'status' => __( 'Status', 'invoicing' ), |
|
157 | + ) |
|
158 | + ); |
|
159 | + |
|
160 | + if ( ! $sub->is_active() ) { |
|
161 | + |
|
162 | + if ( isset( $fields['renews_on'] ) ) { |
|
163 | + unset( $fields['renews_on'] ); |
|
164 | + } |
|
165 | + |
|
166 | + if ( isset( $fields['gateway'] ) ) { |
|
167 | + unset( $fields['gateway'] ); |
|
168 | + } |
|
169 | 169 | |
170 | - } |
|
170 | + } |
|
171 | 171 | |
172 | - $profile_id = $sub->get_profile_id(); |
|
173 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
174 | - unset( $fields['profile_id'] ); |
|
175 | - } |
|
172 | + $profile_id = $sub->get_profile_id(); |
|
173 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
174 | + unset( $fields['profile_id'] ); |
|
175 | + } |
|
176 | 176 | |
177 | - ?> |
|
177 | + ?> |
|
178 | 178 | |
179 | 179 | <table class="table table-borderless" style="font-size: 14px;"> |
180 | 180 | <tbody> |
@@ -208,20 +208,20 @@ discard block |
||
208 | 208 | */ |
209 | 209 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
210 | 210 | |
211 | - $username = __( '(Missing User)', 'invoicing' ); |
|
211 | + $username = __( '(Missing User)', 'invoicing' ); |
|
212 | 212 | |
213 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
214 | - if ( $user ) { |
|
213 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
214 | + if ( $user ) { |
|
215 | 215 | |
216 | - $username = sprintf( |
|
217 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
218 | - absint( $user->ID ), |
|
219 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
220 | - ); |
|
216 | + $username = sprintf( |
|
217 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
218 | + absint( $user->ID ), |
|
219 | + ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
220 | + ); |
|
221 | 221 | |
222 | - } |
|
222 | + } |
|
223 | 223 | |
224 | - echo $username; |
|
224 | + echo $username; |
|
225 | 225 | } |
226 | 226 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
227 | 227 | |
@@ -232,43 +232,43 @@ discard block |
||
232 | 232 | */ |
233 | 233 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
234 | 234 | |
235 | - $initial = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_initial_amount() ) ), $subscription->get_parent_payment()->get_currency() ); |
|
236 | - $recurring = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_recurring_amount() ) ), $subscription->get_parent_payment()->get_currency() ); |
|
237 | - $period = 1 == $subscription->get_frequency() ? getpaid_get_subscription_period_label( $subscription->get_period() ) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->get_period(),$subscription->get_frequency() ); |
|
235 | + $initial = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_initial_amount() ) ), $subscription->get_parent_payment()->get_currency() ); |
|
236 | + $recurring = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_recurring_amount() ) ), $subscription->get_parent_payment()->get_currency() ); |
|
237 | + $period = 1 == $subscription->get_frequency() ? getpaid_get_subscription_period_label( $subscription->get_period() ) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->get_period(),$subscription->get_frequency() ); |
|
238 | 238 | |
239 | - if ( $subscription->has_trial_period() ) { |
|
239 | + if ( $subscription->has_trial_period() ) { |
|
240 | 240 | |
241 | - // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
|
242 | - $amount = sprintf( |
|
243 | - _x( '%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
244 | - $initial, |
|
245 | - sanitize_text_field( $subscription->get_trial_period() ), |
|
246 | - $recurring, |
|
247 | - sanitize_text_field( strtolower( $period ) ) |
|
248 | - ); |
|
241 | + // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
|
242 | + $amount = sprintf( |
|
243 | + _x( '%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
244 | + $initial, |
|
245 | + sanitize_text_field( $subscription->get_trial_period() ), |
|
246 | + $recurring, |
|
247 | + sanitize_text_field( strtolower( $period ) ) |
|
248 | + ); |
|
249 | 249 | |
250 | - } else if ( $initial != $recurring ) { |
|
250 | + } else if ( $initial != $recurring ) { |
|
251 | 251 | |
252 | - // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring perio |
|
253 | - $amount = sprintf( |
|
254 | - _x( 'Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing' ), |
|
255 | - $initial, |
|
256 | - $recurring, |
|
257 | - sanitize_text_field( strtolower( $period ) ) |
|
258 | - ); |
|
252 | + // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring perio |
|
253 | + $amount = sprintf( |
|
254 | + _x( 'Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing' ), |
|
255 | + $initial, |
|
256 | + $recurring, |
|
257 | + sanitize_text_field( strtolower( $period ) ) |
|
258 | + ); |
|
259 | 259 | |
260 | - } else { |
|
260 | + } else { |
|
261 | 261 | |
262 | - // translators: $1: is the recurring amount, $2: is the recurring period |
|
263 | - $amount = sprintf( |
|
264 | - _x( '%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing' ), |
|
265 | - $initial, |
|
266 | - sanitize_text_field( strtolower( $period ) ) |
|
267 | - ); |
|
262 | + // translators: $1: is the recurring amount, $2: is the recurring period |
|
263 | + $amount = sprintf( |
|
264 | + _x( '%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing' ), |
|
265 | + $initial, |
|
266 | + sanitize_text_field( strtolower( $period ) ) |
|
267 | + ); |
|
268 | 268 | |
269 | - } |
|
269 | + } |
|
270 | 270 | |
271 | - echo "<span>$amount</span>"; |
|
271 | + echo "<span>$amount</span>"; |
|
272 | 272 | } |
273 | 273 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
274 | 274 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param WPInv_Subscription $subscription |
279 | 279 | */ |
280 | 280 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
281 | - echo '#' . absint( $subscription->get_id() ); |
|
281 | + echo '#' . absint( $subscription->get_id() ); |
|
282 | 282 | } |
283 | 283 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
284 | 284 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param WPInv_Subscription $subscription |
289 | 289 | */ |
290 | 290 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
291 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
291 | + echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
292 | 292 | } |
293 | 293 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
294 | 294 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @param WPInv_Subscription $subscription |
299 | 299 | */ |
300 | 300 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
301 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
301 | + echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
302 | 302 | } |
303 | 303 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
304 | 304 | |
@@ -308,8 +308,8 @@ discard block |
||
308 | 308 | * @param WPInv_Subscription $subscription |
309 | 309 | */ |
310 | 310 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
311 | - $max_bills = $subscription->get_bill_times(); |
|
312 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
311 | + $max_bills = $subscription->get_bill_times(); |
|
312 | + echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
313 | 313 | } |
314 | 314 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
315 | 315 | |
@@ -320,16 +320,16 @@ discard block |
||
320 | 320 | */ |
321 | 321 | function getpaid_admin_subscription_metabox_display_item( $subscription ) { |
322 | 322 | |
323 | - $item = get_post( $subscription->get_product_id() ); |
|
323 | + $item = get_post( $subscription->get_product_id() ); |
|
324 | 324 | |
325 | - if ( ! empty( $item ) ) { |
|
326 | - $link = get_edit_post_link( $item ); |
|
327 | - $link = esc_url( $link ); |
|
328 | - $name = esc_html( get_the_title( $item ) ); |
|
329 | - echo "<a href='$link'>$name</a>"; |
|
330 | - } else { |
|
331 | - echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
332 | - } |
|
325 | + if ( ! empty( $item ) ) { |
|
326 | + $link = get_edit_post_link( $item ); |
|
327 | + $link = esc_url( $link ); |
|
328 | + $name = esc_html( get_the_title( $item ) ); |
|
329 | + echo "<a href='$link'>$name</a>"; |
|
330 | + } else { |
|
331 | + echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
332 | + } |
|
333 | 333 | |
334 | 334 | } |
335 | 335 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item' ); |
@@ -341,13 +341,13 @@ discard block |
||
341 | 341 | */ |
342 | 342 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
343 | 343 | |
344 | - $gateway = $subscription->get_gateway(); |
|
344 | + $gateway = $subscription->get_gateway(); |
|
345 | 345 | |
346 | - if ( ! empty( $gateway ) ) { |
|
347 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
348 | - } else { |
|
349 | - echo "—"; |
|
350 | - } |
|
346 | + if ( ! empty( $gateway ) ) { |
|
347 | + echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
348 | + } else { |
|
349 | + echo "—"; |
|
350 | + } |
|
351 | 351 | |
352 | 352 | } |
353 | 353 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @param WPInv_Subscription $subscription |
359 | 359 | */ |
360 | 360 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
361 | - echo $subscription->get_status_label_html(); |
|
361 | + echo $subscription->get_status_label_html(); |
|
362 | 362 | } |
363 | 363 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
364 | 364 | |
@@ -369,14 +369,14 @@ discard block |
||
369 | 369 | */ |
370 | 370 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
371 | 371 | |
372 | - $profile_id = $subscription->get_profile_id(); |
|
372 | + $profile_id = $subscription->get_profile_id(); |
|
373 | 373 | |
374 | - if ( ! empty( $profile_id ) ) { |
|
375 | - $profile_id = sanitize_text_field( $profile_id ); |
|
376 | - echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription ); |
|
377 | - } else { |
|
378 | - echo "—"; |
|
379 | - } |
|
374 | + if ( ! empty( $profile_id ) ) { |
|
375 | + $profile_id = sanitize_text_field( $profile_id ); |
|
376 | + echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription ); |
|
377 | + } else { |
|
378 | + echo "—"; |
|
379 | + } |
|
380 | 380 | |
381 | 381 | } |
382 | 382 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -388,39 +388,39 @@ discard block |
||
388 | 388 | */ |
389 | 389 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
390 | 390 | |
391 | - ?> |
|
391 | + ?> |
|
392 | 392 | <div class="mt-3"> |
393 | 393 | |
394 | 394 | <?php |
395 | - echo aui()->select( |
|
396 | - array( |
|
397 | - 'options' => getpaid_get_subscription_statuses(), |
|
398 | - 'name' => 'subscription_status', |
|
399 | - 'id' => 'subscription_status_update_select', |
|
400 | - 'required' => true, |
|
401 | - 'no_wrap' => false, |
|
402 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
403 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
404 | - 'select2' => true, |
|
405 | - 'value' => $subscription->get_status( 'edit' ), |
|
406 | - ) |
|
407 | - ); |
|
408 | - ?> |
|
395 | + echo aui()->select( |
|
396 | + array( |
|
397 | + 'options' => getpaid_get_subscription_statuses(), |
|
398 | + 'name' => 'subscription_status', |
|
399 | + 'id' => 'subscription_status_update_select', |
|
400 | + 'required' => true, |
|
401 | + 'no_wrap' => false, |
|
402 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
403 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
404 | + 'select2' => true, |
|
405 | + 'value' => $subscription->get_status( 'edit' ), |
|
406 | + ) |
|
407 | + ); |
|
408 | + ?> |
|
409 | 409 | |
410 | 410 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
411 | 411 | |
412 | 412 | <?php |
413 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
413 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
414 | 414 | |
415 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
416 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
417 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
415 | + $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
416 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
417 | + $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
418 | 418 | |
419 | - if ( $subscription->is_active() ) { |
|
420 | - echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
421 | - } |
|
419 | + if ( $subscription->is_active() ) { |
|
420 | + echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
421 | + } |
|
422 | 422 | |
423 | - echo '</div></div>'; |
|
423 | + echo '</div></div>'; |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
@@ -430,33 +430,33 @@ discard block |
||
430 | 430 | */ |
431 | 431 | function getpaid_admin_subscription_invoice_details_metabox( $subscription ) { |
432 | 432 | |
433 | - $columns = apply_filters( |
|
434 | - 'getpaid_subscription_related_invoices_columns', |
|
435 | - array( |
|
436 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
437 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
438 | - 'date' => __( 'Date', 'invoicing' ), |
|
439 | - 'status' => __( 'Status', 'invoicing' ), |
|
440 | - 'total' => __( 'Total', 'invoicing' ), |
|
441 | - ), |
|
442 | - $subscription |
|
443 | - ); |
|
444 | - |
|
445 | - // Prepare the invoices. |
|
446 | - $payments = $subscription->get_child_payments(); |
|
447 | - $parent = $subscription->get_parent_invoice(); |
|
448 | - |
|
449 | - if ( $parent->get_id() ) { |
|
450 | - $payments = array_merge( array( $parent ), $payments ); |
|
451 | - } |
|
433 | + $columns = apply_filters( |
|
434 | + 'getpaid_subscription_related_invoices_columns', |
|
435 | + array( |
|
436 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
437 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
438 | + 'date' => __( 'Date', 'invoicing' ), |
|
439 | + 'status' => __( 'Status', 'invoicing' ), |
|
440 | + 'total' => __( 'Total', 'invoicing' ), |
|
441 | + ), |
|
442 | + $subscription |
|
443 | + ); |
|
444 | + |
|
445 | + // Prepare the invoices. |
|
446 | + $payments = $subscription->get_child_payments(); |
|
447 | + $parent = $subscription->get_parent_invoice(); |
|
448 | + |
|
449 | + if ( $parent->get_id() ) { |
|
450 | + $payments = array_merge( array( $parent ), $payments ); |
|
451 | + } |
|
452 | 452 | |
453 | - $table_class = 'w-100 bg-white'; |
|
453 | + $table_class = 'w-100 bg-white'; |
|
454 | 454 | |
455 | - if ( ! is_admin() ) { |
|
456 | - $table_class = 'table table-bordered table-striped'; |
|
457 | - } |
|
455 | + if ( ! is_admin() ) { |
|
456 | + $table_class = 'table table-bordered table-striped'; |
|
457 | + } |
|
458 | 458 | |
459 | - ?> |
|
459 | + ?> |
|
460 | 460 | <div class="m-0" style="overflow: auto;"> |
461 | 461 | |
462 | 462 | <table class="<?php echo $table_class; ?>"> |
@@ -464,13 +464,13 @@ discard block |
||
464 | 464 | <thead> |
465 | 465 | <tr> |
466 | 466 | <?php |
467 | - foreach ( $columns as $key => $label ) { |
|
468 | - $key = esc_attr( $key ); |
|
469 | - $label = sanitize_text_field( $label ); |
|
467 | + foreach ( $columns as $key => $label ) { |
|
468 | + $key = esc_attr( $key ); |
|
469 | + $label = sanitize_text_field( $label ); |
|
470 | 470 | |
471 | - echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark'>$label</th>"; |
|
472 | - } |
|
473 | - ?> |
|
471 | + echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark'>$label</th>"; |
|
472 | + } |
|
473 | + ?> |
|
474 | 474 | </tr> |
475 | 475 | </thead> |
476 | 476 | |
@@ -486,66 +486,66 @@ discard block |
||
486 | 486 | |
487 | 487 | <?php |
488 | 488 | |
489 | - foreach( $payments as $payment ) : |
|
489 | + foreach( $payments as $payment ) : |
|
490 | 490 | |
491 | - // Ensure that we have an invoice. |
|
492 | - $payment = new WPInv_Invoice( $payment ); |
|
491 | + // Ensure that we have an invoice. |
|
492 | + $payment = new WPInv_Invoice( $payment ); |
|
493 | 493 | |
494 | - // Abort if the invoice is invalid. |
|
495 | - if ( ! $payment->get_id() ) { |
|
496 | - continue; |
|
497 | - } |
|
494 | + // Abort if the invoice is invalid. |
|
495 | + if ( ! $payment->get_id() ) { |
|
496 | + continue; |
|
497 | + } |
|
498 | 498 | |
499 | - echo '<tr>'; |
|
499 | + echo '<tr>'; |
|
500 | 500 | |
501 | - foreach ( array_keys( $columns ) as $key ) { |
|
501 | + foreach ( array_keys( $columns ) as $key ) { |
|
502 | 502 | |
503 | - echo '<td class="p-2 text-left">'; |
|
503 | + echo '<td class="p-2 text-left">'; |
|
504 | 504 | |
505 | - switch( $key ) { |
|
505 | + switch( $key ) { |
|
506 | 506 | |
507 | - case 'total': |
|
508 | - echo '<strong>' . wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $payment->get_total ) ), $payment->get_currency() ) . '</strong>'; |
|
509 | - break; |
|
507 | + case 'total': |
|
508 | + echo '<strong>' . wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $payment->get_total ) ), $payment->get_currency() ) . '</strong>'; |
|
509 | + break; |
|
510 | 510 | |
511 | - case 'relationship': |
|
512 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
513 | - break; |
|
511 | + case 'relationship': |
|
512 | + echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
513 | + break; |
|
514 | 514 | |
515 | - case 'date': |
|
516 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
517 | - break; |
|
515 | + case 'date': |
|
516 | + echo getpaid_format_date_value( $payment->get_date_created() ); |
|
517 | + break; |
|
518 | 518 | |
519 | - case 'status': |
|
519 | + case 'status': |
|
520 | 520 | |
521 | - $status = $payment->get_status_nicename(); |
|
522 | - if ( is_admin() ) { |
|
523 | - $status = $payment->get_status_label_html(); |
|
524 | - } |
|
521 | + $status = $payment->get_status_nicename(); |
|
522 | + if ( is_admin() ) { |
|
523 | + $status = $payment->get_status_label_html(); |
|
524 | + } |
|
525 | 525 | |
526 | - echo $status; |
|
527 | - break; |
|
526 | + echo $status; |
|
527 | + break; |
|
528 | 528 | |
529 | - case 'invoice': |
|
530 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
529 | + case 'invoice': |
|
530 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
531 | 531 | |
532 | - if ( ! is_admin() ) { |
|
533 | - $link = esc_url( $payment->get_view_url() ); |
|
534 | - } |
|
532 | + if ( ! is_admin() ) { |
|
533 | + $link = esc_url( $payment->get_view_url() ); |
|
534 | + } |
|
535 | 535 | |
536 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
537 | - echo "<a href='$link'>$invoice</a>"; |
|
538 | - break; |
|
539 | - } |
|
536 | + $invoice = sanitize_text_field( $payment->get_number() ); |
|
537 | + echo "<a href='$link'>$invoice</a>"; |
|
538 | + break; |
|
539 | + } |
|
540 | 540 | |
541 | - echo '</td>'; |
|
541 | + echo '</td>'; |
|
542 | 542 | |
543 | - } |
|
543 | + } |
|
544 | 544 | |
545 | - echo '</tr>'; |
|
545 | + echo '</tr>'; |
|
546 | 546 | |
547 | - endforeach; |
|
548 | - ?> |
|
547 | + endforeach; |
|
548 | + ?> |
|
549 | 549 | |
550 | 550 | </tbody> |
551 | 551 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains functions that display the subscriptions admin page. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Render the Subscriptions page |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
21 | 21 | <div class="bsui"> |
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | 25 | // Verify user permissions. |
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
27 | 27 | |
28 | 28 | echo aui()->alert( |
29 | 29 | array( |
30 | 30 | 'type' => 'danger', |
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
32 | 32 | ) |
33 | 33 | ); |
34 | 34 | |
35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } else if (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
36 | 36 | |
37 | 37 | // Display a single subscription. |
38 | 38 | wpinv_recurring_subscription_details(); |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | function wpinv_recurring_subscription_details() { |
82 | 82 | |
83 | 83 | // Fetch the subscription. |
84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | - if ( ! $sub->get_id() ) { |
|
84 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
85 | + if (!$sub->get_id()) { |
|
86 | 86 | |
87 | 87 | echo aui()->alert( |
88 | 88 | array( |
89 | 89 | 'type' => 'danger', |
90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
90 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
91 | 91 | ) |
92 | 92 | ); |
93 | 93 | |
@@ -95,31 +95,31 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | // Use metaboxes to display the subscription details. |
98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' ); |
|
99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
101 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
98 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal'); |
|
99 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
100 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
101 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
102 | 102 | |
103 | 103 | ?> |
104 | 104 | |
105 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
105 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
106 | 106 | |
107 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
108 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
109 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
107 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
108 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
109 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
110 | 110 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
111 | - <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" /> |
|
111 | + <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
|
112 | 112 | |
113 | 113 | <div id="poststuff"> |
114 | 114 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
115 | 115 | |
116 | 116 | <div id="postbox-container-1" class="postbox-container"> |
117 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
117 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
118 | 118 | </div> |
119 | 119 | |
120 | 120 | <div id="postbox-container-2" class="postbox-container"> |
121 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
122 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
121 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
122 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
123 | 123 | </div> |
124 | 124 | |
125 | 125 | </div> |
@@ -138,40 +138,40 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @param WPInv_Subscription $sub |
140 | 140 | */ |
141 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
141 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
142 | 142 | |
143 | 143 | // Prepare subscription detail columns. |
144 | 144 | $fields = apply_filters( |
145 | 145 | 'getpaid_subscription_admin_page_fields', |
146 | 146 | array( |
147 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
148 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
149 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
150 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
151 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
152 | - 'renewals' => __( 'Renewals', 'invoicing' ), |
|
153 | - 'item' => __( 'Item', 'invoicing' ), |
|
154 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
155 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
156 | - 'status' => __( 'Status', 'invoicing' ), |
|
147 | + 'subscription' => __('Subscription', 'invoicing'), |
|
148 | + 'customer' => __('Customer', 'invoicing'), |
|
149 | + 'amount' => __('Amount', 'invoicing'), |
|
150 | + 'start_date' => __('Start Date', 'invoicing'), |
|
151 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
152 | + 'renewals' => __('Renewals', 'invoicing'), |
|
153 | + 'item' => __('Item', 'invoicing'), |
|
154 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
155 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
156 | + 'status' => __('Status', 'invoicing'), |
|
157 | 157 | ) |
158 | 158 | ); |
159 | 159 | |
160 | - if ( ! $sub->is_active() ) { |
|
160 | + if (!$sub->is_active()) { |
|
161 | 161 | |
162 | - if ( isset( $fields['renews_on'] ) ) { |
|
163 | - unset( $fields['renews_on'] ); |
|
162 | + if (isset($fields['renews_on'])) { |
|
163 | + unset($fields['renews_on']); |
|
164 | 164 | } |
165 | 165 | |
166 | - if ( isset( $fields['gateway'] ) ) { |
|
167 | - unset( $fields['gateway'] ); |
|
166 | + if (isset($fields['gateway'])) { |
|
167 | + unset($fields['gateway']); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | } |
171 | 171 | |
172 | 172 | $profile_id = $sub->get_profile_id(); |
173 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
174 | - unset( $fields['profile_id'] ); |
|
173 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
174 | + unset($fields['profile_id']); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | ?> |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | <table class="table table-borderless" style="font-size: 14px;"> |
180 | 180 | <tbody> |
181 | 181 | |
182 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
182 | + <?php foreach ($fields as $key => $label) : ?> |
|
183 | 183 | |
184 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
184 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
185 | 185 | |
186 | 186 | <th class="w-25" style="font-weight: 500;"> |
187 | - <?php echo sanitize_text_field( $label ); ?> |
|
187 | + <?php echo sanitize_text_field($label); ?> |
|
188 | 188 | </th> |
189 | 189 | |
190 | 190 | <td class="w-75 text-muted"> |
191 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_text_field( $key ), $sub ); ?> |
|
191 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_text_field($key), $sub); ?> |
|
192 | 192 | </td> |
193 | 193 | |
194 | 194 | </tr> |
@@ -206,187 +206,187 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @param WPInv_Subscription $subscription |
208 | 208 | */ |
209 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
209 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
210 | 210 | |
211 | - $username = __( '(Missing User)', 'invoicing' ); |
|
211 | + $username = __('(Missing User)', 'invoicing'); |
|
212 | 212 | |
213 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
214 | - if ( $user ) { |
|
213 | + $user = get_userdata($subscription->get_customer_id()); |
|
214 | + if ($user) { |
|
215 | 215 | |
216 | 216 | $username = sprintf( |
217 | 217 | '<a href="user-edit.php?user_id=%s">%s</a>', |
218 | - absint( $user->ID ), |
|
219 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
218 | + absint($user->ID), |
|
219 | + !empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email) |
|
220 | 220 | ); |
221 | 221 | |
222 | 222 | } |
223 | 223 | |
224 | 224 | echo $username; |
225 | 225 | } |
226 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
226 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
227 | 227 | |
228 | 228 | /** |
229 | 229 | * Displays the subscription amount. |
230 | 230 | * |
231 | 231 | * @param WPInv_Subscription $subscription |
232 | 232 | */ |
233 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
233 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
234 | 234 | |
235 | - $initial = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_initial_amount() ) ), $subscription->get_parent_payment()->get_currency() ); |
|
236 | - $recurring = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_recurring_amount() ) ), $subscription->get_parent_payment()->get_currency() ); |
|
237 | - $period = 1 == $subscription->get_frequency() ? getpaid_get_subscription_period_label( $subscription->get_period() ) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->get_period(),$subscription->get_frequency() ); |
|
235 | + $initial = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($subscription->get_initial_amount())), $subscription->get_parent_payment()->get_currency()); |
|
236 | + $recurring = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($subscription->get_recurring_amount())), $subscription->get_parent_payment()->get_currency()); |
|
237 | + $period = 1 == $subscription->get_frequency() ? getpaid_get_subscription_period_label($subscription->get_period()) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->get_period(), $subscription->get_frequency()); |
|
238 | 238 | |
239 | - if ( $subscription->has_trial_period() ) { |
|
239 | + if ($subscription->has_trial_period()) { |
|
240 | 240 | |
241 | 241 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
242 | 242 | $amount = sprintf( |
243 | - _x( '%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
243 | + _x('%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'), |
|
244 | 244 | $initial, |
245 | - sanitize_text_field( $subscription->get_trial_period() ), |
|
245 | + sanitize_text_field($subscription->get_trial_period()), |
|
246 | 246 | $recurring, |
247 | - sanitize_text_field( strtolower( $period ) ) |
|
247 | + sanitize_text_field(strtolower($period)) |
|
248 | 248 | ); |
249 | 249 | |
250 | - } else if ( $initial != $recurring ) { |
|
250 | + } else if ($initial != $recurring) { |
|
251 | 251 | |
252 | 252 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring perio |
253 | 253 | $amount = sprintf( |
254 | - _x( 'Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing' ), |
|
254 | + _x('Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing'), |
|
255 | 255 | $initial, |
256 | 256 | $recurring, |
257 | - sanitize_text_field( strtolower( $period ) ) |
|
257 | + sanitize_text_field(strtolower($period)) |
|
258 | 258 | ); |
259 | 259 | |
260 | 260 | } else { |
261 | 261 | |
262 | 262 | // translators: $1: is the recurring amount, $2: is the recurring period |
263 | 263 | $amount = sprintf( |
264 | - _x( '%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing' ), |
|
264 | + _x('%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing'), |
|
265 | 265 | $initial, |
266 | - sanitize_text_field( strtolower( $period ) ) |
|
266 | + sanitize_text_field(strtolower($period)) |
|
267 | 267 | ); |
268 | 268 | |
269 | 269 | } |
270 | 270 | |
271 | 271 | echo "<span>$amount</span>"; |
272 | 272 | } |
273 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
273 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
274 | 274 | |
275 | 275 | /** |
276 | 276 | * Displays the subscription id. |
277 | 277 | * |
278 | 278 | * @param WPInv_Subscription $subscription |
279 | 279 | */ |
280 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
281 | - echo '#' . absint( $subscription->get_id() ); |
|
280 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
281 | + echo '#' . absint($subscription->get_id()); |
|
282 | 282 | } |
283 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
283 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
284 | 284 | |
285 | 285 | /** |
286 | 286 | * Displays the subscription renewal date. |
287 | 287 | * |
288 | 288 | * @param WPInv_Subscription $subscription |
289 | 289 | */ |
290 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
291 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
290 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
291 | + echo getpaid_format_date_value($subscription->get_date_created()); |
|
292 | 292 | } |
293 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
293 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
294 | 294 | |
295 | 295 | /** |
296 | 296 | * Displays the subscription renewal date. |
297 | 297 | * |
298 | 298 | * @param WPInv_Subscription $subscription |
299 | 299 | */ |
300 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
301 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
300 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
301 | + echo getpaid_format_date_value($subscription->get_expiration()); |
|
302 | 302 | } |
303 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
303 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
304 | 304 | |
305 | 305 | /** |
306 | 306 | * Displays the subscription renewal count. |
307 | 307 | * |
308 | 308 | * @param WPInv_Subscription $subscription |
309 | 309 | */ |
310 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
310 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
311 | 311 | $max_bills = $subscription->get_bill_times(); |
312 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
312 | + echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
313 | 313 | } |
314 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
314 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
315 | 315 | |
316 | 316 | /** |
317 | 317 | * Displays the subscription item. |
318 | 318 | * |
319 | 319 | * @param WPInv_Subscription $subscription |
320 | 320 | */ |
321 | -function getpaid_admin_subscription_metabox_display_item( $subscription ) { |
|
321 | +function getpaid_admin_subscription_metabox_display_item($subscription) { |
|
322 | 322 | |
323 | - $item = get_post( $subscription->get_product_id() ); |
|
323 | + $item = get_post($subscription->get_product_id()); |
|
324 | 324 | |
325 | - if ( ! empty( $item ) ) { |
|
326 | - $link = get_edit_post_link( $item ); |
|
327 | - $link = esc_url( $link ); |
|
328 | - $name = esc_html( get_the_title( $item ) ); |
|
325 | + if (!empty($item)) { |
|
326 | + $link = get_edit_post_link($item); |
|
327 | + $link = esc_url($link); |
|
328 | + $name = esc_html(get_the_title($item)); |
|
329 | 329 | echo "<a href='$link'>$name</a>"; |
330 | 330 | } else { |
331 | - echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
331 | + echo sprintf(__('Item #%s', 'invoicing'), $subscription->get_product_id()); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | } |
335 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item' ); |
|
335 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item'); |
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * Displays the subscription gateway. |
339 | 339 | * |
340 | 340 | * @param WPInv_Subscription $subscription |
341 | 341 | */ |
342 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
342 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
343 | 343 | |
344 | 344 | $gateway = $subscription->get_gateway(); |
345 | 345 | |
346 | - if ( ! empty( $gateway ) ) { |
|
347 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
346 | + if (!empty($gateway)) { |
|
347 | + echo sanitize_text_field(wpinv_get_gateway_admin_label($gateway)); |
|
348 | 348 | } else { |
349 | 349 | echo "—"; |
350 | 350 | } |
351 | 351 | |
352 | 352 | } |
353 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
353 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
354 | 354 | |
355 | 355 | /** |
356 | 356 | * Displays the subscription status. |
357 | 357 | * |
358 | 358 | * @param WPInv_Subscription $subscription |
359 | 359 | */ |
360 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
360 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
361 | 361 | echo $subscription->get_status_label_html(); |
362 | 362 | } |
363 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
363 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * Displays the subscription profile id. |
367 | 367 | * |
368 | 368 | * @param WPInv_Subscription $subscription |
369 | 369 | */ |
370 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
370 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
371 | 371 | |
372 | 372 | $profile_id = $subscription->get_profile_id(); |
373 | 373 | |
374 | - if ( ! empty( $profile_id ) ) { |
|
375 | - $profile_id = sanitize_text_field( $profile_id ); |
|
376 | - echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription ); |
|
374 | + if (!empty($profile_id)) { |
|
375 | + $profile_id = sanitize_text_field($profile_id); |
|
376 | + echo apply_filters('getpaid_subscription_profile_id_display', $profile_id, $subscription); |
|
377 | 377 | } else { |
378 | 378 | echo "—"; |
379 | 379 | } |
380 | 380 | |
381 | 381 | } |
382 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
382 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
383 | 383 | |
384 | 384 | /** |
385 | 385 | * Displays the subscriptions update metabox. |
386 | 386 | * |
387 | 387 | * @param WPInv_Subscription $subscription |
388 | 388 | */ |
389 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
389 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
390 | 390 | |
391 | 391 | ?> |
392 | 392 | <div class="mt-3"> |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | 'id' => 'subscription_status_update_select', |
400 | 400 | 'required' => true, |
401 | 401 | 'no_wrap' => false, |
402 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
403 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
402 | + 'label' => __('Subscription Status', 'invoicing'), |
|
403 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
404 | 404 | 'select2' => true, |
405 | - 'value' => $subscription->get_status( 'edit' ), |
|
405 | + 'value' => $subscription->get_status('edit'), |
|
406 | 406 | ) |
407 | 407 | ); |
408 | 408 | ?> |
@@ -410,13 +410,13 @@ discard block |
||
410 | 410 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
411 | 411 | |
412 | 412 | <?php |
413 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
413 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
414 | 414 | |
415 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
416 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
417 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
415 | + $url = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce')); |
|
416 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
417 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
418 | 418 | |
419 | - if ( $subscription->is_active() ) { |
|
419 | + if ($subscription->is_active()) { |
|
420 | 420 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
421 | 421 | } |
422 | 422 | |
@@ -428,16 +428,16 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @param WPInv_Subscription $subscription |
430 | 430 | */ |
431 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription ) { |
|
431 | +function getpaid_admin_subscription_invoice_details_metabox($subscription) { |
|
432 | 432 | |
433 | 433 | $columns = apply_filters( |
434 | 434 | 'getpaid_subscription_related_invoices_columns', |
435 | 435 | array( |
436 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
437 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
438 | - 'date' => __( 'Date', 'invoicing' ), |
|
439 | - 'status' => __( 'Status', 'invoicing' ), |
|
440 | - 'total' => __( 'Total', 'invoicing' ), |
|
436 | + 'invoice' => __('Invoice', 'invoicing'), |
|
437 | + 'relationship' => __('Relationship', 'invoicing'), |
|
438 | + 'date' => __('Date', 'invoicing'), |
|
439 | + 'status' => __('Status', 'invoicing'), |
|
440 | + 'total' => __('Total', 'invoicing'), |
|
441 | 441 | ), |
442 | 442 | $subscription |
443 | 443 | ); |
@@ -446,13 +446,13 @@ discard block |
||
446 | 446 | $payments = $subscription->get_child_payments(); |
447 | 447 | $parent = $subscription->get_parent_invoice(); |
448 | 448 | |
449 | - if ( $parent->get_id() ) { |
|
450 | - $payments = array_merge( array( $parent ), $payments ); |
|
449 | + if ($parent->get_id()) { |
|
450 | + $payments = array_merge(array($parent), $payments); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | $table_class = 'w-100 bg-white'; |
454 | 454 | |
455 | - if ( ! is_admin() ) { |
|
455 | + if (!is_admin()) { |
|
456 | 456 | $table_class = 'table table-bordered table-striped'; |
457 | 457 | } |
458 | 458 | |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | <thead> |
465 | 465 | <tr> |
466 | 466 | <?php |
467 | - foreach ( $columns as $key => $label ) { |
|
468 | - $key = esc_attr( $key ); |
|
469 | - $label = sanitize_text_field( $label ); |
|
467 | + foreach ($columns as $key => $label) { |
|
468 | + $key = esc_attr($key); |
|
469 | + $label = sanitize_text_field($label); |
|
470 | 470 | |
471 | 471 | echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark'>$label</th>"; |
472 | 472 | } |
@@ -476,50 +476,50 @@ discard block |
||
476 | 476 | |
477 | 477 | <tbody> |
478 | 478 | |
479 | - <?php if ( empty( $payments ) ) : ?> |
|
479 | + <?php if (empty($payments)) : ?> |
|
480 | 480 | <tr> |
481 | 481 | <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
482 | - <?php _e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
482 | + <?php _e('This subscription has no invoices.', 'invoicing'); ?> |
|
483 | 483 | </td> |
484 | 484 | </tr> |
485 | 485 | <?php endif; ?> |
486 | 486 | |
487 | 487 | <?php |
488 | 488 | |
489 | - foreach( $payments as $payment ) : |
|
489 | + foreach ($payments as $payment) : |
|
490 | 490 | |
491 | 491 | // Ensure that we have an invoice. |
492 | - $payment = new WPInv_Invoice( $payment ); |
|
492 | + $payment = new WPInv_Invoice($payment); |
|
493 | 493 | |
494 | 494 | // Abort if the invoice is invalid. |
495 | - if ( ! $payment->get_id() ) { |
|
495 | + if (!$payment->get_id()) { |
|
496 | 496 | continue; |
497 | 497 | } |
498 | 498 | |
499 | 499 | echo '<tr>'; |
500 | 500 | |
501 | - foreach ( array_keys( $columns ) as $key ) { |
|
501 | + foreach (array_keys($columns) as $key) { |
|
502 | 502 | |
503 | 503 | echo '<td class="p-2 text-left">'; |
504 | 504 | |
505 | - switch( $key ) { |
|
505 | + switch ($key) { |
|
506 | 506 | |
507 | 507 | case 'total': |
508 | - echo '<strong>' . wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $payment->get_total ) ), $payment->get_currency() ) . '</strong>'; |
|
508 | + echo '<strong>' . wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($payment->get_total)), $payment->get_currency()) . '</strong>'; |
|
509 | 509 | break; |
510 | 510 | |
511 | 511 | case 'relationship': |
512 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
512 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
513 | 513 | break; |
514 | 514 | |
515 | 515 | case 'date': |
516 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
516 | + echo getpaid_format_date_value($payment->get_date_created()); |
|
517 | 517 | break; |
518 | 518 | |
519 | 519 | case 'status': |
520 | 520 | |
521 | 521 | $status = $payment->get_status_nicename(); |
522 | - if ( is_admin() ) { |
|
522 | + if (is_admin()) { |
|
523 | 523 | $status = $payment->get_status_label_html(); |
524 | 524 | } |
525 | 525 | |
@@ -527,13 +527,13 @@ discard block |
||
527 | 527 | break; |
528 | 528 | |
529 | 529 | case 'invoice': |
530 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
530 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
531 | 531 | |
532 | - if ( ! is_admin() ) { |
|
533 | - $link = esc_url( $payment->get_view_url() ); |
|
532 | + if (!is_admin()) { |
|
533 | + $link = esc_url($payment->get_view_url()); |
|
534 | 534 | } |
535 | 535 | |
536 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
536 | + $invoice = sanitize_text_field($payment->get_number()); |
|
537 | 537 | echo "<a href='$link'>$invoice</a>"; |
538 | 538 | break; |
539 | 539 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | if ( ! defined( 'ABSPATH' ) ) exit; |
7 | 7 | |
8 | 8 | if ( ! class_exists( 'WP_List_Table' ) ) { |
9 | - include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
9 | + include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
@@ -14,409 +14,409 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class WPInv_Subscriptions_List_Table extends WP_List_Table { |
16 | 16 | |
17 | - /** |
|
18 | - * URL of this page |
|
19 | - * |
|
20 | - * @var string |
|
21 | - * @since 1.0.19 |
|
22 | - */ |
|
23 | - public $base_url; |
|
24 | - |
|
25 | - /** |
|
26 | - * Query |
|
27 | - * |
|
28 | - * @var GetPaid_Subscriptions_Query |
|
29 | - * @since 1.0.19 |
|
30 | - */ |
|
31 | - public $query; |
|
32 | - |
|
33 | - /** |
|
34 | - * Total subscriptions |
|
35 | - * |
|
36 | - * @var string |
|
37 | - * @since 1.0.0 |
|
38 | - */ |
|
39 | - public $total_count; |
|
40 | - |
|
41 | - /** |
|
42 | - * Current status subscriptions |
|
43 | - * |
|
44 | - * @var string |
|
45 | - * @since 1.0.0 |
|
46 | - */ |
|
47 | - public $current_total_count; |
|
48 | - |
|
49 | - /** |
|
50 | - * Status counts |
|
51 | - * |
|
52 | - * @var array |
|
53 | - * @since 1.0.19 |
|
54 | - */ |
|
55 | - public $status_counts; |
|
56 | - |
|
57 | - /** |
|
58 | - * Number of results to show per page |
|
59 | - * |
|
60 | - * @var int |
|
61 | - * @since 1.0.0 |
|
62 | - */ |
|
63 | - public $per_page = 10; |
|
64 | - |
|
65 | - /** |
|
66 | - * Constructor function. |
|
67 | - */ |
|
68 | - public function __construct() { |
|
69 | - |
|
70 | - parent::__construct( |
|
71 | - array( |
|
72 | - 'singular' => 'subscription', |
|
73 | - 'plural' => 'subscriptions', |
|
74 | - ) |
|
75 | - ); |
|
76 | - |
|
77 | - $this->process_bulk_action(); |
|
78 | - |
|
79 | - $this->prepare_query(); |
|
80 | - |
|
81 | - $this->base_url = remove_query_arg( 'status' ); |
|
82 | - |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Prepares the display query |
|
87 | - */ |
|
88 | - public function prepare_query() { |
|
89 | - |
|
90 | - // Prepare query args. |
|
91 | - $query = array( |
|
92 | - 'number' => $this->per_page, |
|
93 | - 'paged' => $this->get_paged(), |
|
94 | - 'status' => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? $_GET['status'] : 'all', |
|
95 | - 'orderby' => ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id', |
|
96 | - 'order' => ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC', |
|
97 | - ); |
|
98 | - |
|
99 | - // Prepare class properties. |
|
100 | - $this->query = new GetPaid_Subscriptions_Query( $query ); |
|
101 | - $this->total_count = $this->query->get_total(); |
|
102 | - $this->current_total_count = $this->query->get_total(); |
|
103 | - $this->items = $this->query->get_results(); |
|
104 | - $this->status_counts = getpaid_get_subscription_status_counts( $query ); |
|
105 | - |
|
106 | - if ( 'all' != $query['status'] ) { |
|
107 | - unset( $query['status'] ); |
|
108 | - $this->total_count = getpaid_get_subscriptions( $query, 'count' ); |
|
109 | - } |
|
110 | - |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Gets the list of views available on this table. |
|
115 | - * |
|
116 | - * The format is an associative array: |
|
117 | - * - `'id' => 'link'` |
|
118 | - * |
|
119 | - * @since 1.0.0 |
|
120 | - * |
|
121 | - * @return array |
|
122 | - */ |
|
123 | - protected function get_views() { |
|
124 | - |
|
125 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : 'all'; |
|
126 | - $views = array( |
|
127 | - |
|
128 | - 'all' => sprintf( |
|
129 | - '<a href="%s" %s>%s <span class="count">(%d)</span></a>', |
|
130 | - esc_url( add_query_arg( 'status', false, $this->base_url ) ), |
|
131 | - $current === 'all' ? ' class="current"' : '', |
|
132 | - __('All','invoicing' ), |
|
133 | - $this->total_count |
|
134 | - ) |
|
135 | - |
|
136 | - ); |
|
137 | - |
|
138 | - foreach ( array_filter( $this->status_counts ) as $status => $count ) { |
|
139 | - |
|
140 | - $views[ $status ] = sprintf( |
|
141 | - '<a href="%s" %s>%s <span class="count">(%d)</span></a>', |
|
142 | - esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ), |
|
143 | - $current === $status ? ' class="current"' : '', |
|
144 | - sanitize_text_field( getpaid_get_subscription_status_label( $status ) ), |
|
145 | - $count |
|
146 | - ); |
|
147 | - |
|
148 | - } |
|
149 | - |
|
150 | - return $views; |
|
151 | - |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Render most columns |
|
156 | - * |
|
157 | - * @access private |
|
158 | - * @since 1.0.0 |
|
159 | - * @return string |
|
160 | - */ |
|
161 | - public function column_default( $item, $column_name ) { |
|
162 | - return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name ); |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * This is how checkbox column renders. |
|
167 | - * |
|
168 | - * @param WPInv_Subscription $item |
|
169 | - * @return string |
|
170 | - */ |
|
171 | - public function column_cb( $item ) { |
|
172 | - return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) ); |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * Status column |
|
177 | - * |
|
178 | - * @param WPInv_Subscription $item |
|
179 | - * @since 1.0.0 |
|
180 | - * @return string |
|
181 | - */ |
|
182 | - public function column_status( $item ) { |
|
183 | - return $item->get_status_label_html(); |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Subscription column |
|
188 | - * |
|
189 | - * @param WPInv_Subscription $item |
|
190 | - * @since 1.0.0 |
|
191 | - * @return string |
|
192 | - */ |
|
193 | - public function column_subscription( $item ) { |
|
194 | - |
|
195 | - $username = __( '(Missing User)', 'invoicing' ); |
|
196 | - |
|
197 | - $user = get_userdata( $item->get_customer_id() ); |
|
198 | - if ( $user ) { |
|
199 | - |
|
200 | - $username = sprintf( |
|
201 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
202 | - absint( $user->ID ), |
|
203 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
204 | - ); |
|
205 | - |
|
206 | - } |
|
207 | - |
|
208 | - // translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name |
|
209 | - $column_content = sprintf( |
|
210 | - _x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ), |
|
211 | - '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">', |
|
212 | - '<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>', |
|
213 | - $username |
|
214 | - ); |
|
215 | - |
|
216 | - $row_actions = array(); |
|
217 | - |
|
218 | - // View subscription. |
|
219 | - $view_url = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) )); |
|
220 | - $row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>'; |
|
221 | - |
|
222 | - // View invoice. |
|
223 | - $invoice = get_post( $item->get_parent_invoice_id() ); |
|
224 | - |
|
225 | - if ( ! empty( $invoice ) ) { |
|
226 | - $view_url = get_edit_post_link( $invoice ); |
|
227 | - $row_actions['invoice'] = '<a href="' . $view_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>'; |
|
228 | - } |
|
229 | - |
|
230 | - $row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) ); |
|
231 | - |
|
232 | - return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions; |
|
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * Renewal date column |
|
237 | - * |
|
238 | - * @param WPInv_Subscription $item |
|
239 | - * @since 1.0.0 |
|
240 | - * @return string |
|
241 | - */ |
|
242 | - public function column_renewal_date( $item ) { |
|
243 | - return getpaid_format_date_value( $item->get_expiration() ); |
|
244 | - } |
|
245 | - |
|
246 | - /** |
|
247 | - * Start date column |
|
248 | - * |
|
249 | - * @param WPInv_Subscription $item |
|
250 | - * @since 1.0.0 |
|
251 | - * @return string |
|
252 | - */ |
|
253 | - public function column_start_date( $item ) { |
|
254 | - return getpaid_format_date_value( $item->get_date_created() ); |
|
255 | - } |
|
256 | - |
|
257 | - /** |
|
258 | - * Amount column |
|
259 | - * |
|
260 | - * @param WPInv_Subscription $item |
|
261 | - * @since 1.0.19 |
|
262 | - * @return string |
|
263 | - */ |
|
264 | - public function column_amount( $item ) { |
|
265 | - |
|
266 | - $initial = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_initial_amount() ) ), $item->get_parent_payment()->get_currency() ); |
|
267 | - $recurring = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_recurring_amount() ) ), $item->get_parent_payment()->get_currency() ); |
|
268 | - $period = 1 == $item->get_frequency() ? getpaid_get_subscription_period_label( $item->get_period() ) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->get_period(),$item->get_frequency() ); |
|
269 | - |
|
270 | - if ( $item->has_trial_period() ) { |
|
271 | - |
|
272 | - // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
|
273 | - $amount = sprintf( |
|
274 | - _x( '%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
275 | - $initial, |
|
276 | - sanitize_text_field( $item->get_trial_period() ), |
|
277 | - $recurring, |
|
278 | - sanitize_text_field( strtolower( $period ) ) |
|
279 | - ); |
|
280 | - |
|
281 | - } else if ( $initial != $recurring ) { |
|
282 | - |
|
283 | - // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring perio |
|
284 | - $amount = sprintf( |
|
285 | - _x( 'Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing' ), |
|
286 | - $initial, |
|
287 | - $recurring, |
|
288 | - sanitize_text_field( strtolower( $period ) ) |
|
289 | - ); |
|
290 | - |
|
291 | - } else { |
|
292 | - |
|
293 | - // translators: $1: is the recurring amount, $2: is the recurring period |
|
294 | - $amount = sprintf( |
|
295 | - _x( '%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing' ), |
|
296 | - $initial, |
|
297 | - sanitize_text_field( strtolower( $period ) ) |
|
298 | - ); |
|
299 | - |
|
300 | - } |
|
301 | - |
|
302 | - return "<span class='text-muted form-text mt-2 mb-2'>$amount</span>"; |
|
303 | - } |
|
304 | - |
|
305 | - /** |
|
306 | - * Billing Times column |
|
307 | - * |
|
308 | - * @param WPInv_Subscription $item |
|
309 | - * @since 1.0.0 |
|
310 | - * @return string |
|
311 | - */ |
|
312 | - public function column_renewals( $item ) { |
|
313 | - $max_bills = $item->get_bill_times(); |
|
314 | - return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
315 | - } |
|
316 | - |
|
317 | - /** |
|
318 | - * Product ID column |
|
319 | - * |
|
320 | - * @param WPInv_Subscription $item |
|
321 | - * @since 1.0.0 |
|
322 | - * @return string |
|
323 | - */ |
|
324 | - public function column_item( $item ) { |
|
325 | - $_item = get_post( $item->get_product_id() ); |
|
326 | - |
|
327 | - if ( ! empty( $_item ) ) { |
|
328 | - $link = get_edit_post_link( $_item ); |
|
329 | - $link = esc_url( $link ); |
|
330 | - $name = esc_html( get_the_title( $_item ) ); |
|
331 | - return "<a href='$link'>$name</a>"; |
|
332 | - } else { |
|
333 | - return sprintf( __( 'Item #%s', 'invoicing' ), $item->get_product_id() ); |
|
334 | - } |
|
335 | - |
|
336 | - } |
|
337 | - |
|
338 | - /** |
|
339 | - * Retrieve the current page number |
|
340 | - * |
|
341 | - * @return int |
|
342 | - */ |
|
343 | - public function get_paged() { |
|
344 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
345 | - } |
|
346 | - |
|
347 | - /** |
|
348 | - * Setup the final data for the table |
|
349 | - * |
|
350 | - */ |
|
351 | - public function prepare_items() { |
|
352 | - |
|
353 | - $columns = $this->get_columns(); |
|
354 | - $hidden = array(); |
|
355 | - $sortable = $this->get_sortable_columns(); |
|
356 | - |
|
357 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
358 | - |
|
359 | - $this->set_pagination_args( |
|
360 | - array( |
|
361 | - 'total_items' => $this->current_total_count, |
|
362 | - 'per_page' => $this->per_page, |
|
363 | - 'total_pages' => ceil( $this->current_total_count / $this->per_page ) |
|
364 | - ) |
|
365 | - ); |
|
366 | - } |
|
367 | - |
|
368 | - /** |
|
369 | - * Table columns |
|
370 | - * |
|
371 | - * @return array |
|
372 | - */ |
|
373 | - public function get_columns(){ |
|
374 | - $columns = array( |
|
375 | - 'cb' => '<input type="checkbox" />', |
|
376 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
377 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
378 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
379 | - 'renewals' => __( 'Renewals', 'invoicing' ), |
|
380 | - 'item' => __( 'Item', 'invoicing' ), |
|
381 | - 'status' => __( 'Status', 'invoicing' ), |
|
382 | - ); |
|
383 | - |
|
384 | - return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns ); |
|
385 | - } |
|
386 | - |
|
387 | - /** |
|
388 | - * Sortable table columns. |
|
389 | - * |
|
390 | - * @return array |
|
391 | - */ |
|
392 | - public function get_sortable_columns() { |
|
393 | - $sortable = array( |
|
394 | - 'subscription' => array( 'id', true ), |
|
395 | - 'start_date' => array( 'created', true ), |
|
396 | - 'renewal_date' => array( 'expiration', true ), |
|
397 | - 'renewals' => array( 'bill_times', true ), |
|
398 | - 'item' => array( 'product_id', true ), |
|
399 | - 'status' => array( 'status', true ), |
|
400 | - ); |
|
401 | - |
|
402 | - return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable ); |
|
403 | - } |
|
404 | - |
|
405 | - /** |
|
406 | - * Whether the table has items to display or not |
|
407 | - * |
|
408 | - * @return bool |
|
409 | - */ |
|
410 | - public function has_items() { |
|
411 | - return ! empty( $this->current_total_count ); |
|
412 | - } |
|
413 | - |
|
414 | - /** |
|
415 | - * Processes bulk actions. |
|
416 | - * |
|
417 | - */ |
|
418 | - public function process_bulk_action() { |
|
419 | - |
|
420 | - } |
|
17 | + /** |
|
18 | + * URL of this page |
|
19 | + * |
|
20 | + * @var string |
|
21 | + * @since 1.0.19 |
|
22 | + */ |
|
23 | + public $base_url; |
|
24 | + |
|
25 | + /** |
|
26 | + * Query |
|
27 | + * |
|
28 | + * @var GetPaid_Subscriptions_Query |
|
29 | + * @since 1.0.19 |
|
30 | + */ |
|
31 | + public $query; |
|
32 | + |
|
33 | + /** |
|
34 | + * Total subscriptions |
|
35 | + * |
|
36 | + * @var string |
|
37 | + * @since 1.0.0 |
|
38 | + */ |
|
39 | + public $total_count; |
|
40 | + |
|
41 | + /** |
|
42 | + * Current status subscriptions |
|
43 | + * |
|
44 | + * @var string |
|
45 | + * @since 1.0.0 |
|
46 | + */ |
|
47 | + public $current_total_count; |
|
48 | + |
|
49 | + /** |
|
50 | + * Status counts |
|
51 | + * |
|
52 | + * @var array |
|
53 | + * @since 1.0.19 |
|
54 | + */ |
|
55 | + public $status_counts; |
|
56 | + |
|
57 | + /** |
|
58 | + * Number of results to show per page |
|
59 | + * |
|
60 | + * @var int |
|
61 | + * @since 1.0.0 |
|
62 | + */ |
|
63 | + public $per_page = 10; |
|
64 | + |
|
65 | + /** |
|
66 | + * Constructor function. |
|
67 | + */ |
|
68 | + public function __construct() { |
|
69 | + |
|
70 | + parent::__construct( |
|
71 | + array( |
|
72 | + 'singular' => 'subscription', |
|
73 | + 'plural' => 'subscriptions', |
|
74 | + ) |
|
75 | + ); |
|
76 | + |
|
77 | + $this->process_bulk_action(); |
|
78 | + |
|
79 | + $this->prepare_query(); |
|
80 | + |
|
81 | + $this->base_url = remove_query_arg( 'status' ); |
|
82 | + |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Prepares the display query |
|
87 | + */ |
|
88 | + public function prepare_query() { |
|
89 | + |
|
90 | + // Prepare query args. |
|
91 | + $query = array( |
|
92 | + 'number' => $this->per_page, |
|
93 | + 'paged' => $this->get_paged(), |
|
94 | + 'status' => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? $_GET['status'] : 'all', |
|
95 | + 'orderby' => ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id', |
|
96 | + 'order' => ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC', |
|
97 | + ); |
|
98 | + |
|
99 | + // Prepare class properties. |
|
100 | + $this->query = new GetPaid_Subscriptions_Query( $query ); |
|
101 | + $this->total_count = $this->query->get_total(); |
|
102 | + $this->current_total_count = $this->query->get_total(); |
|
103 | + $this->items = $this->query->get_results(); |
|
104 | + $this->status_counts = getpaid_get_subscription_status_counts( $query ); |
|
105 | + |
|
106 | + if ( 'all' != $query['status'] ) { |
|
107 | + unset( $query['status'] ); |
|
108 | + $this->total_count = getpaid_get_subscriptions( $query, 'count' ); |
|
109 | + } |
|
110 | + |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Gets the list of views available on this table. |
|
115 | + * |
|
116 | + * The format is an associative array: |
|
117 | + * - `'id' => 'link'` |
|
118 | + * |
|
119 | + * @since 1.0.0 |
|
120 | + * |
|
121 | + * @return array |
|
122 | + */ |
|
123 | + protected function get_views() { |
|
124 | + |
|
125 | + $current = isset( $_GET['status'] ) ? $_GET['status'] : 'all'; |
|
126 | + $views = array( |
|
127 | + |
|
128 | + 'all' => sprintf( |
|
129 | + '<a href="%s" %s>%s <span class="count">(%d)</span></a>', |
|
130 | + esc_url( add_query_arg( 'status', false, $this->base_url ) ), |
|
131 | + $current === 'all' ? ' class="current"' : '', |
|
132 | + __('All','invoicing' ), |
|
133 | + $this->total_count |
|
134 | + ) |
|
135 | + |
|
136 | + ); |
|
137 | + |
|
138 | + foreach ( array_filter( $this->status_counts ) as $status => $count ) { |
|
139 | + |
|
140 | + $views[ $status ] = sprintf( |
|
141 | + '<a href="%s" %s>%s <span class="count">(%d)</span></a>', |
|
142 | + esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ), |
|
143 | + $current === $status ? ' class="current"' : '', |
|
144 | + sanitize_text_field( getpaid_get_subscription_status_label( $status ) ), |
|
145 | + $count |
|
146 | + ); |
|
147 | + |
|
148 | + } |
|
149 | + |
|
150 | + return $views; |
|
151 | + |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Render most columns |
|
156 | + * |
|
157 | + * @access private |
|
158 | + * @since 1.0.0 |
|
159 | + * @return string |
|
160 | + */ |
|
161 | + public function column_default( $item, $column_name ) { |
|
162 | + return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name ); |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * This is how checkbox column renders. |
|
167 | + * |
|
168 | + * @param WPInv_Subscription $item |
|
169 | + * @return string |
|
170 | + */ |
|
171 | + public function column_cb( $item ) { |
|
172 | + return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) ); |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * Status column |
|
177 | + * |
|
178 | + * @param WPInv_Subscription $item |
|
179 | + * @since 1.0.0 |
|
180 | + * @return string |
|
181 | + */ |
|
182 | + public function column_status( $item ) { |
|
183 | + return $item->get_status_label_html(); |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Subscription column |
|
188 | + * |
|
189 | + * @param WPInv_Subscription $item |
|
190 | + * @since 1.0.0 |
|
191 | + * @return string |
|
192 | + */ |
|
193 | + public function column_subscription( $item ) { |
|
194 | + |
|
195 | + $username = __( '(Missing User)', 'invoicing' ); |
|
196 | + |
|
197 | + $user = get_userdata( $item->get_customer_id() ); |
|
198 | + if ( $user ) { |
|
199 | + |
|
200 | + $username = sprintf( |
|
201 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
202 | + absint( $user->ID ), |
|
203 | + ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
204 | + ); |
|
205 | + |
|
206 | + } |
|
207 | + |
|
208 | + // translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name |
|
209 | + $column_content = sprintf( |
|
210 | + _x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ), |
|
211 | + '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">', |
|
212 | + '<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>', |
|
213 | + $username |
|
214 | + ); |
|
215 | + |
|
216 | + $row_actions = array(); |
|
217 | + |
|
218 | + // View subscription. |
|
219 | + $view_url = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) )); |
|
220 | + $row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>'; |
|
221 | + |
|
222 | + // View invoice. |
|
223 | + $invoice = get_post( $item->get_parent_invoice_id() ); |
|
224 | + |
|
225 | + if ( ! empty( $invoice ) ) { |
|
226 | + $view_url = get_edit_post_link( $invoice ); |
|
227 | + $row_actions['invoice'] = '<a href="' . $view_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>'; |
|
228 | + } |
|
229 | + |
|
230 | + $row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) ); |
|
231 | + |
|
232 | + return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions; |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * Renewal date column |
|
237 | + * |
|
238 | + * @param WPInv_Subscription $item |
|
239 | + * @since 1.0.0 |
|
240 | + * @return string |
|
241 | + */ |
|
242 | + public function column_renewal_date( $item ) { |
|
243 | + return getpaid_format_date_value( $item->get_expiration() ); |
|
244 | + } |
|
245 | + |
|
246 | + /** |
|
247 | + * Start date column |
|
248 | + * |
|
249 | + * @param WPInv_Subscription $item |
|
250 | + * @since 1.0.0 |
|
251 | + * @return string |
|
252 | + */ |
|
253 | + public function column_start_date( $item ) { |
|
254 | + return getpaid_format_date_value( $item->get_date_created() ); |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * Amount column |
|
259 | + * |
|
260 | + * @param WPInv_Subscription $item |
|
261 | + * @since 1.0.19 |
|
262 | + * @return string |
|
263 | + */ |
|
264 | + public function column_amount( $item ) { |
|
265 | + |
|
266 | + $initial = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_initial_amount() ) ), $item->get_parent_payment()->get_currency() ); |
|
267 | + $recurring = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_recurring_amount() ) ), $item->get_parent_payment()->get_currency() ); |
|
268 | + $period = 1 == $item->get_frequency() ? getpaid_get_subscription_period_label( $item->get_period() ) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->get_period(),$item->get_frequency() ); |
|
269 | + |
|
270 | + if ( $item->has_trial_period() ) { |
|
271 | + |
|
272 | + // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
|
273 | + $amount = sprintf( |
|
274 | + _x( '%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
275 | + $initial, |
|
276 | + sanitize_text_field( $item->get_trial_period() ), |
|
277 | + $recurring, |
|
278 | + sanitize_text_field( strtolower( $period ) ) |
|
279 | + ); |
|
280 | + |
|
281 | + } else if ( $initial != $recurring ) { |
|
282 | + |
|
283 | + // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring perio |
|
284 | + $amount = sprintf( |
|
285 | + _x( 'Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing' ), |
|
286 | + $initial, |
|
287 | + $recurring, |
|
288 | + sanitize_text_field( strtolower( $period ) ) |
|
289 | + ); |
|
290 | + |
|
291 | + } else { |
|
292 | + |
|
293 | + // translators: $1: is the recurring amount, $2: is the recurring period |
|
294 | + $amount = sprintf( |
|
295 | + _x( '%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing' ), |
|
296 | + $initial, |
|
297 | + sanitize_text_field( strtolower( $period ) ) |
|
298 | + ); |
|
299 | + |
|
300 | + } |
|
301 | + |
|
302 | + return "<span class='text-muted form-text mt-2 mb-2'>$amount</span>"; |
|
303 | + } |
|
304 | + |
|
305 | + /** |
|
306 | + * Billing Times column |
|
307 | + * |
|
308 | + * @param WPInv_Subscription $item |
|
309 | + * @since 1.0.0 |
|
310 | + * @return string |
|
311 | + */ |
|
312 | + public function column_renewals( $item ) { |
|
313 | + $max_bills = $item->get_bill_times(); |
|
314 | + return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
315 | + } |
|
316 | + |
|
317 | + /** |
|
318 | + * Product ID column |
|
319 | + * |
|
320 | + * @param WPInv_Subscription $item |
|
321 | + * @since 1.0.0 |
|
322 | + * @return string |
|
323 | + */ |
|
324 | + public function column_item( $item ) { |
|
325 | + $_item = get_post( $item->get_product_id() ); |
|
326 | + |
|
327 | + if ( ! empty( $_item ) ) { |
|
328 | + $link = get_edit_post_link( $_item ); |
|
329 | + $link = esc_url( $link ); |
|
330 | + $name = esc_html( get_the_title( $_item ) ); |
|
331 | + return "<a href='$link'>$name</a>"; |
|
332 | + } else { |
|
333 | + return sprintf( __( 'Item #%s', 'invoicing' ), $item->get_product_id() ); |
|
334 | + } |
|
335 | + |
|
336 | + } |
|
337 | + |
|
338 | + /** |
|
339 | + * Retrieve the current page number |
|
340 | + * |
|
341 | + * @return int |
|
342 | + */ |
|
343 | + public function get_paged() { |
|
344 | + return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
345 | + } |
|
346 | + |
|
347 | + /** |
|
348 | + * Setup the final data for the table |
|
349 | + * |
|
350 | + */ |
|
351 | + public function prepare_items() { |
|
352 | + |
|
353 | + $columns = $this->get_columns(); |
|
354 | + $hidden = array(); |
|
355 | + $sortable = $this->get_sortable_columns(); |
|
356 | + |
|
357 | + $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
358 | + |
|
359 | + $this->set_pagination_args( |
|
360 | + array( |
|
361 | + 'total_items' => $this->current_total_count, |
|
362 | + 'per_page' => $this->per_page, |
|
363 | + 'total_pages' => ceil( $this->current_total_count / $this->per_page ) |
|
364 | + ) |
|
365 | + ); |
|
366 | + } |
|
367 | + |
|
368 | + /** |
|
369 | + * Table columns |
|
370 | + * |
|
371 | + * @return array |
|
372 | + */ |
|
373 | + public function get_columns(){ |
|
374 | + $columns = array( |
|
375 | + 'cb' => '<input type="checkbox" />', |
|
376 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
377 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
378 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
379 | + 'renewals' => __( 'Renewals', 'invoicing' ), |
|
380 | + 'item' => __( 'Item', 'invoicing' ), |
|
381 | + 'status' => __( 'Status', 'invoicing' ), |
|
382 | + ); |
|
383 | + |
|
384 | + return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns ); |
|
385 | + } |
|
386 | + |
|
387 | + /** |
|
388 | + * Sortable table columns. |
|
389 | + * |
|
390 | + * @return array |
|
391 | + */ |
|
392 | + public function get_sortable_columns() { |
|
393 | + $sortable = array( |
|
394 | + 'subscription' => array( 'id', true ), |
|
395 | + 'start_date' => array( 'created', true ), |
|
396 | + 'renewal_date' => array( 'expiration', true ), |
|
397 | + 'renewals' => array( 'bill_times', true ), |
|
398 | + 'item' => array( 'product_id', true ), |
|
399 | + 'status' => array( 'status', true ), |
|
400 | + ); |
|
401 | + |
|
402 | + return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable ); |
|
403 | + } |
|
404 | + |
|
405 | + /** |
|
406 | + * Whether the table has items to display or not |
|
407 | + * |
|
408 | + * @return bool |
|
409 | + */ |
|
410 | + public function has_items() { |
|
411 | + return ! empty( $this->current_total_count ); |
|
412 | + } |
|
413 | + |
|
414 | + /** |
|
415 | + * Processes bulk actions. |
|
416 | + * |
|
417 | + */ |
|
418 | + public function process_bulk_action() { |
|
419 | + |
|
420 | + } |
|
421 | 421 | |
422 | 422 | } |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | * Displays a list of all subscriptions rules |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
6 | +if (!defined('ABSPATH')) exit; |
|
7 | 7 | |
8 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
8 | +if (!class_exists('WP_List_Table')) { |
|
9 | 9 | include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
10 | 10 | } |
11 | 11 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $this->prepare_query(); |
80 | 80 | |
81 | - $this->base_url = remove_query_arg( 'status' ); |
|
81 | + $this->base_url = remove_query_arg('status'); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | |
@@ -91,21 +91,21 @@ discard block |
||
91 | 91 | $query = array( |
92 | 92 | 'number' => $this->per_page, |
93 | 93 | 'paged' => $this->get_paged(), |
94 | - 'status' => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? $_GET['status'] : 'all', |
|
95 | - 'orderby' => ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id', |
|
96 | - 'order' => ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC', |
|
94 | + 'status' => (isset($_GET['status']) && array_key_exists($_GET['status'], getpaid_get_subscription_statuses())) ? $_GET['status'] : 'all', |
|
95 | + 'orderby' => (isset($_GET['orderby'])) ? $_GET['orderby'] : 'id', |
|
96 | + 'order' => (isset($_GET['order'])) ? $_GET['order'] : 'DESC', |
|
97 | 97 | ); |
98 | 98 | |
99 | 99 | // Prepare class properties. |
100 | - $this->query = new GetPaid_Subscriptions_Query( $query ); |
|
100 | + $this->query = new GetPaid_Subscriptions_Query($query); |
|
101 | 101 | $this->total_count = $this->query->get_total(); |
102 | 102 | $this->current_total_count = $this->query->get_total(); |
103 | 103 | $this->items = $this->query->get_results(); |
104 | - $this->status_counts = getpaid_get_subscription_status_counts( $query ); |
|
104 | + $this->status_counts = getpaid_get_subscription_status_counts($query); |
|
105 | 105 | |
106 | - if ( 'all' != $query['status'] ) { |
|
107 | - unset( $query['status'] ); |
|
108 | - $this->total_count = getpaid_get_subscriptions( $query, 'count' ); |
|
106 | + if ('all' != $query['status']) { |
|
107 | + unset($query['status']); |
|
108 | + $this->total_count = getpaid_get_subscriptions($query, 'count'); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | } |
@@ -122,26 +122,26 @@ discard block |
||
122 | 122 | */ |
123 | 123 | protected function get_views() { |
124 | 124 | |
125 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : 'all'; |
|
125 | + $current = isset($_GET['status']) ? $_GET['status'] : 'all'; |
|
126 | 126 | $views = array( |
127 | 127 | |
128 | 128 | 'all' => sprintf( |
129 | 129 | '<a href="%s" %s>%s <span class="count">(%d)</span></a>', |
130 | - esc_url( add_query_arg( 'status', false, $this->base_url ) ), |
|
130 | + esc_url(add_query_arg('status', false, $this->base_url)), |
|
131 | 131 | $current === 'all' ? ' class="current"' : '', |
132 | - __('All','invoicing' ), |
|
132 | + __('All', 'invoicing'), |
|
133 | 133 | $this->total_count |
134 | 134 | ) |
135 | 135 | |
136 | 136 | ); |
137 | 137 | |
138 | - foreach ( array_filter( $this->status_counts ) as $status => $count ) { |
|
138 | + foreach (array_filter($this->status_counts) as $status => $count) { |
|
139 | 139 | |
140 | - $views[ $status ] = sprintf( |
|
140 | + $views[$status] = sprintf( |
|
141 | 141 | '<a href="%s" %s>%s <span class="count">(%d)</span></a>', |
142 | - esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ), |
|
142 | + esc_url(add_query_arg('status', urlencode($status), $this->base_url)), |
|
143 | 143 | $current === $status ? ' class="current"' : '', |
144 | - sanitize_text_field( getpaid_get_subscription_status_label( $status ) ), |
|
144 | + sanitize_text_field(getpaid_get_subscription_status_label($status)), |
|
145 | 145 | $count |
146 | 146 | ); |
147 | 147 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @since 1.0.0 |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - public function column_default( $item, $column_name ) { |
|
162 | - return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name ); |
|
161 | + public function column_default($item, $column_name) { |
|
162 | + return apply_filters("getpaid_subscriptions_table_column_$column_name", $item->$column_name); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * @param WPInv_Subscription $item |
169 | 169 | * @return string |
170 | 170 | */ |
171 | - public function column_cb( $item ) { |
|
172 | - return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) ); |
|
171 | + public function column_cb($item) { |
|
172 | + return sprintf('<input type="checkbox" name="id[]" value="%s" />', esc_html($item->get_id())); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @since 1.0.0 |
180 | 180 | * @return string |
181 | 181 | */ |
182 | - public function column_status( $item ) { |
|
182 | + public function column_status($item) { |
|
183 | 183 | return $item->get_status_label_html(); |
184 | 184 | } |
185 | 185 | |
@@ -190,46 +190,46 @@ discard block |
||
190 | 190 | * @since 1.0.0 |
191 | 191 | * @return string |
192 | 192 | */ |
193 | - public function column_subscription( $item ) { |
|
193 | + public function column_subscription($item) { |
|
194 | 194 | |
195 | - $username = __( '(Missing User)', 'invoicing' ); |
|
195 | + $username = __('(Missing User)', 'invoicing'); |
|
196 | 196 | |
197 | - $user = get_userdata( $item->get_customer_id() ); |
|
198 | - if ( $user ) { |
|
197 | + $user = get_userdata($item->get_customer_id()); |
|
198 | + if ($user) { |
|
199 | 199 | |
200 | 200 | $username = sprintf( |
201 | 201 | '<a href="user-edit.php?user_id=%s">%s</a>', |
202 | - absint( $user->ID ), |
|
203 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
202 | + absint($user->ID), |
|
203 | + !empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email) |
|
204 | 204 | ); |
205 | 205 | |
206 | 206 | } |
207 | 207 | |
208 | 208 | // translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name |
209 | 209 | $column_content = sprintf( |
210 | - _x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ), |
|
211 | - '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">', |
|
212 | - '<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>', |
|
210 | + _x('%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing'), |
|
211 | + '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($item->get_id()))) . '">', |
|
212 | + '<strong>' . esc_attr($item->get_id()) . '</strong>', '</a>', |
|
213 | 213 | $username |
214 | 214 | ); |
215 | 215 | |
216 | 216 | $row_actions = array(); |
217 | 217 | |
218 | 218 | // View subscription. |
219 | - $view_url = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) )); |
|
220 | - $row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>'; |
|
219 | + $view_url = esc_url(add_query_arg('id', $item->get_id(), admin_url('admin.php?page=wpinv-subscriptions'))); |
|
220 | + $row_actions['view'] = '<a href="' . $view_url . '">' . __('View Subscription', 'invoicing') . '</a>'; |
|
221 | 221 | |
222 | 222 | // View invoice. |
223 | - $invoice = get_post( $item->get_parent_invoice_id() ); |
|
223 | + $invoice = get_post($item->get_parent_invoice_id()); |
|
224 | 224 | |
225 | - if ( ! empty( $invoice ) ) { |
|
226 | - $view_url = get_edit_post_link( $invoice ); |
|
227 | - $row_actions['invoice'] = '<a href="' . $view_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>'; |
|
225 | + if (!empty($invoice)) { |
|
226 | + $view_url = get_edit_post_link($invoice); |
|
227 | + $row_actions['invoice'] = '<a href="' . $view_url . '">' . __('View Invoice', 'invoicing') . '</a>'; |
|
228 | 228 | } |
229 | 229 | |
230 | - $row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) ); |
|
230 | + $row_actions = $this->row_actions(apply_filters('getpaid_subscription_table_row_actions', $row_actions, $item)); |
|
231 | 231 | |
232 | - return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions; |
|
232 | + return "<strong>$column_content</strong>" . $this->column_amount($item) . $row_actions; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | * @since 1.0.0 |
240 | 240 | * @return string |
241 | 241 | */ |
242 | - public function column_renewal_date( $item ) { |
|
243 | - return getpaid_format_date_value( $item->get_expiration() ); |
|
242 | + public function column_renewal_date($item) { |
|
243 | + return getpaid_format_date_value($item->get_expiration()); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | * @since 1.0.0 |
251 | 251 | * @return string |
252 | 252 | */ |
253 | - public function column_start_date( $item ) { |
|
254 | - return getpaid_format_date_value( $item->get_date_created() ); |
|
253 | + public function column_start_date($item) { |
|
254 | + return getpaid_format_date_value($item->get_date_created()); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -261,40 +261,40 @@ discard block |
||
261 | 261 | * @since 1.0.19 |
262 | 262 | * @return string |
263 | 263 | */ |
264 | - public function column_amount( $item ) { |
|
264 | + public function column_amount($item) { |
|
265 | 265 | |
266 | - $initial = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_initial_amount() ) ), $item->get_parent_payment()->get_currency() ); |
|
267 | - $recurring = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_recurring_amount() ) ), $item->get_parent_payment()->get_currency() ); |
|
268 | - $period = 1 == $item->get_frequency() ? getpaid_get_subscription_period_label( $item->get_period() ) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->get_period(),$item->get_frequency() ); |
|
266 | + $initial = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($item->get_initial_amount())), $item->get_parent_payment()->get_currency()); |
|
267 | + $recurring = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($item->get_recurring_amount())), $item->get_parent_payment()->get_currency()); |
|
268 | + $period = 1 == $item->get_frequency() ? getpaid_get_subscription_period_label($item->get_period()) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($item->get_period(), $item->get_frequency()); |
|
269 | 269 | |
270 | - if ( $item->has_trial_period() ) { |
|
270 | + if ($item->has_trial_period()) { |
|
271 | 271 | |
272 | 272 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
273 | 273 | $amount = sprintf( |
274 | - _x( '%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
274 | + _x('%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'), |
|
275 | 275 | $initial, |
276 | - sanitize_text_field( $item->get_trial_period() ), |
|
276 | + sanitize_text_field($item->get_trial_period()), |
|
277 | 277 | $recurring, |
278 | - sanitize_text_field( strtolower( $period ) ) |
|
278 | + sanitize_text_field(strtolower($period)) |
|
279 | 279 | ); |
280 | 280 | |
281 | - } else if ( $initial != $recurring ) { |
|
281 | + } else if ($initial != $recurring) { |
|
282 | 282 | |
283 | 283 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring perio |
284 | 284 | $amount = sprintf( |
285 | - _x( 'Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing' ), |
|
285 | + _x('Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing'), |
|
286 | 286 | $initial, |
287 | 287 | $recurring, |
288 | - sanitize_text_field( strtolower( $period ) ) |
|
288 | + sanitize_text_field(strtolower($period)) |
|
289 | 289 | ); |
290 | 290 | |
291 | 291 | } else { |
292 | 292 | |
293 | 293 | // translators: $1: is the recurring amount, $2: is the recurring period |
294 | 294 | $amount = sprintf( |
295 | - _x( '%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing' ), |
|
295 | + _x('%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing'), |
|
296 | 296 | $initial, |
297 | - sanitize_text_field( strtolower( $period ) ) |
|
297 | + sanitize_text_field(strtolower($period)) |
|
298 | 298 | ); |
299 | 299 | |
300 | 300 | } |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | * @since 1.0.0 |
310 | 310 | * @return string |
311 | 311 | */ |
312 | - public function column_renewals( $item ) { |
|
312 | + public function column_renewals($item) { |
|
313 | 313 | $max_bills = $item->get_bill_times(); |
314 | - return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
314 | + return $item->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -321,16 +321,16 @@ discard block |
||
321 | 321 | * @since 1.0.0 |
322 | 322 | * @return string |
323 | 323 | */ |
324 | - public function column_item( $item ) { |
|
325 | - $_item = get_post( $item->get_product_id() ); |
|
324 | + public function column_item($item) { |
|
325 | + $_item = get_post($item->get_product_id()); |
|
326 | 326 | |
327 | - if ( ! empty( $_item ) ) { |
|
328 | - $link = get_edit_post_link( $_item ); |
|
329 | - $link = esc_url( $link ); |
|
330 | - $name = esc_html( get_the_title( $_item ) ); |
|
327 | + if (!empty($_item)) { |
|
328 | + $link = get_edit_post_link($_item); |
|
329 | + $link = esc_url($link); |
|
330 | + $name = esc_html(get_the_title($_item)); |
|
331 | 331 | return "<a href='$link'>$name</a>"; |
332 | 332 | } else { |
333 | - return sprintf( __( 'Item #%s', 'invoicing' ), $item->get_product_id() ); |
|
333 | + return sprintf(__('Item #%s', 'invoicing'), $item->get_product_id()); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * @return int |
342 | 342 | */ |
343 | 343 | public function get_paged() { |
344 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
344 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -354,13 +354,13 @@ discard block |
||
354 | 354 | $hidden = array(); |
355 | 355 | $sortable = $this->get_sortable_columns(); |
356 | 356 | |
357 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
357 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
358 | 358 | |
359 | 359 | $this->set_pagination_args( |
360 | 360 | array( |
361 | 361 | 'total_items' => $this->current_total_count, |
362 | 362 | 'per_page' => $this->per_page, |
363 | - 'total_pages' => ceil( $this->current_total_count / $this->per_page ) |
|
363 | + 'total_pages' => ceil($this->current_total_count / $this->per_page) |
|
364 | 364 | ) |
365 | 365 | ); |
366 | 366 | } |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @return array |
372 | 372 | */ |
373 | - public function get_columns(){ |
|
373 | + public function get_columns() { |
|
374 | 374 | $columns = array( |
375 | 375 | 'cb' => '<input type="checkbox" />', |
376 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
377 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
378 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
379 | - 'renewals' => __( 'Renewals', 'invoicing' ), |
|
380 | - 'item' => __( 'Item', 'invoicing' ), |
|
381 | - 'status' => __( 'Status', 'invoicing' ), |
|
376 | + 'subscription' => __('Subscription', 'invoicing'), |
|
377 | + 'start_date' => __('Start Date', 'invoicing'), |
|
378 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
379 | + 'renewals' => __('Renewals', 'invoicing'), |
|
380 | + 'item' => __('Item', 'invoicing'), |
|
381 | + 'status' => __('Status', 'invoicing'), |
|
382 | 382 | ); |
383 | 383 | |
384 | - return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns ); |
|
384 | + return apply_filters('manage_getpaid_subscriptions_table_columns', $columns); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -391,15 +391,15 @@ discard block |
||
391 | 391 | */ |
392 | 392 | public function get_sortable_columns() { |
393 | 393 | $sortable = array( |
394 | - 'subscription' => array( 'id', true ), |
|
395 | - 'start_date' => array( 'created', true ), |
|
396 | - 'renewal_date' => array( 'expiration', true ), |
|
397 | - 'renewals' => array( 'bill_times', true ), |
|
398 | - 'item' => array( 'product_id', true ), |
|
399 | - 'status' => array( 'status', true ), |
|
394 | + 'subscription' => array('id', true), |
|
395 | + 'start_date' => array('created', true), |
|
396 | + 'renewal_date' => array('expiration', true), |
|
397 | + 'renewals' => array('bill_times', true), |
|
398 | + 'item' => array('product_id', true), |
|
399 | + 'status' => array('status', true), |
|
400 | 400 | ); |
401 | 401 | |
402 | - return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable ); |
|
402 | + return apply_filters('manage_getpaid_subscriptions_sortable_table_columns', $sortable); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @return bool |
409 | 409 | */ |
410 | 410 | public function has_items() { |
411 | - return ! empty( $this->current_total_count ); |
|
411 | + return !empty($this->current_total_count); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | /** |