@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class GetPaid_Meta_Box_Invoice_Payment_Meta { |
18 | 18 | |
19 | 19 | /** |
20 | - * Output the metabox. |
|
21 | - * |
|
22 | - * @param WP_Post $post |
|
23 | - */ |
|
20 | + * Output the metabox. |
|
21 | + * |
|
22 | + * @param WP_Post $post |
|
23 | + */ |
|
24 | 24 | public static function output( $post ) { |
25 | 25 | |
26 | 26 | // Prepare the invoice. |
@@ -42,155 +42,155 @@ discard block |
||
42 | 42 | |
43 | 43 | if ( $invoice->is_draft() ) { |
44 | 44 | |
45 | - // Set gateway. |
|
46 | - echo aui()->select( |
|
45 | + // Set gateway. |
|
46 | + echo aui()->select( |
|
47 | 47 | array( |
48 | - 'id' => 'wpinv_gateway', |
|
49 | - 'name' => 'wpinv_gateway', |
|
50 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
51 | - 'label_type' => 'vertical', |
|
52 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
53 | - 'value' => wpinv_get_default_gateway(), |
|
54 | - 'select2' => true, |
|
55 | - 'data-allow-clear' => 'false', |
|
56 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
48 | + 'id' => 'wpinv_gateway', |
|
49 | + 'name' => 'wpinv_gateway', |
|
50 | + 'label' => __( 'Gateway:', 'invoicing' ), |
|
51 | + 'label_type' => 'vertical', |
|
52 | + 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
53 | + 'value' => wpinv_get_default_gateway(), |
|
54 | + 'select2' => true, |
|
55 | + 'data-allow-clear' => 'false', |
|
56 | + 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
57 | 57 | ) |
58 | 58 | ); |
59 | 59 | |
60 | 60 | } else { |
61 | - // Invoice key. |
|
62 | - echo aui()->input( |
|
61 | + // Invoice key. |
|
62 | + echo aui()->input( |
|
63 | 63 | array( |
64 | - 'type' => 'text', |
|
65 | - 'id' => 'wpinv_key', |
|
66 | - 'name' => 'wpinv_key', |
|
67 | - 'label' => sprintf( |
|
64 | + 'type' => 'text', |
|
65 | + 'id' => 'wpinv_key', |
|
66 | + 'name' => 'wpinv_key', |
|
67 | + 'label' => sprintf( |
|
68 | 68 | __( '%s Key:', 'invoicing' ), |
69 | 69 | ucfirst( $invoice->get_invoice_quote_type() ) |
70 | - ), |
|
71 | - 'label_type' => 'vertical', |
|
72 | - 'class' => 'form-control-sm', |
|
73 | - 'value' => $invoice->get_key( 'edit' ), |
|
74 | - 'extra_attributes' => array( |
|
70 | + ), |
|
71 | + 'label_type' => 'vertical', |
|
72 | + 'class' => 'form-control-sm', |
|
73 | + 'value' => $invoice->get_key( 'edit' ), |
|
74 | + 'extra_attributes' => array( |
|
75 | 75 | 'onclick' => 'this.select();', |
76 | 76 | 'readonly' => 'true', |
77 | - ), |
|
77 | + ), |
|
78 | 78 | ) |
79 | - ); |
|
79 | + ); |
|
80 | 80 | |
81 | - // View URL. |
|
82 | - echo aui()->input( |
|
81 | + // View URL. |
|
82 | + echo aui()->input( |
|
83 | 83 | array( |
84 | - 'type' => 'text', |
|
85 | - 'id' => 'wpinv_view_url', |
|
86 | - 'name' => 'wpinv_view_url', |
|
87 | - 'label' => sprintf( |
|
84 | + 'type' => 'text', |
|
85 | + 'id' => 'wpinv_view_url', |
|
86 | + 'name' => 'wpinv_view_url', |
|
87 | + 'label' => sprintf( |
|
88 | 88 | __( '%s URL:', 'invoicing' ), |
89 | 89 | ucfirst( $invoice->get_invoice_quote_type() ) |
90 | - ) . ' <a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>', |
|
91 | - 'label_type' => 'vertical', |
|
92 | - 'class' => 'form-control-sm', |
|
93 | - 'value' => $invoice->get_view_url(), |
|
94 | - 'extra_attributes' => array( |
|
90 | + ) . ' <a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>', |
|
91 | + 'label_type' => 'vertical', |
|
92 | + 'class' => 'form-control-sm', |
|
93 | + 'value' => $invoice->get_view_url(), |
|
94 | + 'extra_attributes' => array( |
|
95 | 95 | 'onclick' => 'this.select();', |
96 | 96 | 'readonly' => 'true', |
97 | - ), |
|
97 | + ), |
|
98 | 98 | ) |
99 | - ); |
|
100 | - |
|
101 | - // If the invoice is paid... |
|
102 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
103 | - |
|
104 | - // Gateway. |
|
105 | - echo aui()->input( |
|
106 | - array( |
|
107 | - 'type' => 'text', |
|
108 | - 'id' => 'wpinv_gateway', |
|
109 | - 'name' => '', |
|
110 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
111 | - 'label_type' => 'vertical', |
|
112 | - 'class' => 'form-control-sm', |
|
113 | - 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
114 | - 'extra_attributes' => array( |
|
115 | - 'onclick' => 'this.select();', |
|
116 | - 'readonly' => 'true', |
|
117 | - ), |
|
118 | - ) |
|
119 | - ); |
|
120 | - |
|
121 | - // Transaction ID. |
|
122 | - $transaction_url = $invoice->get_transaction_url(); |
|
123 | - echo aui()->input( |
|
124 | - array( |
|
125 | - 'type' => 'text', |
|
126 | - 'id' => 'wpinv_transaction_id', |
|
127 | - 'name' => 'wpinv_transaction_id', |
|
128 | - 'label' => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? ' <a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ), |
|
129 | - 'label_type' => 'vertical', |
|
130 | - 'class' => 'form-control-sm', |
|
131 | - 'value' => $invoice->get_transaction_id( 'edit' ), |
|
132 | - 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
133 | - 'extra_attributes' => array( |
|
134 | - 'onclick' => 'this.select();', |
|
135 | - 'readonly' => 'true', |
|
136 | - ), |
|
137 | - ) |
|
138 | - ); |
|
139 | - |
|
140 | - // Currency. |
|
141 | - echo aui()->input( |
|
142 | - array( |
|
143 | - 'type' => 'text', |
|
144 | - 'id' => 'wpinv_currency', |
|
145 | - 'name' => 'wpinv_currency', |
|
146 | - 'label' => __( 'Currency:', 'invoicing' ), |
|
147 | - 'label_type' => 'vertical', |
|
148 | - 'class' => 'form-control-sm', |
|
149 | - 'value' => $invoice->get_currency( 'edit' ), |
|
150 | - 'extra_attributes' => array( |
|
151 | - 'onclick' => 'this.select();', |
|
152 | - 'readonly' => 'true', |
|
153 | - ), |
|
154 | - ) |
|
155 | - ); |
|
156 | - |
|
157 | - } else { |
|
158 | - |
|
159 | - if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
160 | - |
|
161 | - // Payment URL. |
|
162 | - echo aui()->input( |
|
163 | - array( |
|
164 | - 'type' => 'text', |
|
165 | - 'id' => 'wpinv_payment_url', |
|
166 | - 'name' => 'wpinv_payment_url', |
|
167 | - 'label' => __( 'Payment URL:', 'invoicing' ), |
|
168 | - 'label_type' => 'vertical', |
|
169 | - 'class' => 'form-control-sm', |
|
170 | - 'value' => $invoice->get_checkout_payment_url(), |
|
171 | - 'extra_attributes' => array( |
|
172 | - 'onclick' => 'this.select();', |
|
173 | - 'readonly' => 'true', |
|
174 | - ), |
|
175 | - ) |
|
176 | - ); |
|
177 | - |
|
178 | - // Set gateway. |
|
179 | - echo aui()->select( |
|
180 | - array( |
|
181 | - 'id' => 'wpinv_gateway', |
|
182 | - 'name' => 'wpinv_gateway', |
|
183 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
184 | - 'label_type' => 'vertical', |
|
185 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
186 | - 'value' => $invoice->get_gateway( 'edit' ), |
|
187 | - 'select2' => true, |
|
188 | - 'data-allow-clear' => 'false', |
|
189 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
190 | - ) |
|
191 | - ); |
|
192 | - |
|
193 | - } |
|
99 | + ); |
|
100 | + |
|
101 | + // If the invoice is paid... |
|
102 | + if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
103 | + |
|
104 | + // Gateway. |
|
105 | + echo aui()->input( |
|
106 | + array( |
|
107 | + 'type' => 'text', |
|
108 | + 'id' => 'wpinv_gateway', |
|
109 | + 'name' => '', |
|
110 | + 'label' => __( 'Gateway:', 'invoicing' ), |
|
111 | + 'label_type' => 'vertical', |
|
112 | + 'class' => 'form-control-sm', |
|
113 | + 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
114 | + 'extra_attributes' => array( |
|
115 | + 'onclick' => 'this.select();', |
|
116 | + 'readonly' => 'true', |
|
117 | + ), |
|
118 | + ) |
|
119 | + ); |
|
120 | + |
|
121 | + // Transaction ID. |
|
122 | + $transaction_url = $invoice->get_transaction_url(); |
|
123 | + echo aui()->input( |
|
124 | + array( |
|
125 | + 'type' => 'text', |
|
126 | + 'id' => 'wpinv_transaction_id', |
|
127 | + 'name' => 'wpinv_transaction_id', |
|
128 | + 'label' => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? ' <a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ), |
|
129 | + 'label_type' => 'vertical', |
|
130 | + 'class' => 'form-control-sm', |
|
131 | + 'value' => $invoice->get_transaction_id( 'edit' ), |
|
132 | + 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
133 | + 'extra_attributes' => array( |
|
134 | + 'onclick' => 'this.select();', |
|
135 | + 'readonly' => 'true', |
|
136 | + ), |
|
137 | + ) |
|
138 | + ); |
|
139 | + |
|
140 | + // Currency. |
|
141 | + echo aui()->input( |
|
142 | + array( |
|
143 | + 'type' => 'text', |
|
144 | + 'id' => 'wpinv_currency', |
|
145 | + 'name' => 'wpinv_currency', |
|
146 | + 'label' => __( 'Currency:', 'invoicing' ), |
|
147 | + 'label_type' => 'vertical', |
|
148 | + 'class' => 'form-control-sm', |
|
149 | + 'value' => $invoice->get_currency( 'edit' ), |
|
150 | + 'extra_attributes' => array( |
|
151 | + 'onclick' => 'this.select();', |
|
152 | + 'readonly' => 'true', |
|
153 | + ), |
|
154 | + ) |
|
155 | + ); |
|
156 | + |
|
157 | + } else { |
|
158 | + |
|
159 | + if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
160 | + |
|
161 | + // Payment URL. |
|
162 | + echo aui()->input( |
|
163 | + array( |
|
164 | + 'type' => 'text', |
|
165 | + 'id' => 'wpinv_payment_url', |
|
166 | + 'name' => 'wpinv_payment_url', |
|
167 | + 'label' => __( 'Payment URL:', 'invoicing' ), |
|
168 | + 'label_type' => 'vertical', |
|
169 | + 'class' => 'form-control-sm', |
|
170 | + 'value' => $invoice->get_checkout_payment_url(), |
|
171 | + 'extra_attributes' => array( |
|
172 | + 'onclick' => 'this.select();', |
|
173 | + 'readonly' => 'true', |
|
174 | + ), |
|
175 | + ) |
|
176 | + ); |
|
177 | + |
|
178 | + // Set gateway. |
|
179 | + echo aui()->select( |
|
180 | + array( |
|
181 | + 'id' => 'wpinv_gateway', |
|
182 | + 'name' => 'wpinv_gateway', |
|
183 | + 'label' => __( 'Gateway:', 'invoicing' ), |
|
184 | + 'label_type' => 'vertical', |
|
185 | + 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
186 | + 'value' => $invoice->get_gateway( 'edit' ), |
|
187 | + 'select2' => true, |
|
188 | + 'data-allow-clear' => 'false', |
|
189 | + 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
190 | + ) |
|
191 | + ); |
|
192 | + |
|
193 | + } |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | ?> |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 | |
@@ -40,20 +40,20 @@ discard block |
||
40 | 40 | |
41 | 41 | <?php |
42 | 42 | |
43 | - if ( $invoice->is_draft() ) { |
|
43 | + if ($invoice->is_draft()) { |
|
44 | 44 | |
45 | 45 | // Set gateway. |
46 | 46 | echo aui()->select( |
47 | 47 | array( |
48 | 48 | 'id' => 'wpinv_gateway', |
49 | 49 | 'name' => 'wpinv_gateway', |
50 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
50 | + 'label' => __('Gateway:', 'invoicing'), |
|
51 | 51 | 'label_type' => 'vertical', |
52 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
52 | + 'placeholder' => __('Select Gateway', 'invoicing'), |
|
53 | 53 | 'value' => wpinv_get_default_gateway(), |
54 | 54 | 'select2' => true, |
55 | 55 | 'data-allow-clear' => 'false', |
56 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
56 | + 'options' => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'), |
|
57 | 57 | ) |
58 | 58 | ); |
59 | 59 | |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | 'id' => 'wpinv_key', |
66 | 66 | 'name' => 'wpinv_key', |
67 | 67 | 'label' => sprintf( |
68 | - __( '%s Key:', 'invoicing' ), |
|
69 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
68 | + __('%s Key:', 'invoicing'), |
|
69 | + ucfirst($invoice->get_invoice_quote_type()) |
|
70 | 70 | ), |
71 | 71 | 'label_type' => 'vertical', |
72 | 72 | 'class' => 'form-control-sm', |
73 | - 'value' => $invoice->get_key( 'edit' ), |
|
73 | + 'value' => $invoice->get_key('edit'), |
|
74 | 74 | 'extra_attributes' => array( |
75 | 75 | 'onclick' => 'this.select();', |
76 | 76 | 'readonly' => 'true', |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | 'id' => 'wpinv_view_url', |
86 | 86 | 'name' => 'wpinv_view_url', |
87 | 87 | 'label' => sprintf( |
88 | - __( '%s URL:', 'invoicing' ), |
|
89 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
90 | - ) . ' <a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>', |
|
88 | + __('%s URL:', 'invoicing'), |
|
89 | + ucfirst($invoice->get_invoice_quote_type()) |
|
90 | + ) . ' <a href="' . esc_url_raw($invoice->get_view_url()) . '" title="' . __('View invoice', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>', |
|
91 | 91 | 'label_type' => 'vertical', |
92 | 92 | 'class' => 'form-control-sm', |
93 | 93 | 'value' => $invoice->get_view_url(), |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | ); |
100 | 100 | |
101 | 101 | // If the invoice is paid... |
102 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
102 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
103 | 103 | |
104 | 104 | // Gateway. |
105 | 105 | echo aui()->input( |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | 'type' => 'text', |
108 | 108 | 'id' => 'wpinv_gateway', |
109 | 109 | 'name' => '', |
110 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
110 | + 'label' => __('Gateway:', 'invoicing'), |
|
111 | 111 | 'label_type' => 'vertical', |
112 | 112 | 'class' => 'form-control-sm', |
113 | - 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
113 | + 'value' => wpinv_get_gateway_admin_label($invoice->get_gateway('edit')), |
|
114 | 114 | 'extra_attributes' => array( |
115 | 115 | 'onclick' => 'this.select();', |
116 | 116 | 'readonly' => 'true', |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | 'type' => 'text', |
126 | 126 | 'id' => 'wpinv_transaction_id', |
127 | 127 | 'name' => 'wpinv_transaction_id', |
128 | - 'label' => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? ' <a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ), |
|
128 | + 'label' => __('Transaction ID:', 'invoicing') . ($transaction_url ? ' <a href="' . esc_url($transaction_url) . '" title="' . __('View details', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : ''), |
|
129 | 129 | 'label_type' => 'vertical', |
130 | 130 | 'class' => 'form-control-sm', |
131 | - 'value' => $invoice->get_transaction_id( 'edit' ), |
|
132 | - 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
131 | + 'value' => $invoice->get_transaction_id('edit'), |
|
132 | + 'help_text' => apply_filters('wpinv_invoice_transaction_link_' . $invoice->get_gateway('edit'), '', $invoice->get_transaction_id(), $invoice), |
|
133 | 133 | 'extra_attributes' => array( |
134 | 134 | 'onclick' => 'this.select();', |
135 | 135 | 'readonly' => 'true', |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | 'type' => 'text', |
144 | 144 | 'id' => 'wpinv_currency', |
145 | 145 | 'name' => 'wpinv_currency', |
146 | - 'label' => __( 'Currency:', 'invoicing' ), |
|
146 | + 'label' => __('Currency:', 'invoicing'), |
|
147 | 147 | 'label_type' => 'vertical', |
148 | 148 | 'class' => 'form-control-sm', |
149 | - 'value' => $invoice->get_currency( 'edit' ), |
|
149 | + 'value' => $invoice->get_currency('edit'), |
|
150 | 150 | 'extra_attributes' => array( |
151 | 151 | 'onclick' => 'this.select();', |
152 | 152 | 'readonly' => 'true', |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | } else { |
158 | 158 | |
159 | - if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
159 | + if ('wpi_invoice' == $invoice->get_post_type()) { |
|
160 | 160 | |
161 | 161 | // Payment URL. |
162 | 162 | echo aui()->input( |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | 'type' => 'text', |
165 | 165 | 'id' => 'wpinv_payment_url', |
166 | 166 | 'name' => 'wpinv_payment_url', |
167 | - 'label' => __( 'Payment URL:', 'invoicing' ), |
|
167 | + 'label' => __('Payment URL:', 'invoicing'), |
|
168 | 168 | 'label_type' => 'vertical', |
169 | 169 | 'class' => 'form-control-sm', |
170 | 170 | 'value' => $invoice->get_checkout_payment_url(), |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | array( |
181 | 181 | 'id' => 'wpinv_gateway', |
182 | 182 | 'name' => 'wpinv_gateway', |
183 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
183 | + 'label' => __('Gateway:', 'invoicing'), |
|
184 | 184 | 'label_type' => 'vertical', |
185 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
186 | - 'value' => $invoice->get_gateway( 'edit' ), |
|
185 | + 'placeholder' => __('Select Gateway', 'invoicing'), |
|
186 | + 'value' => $invoice->get_gateway('edit'), |
|
187 | 187 | 'select2' => true, |
188 | 188 | 'data-allow-clear' => 'false', |
189 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
189 | + 'options' => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'), |
|
190 | 190 | ) |
191 | 191 | ); |
192 | 192 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class GetPaid_Meta_Box_Item_Details { |
18 | 18 | |
19 | 19 | /** |
20 | - * Output the metabox. |
|
21 | - * |
|
22 | - * @param WP_Post $post |
|
23 | - */ |
|
20 | + * Output the metabox. |
|
21 | + * |
|
22 | + * @param WP_Post $post |
|
23 | + */ |
|
24 | 24 | public static function output( $post ) { |
25 | 25 | |
26 | 26 | // Prepare the item. |
@@ -113,22 +113,22 @@ discard block |
||
113 | 113 | // Dynamic pricing. |
114 | 114 | if ( $item->supports_dynamic_pricing() ) { |
115 | 115 | |
116 | - do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
116 | + do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
117 | 117 | |
118 | - // NYP toggle. |
|
119 | - echo aui()->input( |
|
118 | + // NYP toggle. |
|
119 | + echo aui()->input( |
|
120 | 120 | array( |
121 | - 'id' => 'wpinv_name_your_price', |
|
122 | - 'name' => 'wpinv_name_your_price', |
|
123 | - 'type' => 'checkbox', |
|
124 | - 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
125 | - 'value' => '1', |
|
126 | - 'checked' => $item->user_can_set_their_price(), |
|
127 | - 'no_wrap' => true, |
|
121 | + 'id' => 'wpinv_name_your_price', |
|
122 | + 'name' => 'wpinv_name_your_price', |
|
123 | + 'type' => 'checkbox', |
|
124 | + 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
125 | + 'value' => '1', |
|
126 | + 'checked' => $item->user_can_set_their_price(), |
|
127 | + 'no_wrap' => true, |
|
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | |
131 | - do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
131 | + do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
@@ -270,35 +270,35 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
273 | - * Save meta box data. |
|
274 | - * |
|
275 | - * @param int $post_id |
|
276 | - */ |
|
277 | - public static function save( $post_id ) { |
|
273 | + * Save meta box data. |
|
274 | + * |
|
275 | + * @param int $post_id |
|
276 | + */ |
|
277 | + public static function save( $post_id ) { |
|
278 | 278 | |
279 | 279 | // Prepare the item. |
280 | 280 | $item = new WPInv_Item( $post_id ); |
281 | 281 | |
282 | 282 | // Load new data. |
283 | 283 | $item->set_props( |
284 | - array( |
|
285 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null, |
|
286 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
287 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
288 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
289 | - 'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ), |
|
284 | + array( |
|
285 | + 'price' => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null, |
|
286 | + 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
287 | + 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
288 | + 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
289 | + 'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ), |
|
290 | 290 | 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null, |
291 | - 'is_recurring' => ! empty( $_POST['wpinv_is_recurring'] ), |
|
292 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
293 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
294 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
295 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
296 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
297 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
298 | - ) |
|
291 | + 'is_recurring' => ! empty( $_POST['wpinv_is_recurring'] ), |
|
292 | + 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
293 | + 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
294 | + 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
295 | + 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
296 | + 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
297 | + 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
298 | + ) |
|
299 | 299 | ); |
300 | 300 | |
301 | - $item->save(); |
|
302 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
303 | - } |
|
301 | + $item->save(); |
|
302 | + do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
303 | + } |
|
304 | 304 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,27 +21,27 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the item. |
27 | - $item = new WPInv_Item( $post ); |
|
27 | + $item = new WPInv_Item($post); |
|
28 | 28 | |
29 | 29 | // Nonce field. |
30 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
30 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
31 | 31 | |
32 | 32 | // Set the currency position. |
33 | 33 | $position = wpinv_currency_position(); |
34 | 34 | |
35 | - if ( $position == 'left_space' ) { |
|
35 | + if ($position == 'left_space') { |
|
36 | 36 | $position = 'left'; |
37 | 37 | } |
38 | 38 | |
39 | - if ( $position == 'right_space' ) { |
|
39 | + if ($position == 'right_space') { |
|
40 | 40 | $position = 'right'; |
41 | 41 | } |
42 | 42 | |
43 | 43 | ?> |
44 | - <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" /> |
|
44 | + <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" /> |
|
45 | 45 | <style> |
46 | 46 | #poststuff .input-group-text, |
47 | 47 | #poststuff .form-control { |
@@ -55,21 +55,21 @@ discard block |
||
55 | 55 | </style> |
56 | 56 | <div class='bsui' style='max-width: 600px;padding-top: 10px;'> |
57 | 57 | |
58 | - <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?> |
|
58 | + <?php do_action('wpinv_item_details_metabox_before_price', $item); ?> |
|
59 | 59 | <div class="form-group row"> |
60 | - <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' ); ?></span></label> |
|
60 | + <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing'); ?></span></label> |
|
61 | 61 | <div class="col-sm-8"> |
62 | 62 | <div class="row"> |
63 | 63 | <div class="col-sm-4 getpaid-price-input"> |
64 | 64 | <div class="input-group input-group-sm"> |
65 | - <?php if ( 'left' == $position ) : ?> |
|
65 | + <?php if ('left' == $position) : ?> |
|
66 | 66 | <div class="input-group-prepend"> |
67 | 67 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
68 | 68 | </div> |
69 | 69 | <?php endif; ?> |
70 | - <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
70 | + <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
71 | 71 | |
72 | - <?php if ( 'left' != $position ) : ?> |
|
72 | + <?php if ('left' != $position) : ?> |
|
73 | 73 | <div class="input-group-append"> |
74 | 74 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
75 | 75 | </div> |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | </div> |
80 | 80 | <div class="col-sm-4 wpinv_show_if_recurring"> |
81 | 81 | <?php |
82 | - _e( 'every' ); |
|
82 | + _e('every'); |
|
83 | 83 | echo ' '; |
84 | 84 | ?> |
85 | - <input type="number" style="max-width: 60px;" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" /> |
|
85 | + <input type="number" style="max-width: 60px;" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" /> |
|
86 | 86 | </div> |
87 | 87 | <div class="col-sm-4 wpinv_show_if_recurring"> |
88 | 88 | <?php |
@@ -90,16 +90,16 @@ discard block |
||
90 | 90 | array( |
91 | 91 | 'id' => 'wpinv_recurring_period', |
92 | 92 | 'name' => 'wpinv_recurring_period', |
93 | - 'label' => __( 'Period', 'invoicing' ), |
|
94 | - 'placeholder' => __( 'Select Period', 'invoicing' ), |
|
95 | - 'value' => $item->get_recurring_period( 'edit' ), |
|
93 | + 'label' => __('Period', 'invoicing'), |
|
94 | + 'placeholder' => __('Select Period', 'invoicing'), |
|
95 | + 'value' => $item->get_recurring_period('edit'), |
|
96 | 96 | 'select2' => true, |
97 | 97 | 'data-allow-clear' => 'false', |
98 | 98 | 'options' => array( |
99 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
100 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
101 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
102 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
99 | + 'D' => __('day(s)', 'invoicing'), |
|
100 | + 'W' => __('week(s)', 'invoicing'), |
|
101 | + 'M' => __('month(s)', 'invoicing'), |
|
102 | + 'Y' => __('year(s)', 'invoicing'), |
|
103 | 103 | ), |
104 | 104 | ) |
105 | 105 | ); |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | <?php |
112 | 112 | |
113 | 113 | // Dynamic pricing. |
114 | - if ( $item->supports_dynamic_pricing() ) { |
|
114 | + if ($item->supports_dynamic_pricing()) { |
|
115 | 115 | |
116 | - do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
116 | + do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item); |
|
117 | 117 | |
118 | 118 | // NYP toggle. |
119 | 119 | echo aui()->input( |
@@ -121,31 +121,31 @@ discard block |
||
121 | 121 | 'id' => 'wpinv_name_your_price', |
122 | 122 | 'name' => 'wpinv_name_your_price', |
123 | 123 | 'type' => 'checkbox', |
124 | - 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
124 | + 'label' => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')), |
|
125 | 125 | 'value' => '1', |
126 | 126 | 'checked' => $item->user_can_set_their_price(), |
127 | 127 | 'no_wrap' => true, |
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | |
131 | - do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
131 | + do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | 135 | // Subscriptions. |
136 | - do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item ); |
|
136 | + do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item); |
|
137 | 137 | echo aui()->input( |
138 | 138 | array( |
139 | 139 | 'id' => 'wpinv_is_recurring', |
140 | 140 | 'name' => 'wpinv_is_recurring', |
141 | 141 | 'type' => 'checkbox', |
142 | - 'label' => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ), |
|
142 | + 'label' => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')), |
|
143 | 143 | 'value' => '1', |
144 | 144 | 'checked' => $item->is_recurring(), |
145 | 145 | 'no_wrap' => true, |
146 | 146 | ) |
147 | 147 | ); |
148 | - do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item ); |
|
148 | + do_action('wpinv_item_details_metabox_subscription_checkbox', $item); |
|
149 | 149 | |
150 | 150 | ?> |
151 | 151 | <div class="wpinv_show_if_recurring"> |
@@ -155,30 +155,30 @@ discard block |
||
155 | 155 | </div> |
156 | 156 | </div> |
157 | 157 | <div class="col-sm-1 pt-2 pl-0"> |
158 | - <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span> |
|
158 | + <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span> |
|
159 | 159 | </div> |
160 | 160 | </div> |
161 | - <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?> |
|
161 | + <?php do_action('wpinv_item_details_metabox_after_price', $item); ?> |
|
162 | 162 | |
163 | - <?php if ( $item->supports_dynamic_pricing() ) : ?> |
|
164 | - <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?> |
|
163 | + <?php if ($item->supports_dynamic_pricing()) : ?> |
|
164 | + <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?> |
|
165 | 165 | <div class="wpinv_show_if_dynamic wpinv_minimum_price"> |
166 | 166 | |
167 | 167 | <div class="form-group row"> |
168 | 168 | <label for="wpinv_minimum_price" class="col-sm-3 col-form-label"> |
169 | - <?php _e( 'Minimum Price', 'invoicing' ); ?> |
|
169 | + <?php _e('Minimum Price', 'invoicing'); ?> |
|
170 | 170 | </label> |
171 | 171 | <div class="col-sm-8"> |
172 | 172 | <div class="input-group input-group-sm"> |
173 | - <?php if ( 'left' == $position ) : ?> |
|
173 | + <?php if ('left' == $position) : ?> |
|
174 | 174 | <div class="input-group-prepend"> |
175 | 175 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
176 | 176 | </div> |
177 | 177 | <?php endif; ?> |
178 | 178 | |
179 | - <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
179 | + <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
180 | 180 | |
181 | - <?php if ( 'left' != $position ) : ?> |
|
181 | + <?php if ('left' != $position) : ?> |
|
182 | 182 | <div class="input-group-append"> |
183 | 183 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
184 | 184 | </div> |
@@ -187,45 +187,45 @@ discard block |
||
187 | 187 | </div> |
188 | 188 | |
189 | 189 | <div class="col-sm-1 pt-2 pl-0"> |
190 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span> |
|
190 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span> |
|
191 | 191 | </div> |
192 | 192 | </div> |
193 | 193 | |
194 | 194 | </div> |
195 | - <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?> |
|
195 | + <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?> |
|
196 | 196 | <?php endif; ?> |
197 | 197 | |
198 | - <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?> |
|
198 | + <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?> |
|
199 | 199 | <div class="wpinv_show_if_recurring wpinv_maximum_renewals"> |
200 | 200 | |
201 | 201 | <div class="form-group row"> |
202 | 202 | <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label"> |
203 | - <?php _e( 'Maximum Renewals', 'invoicing' ); ?> |
|
203 | + <?php _e('Maximum Renewals', 'invoicing'); ?> |
|
204 | 204 | </label> |
205 | 205 | <div class="col-sm-8"> |
206 | - <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
206 | + <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
207 | 207 | </div> |
208 | 208 | <div class="col-sm-1 pt-2 pl-0"> |
209 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span> |
|
209 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span> |
|
210 | 210 | </div> |
211 | 211 | </div> |
212 | 212 | |
213 | 213 | </div> |
214 | - <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?> |
|
214 | + <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?> |
|
215 | 215 | |
216 | - <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?> |
|
216 | + <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?> |
|
217 | 217 | <div class="wpinv_show_if_recurring wpinv_free_trial"> |
218 | 218 | |
219 | 219 | <div class="form-group row"> |
220 | - <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined( 'GETPAID_PAID_TRIALS_VERSION' ) ? _e( 'Free/Paid Trial', 'invoicing' ) : _e( 'Free Trial', 'invoicing' ); ?></label> |
|
220 | + <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined('GETPAID_PAID_TRIALS_VERSION') ? _e('Free/Paid Trial', 'invoicing') : _e('Free Trial', 'invoicing'); ?></label> |
|
221 | 221 | |
222 | 222 | <div class="col-sm-8"> |
223 | 223 | <div class="row"> |
224 | 224 | <div class="col-sm-6"> |
225 | - <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0; ?> |
|
225 | + <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?> |
|
226 | 226 | |
227 | 227 | <div> |
228 | - <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" > |
|
228 | + <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" > |
|
229 | 229 | </div> |
230 | 230 | </div> |
231 | 231 | <div class="col-sm-6"> |
@@ -234,17 +234,17 @@ discard block |
||
234 | 234 | array( |
235 | 235 | 'id' => 'wpinv_trial_period', |
236 | 236 | 'name' => 'wpinv_trial_period', |
237 | - 'label' => __( 'Trial Period', 'invoicing' ), |
|
238 | - 'placeholder' => __( 'Trial Period', 'invoicing' ), |
|
239 | - 'value' => $item->get_trial_period( 'edit' ), |
|
237 | + 'label' => __('Trial Period', 'invoicing'), |
|
238 | + 'placeholder' => __('Trial Period', 'invoicing'), |
|
239 | + 'value' => $item->get_trial_period('edit'), |
|
240 | 240 | 'select2' => true, |
241 | 241 | 'data-allow-clear' => 'false', |
242 | 242 | 'no_wrap' => true, |
243 | 243 | 'options' => array( |
244 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
245 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
246 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
247 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
244 | + 'D' => __('day(s)', 'invoicing'), |
|
245 | + 'W' => __('week(s)', 'invoicing'), |
|
246 | + 'M' => __('month(s)', 'invoicing'), |
|
247 | + 'Y' => __('year(s)', 'invoicing'), |
|
248 | 248 | ), |
249 | 249 | ) |
250 | 250 | ); |
@@ -255,15 +255,15 @@ discard block |
||
255 | 255 | </div> |
256 | 256 | |
257 | 257 | <div class="col-sm-1 pt-2 pl-0"> |
258 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span> |
|
258 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span> |
|
259 | 259 | </div> |
260 | 260 | |
261 | 261 | </div> |
262 | 262 | |
263 | 263 | </div> |
264 | - <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?> |
|
264 | + <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?> |
|
265 | 265 | |
266 | - <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?> |
|
266 | + <?php do_action('wpinv_item_details_metabox_item_details', $item); ?> |
|
267 | 267 | </div> |
268 | 268 | <?php |
269 | 269 | |
@@ -274,31 +274,31 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @param int $post_id |
276 | 276 | */ |
277 | - public static function save( $post_id ) { |
|
277 | + public static function save($post_id) { |
|
278 | 278 | |
279 | 279 | // Prepare the item. |
280 | - $item = new WPInv_Item( $post_id ); |
|
280 | + $item = new WPInv_Item($post_id); |
|
281 | 281 | |
282 | 282 | // Load new data. |
283 | 283 | $item->set_props( |
284 | 284 | array( |
285 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null, |
|
286 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
287 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
288 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
289 | - 'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ), |
|
290 | - 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null, |
|
291 | - 'is_recurring' => ! empty( $_POST['wpinv_is_recurring'] ), |
|
292 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
293 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
294 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
295 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
296 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
297 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
285 | + 'price' => isset($_POST['wpinv_item_price']) ? getpaid_standardize_amount($_POST['wpinv_item_price']) : null, |
|
286 | + 'vat_rule' => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null, |
|
287 | + 'vat_class' => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null, |
|
288 | + 'type' => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null, |
|
289 | + 'is_dynamic_pricing' => !empty($_POST['wpinv_name_your_price']), |
|
290 | + 'minimum_price' => isset($_POST['wpinv_minimum_price']) ? getpaid_standardize_amount($_POST['wpinv_minimum_price']) : null, |
|
291 | + 'is_recurring' => !empty($_POST['wpinv_is_recurring']), |
|
292 | + 'recurring_period' => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null, |
|
293 | + 'recurring_interval' => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
294 | + 'recurring_limit' => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
295 | + 'is_free_trial' => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null, |
|
296 | + 'trial_period' => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null, |
|
297 | + 'trial_interval' => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
298 | 298 | ) |
299 | 299 | ); |
300 | 300 | |
301 | 301 | $item->save(); |
302 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
302 | + do_action('getpaid_item_metabox_save', $post_id, $item); |
|
303 | 303 | } |
304 | 304 | } |
@@ -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( |
|
28 | + echo aui()->alert( |
|
29 | 29 | array( |
30 | - 'type' => 'danger', |
|
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
30 | + 'type' => 'danger', |
|
31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | 32 | ) |
33 | 33 | ); |
34 | 34 | |
35 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } elseif ( ! 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 | <?php $subscribers_table->views(); ?> |
67 | 67 | <form id="subscribers-filter" class="bsui" method="get"> |
68 | 68 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
@@ -81,41 +81,41 @@ discard block |
||
81 | 81 | */ |
82 | 82 | function wpinv_recurring_subscription_details() { |
83 | 83 | |
84 | - // Fetch the subscription. |
|
85 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
86 | - if ( ! $sub->exists() ) { |
|
84 | + // Fetch the subscription. |
|
85 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
86 | + if ( ! $sub->exists() ) { |
|
87 | 87 | |
88 | - echo aui()->alert( |
|
89 | - array( |
|
90 | - 'type' => 'danger', |
|
91 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
92 | - ) |
|
93 | - ); |
|
88 | + echo aui()->alert( |
|
89 | + array( |
|
90 | + 'type' => 'danger', |
|
91 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
92 | + ) |
|
93 | + ); |
|
94 | 94 | |
95 | - return; |
|
96 | - } |
|
95 | + return; |
|
96 | + } |
|
97 | 97 | |
98 | - // Use metaboxes to display the subscription details. |
|
99 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
100 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
98 | + // Use metaboxes to display the subscription details. |
|
99 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
100 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
101 | 101 | |
102 | - $subscription_id = $sub->get_id(); |
|
103 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
104 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
102 | + $subscription_id = $sub->get_id(); |
|
103 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
104 | + $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
105 | 105 | |
106 | - if ( 1 < count( $subscription_groups ) ) { |
|
107 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
108 | - } |
|
106 | + if ( 1 < count( $subscription_groups ) ) { |
|
107 | + add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
108 | + } |
|
109 | 109 | |
110 | - if ( ! empty( $subscription_group ) ) { |
|
111 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
112 | - } |
|
110 | + if ( ! empty( $subscription_group ) ) { |
|
111 | + add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
112 | + } |
|
113 | 113 | |
114 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
114 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
115 | 115 | |
116 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
116 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
117 | 117 | |
118 | - ?> |
|
118 | + ?> |
|
119 | 119 | |
120 | 120 | <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
121 | 121 | |
@@ -155,44 +155,44 @@ discard block |
||
155 | 155 | */ |
156 | 156 | function getpaid_admin_subscription_details_metabox( $sub ) { |
157 | 157 | |
158 | - // Subscription items. |
|
159 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
160 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
161 | - |
|
162 | - // Prepare subscription detail columns. |
|
163 | - $fields = apply_filters( |
|
164 | - 'getpaid_subscription_admin_page_fields', |
|
165 | - array( |
|
166 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
167 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
168 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
169 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
170 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
171 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
172 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
173 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
174 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
175 | - 'status' => __( 'Status', 'invoicing' ), |
|
176 | - ) |
|
177 | - ); |
|
178 | - |
|
179 | - if ( ! $sub->is_active() ) { |
|
180 | - |
|
181 | - if ( isset( $fields['renews_on'] ) ) { |
|
182 | - unset( $fields['renews_on'] ); |
|
183 | - } |
|
184 | - |
|
185 | - if ( isset( $fields['gateway'] ) ) { |
|
186 | - unset( $fields['gateway'] ); |
|
187 | - } |
|
158 | + // Subscription items. |
|
159 | + $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
160 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
161 | + |
|
162 | + // Prepare subscription detail columns. |
|
163 | + $fields = apply_filters( |
|
164 | + 'getpaid_subscription_admin_page_fields', |
|
165 | + array( |
|
166 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
167 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
168 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
169 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
170 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
171 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
172 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
173 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
174 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
175 | + 'status' => __( 'Status', 'invoicing' ), |
|
176 | + ) |
|
177 | + ); |
|
178 | + |
|
179 | + if ( ! $sub->is_active() ) { |
|
180 | + |
|
181 | + if ( isset( $fields['renews_on'] ) ) { |
|
182 | + unset( $fields['renews_on'] ); |
|
183 | + } |
|
184 | + |
|
185 | + if ( isset( $fields['gateway'] ) ) { |
|
186 | + unset( $fields['gateway'] ); |
|
187 | + } |
|
188 | 188 | } |
189 | 189 | |
190 | - $profile_id = $sub->get_profile_id(); |
|
191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | - unset( $fields['profile_id'] ); |
|
193 | - } |
|
190 | + $profile_id = $sub->get_profile_id(); |
|
191 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | + unset( $fields['profile_id'] ); |
|
193 | + } |
|
194 | 194 | |
195 | - ?> |
|
195 | + ?> |
|
196 | 196 | |
197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
198 | 198 | <tbody> |
@@ -226,20 +226,20 @@ discard block |
||
226 | 226 | */ |
227 | 227 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
228 | 228 | |
229 | - $username = __( '(Missing User)', 'invoicing' ); |
|
229 | + $username = __( '(Missing User)', 'invoicing' ); |
|
230 | 230 | |
231 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
232 | - if ( $user ) { |
|
231 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
232 | + if ( $user ) { |
|
233 | 233 | |
234 | - $username = sprintf( |
|
235 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
236 | - absint( $user->ID ), |
|
237 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
238 | - ); |
|
234 | + $username = sprintf( |
|
235 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
236 | + absint( $user->ID ), |
|
237 | + ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
238 | + ); |
|
239 | 239 | |
240 | - } |
|
240 | + } |
|
241 | 241 | |
242 | - echo wp_kses_post( $username ); |
|
242 | + echo wp_kses_post( $username ); |
|
243 | 243 | } |
244 | 244 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
245 | 245 | |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | * @param WPInv_Subscription $subscription |
250 | 250 | */ |
251 | 251 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
252 | - $amount = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
253 | - echo "<span>$amount</span>"; |
|
252 | + $amount = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
253 | + echo "<span>$amount</span>"; |
|
254 | 254 | } |
255 | 255 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
256 | 256 | |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | */ |
262 | 262 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
263 | 263 | |
264 | - printf( |
|
265 | - '<a href="%s">#%s</a>', |
|
266 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
267 | - absint( $subscription->get_id() ) |
|
268 | - ); |
|
264 | + printf( |
|
265 | + '<a href="%s">#%s</a>', |
|
266 | + esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
267 | + absint( $subscription->get_id() ) |
|
268 | + ); |
|
269 | 269 | |
270 | 270 | } |
271 | 271 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @param WPInv_Subscription $subscription |
277 | 277 | */ |
278 | 278 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
279 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
279 | + echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
280 | 280 | } |
281 | 281 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
282 | 282 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * @param WPInv_Subscription $subscription |
287 | 287 | */ |
288 | 288 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
289 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
289 | + echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
290 | 290 | } |
291 | 291 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
292 | 292 | |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | * @param WPInv_Subscription $subscription |
297 | 297 | */ |
298 | 298 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
299 | - $max_bills = $subscription->get_bill_times(); |
|
300 | - echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
299 | + $max_bills = $subscription->get_bill_times(); |
|
300 | + echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
301 | 301 | } |
302 | 302 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
303 | 303 | /** |
@@ -308,13 +308,13 @@ discard block |
||
308 | 308 | */ |
309 | 309 | function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
310 | 310 | |
311 | - if ( empty( $subscription_group ) ) { |
|
312 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
313 | - return; |
|
314 | - } |
|
311 | + if ( empty( $subscription_group ) ) { |
|
312 | + echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
313 | + return; |
|
314 | + } |
|
315 | 315 | |
316 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
317 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
316 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
317 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
318 | 318 | |
319 | 319 | } |
320 | 320 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | */ |
327 | 327 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
328 | 328 | |
329 | - $gateway = $subscription->get_gateway(); |
|
329 | + $gateway = $subscription->get_gateway(); |
|
330 | 330 | |
331 | - if ( ! empty( $gateway ) ) { |
|
332 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
333 | - } else { |
|
334 | - echo '—'; |
|
335 | - } |
|
331 | + if ( ! empty( $gateway ) ) { |
|
332 | + echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
333 | + } else { |
|
334 | + echo '—'; |
|
335 | + } |
|
336 | 336 | |
337 | 337 | } |
338 | 338 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @param WPInv_Subscription $subscription |
344 | 344 | */ |
345 | 345 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
346 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
346 | + echo wp_kses_post( $subscription->get_status_label_html() ); |
|
347 | 347 | } |
348 | 348 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
349 | 349 | |
@@ -354,28 +354,28 @@ discard block |
||
354 | 354 | */ |
355 | 355 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
356 | 356 | |
357 | - $profile_id = $subscription->get_profile_id(); |
|
358 | - |
|
359 | - $input = aui()->input( |
|
360 | - array( |
|
361 | - 'type' => 'text', |
|
362 | - 'id' => 'wpinv_subscription_profile_id', |
|
363 | - 'name' => 'wpinv_subscription_profile_id', |
|
364 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
365 | - 'label_type' => 'hidden', |
|
366 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
367 | - 'value' => esc_attr( $profile_id ), |
|
368 | - 'input_group_right' => '', |
|
369 | - 'no_wrap' => true, |
|
370 | - ) |
|
371 | - ); |
|
372 | - |
|
373 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
374 | - |
|
375 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
376 | - if ( ! empty( $url ) ) { |
|
377 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
378 | - } |
|
357 | + $profile_id = $subscription->get_profile_id(); |
|
358 | + |
|
359 | + $input = aui()->input( |
|
360 | + array( |
|
361 | + 'type' => 'text', |
|
362 | + 'id' => 'wpinv_subscription_profile_id', |
|
363 | + 'name' => 'wpinv_subscription_profile_id', |
|
364 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
365 | + 'label_type' => 'hidden', |
|
366 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
367 | + 'value' => esc_attr( $profile_id ), |
|
368 | + 'input_group_right' => '', |
|
369 | + 'no_wrap' => true, |
|
370 | + ) |
|
371 | + ); |
|
372 | + |
|
373 | + echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
374 | + |
|
375 | + $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
376 | + if ( ! empty( $url ) ) { |
|
377 | + echo ' <a href="' . esc_url_raw( $url ) . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
378 | + } |
|
379 | 379 | |
380 | 380 | } |
381 | 381 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -387,39 +387,39 @@ discard block |
||
387 | 387 | */ |
388 | 388 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
389 | 389 | |
390 | - ?> |
|
390 | + ?> |
|
391 | 391 | <div class="mt-3"> |
392 | 392 | |
393 | 393 | <?php |
394 | - echo aui()->select( |
|
395 | - array( |
|
396 | - 'options' => getpaid_get_subscription_statuses(), |
|
397 | - 'name' => 'subscription_status', |
|
398 | - 'id' => 'subscription_status_update_select', |
|
399 | - 'required' => true, |
|
400 | - 'no_wrap' => false, |
|
401 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
402 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
403 | - 'select2' => true, |
|
404 | - 'value' => $subscription->get_status( 'edit' ), |
|
405 | - ) |
|
406 | - ); |
|
407 | - ?> |
|
394 | + echo aui()->select( |
|
395 | + array( |
|
396 | + 'options' => getpaid_get_subscription_statuses(), |
|
397 | + 'name' => 'subscription_status', |
|
398 | + 'id' => 'subscription_status_update_select', |
|
399 | + 'required' => true, |
|
400 | + 'no_wrap' => false, |
|
401 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
402 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
403 | + 'select2' => true, |
|
404 | + 'value' => $subscription->get_status( 'edit' ), |
|
405 | + ) |
|
406 | + ); |
|
407 | + ?> |
|
408 | 408 | |
409 | 409 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
410 | 410 | |
411 | 411 | <?php |
412 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
412 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
413 | 413 | |
414 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
415 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
416 | - $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' ); |
|
414 | + $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
415 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
416 | + $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' ); |
|
417 | 417 | |
418 | - if ( $subscription->is_active() ) { |
|
419 | - echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
420 | - } |
|
418 | + if ( $subscription->is_active() ) { |
|
419 | + echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
420 | + } |
|
421 | 421 | |
422 | - echo '</div></div>'; |
|
422 | + echo '</div></div>'; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -430,33 +430,33 @@ discard block |
||
430 | 430 | */ |
431 | 431 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
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( ! is_admin() ); |
|
447 | - $parent = $subscription->get_parent_invoice(); |
|
448 | - |
|
449 | - if ( $parent->exists() ) { |
|
450 | - $payments = array_merge( array( $parent ), $payments ); |
|
451 | - } |
|
452 | - |
|
453 | - $table_class = 'w-100 bg-white'; |
|
454 | - |
|
455 | - if ( ! is_admin() ) { |
|
456 | - $table_class = 'table table-bordered'; |
|
457 | - } |
|
458 | - |
|
459 | - ?> |
|
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( ! is_admin() ); |
|
447 | + $parent = $subscription->get_parent_invoice(); |
|
448 | + |
|
449 | + if ( $parent->exists() ) { |
|
450 | + $payments = array_merge( array( $parent ), $payments ); |
|
451 | + } |
|
452 | + |
|
453 | + $table_class = 'w-100 bg-white'; |
|
454 | + |
|
455 | + if ( ! is_admin() ) { |
|
456 | + $table_class = 'table table-bordered'; |
|
457 | + } |
|
458 | + |
|
459 | + ?> |
|
460 | 460 | <div class="m-0" style="overflow: auto;"> |
461 | 461 | |
462 | 462 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -464,14 +464,14 @@ discard block |
||
464 | 464 | <thead> |
465 | 465 | <tr> |
466 | 466 | <?php |
467 | - foreach ( $columns as $key => $label ) { |
|
468 | - $key = esc_attr( $key ); |
|
469 | - $label = esc_html( $label ); |
|
470 | - $class = 'text-left'; |
|
471 | - |
|
472 | - echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
473 | - } |
|
474 | - ?> |
|
467 | + foreach ( $columns as $key => $label ) { |
|
468 | + $key = esc_attr( $key ); |
|
469 | + $label = esc_html( $label ); |
|
470 | + $class = 'text-left'; |
|
471 | + |
|
472 | + echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
473 | + } |
|
474 | + ?> |
|
475 | 475 | </tr> |
476 | 476 | </thead> |
477 | 477 | |
@@ -487,72 +487,72 @@ discard block |
||
487 | 487 | |
488 | 488 | <?php |
489 | 489 | |
490 | - foreach ( $payments as $payment ) : |
|
490 | + foreach ( $payments as $payment ) : |
|
491 | 491 | |
492 | - // Ensure that we have an invoice. |
|
493 | - $payment = new WPInv_Invoice( $payment ); |
|
492 | + // Ensure that we have an invoice. |
|
493 | + $payment = new WPInv_Invoice( $payment ); |
|
494 | 494 | |
495 | - // Abort if the invoice is invalid... |
|
496 | - if ( ! $payment->exists() ) { |
|
497 | - continue; |
|
498 | - } |
|
495 | + // Abort if the invoice is invalid... |
|
496 | + if ( ! $payment->exists() ) { |
|
497 | + continue; |
|
498 | + } |
|
499 | 499 | |
500 | - // ... or belongs to a different subscription. |
|
501 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
502 | - continue; |
|
503 | - } |
|
500 | + // ... or belongs to a different subscription. |
|
501 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
502 | + continue; |
|
503 | + } |
|
504 | 504 | |
505 | - echo '<tr>'; |
|
505 | + echo '<tr>'; |
|
506 | 506 | |
507 | - foreach ( array_keys( $columns ) as $key ) { |
|
507 | + foreach ( array_keys( $columns ) as $key ) { |
|
508 | 508 | |
509 | - $class = 'text-left'; |
|
509 | + $class = 'text-left'; |
|
510 | 510 | |
511 | - echo "<td class='p-2 text-left'>"; |
|
511 | + echo "<td class='p-2 text-left'>"; |
|
512 | 512 | |
513 | - switch ( $key ) { |
|
513 | + switch ( $key ) { |
|
514 | 514 | |
515 | - case 'total': |
|
516 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
517 | - break; |
|
515 | + case 'total': |
|
516 | + echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
517 | + break; |
|
518 | 518 | |
519 | - case 'relationship': |
|
520 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
521 | - break; |
|
519 | + case 'relationship': |
|
520 | + echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
521 | + break; |
|
522 | 522 | |
523 | - case 'date': |
|
524 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
525 | - break; |
|
523 | + case 'date': |
|
524 | + echo getpaid_format_date_value( $payment->get_date_created() ); |
|
525 | + break; |
|
526 | 526 | |
527 | - case 'status': |
|
528 | - $status = $payment->get_status_nicename(); |
|
529 | - if ( is_admin() ) { |
|
530 | - $status = $payment->get_status_label_html(); |
|
531 | - } |
|
527 | + case 'status': |
|
528 | + $status = $payment->get_status_nicename(); |
|
529 | + if ( is_admin() ) { |
|
530 | + $status = $payment->get_status_label_html(); |
|
531 | + } |
|
532 | 532 | |
533 | - echo wp_kses_post( $status ); |
|
534 | - break; |
|
533 | + echo wp_kses_post( $status ); |
|
534 | + break; |
|
535 | 535 | |
536 | - case 'invoice': |
|
537 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
536 | + case 'invoice': |
|
537 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
538 | 538 | |
539 | - if ( ! is_admin() ) { |
|
540 | - $link = esc_url( $payment->get_view_url() ); |
|
541 | - } |
|
539 | + if ( ! is_admin() ) { |
|
540 | + $link = esc_url( $payment->get_view_url() ); |
|
541 | + } |
|
542 | 542 | |
543 | - $invoice = esc_html( $payment->get_number() ); |
|
544 | - echo "<a href='$link'>$invoice</a>"; |
|
545 | - break; |
|
546 | - } |
|
543 | + $invoice = esc_html( $payment->get_number() ); |
|
544 | + echo "<a href='$link'>$invoice</a>"; |
|
545 | + break; |
|
546 | + } |
|
547 | 547 | |
548 | - echo '</td>'; |
|
548 | + echo '</td>'; |
|
549 | 549 | |
550 | - } |
|
550 | + } |
|
551 | 551 | |
552 | - echo '</tr>'; |
|
552 | + echo '</tr>'; |
|
553 | 553 | |
554 | - endforeach; |
|
555 | - ?> |
|
554 | + endforeach; |
|
555 | + ?> |
|
556 | 556 | |
557 | 557 | </tbody> |
558 | 558 | |
@@ -570,42 +570,42 @@ discard block |
||
570 | 570 | */ |
571 | 571 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
572 | 572 | |
573 | - // Fetch the subscription group. |
|
574 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
573 | + // Fetch the subscription group. |
|
574 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
575 | 575 | |
576 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
577 | - return; |
|
578 | - } |
|
576 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
577 | + return; |
|
578 | + } |
|
579 | 579 | |
580 | - // Prepare table columns. |
|
581 | - $columns = apply_filters( |
|
582 | - 'getpaid_subscription_item_details_columns', |
|
583 | - array( |
|
584 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
585 | - 'price' => __( 'Price', 'invoicing' ), |
|
586 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
587 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
588 | - //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
589 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
590 | - ), |
|
591 | - $subscription |
|
592 | - ); |
|
580 | + // Prepare table columns. |
|
581 | + $columns = apply_filters( |
|
582 | + 'getpaid_subscription_item_details_columns', |
|
583 | + array( |
|
584 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
585 | + 'price' => __( 'Price', 'invoicing' ), |
|
586 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
587 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
588 | + //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
589 | + 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
590 | + ), |
|
591 | + $subscription |
|
592 | + ); |
|
593 | 593 | |
594 | - // Prepare the invoices. |
|
594 | + // Prepare the invoices. |
|
595 | 595 | |
596 | - $invoice = $subscription->get_parent_invoice(); |
|
596 | + $invoice = $subscription->get_parent_invoice(); |
|
597 | 597 | |
598 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
599 | - unset( $columns['tax'] ); |
|
600 | - } |
|
598 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
599 | + unset( $columns['tax'] ); |
|
600 | + } |
|
601 | 601 | |
602 | - $table_class = 'w-100 bg-white'; |
|
602 | + $table_class = 'w-100 bg-white'; |
|
603 | 603 | |
604 | - if ( ! is_admin() ) { |
|
605 | - $table_class = 'table table-bordered'; |
|
606 | - } |
|
604 | + if ( ! is_admin() ) { |
|
605 | + $table_class = 'table table-bordered'; |
|
606 | + } |
|
607 | 607 | |
608 | - ?> |
|
608 | + ?> |
|
609 | 609 | <div class="m-0" style="overflow: auto;"> |
610 | 610 | |
611 | 611 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -614,14 +614,14 @@ discard block |
||
614 | 614 | <tr> |
615 | 615 | <?php |
616 | 616 | |
617 | - foreach ( $columns as $key => $label ) { |
|
618 | - $key = esc_attr( $key ); |
|
619 | - $label = esc_html( $label ); |
|
620 | - $class = 'text-left'; |
|
617 | + foreach ( $columns as $key => $label ) { |
|
618 | + $key = esc_attr( $key ); |
|
619 | + $label = esc_html( $label ); |
|
620 | + $class = 'text-left'; |
|
621 | 621 | |
622 | - echo "<th class='subscription-item-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
623 | - } |
|
624 | - ?> |
|
622 | + echo "<th class='subscription-item-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
623 | + } |
|
624 | + ?> |
|
625 | 625 | </tr> |
626 | 626 | </thead> |
627 | 627 | |
@@ -629,106 +629,106 @@ discard block |
||
629 | 629 | |
630 | 630 | <?php |
631 | 631 | |
632 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
632 | + foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
633 | 633 | |
634 | - echo '<tr>'; |
|
634 | + echo '<tr>'; |
|
635 | 635 | |
636 | - foreach ( array_keys( $columns ) as $key ) { |
|
636 | + foreach ( array_keys( $columns ) as $key ) { |
|
637 | 637 | |
638 | - $class = 'text-left'; |
|
638 | + $class = 'text-left'; |
|
639 | 639 | |
640 | - echo "<td class='p-2 text-left'>"; |
|
640 | + echo "<td class='p-2 text-left'>"; |
|
641 | 641 | |
642 | - switch ( $key ) { |
|
642 | + switch ( $key ) { |
|
643 | 643 | |
644 | - case 'item_name': |
|
645 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
646 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
644 | + case 'item_name': |
|
645 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
646 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
647 | 647 | |
648 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
649 | - echo esc_html( $item_name ); |
|
650 | - } else { |
|
651 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
652 | - } |
|
648 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
649 | + echo esc_html( $item_name ); |
|
650 | + } else { |
|
651 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
652 | + } |
|
653 | 653 | |
654 | - break; |
|
654 | + break; |
|
655 | 655 | |
656 | - case 'price': |
|
657 | - echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
658 | - break; |
|
656 | + case 'price': |
|
657 | + echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
658 | + break; |
|
659 | 659 | |
660 | - case 'tax': |
|
661 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
662 | - break; |
|
660 | + case 'tax': |
|
661 | + echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
662 | + break; |
|
663 | 663 | |
664 | - case 'discount': |
|
665 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
666 | - break; |
|
664 | + case 'discount': |
|
665 | + echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
666 | + break; |
|
667 | 667 | |
668 | - case 'initial': |
|
669 | - echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
670 | - break; |
|
668 | + case 'initial': |
|
669 | + echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
670 | + break; |
|
671 | 671 | |
672 | - case 'recurring': |
|
673 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
674 | - break; |
|
672 | + case 'recurring': |
|
673 | + echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
674 | + break; |
|
675 | 675 | |
676 | - } |
|
676 | + } |
|
677 | 677 | |
678 | - echo '</td>'; |
|
678 | + echo '</td>'; |
|
679 | 679 | |
680 | - } |
|
680 | + } |
|
681 | 681 | |
682 | - echo '</tr>'; |
|
682 | + echo '</tr>'; |
|
683 | 683 | |
684 | - endforeach; |
|
684 | + endforeach; |
|
685 | 685 | |
686 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
686 | + foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
687 | 687 | |
688 | - echo '<tr>'; |
|
688 | + echo '<tr>'; |
|
689 | 689 | |
690 | - foreach ( array_keys( $columns ) as $key ) { |
|
690 | + foreach ( array_keys( $columns ) as $key ) { |
|
691 | 691 | |
692 | - $class = 'text-left'; |
|
692 | + $class = 'text-left'; |
|
693 | 693 | |
694 | - echo "<td class='p-2 text-left'>"; |
|
694 | + echo "<td class='p-2 text-left'>"; |
|
695 | 695 | |
696 | - switch ( $key ) { |
|
696 | + switch ( $key ) { |
|
697 | 697 | |
698 | - case 'item_name': |
|
699 | - echo esc_html( $subscription_group_fee['name'] ); |
|
700 | - break; |
|
698 | + case 'item_name': |
|
699 | + echo esc_html( $subscription_group_fee['name'] ); |
|
700 | + break; |
|
701 | 701 | |
702 | - case 'price': |
|
703 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
704 | - break; |
|
702 | + case 'price': |
|
703 | + echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
704 | + break; |
|
705 | 705 | |
706 | - case 'tax': |
|
707 | - echo '—'; |
|
708 | - break; |
|
706 | + case 'tax': |
|
707 | + echo '—'; |
|
708 | + break; |
|
709 | 709 | |
710 | - case 'discount': |
|
711 | - echo '—'; |
|
712 | - break; |
|
710 | + case 'discount': |
|
711 | + echo '—'; |
|
712 | + break; |
|
713 | 713 | |
714 | - case 'initial': |
|
715 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
716 | - break; |
|
714 | + case 'initial': |
|
715 | + echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
716 | + break; |
|
717 | 717 | |
718 | - case 'recurring': |
|
719 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
720 | - break; |
|
718 | + case 'recurring': |
|
719 | + echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
720 | + break; |
|
721 | 721 | |
722 | - } |
|
722 | + } |
|
723 | 723 | |
724 | - echo '</td>'; |
|
724 | + echo '</td>'; |
|
725 | 725 | |
726 | - } |
|
726 | + } |
|
727 | 727 | |
728 | - echo '</tr>'; |
|
728 | + echo '</tr>'; |
|
729 | 729 | |
730 | - endforeach; |
|
731 | - ?> |
|
730 | + endforeach; |
|
731 | + ?> |
|
732 | 732 | |
733 | 733 | </tbody> |
734 | 734 | |
@@ -747,38 +747,38 @@ discard block |
||
747 | 747 | */ |
748 | 748 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
749 | 749 | |
750 | - // Fetch the subscription groups. |
|
751 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
752 | - |
|
753 | - if ( empty( $subscription_groups ) ) { |
|
754 | - return; |
|
755 | - } |
|
756 | - |
|
757 | - // Prepare table columns. |
|
758 | - $columns = apply_filters( |
|
759 | - 'getpaid_subscription_related_subscriptions_columns', |
|
760 | - array( |
|
761 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
762 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
763 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
764 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
765 | - 'item' => __( 'Items', 'invoicing' ), |
|
766 | - 'status' => __( 'Status', 'invoicing' ), |
|
767 | - ), |
|
768 | - $subscription |
|
769 | - ); |
|
770 | - |
|
771 | - if ( $subscription->get_status() == 'pending' ) { |
|
772 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
773 | - } |
|
774 | - |
|
775 | - $table_class = 'w-100 bg-white'; |
|
776 | - |
|
777 | - if ( ! is_admin() ) { |
|
778 | - $table_class = 'table table-bordered'; |
|
779 | - } |
|
780 | - |
|
781 | - ?> |
|
750 | + // Fetch the subscription groups. |
|
751 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
752 | + |
|
753 | + if ( empty( $subscription_groups ) ) { |
|
754 | + return; |
|
755 | + } |
|
756 | + |
|
757 | + // Prepare table columns. |
|
758 | + $columns = apply_filters( |
|
759 | + 'getpaid_subscription_related_subscriptions_columns', |
|
760 | + array( |
|
761 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
762 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
763 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
764 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
765 | + 'item' => __( 'Items', 'invoicing' ), |
|
766 | + 'status' => __( 'Status', 'invoicing' ), |
|
767 | + ), |
|
768 | + $subscription |
|
769 | + ); |
|
770 | + |
|
771 | + if ( $subscription->get_status() == 'pending' ) { |
|
772 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
773 | + } |
|
774 | + |
|
775 | + $table_class = 'w-100 bg-white'; |
|
776 | + |
|
777 | + if ( ! is_admin() ) { |
|
778 | + $table_class = 'table table-bordered'; |
|
779 | + } |
|
780 | + |
|
781 | + ?> |
|
782 | 782 | <div class="m-0" style="overflow: auto;"> |
783 | 783 | |
784 | 784 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -787,14 +787,14 @@ discard block |
||
787 | 787 | <tr> |
788 | 788 | <?php |
789 | 789 | |
790 | - foreach ( $columns as $key => $label ) { |
|
791 | - $key = esc_attr( $key ); |
|
792 | - $label = esc_html( $label ); |
|
793 | - $class = 'text-left'; |
|
790 | + foreach ( $columns as $key => $label ) { |
|
791 | + $key = esc_attr( $key ); |
|
792 | + $label = esc_html( $label ); |
|
793 | + $class = 'text-left'; |
|
794 | 794 | |
795 | - echo "<th class='related-subscription-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
796 | - } |
|
797 | - ?> |
|
795 | + echo "<th class='related-subscription-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
796 | + } |
|
797 | + ?> |
|
798 | 798 | </tr> |
799 | 799 | </thead> |
800 | 800 | |
@@ -802,74 +802,74 @@ discard block |
||
802 | 802 | |
803 | 803 | <?php |
804 | 804 | |
805 | - foreach ( $subscription_groups as $subscription_group ) : |
|
805 | + foreach ( $subscription_groups as $subscription_group ) : |
|
806 | 806 | |
807 | - // Do not list current subscription. |
|
808 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
809 | - continue; |
|
810 | - } |
|
807 | + // Do not list current subscription. |
|
808 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
809 | + continue; |
|
810 | + } |
|
811 | 811 | |
812 | - // Ensure the subscription exists. |
|
813 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
812 | + // Ensure the subscription exists. |
|
813 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
814 | 814 | |
815 | - if ( ! $_suscription->exists() ) { |
|
816 | - continue; |
|
817 | - } |
|
815 | + if ( ! $_suscription->exists() ) { |
|
816 | + continue; |
|
817 | + } |
|
818 | 818 | |
819 | - echo '<tr>'; |
|
819 | + echo '<tr>'; |
|
820 | 820 | |
821 | - foreach ( array_keys( $columns ) as $key ) { |
|
821 | + foreach ( array_keys( $columns ) as $key ) { |
|
822 | 822 | |
823 | - $class = 'text-left'; |
|
823 | + $class = 'text-left'; |
|
824 | 824 | |
825 | - echo "<td class='p-2 text-left'>"; |
|
825 | + echo "<td class='p-2 text-left'>"; |
|
826 | 826 | |
827 | - switch ( $key ) { |
|
827 | + switch ( $key ) { |
|
828 | 828 | |
829 | - case 'status': |
|
830 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
831 | - break; |
|
829 | + case 'status': |
|
830 | + echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
831 | + break; |
|
832 | 832 | |
833 | - case 'item': |
|
834 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
835 | - echo implode( ' | ', $markup ); |
|
836 | - break; |
|
833 | + case 'item': |
|
834 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
835 | + echo implode( ' | ', $markup ); |
|
836 | + break; |
|
837 | 837 | |
838 | - case 'renewals': |
|
839 | - $max_bills = $_suscription->get_bill_times(); |
|
840 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
841 | - break; |
|
838 | + case 'renewals': |
|
839 | + $max_bills = $_suscription->get_bill_times(); |
|
840 | + echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
841 | + break; |
|
842 | 842 | |
843 | - case 'renewal_date': |
|
844 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
845 | - break; |
|
843 | + case 'renewal_date': |
|
844 | + echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
845 | + break; |
|
846 | 846 | |
847 | - case 'start_date': |
|
848 | - echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
849 | - break; |
|
847 | + case 'start_date': |
|
848 | + echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
849 | + break; |
|
850 | 850 | |
851 | - case 'subscription': |
|
852 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
853 | - printf( |
|
851 | + case 'subscription': |
|
852 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
853 | + printf( |
|
854 | 854 | '%1$s#%2$s%3$s', |
855 | 855 | '<a href="' . esc_url( $url ) . '">', |
856 | 856 | '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
857 | - '</a>' |
|
857 | + '</a>' |
|
858 | 858 | ); |
859 | 859 | |
860 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
861 | - break; |
|
860 | + echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
861 | + break; |
|
862 | 862 | |
863 | - } |
|
863 | + } |
|
864 | 864 | |
865 | - echo '</td>'; |
|
865 | + echo '</td>'; |
|
866 | 866 | |
867 | - } |
|
867 | + } |
|
868 | 868 | |
869 | - echo '</tr>'; |
|
869 | + echo '</tr>'; |
|
870 | 870 | |
871 | - endforeach; |
|
872 | - ?> |
|
871 | + endforeach; |
|
872 | + ?> |
|
873 | 873 | |
874 | 874 | </tbody> |
875 | 875 |
@@ -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 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } elseif (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
36 | 36 | |
37 | 37 | // Display a single subscription. |
38 | 38 | wpinv_recurring_subscription_details(); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | <?php $subscribers_table->views(); ?> |
67 | 67 | <form id="subscribers-filter" class="bsui" method="get"> |
68 | 68 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
69 | - <?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?> |
|
69 | + <?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?> |
|
70 | 70 | <?php $subscribers_table->display(); ?> |
71 | 71 | </form> |
72 | 72 | <?php |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | function wpinv_recurring_subscription_details() { |
83 | 83 | |
84 | 84 | // Fetch the subscription. |
85 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
86 | - if ( ! $sub->exists() ) { |
|
85 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
86 | + if (!$sub->exists()) { |
|
87 | 87 | |
88 | 88 | echo aui()->alert( |
89 | 89 | array( |
90 | 90 | 'type' => 'danger', |
91 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
91 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
92 | 92 | ) |
93 | 93 | ); |
94 | 94 | |
@@ -96,32 +96,32 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | // Use metaboxes to display the subscription details. |
99 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
100 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
99 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
100 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
101 | 101 | |
102 | 102 | $subscription_id = $sub->get_id(); |
103 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
104 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
103 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
104 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
105 | 105 | |
106 | - if ( 1 < count( $subscription_groups ) ) { |
|
107 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
106 | + if (1 < count($subscription_groups)) { |
|
107 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
108 | 108 | } |
109 | 109 | |
110 | - if ( ! empty( $subscription_group ) ) { |
|
111 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
110 | + if (!empty($subscription_group)) { |
|
111 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
112 | 112 | } |
113 | 113 | |
114 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
114 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
115 | 115 | |
116 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
116 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
117 | 117 | |
118 | 118 | ?> |
119 | 119 | |
120 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
120 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
121 | 121 | |
122 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
123 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
124 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
122 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
123 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
124 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
125 | 125 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
126 | 126 | <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
127 | 127 | |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
130 | 130 | |
131 | 131 | <div id="postbox-container-1" class="postbox-container"> |
132 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
132 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
133 | 133 | </div> |
134 | 134 | |
135 | 135 | <div id="postbox-container-2" class="postbox-container"> |
136 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
137 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
136 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
137 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
138 | 138 | </div> |
139 | 139 | |
140 | 140 | </div> |
@@ -153,43 +153,43 @@ discard block |
||
153 | 153 | * |
154 | 154 | * @param WPInv_Subscription $sub |
155 | 155 | */ |
156 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
156 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
157 | 157 | |
158 | 158 | // Subscription items. |
159 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
160 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
159 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
160 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
161 | 161 | |
162 | 162 | // Prepare subscription detail columns. |
163 | 163 | $fields = apply_filters( |
164 | 164 | 'getpaid_subscription_admin_page_fields', |
165 | 165 | array( |
166 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
167 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
168 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
169 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
170 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
171 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
172 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
173 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
174 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
175 | - 'status' => __( 'Status', 'invoicing' ), |
|
166 | + 'subscription' => __('Subscription', 'invoicing'), |
|
167 | + 'customer' => __('Customer', 'invoicing'), |
|
168 | + 'amount' => __('Amount', 'invoicing'), |
|
169 | + 'start_date' => __('Start Date', 'invoicing'), |
|
170 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
171 | + 'renewals' => __('Payments', 'invoicing'), |
|
172 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
173 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
174 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
175 | + 'status' => __('Status', 'invoicing'), |
|
176 | 176 | ) |
177 | 177 | ); |
178 | 178 | |
179 | - if ( ! $sub->is_active() ) { |
|
179 | + if (!$sub->is_active()) { |
|
180 | 180 | |
181 | - if ( isset( $fields['renews_on'] ) ) { |
|
182 | - unset( $fields['renews_on'] ); |
|
181 | + if (isset($fields['renews_on'])) { |
|
182 | + unset($fields['renews_on']); |
|
183 | 183 | } |
184 | 184 | |
185 | - if ( isset( $fields['gateway'] ) ) { |
|
186 | - unset( $fields['gateway'] ); |
|
185 | + if (isset($fields['gateway'])) { |
|
186 | + unset($fields['gateway']); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | 190 | $profile_id = $sub->get_profile_id(); |
191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | - unset( $fields['profile_id'] ); |
|
191 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
192 | + unset($fields['profile_id']); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | ?> |
@@ -197,16 +197,16 @@ discard block |
||
197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
198 | 198 | <tbody> |
199 | 199 | |
200 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
200 | + <?php foreach ($fields as $key => $label) : ?> |
|
201 | 201 | |
202 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
202 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
203 | 203 | |
204 | 204 | <th class="w-25" style="font-weight: 500;"> |
205 | - <?php echo esc_html( $label ); ?> |
|
205 | + <?php echo esc_html($label); ?> |
|
206 | 206 | </th> |
207 | 207 | |
208 | 208 | <td class="w-75 text-muted"> |
209 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?> |
|
209 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?> |
|
210 | 210 | </td> |
211 | 211 | |
212 | 212 | </tr> |
@@ -224,135 +224,135 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @param WPInv_Subscription $subscription |
226 | 226 | */ |
227 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
227 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
228 | 228 | |
229 | - $username = __( '(Missing User)', 'invoicing' ); |
|
229 | + $username = __('(Missing User)', 'invoicing'); |
|
230 | 230 | |
231 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
232 | - if ( $user ) { |
|
231 | + $user = get_userdata($subscription->get_customer_id()); |
|
232 | + if ($user) { |
|
233 | 233 | |
234 | 234 | $username = sprintf( |
235 | 235 | '<a href="user-edit.php?user_id=%s">%s</a>', |
236 | - absint( $user->ID ), |
|
237 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
236 | + absint($user->ID), |
|
237 | + !empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email) |
|
238 | 238 | ); |
239 | 239 | |
240 | 240 | } |
241 | 241 | |
242 | - echo wp_kses_post( $username ); |
|
242 | + echo wp_kses_post($username); |
|
243 | 243 | } |
244 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
244 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
245 | 245 | |
246 | 246 | /** |
247 | 247 | * Displays the subscription amount. |
248 | 248 | * |
249 | 249 | * @param WPInv_Subscription $subscription |
250 | 250 | */ |
251 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
252 | - $amount = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
251 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
252 | + $amount = wp_kses_post(getpaid_get_formatted_subscription_amount($subscription)); |
|
253 | 253 | echo "<span>$amount</span>"; |
254 | 254 | } |
255 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
255 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Displays the subscription id. |
259 | 259 | * |
260 | 260 | * @param WPInv_Subscription $subscription |
261 | 261 | */ |
262 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
262 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
263 | 263 | |
264 | 264 | printf( |
265 | 265 | '<a href="%s">#%s</a>', |
266 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
267 | - absint( $subscription->get_id() ) |
|
266 | + esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))), |
|
267 | + absint($subscription->get_id()) |
|
268 | 268 | ); |
269 | 269 | |
270 | 270 | } |
271 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
271 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
272 | 272 | |
273 | 273 | /** |
274 | 274 | * Displays the subscription renewal date. |
275 | 275 | * |
276 | 276 | * @param WPInv_Subscription $subscription |
277 | 277 | */ |
278 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
279 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
278 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
279 | + echo getpaid_format_date_value($subscription->get_date_created()); |
|
280 | 280 | } |
281 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
281 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
282 | 282 | |
283 | 283 | /** |
284 | 284 | * Displays the subscription renewal date. |
285 | 285 | * |
286 | 286 | * @param WPInv_Subscription $subscription |
287 | 287 | */ |
288 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
289 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
288 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
289 | + echo getpaid_format_date_value($subscription->get_expiration()); |
|
290 | 290 | } |
291 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
291 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
292 | 292 | |
293 | 293 | /** |
294 | 294 | * Displays the subscription renewal count. |
295 | 295 | * |
296 | 296 | * @param WPInv_Subscription $subscription |
297 | 297 | */ |
298 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
298 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
299 | 299 | $max_bills = $subscription->get_bill_times(); |
300 | - echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
300 | + echo ((int) $subscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
301 | 301 | } |
302 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
302 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
303 | 303 | /** |
304 | 304 | * Displays the subscription item. |
305 | 305 | * |
306 | 306 | * @param WPInv_Subscription $subscription |
307 | 307 | * @param false|array $subscription_group |
308 | 308 | */ |
309 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
309 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
310 | 310 | |
311 | - if ( empty( $subscription_group ) ) { |
|
312 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
311 | + if (empty($subscription_group)) { |
|
312 | + echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()); |
|
313 | 313 | return; |
314 | 314 | } |
315 | 315 | |
316 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
317 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
316 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
317 | + echo wp_kses_post(implode(' | ', $markup)); |
|
318 | 318 | |
319 | 319 | } |
320 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
320 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
321 | 321 | |
322 | 322 | /** |
323 | 323 | * Displays the subscription gateway. |
324 | 324 | * |
325 | 325 | * @param WPInv_Subscription $subscription |
326 | 326 | */ |
327 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
327 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
328 | 328 | |
329 | 329 | $gateway = $subscription->get_gateway(); |
330 | 330 | |
331 | - if ( ! empty( $gateway ) ) { |
|
332 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
331 | + if (!empty($gateway)) { |
|
332 | + echo esc_html(wpinv_get_gateway_admin_label($gateway)); |
|
333 | 333 | } else { |
334 | 334 | echo '—'; |
335 | 335 | } |
336 | 336 | |
337 | 337 | } |
338 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
338 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
339 | 339 | |
340 | 340 | /** |
341 | 341 | * Displays the subscription status. |
342 | 342 | * |
343 | 343 | * @param WPInv_Subscription $subscription |
344 | 344 | */ |
345 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
346 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
345 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
346 | + echo wp_kses_post($subscription->get_status_label_html()); |
|
347 | 347 | } |
348 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
348 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
349 | 349 | |
350 | 350 | /** |
351 | 351 | * Displays the subscription profile id. |
352 | 352 | * |
353 | 353 | * @param WPInv_Subscription $subscription |
354 | 354 | */ |
355 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
355 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
356 | 356 | |
357 | 357 | $profile_id = $subscription->get_profile_id(); |
358 | 358 | |
@@ -361,31 +361,31 @@ discard block |
||
361 | 361 | 'type' => 'text', |
362 | 362 | 'id' => 'wpinv_subscription_profile_id', |
363 | 363 | 'name' => 'wpinv_subscription_profile_id', |
364 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
364 | + 'label' => __('Profile Id', 'invoicing'), |
|
365 | 365 | 'label_type' => 'hidden', |
366 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
367 | - 'value' => esc_attr( $profile_id ), |
|
366 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
367 | + 'value' => esc_attr($profile_id), |
|
368 | 368 | 'input_group_right' => '', |
369 | 369 | 'no_wrap' => true, |
370 | 370 | ) |
371 | 371 | ); |
372 | 372 | |
373 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
373 | + echo str_ireplace('form-control', 'regular-text', $input); |
|
374 | 374 | |
375 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
376 | - if ( ! empty( $url ) ) { |
|
377 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
375 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
376 | + if (!empty($url)) { |
|
377 | + echo ' <a href="' . esc_url_raw($url) . '" title="' . __('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | } |
381 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
381 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
382 | 382 | |
383 | 383 | /** |
384 | 384 | * Displays the subscriptions update metabox. |
385 | 385 | * |
386 | 386 | * @param WPInv_Subscription $subscription |
387 | 387 | */ |
388 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
388 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
389 | 389 | |
390 | 390 | ?> |
391 | 391 | <div class="mt-3"> |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | 'id' => 'subscription_status_update_select', |
399 | 399 | 'required' => true, |
400 | 400 | 'no_wrap' => false, |
401 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
402 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
401 | + 'label' => __('Subscription Status', 'invoicing'), |
|
402 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
403 | 403 | 'select2' => true, |
404 | - 'value' => $subscription->get_status( 'edit' ), |
|
404 | + 'value' => $subscription->get_status('edit'), |
|
405 | 405 | ) |
406 | 406 | ); |
407 | 407 | ?> |
@@ -409,13 +409,13 @@ discard block |
||
409 | 409 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
410 | 410 | |
411 | 411 | <?php |
412 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
412 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
413 | 413 | |
414 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
415 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
416 | - $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' ); |
|
414 | + $url = wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'); |
|
415 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
416 | + $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'); |
|
417 | 417 | |
418 | - if ( $subscription->is_active() ) { |
|
418 | + if ($subscription->is_active()) { |
|
419 | 419 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
420 | 420 | } |
421 | 421 | |
@@ -428,45 +428,45 @@ discard block |
||
428 | 428 | * @param WPInv_Subscription $subscription |
429 | 429 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
430 | 430 | */ |
431 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
431 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
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 | ); |
444 | 444 | |
445 | 445 | // Prepare the invoices. |
446 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
446 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
447 | 447 | $parent = $subscription->get_parent_invoice(); |
448 | 448 | |
449 | - if ( $parent->exists() ) { |
|
450 | - $payments = array_merge( array( $parent ), $payments ); |
|
449 | + if ($parent->exists()) { |
|
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'; |
457 | 457 | } |
458 | 458 | |
459 | 459 | ?> |
460 | 460 | <div class="m-0" style="overflow: auto;"> |
461 | 461 | |
462 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
462 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
463 | 463 | |
464 | 464 | <thead> |
465 | 465 | <tr> |
466 | 466 | <?php |
467 | - foreach ( $columns as $key => $label ) { |
|
468 | - $key = esc_attr( $key ); |
|
469 | - $label = esc_html( $label ); |
|
467 | + foreach ($columns as $key => $label) { |
|
468 | + $key = esc_attr($key); |
|
469 | + $label = esc_html($label); |
|
470 | 470 | $class = 'text-left'; |
471 | 471 | |
472 | 472 | echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -477,70 +477,70 @@ discard block |
||
477 | 477 | |
478 | 478 | <tbody> |
479 | 479 | |
480 | - <?php if ( empty( $payments ) ) : ?> |
|
480 | + <?php if (empty($payments)) : ?> |
|
481 | 481 | <tr> |
482 | - <td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted"> |
|
483 | - <?php _e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
482 | + <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
|
483 | + <?php _e('This subscription has no invoices.', 'invoicing'); ?> |
|
484 | 484 | </td> |
485 | 485 | </tr> |
486 | 486 | <?php endif; ?> |
487 | 487 | |
488 | 488 | <?php |
489 | 489 | |
490 | - foreach ( $payments as $payment ) : |
|
490 | + foreach ($payments as $payment) : |
|
491 | 491 | |
492 | 492 | // Ensure that we have an invoice. |
493 | - $payment = new WPInv_Invoice( $payment ); |
|
493 | + $payment = new WPInv_Invoice($payment); |
|
494 | 494 | |
495 | 495 | // Abort if the invoice is invalid... |
496 | - if ( ! $payment->exists() ) { |
|
496 | + if (!$payment->exists()) { |
|
497 | 497 | continue; |
498 | 498 | } |
499 | 499 | |
500 | 500 | // ... or belongs to a different subscription. |
501 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
501 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
502 | 502 | continue; |
503 | 503 | } |
504 | 504 | |
505 | 505 | echo '<tr>'; |
506 | 506 | |
507 | - foreach ( array_keys( $columns ) as $key ) { |
|
507 | + foreach (array_keys($columns) as $key) { |
|
508 | 508 | |
509 | 509 | $class = 'text-left'; |
510 | 510 | |
511 | 511 | echo "<td class='p-2 text-left'>"; |
512 | 512 | |
513 | - switch ( $key ) { |
|
513 | + switch ($key) { |
|
514 | 514 | |
515 | 515 | case 'total': |
516 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
516 | + echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>'; |
|
517 | 517 | break; |
518 | 518 | |
519 | 519 | case 'relationship': |
520 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
520 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
521 | 521 | break; |
522 | 522 | |
523 | 523 | case 'date': |
524 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
524 | + echo getpaid_format_date_value($payment->get_date_created()); |
|
525 | 525 | break; |
526 | 526 | |
527 | 527 | case 'status': |
528 | 528 | $status = $payment->get_status_nicename(); |
529 | - if ( is_admin() ) { |
|
529 | + if (is_admin()) { |
|
530 | 530 | $status = $payment->get_status_label_html(); |
531 | 531 | } |
532 | 532 | |
533 | - echo wp_kses_post( $status ); |
|
533 | + echo wp_kses_post($status); |
|
534 | 534 | break; |
535 | 535 | |
536 | 536 | case 'invoice': |
537 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
537 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
538 | 538 | |
539 | - if ( ! is_admin() ) { |
|
540 | - $link = esc_url( $payment->get_view_url() ); |
|
539 | + if (!is_admin()) { |
|
540 | + $link = esc_url($payment->get_view_url()); |
|
541 | 541 | } |
542 | 542 | |
543 | - $invoice = esc_html( $payment->get_number() ); |
|
543 | + $invoice = esc_html($payment->get_number()); |
|
544 | 544 | echo "<a href='$link'>$invoice</a>"; |
545 | 545 | break; |
546 | 546 | } |
@@ -568,12 +568,12 @@ discard block |
||
568 | 568 | * |
569 | 569 | * @param WPInv_Subscription $subscription |
570 | 570 | */ |
571 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
571 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
572 | 572 | |
573 | 573 | // Fetch the subscription group. |
574 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
574 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
575 | 575 | |
576 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
576 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
577 | 577 | return; |
578 | 578 | } |
579 | 579 | |
@@ -581,12 +581,12 @@ discard block |
||
581 | 581 | $columns = apply_filters( |
582 | 582 | 'getpaid_subscription_item_details_columns', |
583 | 583 | array( |
584 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
585 | - 'price' => __( 'Price', 'invoicing' ), |
|
586 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
587 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
584 | + 'item_name' => __('Item', 'invoicing'), |
|
585 | + 'price' => __('Price', 'invoicing'), |
|
586 | + 'tax' => __('Tax', 'invoicing'), |
|
587 | + 'discount' => __('Discount', 'invoicing'), |
|
588 | 588 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
589 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
589 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
590 | 590 | ), |
591 | 591 | $subscription |
592 | 592 | ); |
@@ -595,28 +595,28 @@ discard block |
||
595 | 595 | |
596 | 596 | $invoice = $subscription->get_parent_invoice(); |
597 | 597 | |
598 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
599 | - unset( $columns['tax'] ); |
|
598 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
599 | + unset($columns['tax']); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | $table_class = 'w-100 bg-white'; |
603 | 603 | |
604 | - if ( ! is_admin() ) { |
|
604 | + if (!is_admin()) { |
|
605 | 605 | $table_class = 'table table-bordered'; |
606 | 606 | } |
607 | 607 | |
608 | 608 | ?> |
609 | 609 | <div class="m-0" style="overflow: auto;"> |
610 | 610 | |
611 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
611 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
612 | 612 | |
613 | 613 | <thead> |
614 | 614 | <tr> |
615 | 615 | <?php |
616 | 616 | |
617 | - foreach ( $columns as $key => $label ) { |
|
618 | - $key = esc_attr( $key ); |
|
619 | - $label = esc_html( $label ); |
|
617 | + foreach ($columns as $key => $label) { |
|
618 | + $key = esc_attr($key); |
|
619 | + $label = esc_html($label); |
|
620 | 620 | $class = 'text-left'; |
621 | 621 | |
622 | 622 | echo "<th class='subscription-item-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
@@ -629,48 +629,48 @@ discard block |
||
629 | 629 | |
630 | 630 | <?php |
631 | 631 | |
632 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
632 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
633 | 633 | |
634 | 634 | echo '<tr>'; |
635 | 635 | |
636 | - foreach ( array_keys( $columns ) as $key ) { |
|
636 | + foreach (array_keys($columns) as $key) { |
|
637 | 637 | |
638 | 638 | $class = 'text-left'; |
639 | 639 | |
640 | 640 | echo "<td class='p-2 text-left'>"; |
641 | 641 | |
642 | - switch ( $key ) { |
|
642 | + switch ($key) { |
|
643 | 643 | |
644 | 644 | case 'item_name': |
645 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
646 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
645 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
646 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
647 | 647 | |
648 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
649 | - echo esc_html( $item_name ); |
|
648 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
649 | + echo esc_html($item_name); |
|
650 | 650 | } else { |
651 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
651 | + printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | break; |
655 | 655 | |
656 | 656 | case 'price': |
657 | - echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
657 | + echo wpinv_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
658 | 658 | break; |
659 | 659 | |
660 | 660 | case 'tax': |
661 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
661 | + echo wpinv_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
662 | 662 | break; |
663 | 663 | |
664 | 664 | case 'discount': |
665 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
665 | + echo wpinv_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
666 | 666 | break; |
667 | 667 | |
668 | 668 | case 'initial': |
669 | - echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
669 | + echo wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
670 | 670 | break; |
671 | 671 | |
672 | 672 | case 'recurring': |
673 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
673 | + echo '<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'; |
|
674 | 674 | break; |
675 | 675 | |
676 | 676 | } |
@@ -683,24 +683,24 @@ discard block |
||
683 | 683 | |
684 | 684 | endforeach; |
685 | 685 | |
686 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
686 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
687 | 687 | |
688 | 688 | echo '<tr>'; |
689 | 689 | |
690 | - foreach ( array_keys( $columns ) as $key ) { |
|
690 | + foreach (array_keys($columns) as $key) { |
|
691 | 691 | |
692 | 692 | $class = 'text-left'; |
693 | 693 | |
694 | 694 | echo "<td class='p-2 text-left'>"; |
695 | 695 | |
696 | - switch ( $key ) { |
|
696 | + switch ($key) { |
|
697 | 697 | |
698 | 698 | case 'item_name': |
699 | - echo esc_html( $subscription_group_fee['name'] ); |
|
699 | + echo esc_html($subscription_group_fee['name']); |
|
700 | 700 | break; |
701 | 701 | |
702 | 702 | case 'price': |
703 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
703 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
704 | 704 | break; |
705 | 705 | |
706 | 706 | case 'tax': |
@@ -712,11 +712,11 @@ discard block |
||
712 | 712 | break; |
713 | 713 | |
714 | 714 | case 'initial': |
715 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
715 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
716 | 716 | break; |
717 | 717 | |
718 | 718 | case 'recurring': |
719 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
719 | + echo '<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'; |
|
720 | 720 | break; |
721 | 721 | |
722 | 722 | } |
@@ -745,12 +745,12 @@ discard block |
||
745 | 745 | * @param WPInv_Subscription $subscription |
746 | 746 | * @param bool $skip_current |
747 | 747 | */ |
748 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
748 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
749 | 749 | |
750 | 750 | // Fetch the subscription groups. |
751 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
751 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
752 | 752 | |
753 | - if ( empty( $subscription_groups ) ) { |
|
753 | + if (empty($subscription_groups)) { |
|
754 | 754 | return; |
755 | 755 | } |
756 | 756 | |
@@ -758,38 +758,38 @@ discard block |
||
758 | 758 | $columns = apply_filters( |
759 | 759 | 'getpaid_subscription_related_subscriptions_columns', |
760 | 760 | array( |
761 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
762 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
763 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
764 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
765 | - 'item' => __( 'Items', 'invoicing' ), |
|
766 | - 'status' => __( 'Status', 'invoicing' ), |
|
761 | + 'subscription' => __('Subscription', 'invoicing'), |
|
762 | + 'start_date' => __('Start Date', 'invoicing'), |
|
763 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
764 | + 'renewals' => __('Payments', 'invoicing'), |
|
765 | + 'item' => __('Items', 'invoicing'), |
|
766 | + 'status' => __('Status', 'invoicing'), |
|
767 | 767 | ), |
768 | 768 | $subscription |
769 | 769 | ); |
770 | 770 | |
771 | - if ( $subscription->get_status() == 'pending' ) { |
|
772 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
771 | + if ($subscription->get_status() == 'pending') { |
|
772 | + unset($columns['start_date'], $columns['renewal_date']); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | $table_class = 'w-100 bg-white'; |
776 | 776 | |
777 | - if ( ! is_admin() ) { |
|
777 | + if (!is_admin()) { |
|
778 | 778 | $table_class = 'table table-bordered'; |
779 | 779 | } |
780 | 780 | |
781 | 781 | ?> |
782 | 782 | <div class="m-0" style="overflow: auto;"> |
783 | 783 | |
784 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
784 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
785 | 785 | |
786 | 786 | <thead> |
787 | 787 | <tr> |
788 | 788 | <?php |
789 | 789 | |
790 | - foreach ( $columns as $key => $label ) { |
|
791 | - $key = esc_attr( $key ); |
|
792 | - $label = esc_html( $label ); |
|
790 | + foreach ($columns as $key => $label) { |
|
791 | + $key = esc_attr($key); |
|
792 | + $label = esc_html($label); |
|
793 | 793 | $class = 'text-left'; |
794 | 794 | |
795 | 795 | echo "<th class='related-subscription-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
@@ -802,62 +802,62 @@ discard block |
||
802 | 802 | |
803 | 803 | <?php |
804 | 804 | |
805 | - foreach ( $subscription_groups as $subscription_group ) : |
|
805 | + foreach ($subscription_groups as $subscription_group) : |
|
806 | 806 | |
807 | 807 | // Do not list current subscription. |
808 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
808 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
809 | 809 | continue; |
810 | 810 | } |
811 | 811 | |
812 | 812 | // Ensure the subscription exists. |
813 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
813 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
814 | 814 | |
815 | - if ( ! $_suscription->exists() ) { |
|
815 | + if (!$_suscription->exists()) { |
|
816 | 816 | continue; |
817 | 817 | } |
818 | 818 | |
819 | 819 | echo '<tr>'; |
820 | 820 | |
821 | - foreach ( array_keys( $columns ) as $key ) { |
|
821 | + foreach (array_keys($columns) as $key) { |
|
822 | 822 | |
823 | 823 | $class = 'text-left'; |
824 | 824 | |
825 | 825 | echo "<td class='p-2 text-left'>"; |
826 | 826 | |
827 | - switch ( $key ) { |
|
827 | + switch ($key) { |
|
828 | 828 | |
829 | 829 | case 'status': |
830 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
830 | + echo wp_kses_post($_suscription->get_status_label_html()); |
|
831 | 831 | break; |
832 | 832 | |
833 | 833 | case 'item': |
834 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
835 | - echo implode( ' | ', $markup ); |
|
834 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
835 | + echo implode(' | ', $markup); |
|
836 | 836 | break; |
837 | 837 | |
838 | 838 | case 'renewals': |
839 | 839 | $max_bills = $_suscription->get_bill_times(); |
840 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
840 | + echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
841 | 841 | break; |
842 | 842 | |
843 | 843 | case 'renewal_date': |
844 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
844 | + echo $_suscription->is_active() ? getpaid_format_date_value($_suscription->get_expiration()) : '—'; |
|
845 | 845 | break; |
846 | 846 | |
847 | 847 | case 'start_date': |
848 | - echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
848 | + echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value($_suscription->get_date_created()); |
|
849 | 849 | break; |
850 | 850 | |
851 | 851 | case 'subscription': |
852 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
852 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
853 | 853 | printf( |
854 | 854 | '%1$s#%2$s%3$s', |
855 | - '<a href="' . esc_url( $url ) . '">', |
|
856 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
855 | + '<a href="' . esc_url($url) . '">', |
|
856 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
857 | 857 | '</a>' |
858 | 858 | ); |
859 | 859 | |
860 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
860 | + echo WPInv_Subscriptions_List_Table::column_amount($_suscription); |
|
861 | 861 | break; |
862 | 862 | |
863 | 863 | } |
@@ -21,101 +21,101 @@ |
||
21 | 21 | global $wp_settings_fields; |
22 | 22 | |
23 | 23 | if ( isset( $wp_settings_fields[ $page ][ $section ] ) ) { |
24 | - $settings = $wp_settings_fields[ $page ][ $section ]; |
|
25 | - |
|
26 | - foreach ( $settings as $field ) { |
|
27 | - |
|
28 | - $name = esc_attr( $field['id'] ); |
|
29 | - $id = sanitize_key( $name ); |
|
30 | - $class = ''; |
|
31 | - $value = isset( $field['args']['std'] ) ? $field['args']['std'] : ''; |
|
32 | - $value = wpinv_clean( wpinv_get_option( $field['args']['id'], $value ) ); |
|
33 | - $help_text = isset( $field['args']['desc'] ) ? wp_kses_post( $field['args']['desc'] ) : ''; |
|
34 | - $type = str_replace( 'wpinv_', '', str_replace( '_callback', '', $field['callback'] ) ); |
|
35 | - $label = isset( $field['args']['name'] ) ? wp_kses_post( $field['args']['name'] ) : ''; |
|
36 | - $options = isset( $field['args']['options'] ) ? $field['args']['options'] : array(); |
|
37 | - |
|
38 | - if ( false !== strpos( $name, 'logo' ) ) { |
|
39 | - $type = 'hidden'; |
|
24 | + $settings = $wp_settings_fields[ $page ][ $section ]; |
|
25 | + |
|
26 | + foreach ( $settings as $field ) { |
|
27 | + |
|
28 | + $name = esc_attr( $field['id'] ); |
|
29 | + $id = sanitize_key( $name ); |
|
30 | + $class = ''; |
|
31 | + $value = isset( $field['args']['std'] ) ? $field['args']['std'] : ''; |
|
32 | + $value = wpinv_clean( wpinv_get_option( $field['args']['id'], $value ) ); |
|
33 | + $help_text = isset( $field['args']['desc'] ) ? wp_kses_post( $field['args']['desc'] ) : ''; |
|
34 | + $type = str_replace( 'wpinv_', '', str_replace( '_callback', '', $field['callback'] ) ); |
|
35 | + $label = isset( $field['args']['name'] ) ? wp_kses_post( $field['args']['name'] ) : ''; |
|
36 | + $options = isset( $field['args']['options'] ) ? $field['args']['options'] : array(); |
|
37 | + |
|
38 | + if ( false !== strpos( $name, 'logo' ) ) { |
|
39 | + $type = 'hidden'; |
|
40 | 40 | } |
41 | 41 | |
42 | - if ( 'country_states' == $type ) { |
|
42 | + if ( 'country_states' == $type ) { |
|
43 | 43 | |
44 | - if ( 0 == count( wpinv_get_country_states( wpinv_get_default_country() ) ) ) { |
|
45 | - $type = 'text'; |
|
44 | + if ( 0 == count( wpinv_get_country_states( wpinv_get_default_country() ) ) ) { |
|
45 | + $type = 'text'; |
|
46 | 46 | } else { |
47 | - $type = 'select'; |
|
47 | + $type = 'select'; |
|
48 | 48 | } |
49 | 49 | |
50 | - $class = 'getpaid_js_field-state'; |
|
50 | + $class = 'getpaid_js_field-state'; |
|
51 | 51 | } |
52 | 52 | |
53 | - if ( 'wpinv_settings[default_country]' == $name ) { |
|
54 | - $class = 'getpaid_js_field-country'; |
|
53 | + if ( 'wpinv_settings[default_country]' == $name ) { |
|
54 | + $class = 'getpaid_js_field-country'; |
|
55 | 55 | } |
56 | 56 | |
57 | - switch ( $type ) { |
|
57 | + switch ( $type ) { |
|
58 | 58 | |
59 | - case 'hidden': |
|
60 | - echo "<input type='hidden' id='$id' name='$name' value='$value' />"; |
|
61 | - break; |
|
62 | - case 'text': |
|
59 | + case 'hidden': |
|
60 | + echo "<input type='hidden' id='$id' name='$name' value='$value' />"; |
|
61 | + break; |
|
62 | + case 'text': |
|
63 | 63 | case 'number': |
64 | - echo aui()->input( |
|
64 | + echo aui()->input( |
|
65 | 65 | array( |
66 | - 'type' => $type, |
|
67 | - 'id' => $id, |
|
68 | - 'name' => $name, |
|
69 | - 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
70 | - 'required' => false, |
|
71 | - 'help_text' => $help_text, |
|
72 | - 'label' => $label, |
|
73 | - 'class' => $class, |
|
74 | - 'label_type' => 'floating', |
|
75 | - 'label_class' => 'settings-label', |
|
66 | + 'type' => $type, |
|
67 | + 'id' => $id, |
|
68 | + 'name' => $name, |
|
69 | + 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
70 | + 'required' => false, |
|
71 | + 'help_text' => $help_text, |
|
72 | + 'label' => $label, |
|
73 | + 'class' => $class, |
|
74 | + 'label_type' => 'floating', |
|
75 | + 'label_class' => 'settings-label', |
|
76 | 76 | ) |
77 | 77 | ); |
78 | - break; |
|
79 | - case 'textarea': |
|
80 | - $textarea = aui()->textarea( |
|
81 | - array( |
|
82 | - 'id' => $id, |
|
83 | - 'name' => $name, |
|
84 | - 'value' => is_scalar( $value ) ? esc_textarea( $value ) : '', |
|
85 | - 'required' => false, |
|
86 | - 'help_text' => $help_text, |
|
87 | - 'label' => $label, |
|
88 | - 'rows' => '4', |
|
89 | - 'class' => $class, |
|
90 | - 'label_type' => 'floating', |
|
91 | - 'label_class' => 'settings-label', |
|
92 | - ) |
|
93 | - ); |
|
94 | - |
|
95 | - // Bug fixed in AUI 0.1.51 for name stripping [] |
|
96 | - echo str_replace( sanitize_html_class( $name ), esc_attr( $name ), $textarea ); |
|
97 | - |
|
98 | - break; |
|
99 | - case 'select': |
|
100 | - echo aui()->select( |
|
101 | - array( |
|
102 | - 'id' => $id, |
|
103 | - 'name' => $name, |
|
104 | - 'placeholder' => '', |
|
105 | - 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
106 | - 'required' => false, |
|
107 | - 'help_text' => $help_text, |
|
108 | - 'label' => $label, |
|
109 | - 'options' => $options, |
|
110 | - 'label_type' => 'floating', |
|
111 | - 'label_class' => 'settings-label', |
|
112 | - 'class' => $class, |
|
113 | - ) |
|
114 | - ); |
|
115 | - break; |
|
116 | - default: |
|
117 | - // Do something. |
|
118 | - break; |
|
78 | + break; |
|
79 | + case 'textarea': |
|
80 | + $textarea = aui()->textarea( |
|
81 | + array( |
|
82 | + 'id' => $id, |
|
83 | + 'name' => $name, |
|
84 | + 'value' => is_scalar( $value ) ? esc_textarea( $value ) : '', |
|
85 | + 'required' => false, |
|
86 | + 'help_text' => $help_text, |
|
87 | + 'label' => $label, |
|
88 | + 'rows' => '4', |
|
89 | + 'class' => $class, |
|
90 | + 'label_type' => 'floating', |
|
91 | + 'label_class' => 'settings-label', |
|
92 | + ) |
|
93 | + ); |
|
94 | + |
|
95 | + // Bug fixed in AUI 0.1.51 for name stripping [] |
|
96 | + echo str_replace( sanitize_html_class( $name ), esc_attr( $name ), $textarea ); |
|
97 | + |
|
98 | + break; |
|
99 | + case 'select': |
|
100 | + echo aui()->select( |
|
101 | + array( |
|
102 | + 'id' => $id, |
|
103 | + 'name' => $name, |
|
104 | + 'placeholder' => '', |
|
105 | + 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
106 | + 'required' => false, |
|
107 | + 'help_text' => $help_text, |
|
108 | + 'label' => $label, |
|
109 | + 'options' => $options, |
|
110 | + 'label_type' => 'floating', |
|
111 | + 'label_class' => 'settings-label', |
|
112 | + 'class' => $class, |
|
113 | + ) |
|
114 | + ); |
|
115 | + break; |
|
116 | + default: |
|
117 | + // Do something. |
|
118 | + break; |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | } |
@@ -4,15 +4,15 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | ?> |
10 | 10 | |
11 | 11 | <div class="card shadow-sm my-5"> |
12 | 12 | |
13 | 13 | <form method="post" class="text-left card-body" action="options.php"> |
14 | - <?php settings_fields( 'wpinv_settings' ); ?> |
|
15 | - <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $next_url ); ?>"> |
|
14 | + <?php settings_fields('wpinv_settings'); ?> |
|
15 | + <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url($next_url); ?>"> |
|
16 | 16 | |
17 | 17 | <table class="gp-setup-maps w-100 " cellspacing="0"> |
18 | 18 | <tbody> |
@@ -20,28 +20,28 @@ discard block |
||
20 | 20 | |
21 | 21 | global $wp_settings_fields; |
22 | 22 | |
23 | - if ( isset( $wp_settings_fields[ $page ][ $section ] ) ) { |
|
24 | - $settings = $wp_settings_fields[ $page ][ $section ]; |
|
23 | + if (isset($wp_settings_fields[$page][$section])) { |
|
24 | + $settings = $wp_settings_fields[$page][$section]; |
|
25 | 25 | |
26 | - foreach ( $settings as $field ) { |
|
26 | + foreach ($settings as $field) { |
|
27 | 27 | |
28 | - $name = esc_attr( $field['id'] ); |
|
29 | - $id = sanitize_key( $name ); |
|
28 | + $name = esc_attr($field['id']); |
|
29 | + $id = sanitize_key($name); |
|
30 | 30 | $class = ''; |
31 | - $value = isset( $field['args']['std'] ) ? $field['args']['std'] : ''; |
|
32 | - $value = wpinv_clean( wpinv_get_option( $field['args']['id'], $value ) ); |
|
33 | - $help_text = isset( $field['args']['desc'] ) ? wp_kses_post( $field['args']['desc'] ) : ''; |
|
34 | - $type = str_replace( 'wpinv_', '', str_replace( '_callback', '', $field['callback'] ) ); |
|
35 | - $label = isset( $field['args']['name'] ) ? wp_kses_post( $field['args']['name'] ) : ''; |
|
36 | - $options = isset( $field['args']['options'] ) ? $field['args']['options'] : array(); |
|
37 | - |
|
38 | - if ( false !== strpos( $name, 'logo' ) ) { |
|
31 | + $value = isset($field['args']['std']) ? $field['args']['std'] : ''; |
|
32 | + $value = wpinv_clean(wpinv_get_option($field['args']['id'], $value)); |
|
33 | + $help_text = isset($field['args']['desc']) ? wp_kses_post($field['args']['desc']) : ''; |
|
34 | + $type = str_replace('wpinv_', '', str_replace('_callback', '', $field['callback'])); |
|
35 | + $label = isset($field['args']['name']) ? wp_kses_post($field['args']['name']) : ''; |
|
36 | + $options = isset($field['args']['options']) ? $field['args']['options'] : array(); |
|
37 | + |
|
38 | + if (false !== strpos($name, 'logo')) { |
|
39 | 39 | $type = 'hidden'; |
40 | 40 | } |
41 | 41 | |
42 | - if ( 'country_states' == $type ) { |
|
42 | + if ('country_states' == $type) { |
|
43 | 43 | |
44 | - if ( 0 == count( wpinv_get_country_states( wpinv_get_default_country() ) ) ) { |
|
44 | + if (0 == count(wpinv_get_country_states(wpinv_get_default_country()))) { |
|
45 | 45 | $type = 'text'; |
46 | 46 | } else { |
47 | 47 | $type = 'select'; |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | $class = 'getpaid_js_field-state'; |
51 | 51 | } |
52 | 52 | |
53 | - if ( 'wpinv_settings[default_country]' == $name ) { |
|
53 | + if ('wpinv_settings[default_country]' == $name) { |
|
54 | 54 | $class = 'getpaid_js_field-country'; |
55 | 55 | } |
56 | 56 | |
57 | - switch ( $type ) { |
|
57 | + switch ($type) { |
|
58 | 58 | |
59 | 59 | case 'hidden': |
60 | 60 | echo "<input type='hidden' id='$id' name='$name' value='$value' />"; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | 'type' => $type, |
67 | 67 | 'id' => $id, |
68 | 68 | 'name' => $name, |
69 | - 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
69 | + 'value' => is_scalar($value) ? esc_attr($value) : '', |
|
70 | 70 | 'required' => false, |
71 | 71 | 'help_text' => $help_text, |
72 | 72 | 'label' => $label, |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | array( |
82 | 82 | 'id' => $id, |
83 | 83 | 'name' => $name, |
84 | - 'value' => is_scalar( $value ) ? esc_textarea( $value ) : '', |
|
84 | + 'value' => is_scalar($value) ? esc_textarea($value) : '', |
|
85 | 85 | 'required' => false, |
86 | 86 | 'help_text' => $help_text, |
87 | 87 | 'label' => $label, |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | ); |
94 | 94 | |
95 | 95 | // Bug fixed in AUI 0.1.51 for name stripping [] |
96 | - echo str_replace( sanitize_html_class( $name ), esc_attr( $name ), $textarea ); |
|
96 | + echo str_replace(sanitize_html_class($name), esc_attr($name), $textarea); |
|
97 | 97 | |
98 | 98 | break; |
99 | 99 | case 'select': |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | 'id' => $id, |
103 | 103 | 'name' => $name, |
104 | 104 | 'placeholder' => '', |
105 | - 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
105 | + 'value' => is_scalar($value) ? esc_attr($value) : '', |
|
106 | 106 | 'required' => false, |
107 | 107 | 'help_text' => $help_text, |
108 | 108 | 'label' => $label, |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | <input |
128 | 128 | type="submit" |
129 | 129 | class="btn btn-primary button-next" |
130 | - value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/> |
|
130 | + value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/> |
|
131 | 131 | </p> |
132 | 132 | </table> |
133 | 133 | </form> |
@@ -12,49 +12,49 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Reports { |
14 | 14 | |
15 | - /** |
|
16 | - * Class constructor. |
|
17 | - * |
|
18 | - */ |
|
19 | - public function __construct() { |
|
20 | - add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
21 | - add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
22 | - add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
23 | - add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
24 | - add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
25 | - |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * Registers the reports page. |
|
30 | - * |
|
31 | - */ |
|
32 | - public function register_reports_page() { |
|
33 | - |
|
34 | - add_submenu_page( |
|
15 | + /** |
|
16 | + * Class constructor. |
|
17 | + * |
|
18 | + */ |
|
19 | + public function __construct() { |
|
20 | + add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
21 | + add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
22 | + add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
23 | + add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
24 | + add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
25 | + |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * Registers the reports page. |
|
30 | + * |
|
31 | + */ |
|
32 | + public function register_reports_page() { |
|
33 | + |
|
34 | + add_submenu_page( |
|
35 | 35 | 'wpinv', |
36 | 36 | __( 'Reports', 'invoicing' ), |
37 | 37 | __( 'Reports', 'invoicing' ), |
38 | 38 | wpinv_get_capability(), |
39 | 39 | 'wpinv-reports', |
40 | 40 | array( $this, 'display_reports_page' ) |
41 | - ); |
|
41 | + ); |
|
42 | 42 | |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Displays the reports page. |
|
47 | - * |
|
48 | - */ |
|
49 | - public function display_reports_page() { |
|
45 | + /** |
|
46 | + * Displays the reports page. |
|
47 | + * |
|
48 | + */ |
|
49 | + public function display_reports_page() { |
|
50 | 50 | |
51 | - // Prepare variables. |
|
52 | - $tabs = $this->get_tabs(); |
|
53 | - $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
54 | - $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
51 | + // Prepare variables. |
|
52 | + $tabs = $this->get_tabs(); |
|
53 | + $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
54 | + $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
55 | 55 | |
56 | - // Display the current tab. |
|
57 | - ?> |
|
56 | + // Display the current tab. |
|
57 | + ?> |
|
58 | 58 | |
59 | 59 | <div class="wrap"> |
60 | 60 | |
@@ -63,19 +63,19 @@ discard block |
||
63 | 63 | <nav class="nav-tab-wrapper"> |
64 | 64 | |
65 | 65 | <?php |
66 | - foreach ( $tabs as $key => $label ) { |
|
66 | + foreach ( $tabs as $key => $label ) { |
|
67 | 67 | |
68 | - $key = sanitize_key( $key ); |
|
69 | - $label = esc_html( $label ); |
|
70 | - $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
|
71 | - $url = esc_url( |
|
68 | + $key = sanitize_key( $key ); |
|
69 | + $label = esc_html( $label ); |
|
70 | + $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
|
71 | + $url = esc_url( |
|
72 | 72 | add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
73 | 73 | ); |
74 | 74 | |
75 | - echo "\n\t\t\t<a href='$url' class='$class'>$label</a>"; |
|
75 | + echo "\n\t\t\t<a href='$url' class='$class'>$label</a>"; |
|
76 | 76 | |
77 | - } |
|
78 | - ?> |
|
77 | + } |
|
78 | + ?> |
|
79 | 79 | |
80 | 80 | </nav> |
81 | 81 | |
@@ -86,82 +86,82 @@ discard block |
||
86 | 86 | </div> |
87 | 87 | <?php |
88 | 88 | |
89 | - // Wordfence loads an unsupported version of chart js on our page. |
|
90 | - wp_deregister_style( 'chart-js' ); |
|
91 | - wp_deregister_script( 'chart-js' ); |
|
92 | - wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true ); |
|
89 | + // Wordfence loads an unsupported version of chart js on our page. |
|
90 | + wp_deregister_style( 'chart-js' ); |
|
91 | + wp_deregister_script( 'chart-js' ); |
|
92 | + wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true ); |
|
93 | 93 | |
94 | - } |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Retrieves reports page tabs. |
|
98 | - * |
|
99 | - * @return array |
|
100 | - */ |
|
101 | - public function get_tabs() { |
|
96 | + /** |
|
97 | + * Retrieves reports page tabs. |
|
98 | + * |
|
99 | + * @return array |
|
100 | + */ |
|
101 | + public function get_tabs() { |
|
102 | 102 | |
103 | - $tabs = array( |
|
104 | - 'reports' => __( 'Reports', 'invoicing' ), |
|
105 | - 'export' => __( 'Export', 'invoicing' ), |
|
106 | - ); |
|
103 | + $tabs = array( |
|
104 | + 'reports' => __( 'Reports', 'invoicing' ), |
|
105 | + 'export' => __( 'Export', 'invoicing' ), |
|
106 | + ); |
|
107 | 107 | |
108 | - return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
109 | - } |
|
108 | + return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Displays the reports tab. |
|
113 | - * |
|
114 | - */ |
|
115 | - public function display_reports_tab() { |
|
111 | + /** |
|
112 | + * Displays the reports tab. |
|
113 | + * |
|
114 | + */ |
|
115 | + public function display_reports_tab() { |
|
116 | 116 | |
117 | - $reports = new GetPaid_Reports_Report(); |
|
118 | - $reports->display(); |
|
117 | + $reports = new GetPaid_Reports_Report(); |
|
118 | + $reports->display(); |
|
119 | 119 | |
120 | - } |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Displays the exports tab. |
|
124 | - * |
|
125 | - */ |
|
126 | - public function display_exports_tab() { |
|
122 | + /** |
|
123 | + * Displays the exports tab. |
|
124 | + * |
|
125 | + */ |
|
126 | + public function display_exports_tab() { |
|
127 | 127 | |
128 | - $exports = new GetPaid_Reports_Export(); |
|
129 | - $exports->display(); |
|
128 | + $exports = new GetPaid_Reports_Export(); |
|
129 | + $exports->display(); |
|
130 | 130 | |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * Donwnloads a graph. |
|
135 | - * |
|
136 | - * @param array $args |
|
137 | - */ |
|
138 | - public function download_graph( $args ) { |
|
133 | + /** |
|
134 | + * Donwnloads a graph. |
|
135 | + * |
|
136 | + * @param array $args |
|
137 | + */ |
|
138 | + public function download_graph( $args ) { |
|
139 | 139 | |
140 | - if ( ! empty( $args['graph'] ) ) { |
|
141 | - $downloader = new GetPaid_Graph_Downloader(); |
|
142 | - $downloader->download( $args['graph'] ); |
|
143 | - } |
|
140 | + if ( ! empty( $args['graph'] ) ) { |
|
141 | + $downloader = new GetPaid_Graph_Downloader(); |
|
142 | + $downloader->download( $args['graph'] ); |
|
143 | + } |
|
144 | 144 | |
145 | - } |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * Exports invoices. |
|
149 | - * |
|
150 | - * @param array $args |
|
151 | - */ |
|
152 | - public function export_invoices( $args ) { |
|
147 | + /** |
|
148 | + * Exports invoices. |
|
149 | + * |
|
150 | + * @param array $args |
|
151 | + */ |
|
152 | + public function export_invoices( $args ) { |
|
153 | 153 | |
154 | - if ( ! empty( $args['post_type'] ) ) { |
|
154 | + if ( ! empty( $args['post_type'] ) ) { |
|
155 | 155 | |
156 | - if ( 'subscriptions' === $args['post_type'] ) { |
|
157 | - $downloader = new GetPaid_Subscription_Exporter(); |
|
158 | - } else { |
|
159 | - $downloader = new GetPaid_Invoice_Exporter(); |
|
160 | - } |
|
156 | + if ( 'subscriptions' === $args['post_type'] ) { |
|
157 | + $downloader = new GetPaid_Subscription_Exporter(); |
|
158 | + } else { |
|
159 | + $downloader = new GetPaid_Invoice_Exporter(); |
|
160 | + } |
|
161 | 161 | |
162 | - $downloader->export( $args['post_type'], $args ); |
|
163 | - } |
|
162 | + $downloader->export( $args['post_type'], $args ); |
|
163 | + } |
|
164 | 164 | |
165 | - } |
|
165 | + } |
|
166 | 166 | |
167 | 167 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * GetPaid_Reports Class. |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | * |
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | - add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
21 | - add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
22 | - add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
23 | - add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
24 | - add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
20 | + add_action('admin_menu', array($this, 'register_reports_page'), 20); |
|
21 | + add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab')); |
|
22 | + add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab')); |
|
23 | + add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph')); |
|
24 | + add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices')); |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | |
34 | 34 | add_submenu_page( |
35 | 35 | 'wpinv', |
36 | - __( 'Reports', 'invoicing' ), |
|
37 | - __( 'Reports', 'invoicing' ), |
|
36 | + __('Reports', 'invoicing'), |
|
37 | + __('Reports', 'invoicing'), |
|
38 | 38 | wpinv_get_capability(), |
39 | 39 | 'wpinv-reports', |
40 | - array( $this, 'display_reports_page' ) |
|
40 | + array($this, 'display_reports_page') |
|
41 | 41 | ); |
42 | 42 | |
43 | 43 | } |
@@ -50,26 +50,26 @@ discard block |
||
50 | 50 | |
51 | 51 | // Prepare variables. |
52 | 52 | $tabs = $this->get_tabs(); |
53 | - $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
54 | - $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
53 | + $current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports'; |
|
54 | + $current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports'; |
|
55 | 55 | |
56 | 56 | // Display the current tab. |
57 | 57 | ?> |
58 | 58 | |
59 | 59 | <div class="wrap"> |
60 | 60 | |
61 | - <h1><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1> |
|
61 | + <h1><?php echo esc_html($tabs[$current_tab]); ?></h1> |
|
62 | 62 | |
63 | 63 | <nav class="nav-tab-wrapper"> |
64 | 64 | |
65 | 65 | <?php |
66 | - foreach ( $tabs as $key => $label ) { |
|
66 | + foreach ($tabs as $key => $label) { |
|
67 | 67 | |
68 | - $key = sanitize_key( $key ); |
|
69 | - $label = esc_html( $label ); |
|
68 | + $key = sanitize_key($key); |
|
69 | + $label = esc_html($label); |
|
70 | 70 | $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
71 | 71 | $url = esc_url( |
72 | - add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
|
72 | + add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports')) |
|
73 | 73 | ); |
74 | 74 | |
75 | 75 | echo "\n\t\t\t<a href='$url' class='$class'>$label</a>"; |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | |
80 | 80 | </nav> |
81 | 81 | |
82 | - <div class="bsui <?php echo esc_attr( $current_tab ); ?>"> |
|
83 | - <?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?> |
|
82 | + <div class="bsui <?php echo esc_attr($current_tab); ?>"> |
|
83 | + <?php do_action("wpinv_reports_tab_{$current_tab}"); ?> |
|
84 | 84 | </div> |
85 | 85 | |
86 | 86 | </div> |
87 | 87 | <?php |
88 | 88 | |
89 | 89 | // Wordfence loads an unsupported version of chart js on our page. |
90 | - wp_deregister_style( 'chart-js' ); |
|
91 | - wp_deregister_script( 'chart-js' ); |
|
92 | - wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true ); |
|
90 | + wp_deregister_style('chart-js'); |
|
91 | + wp_deregister_script('chart-js'); |
|
92 | + wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array('jquery'), '3.7.1', true); |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | public function get_tabs() { |
102 | 102 | |
103 | 103 | $tabs = array( |
104 | - 'reports' => __( 'Reports', 'invoicing' ), |
|
105 | - 'export' => __( 'Export', 'invoicing' ), |
|
104 | + 'reports' => __('Reports', 'invoicing'), |
|
105 | + 'export' => __('Export', 'invoicing'), |
|
106 | 106 | ); |
107 | 107 | |
108 | - return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
108 | + return apply_filters('getpaid_report_tabs', $tabs); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param array $args |
137 | 137 | */ |
138 | - public function download_graph( $args ) { |
|
138 | + public function download_graph($args) { |
|
139 | 139 | |
140 | - if ( ! empty( $args['graph'] ) ) { |
|
140 | + if (!empty($args['graph'])) { |
|
141 | 141 | $downloader = new GetPaid_Graph_Downloader(); |
142 | - $downloader->download( $args['graph'] ); |
|
142 | + $downloader->download($args['graph']); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | } |
@@ -149,17 +149,17 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @param array $args |
151 | 151 | */ |
152 | - public function export_invoices( $args ) { |
|
152 | + public function export_invoices($args) { |
|
153 | 153 | |
154 | - if ( ! empty( $args['post_type'] ) ) { |
|
154 | + if (!empty($args['post_type'])) { |
|
155 | 155 | |
156 | - if ( 'subscriptions' === $args['post_type'] ) { |
|
156 | + if ('subscriptions' === $args['post_type']) { |
|
157 | 157 | $downloader = new GetPaid_Subscription_Exporter(); |
158 | 158 | } else { |
159 | 159 | $downloader = new GetPaid_Invoice_Exporter(); |
160 | 160 | } |
161 | 161 | |
162 | - $downloader->export( $args['post_type'], $args ); |
|
162 | + $downloader->export($args['post_type'], $args); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | } |