@@ -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,24 +21,24 @@ 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 discount. |
27 | - $discount = new WPInv_Discount( $post ); |
|
27 | + $discount = new WPInv_Discount($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 | - do_action( 'wpinv_discount_form_top', $discount ); |
|
32 | + do_action('wpinv_discount_form_top', $discount); |
|
33 | 33 | |
34 | 34 | // Set the currency position. |
35 | 35 | $position = wpinv_currency_position(); |
36 | 36 | |
37 | - if ( $position == 'left_space' ) { |
|
37 | + if ($position == 'left_space') { |
|
38 | 38 | $position = 'left'; |
39 | 39 | } |
40 | 40 | |
41 | - if ( $position == 'right_space' ) { |
|
41 | + if ($position == 'right_space') { |
|
42 | 42 | $position = 'right'; |
43 | 43 | } |
44 | 44 | |
@@ -52,68 +52,68 @@ discard block |
||
52 | 52 | </style> |
53 | 53 | <div class='bsui' style='max-width: 600px;padding-top: 10px;'> |
54 | 54 | |
55 | - <?php do_action( 'wpinv_discount_form_first', $discount ); ?> |
|
55 | + <?php do_action('wpinv_discount_form_first', $discount); ?> |
|
56 | 56 | |
57 | - <?php do_action( 'wpinv_discount_form_before_code', $discount ); ?> |
|
57 | + <?php do_action('wpinv_discount_form_before_code', $discount); ?> |
|
58 | 58 | <div class="form-group row"> |
59 | 59 | <label for="wpinv_discount_code" class="col-sm-3 col-form-label"> |
60 | - <?php esc_html_e( 'Discount Code', 'invoicing' ); ?> |
|
60 | + <?php esc_html_e('Discount Code', 'invoicing'); ?> |
|
61 | 61 | </label> |
62 | 62 | <div class="col-sm-8"> |
63 | 63 | <div class="row"> |
64 | 64 | <div class="col-sm-12 form-group"> |
65 | - <input type="text" value="<?php echo esc_attr( $discount->get_code( 'edit' ) ); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" /> |
|
65 | + <input type="text" value="<?php echo esc_attr($discount->get_code('edit')); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" /> |
|
66 | 66 | </div> |
67 | 67 | <div class="col-sm-12"> |
68 | 68 | <?php |
69 | - do_action( 'wpinv_discount_form_before_single_use', $discount ); |
|
69 | + do_action('wpinv_discount_form_before_single_use', $discount); |
|
70 | 70 | |
71 | 71 | aui()->input( |
72 | 72 | array( |
73 | 73 | 'id' => 'wpinv_discount_single_use', |
74 | 74 | 'name' => 'wpinv_discount_single_use', |
75 | 75 | 'type' => 'checkbox', |
76 | - 'label' => __( 'Each customer can only use this discount once', 'invoicing' ), |
|
76 | + 'label' => __('Each customer can only use this discount once', 'invoicing'), |
|
77 | 77 | 'value' => '1', |
78 | 78 | 'checked' => $discount->is_single_use(), |
79 | 79 | ), |
80 | 80 | true |
81 | 81 | ); |
82 | 82 | |
83 | - do_action( 'wpinv_discount_form_single_use', $discount ); |
|
83 | + do_action('wpinv_discount_form_single_use', $discount); |
|
84 | 84 | ?> |
85 | 85 | </div> |
86 | 86 | <div class="col-sm-12"> |
87 | 87 | <?php |
88 | - do_action( 'wpinv_discount_form_before_recurring', $discount ); |
|
88 | + do_action('wpinv_discount_form_before_recurring', $discount); |
|
89 | 89 | |
90 | 90 | aui()->input( |
91 | 91 | array( |
92 | 92 | 'id' => 'wpinv_discount_recurring', |
93 | 93 | 'name' => 'wpinv_discount_recurring', |
94 | 94 | 'type' => 'checkbox', |
95 | - 'label' => __( 'Apply this discount to all recurring payments for subscriptions', 'invoicing' ), |
|
95 | + 'label' => __('Apply this discount to all recurring payments for subscriptions', 'invoicing'), |
|
96 | 96 | 'value' => '1', |
97 | 97 | 'checked' => $discount->is_recurring(), |
98 | 98 | ), |
99 | 99 | true |
100 | 100 | ); |
101 | 101 | |
102 | - do_action( 'wpinv_discount_form_recurring', $discount ); |
|
102 | + do_action('wpinv_discount_form_recurring', $discount); |
|
103 | 103 | ?> |
104 | 104 | </div> |
105 | 105 | </div> |
106 | 106 | </div> |
107 | 107 | <div class="col-sm-1 pt-2 pl-0"> |
108 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter a discount code such as 10OFF.', 'invoicing' ); ?>"></span> |
|
108 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter a discount code such as 10OFF.', 'invoicing'); ?>"></span> |
|
109 | 109 | </div> |
110 | 110 | </div> |
111 | - <?php do_action( 'wpinv_discount_form_code', $discount ); ?> |
|
111 | + <?php do_action('wpinv_discount_form_code', $discount); ?> |
|
112 | 112 | |
113 | - <?php do_action( 'wpinv_discount_form_before_type', $discount ); ?> |
|
113 | + <?php do_action('wpinv_discount_form_before_type', $discount); ?> |
|
114 | 114 | <div class="form-group row"> |
115 | 115 | <label for="wpinv_discount_type" class="col-sm-3 col-form-label"> |
116 | - <?php esc_html_e( 'Discount Type', 'invoicing' ); ?> |
|
116 | + <?php esc_html_e('Discount Type', 'invoicing'); ?> |
|
117 | 117 | </label> |
118 | 118 | <div class="col-sm-8"> |
119 | 119 | <?php |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | array( |
122 | 122 | 'id' => 'wpinv_discount_type', |
123 | 123 | 'name' => 'wpinv_discount_type', |
124 | - 'label' => __( 'Discount Type', 'invoicing' ), |
|
125 | - 'placeholder' => __( 'Select Discount Type', 'invoicing' ), |
|
126 | - 'value' => $discount->get_type( 'edit' ), |
|
124 | + 'label' => __('Discount Type', 'invoicing'), |
|
125 | + 'placeholder' => __('Select Discount Type', 'invoicing'), |
|
126 | + 'value' => $discount->get_type('edit'), |
|
127 | 127 | 'select2' => true, |
128 | 128 | 'data-allow-clear' => 'false', |
129 | 129 | 'options' => wpinv_get_discount_types(), |
@@ -133,32 +133,32 @@ discard block |
||
133 | 133 | ?> |
134 | 134 | </div> |
135 | 135 | <div class="col-sm-1 pt-2 pl-0"> |
136 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Discount type.', 'invoicing' ); ?>"></span> |
|
136 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Discount type.', 'invoicing'); ?>"></span> |
|
137 | 137 | </div> |
138 | 138 | </div> |
139 | - <?php do_action( 'wpinv_discount_form_type', $discount ); ?> |
|
139 | + <?php do_action('wpinv_discount_form_type', $discount); ?> |
|
140 | 140 | |
141 | - <?php do_action( 'wpinv_discount_form_before_amount', $discount ); ?> |
|
142 | - <div class="form-group row <?php echo esc_attr( $discount->get_type( 'edit' ) ); ?>" id="wpinv_discount_amount_wrap"> |
|
141 | + <?php do_action('wpinv_discount_form_before_amount', $discount); ?> |
|
142 | + <div class="form-group row <?php echo esc_attr($discount->get_type('edit')); ?>" id="wpinv_discount_amount_wrap"> |
|
143 | 143 | <label for="wpinv_discount_amount" class="col-sm-3 col-form-label"> |
144 | - <?php esc_html_e( 'Discount Amount', 'invoicing' ); ?> |
|
144 | + <?php esc_html_e('Discount Amount', 'invoicing'); ?> |
|
145 | 145 | </label> |
146 | 146 | <div class="col-sm-8"> |
147 | 147 | <div class="input-group input-group-sm"> |
148 | - <?php if ( 'left' == $position ) : ?> |
|
148 | + <?php if ('left' == $position) : ?> |
|
149 | 149 | <div class="input-group-prepend left wpinv-if-flat"> |
150 | 150 | <span class="input-group-text"> |
151 | - <?php echo wp_kses_post( wpinv_currency_symbol() ); ?> |
|
151 | + <?php echo wp_kses_post(wpinv_currency_symbol()); ?> |
|
152 | 152 | </span> |
153 | 153 | </div> |
154 | 154 | <?php endif; ?> |
155 | 155 | |
156 | - <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr( $discount->get_amount( 'edit' ) ); ?>" placeholder="0" class="form-control"> |
|
156 | + <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr($discount->get_amount('edit')); ?>" placeholder="0" class="form-control"> |
|
157 | 157 | |
158 | - <?php if ( 'right' == $position ) : ?> |
|
158 | + <?php if ('right' == $position) : ?> |
|
159 | 159 | <div class="input-group-prepend left wpinv-if-flat"> |
160 | 160 | <span class="input-group-text"> |
161 | - <?php echo wp_kses_post( wpinv_currency_symbol() ); ?> |
|
161 | + <?php echo wp_kses_post(wpinv_currency_symbol()); ?> |
|
162 | 162 | </span> |
163 | 163 | </div> |
164 | 164 | <?php endif; ?> |
@@ -168,15 +168,15 @@ discard block |
||
168 | 168 | </div> |
169 | 169 | </div> |
170 | 170 | <div class="col-sm-1 pt-2 pl-0"> |
171 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?>"></span> |
|
171 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the discount value. Ex: 10', 'invoicing'); ?>"></span> |
|
172 | 172 | </div> |
173 | 173 | </div> |
174 | - <?php do_action( 'wpinv_discount_form_amount', $discount ); ?> |
|
174 | + <?php do_action('wpinv_discount_form_amount', $discount); ?> |
|
175 | 175 | |
176 | - <?php do_action( 'wpinv_discount_form_before_items', $discount ); ?> |
|
176 | + <?php do_action('wpinv_discount_form_before_items', $discount); ?> |
|
177 | 177 | <div class="form-group row"> |
178 | 178 | <label for="wpinv_discount_items" class="col-sm-3 col-form-label"> |
179 | - <?php esc_html_e( 'Items', 'invoicing' ); ?> |
|
179 | + <?php esc_html_e('Items', 'invoicing'); ?> |
|
180 | 180 | </label> |
181 | 181 | <div class="col-sm-8"> |
182 | 182 | <?php |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | array( |
185 | 185 | 'id' => 'wpinv_discount_items', |
186 | 186 | 'name' => 'wpinv_discount_items[]', |
187 | - 'label' => __( 'Items', 'invoicing' ), |
|
188 | - 'placeholder' => __( 'Select Items', 'invoicing' ), |
|
189 | - 'value' => $discount->get_items( 'edit' ), |
|
187 | + 'label' => __('Items', 'invoicing'), |
|
188 | + 'placeholder' => __('Select Items', 'invoicing'), |
|
189 | + 'value' => $discount->get_items('edit'), |
|
190 | 190 | 'select2' => true, |
191 | 191 | 'multiple' => true, |
192 | 192 | 'data-allow-clear' => 'false', |
@@ -197,15 +197,15 @@ discard block |
||
197 | 197 | ?> |
198 | 198 | </div> |
199 | 199 | <div class="col-sm-1 pt-2 pl-0"> |
200 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing' ); ?>"></span> |
|
200 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing'); ?>"></span> |
|
201 | 201 | </div> |
202 | 202 | </div> |
203 | - <?php do_action( 'wpinv_discount_form_items', $discount ); ?> |
|
203 | + <?php do_action('wpinv_discount_form_items', $discount); ?> |
|
204 | 204 | |
205 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $discount ); ?> |
|
205 | + <?php do_action('wpinv_discount_form_before_excluded_items', $discount); ?> |
|
206 | 206 | <div class="form-group row"> |
207 | 207 | <label for="wpinv_discount_excluded_items" class="col-sm-3 col-form-label"> |
208 | - <?php esc_html_e( 'Excluded Items', 'invoicing' ); ?> |
|
208 | + <?php esc_html_e('Excluded Items', 'invoicing'); ?> |
|
209 | 209 | </label> |
210 | 210 | <div class="col-sm-8"> |
211 | 211 | <?php |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | array( |
214 | 214 | 'id' => 'wpinv_discount_excluded_items', |
215 | 215 | 'name' => 'wpinv_discount_excluded_items[]', |
216 | - 'label' => __( 'Excluded Items', 'invoicing' ), |
|
217 | - 'placeholder' => __( 'Select Items', 'invoicing' ), |
|
218 | - 'value' => $discount->get_excluded_items( 'edit' ), |
|
216 | + 'label' => __('Excluded Items', 'invoicing'), |
|
217 | + 'placeholder' => __('Select Items', 'invoicing'), |
|
218 | + 'value' => $discount->get_excluded_items('edit'), |
|
219 | 219 | 'select2' => true, |
220 | 220 | 'multiple' => true, |
221 | 221 | 'data-allow-clear' => 'false', |
@@ -226,15 +226,15 @@ discard block |
||
226 | 226 | ?> |
227 | 227 | </div> |
228 | 228 | <div class="col-sm-1 pt-2 pl-0"> |
229 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are not allowed to use this discount.', 'invoicing' ); ?>"></span> |
|
229 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are not allowed to use this discount.', 'invoicing'); ?>"></span> |
|
230 | 230 | </div> |
231 | 231 | </div> |
232 | - <?php do_action( 'wpinv_discount_form_excluded_items', $discount ); ?> |
|
232 | + <?php do_action('wpinv_discount_form_excluded_items', $discount); ?> |
|
233 | 233 | |
234 | - <?php do_action( 'wpinv_discount_form_before_required_items', $discount ); ?> |
|
234 | + <?php do_action('wpinv_discount_form_before_required_items', $discount); ?> |
|
235 | 235 | <div class="form-group row"> |
236 | 236 | <label for="wpinv_discount_required_items" class="col-sm-3 col-form-label"> |
237 | - <?php esc_html_e( 'Required Items', 'invoicing' ); ?> |
|
237 | + <?php esc_html_e('Required Items', 'invoicing'); ?> |
|
238 | 238 | </label> |
239 | 239 | <div class="col-sm-8"> |
240 | 240 | <?php |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | array( |
243 | 243 | 'id' => 'wpinv_discount_required_items', |
244 | 244 | 'name' => 'wpinv_discount_required_items[]', |
245 | - 'label' => __( 'Required Items', 'invoicing' ), |
|
246 | - 'placeholder' => __( 'Select Items', 'invoicing' ), |
|
247 | - 'value' => $discount->get_required_items( 'edit' ), |
|
245 | + 'label' => __('Required Items', 'invoicing'), |
|
246 | + 'placeholder' => __('Select Items', 'invoicing'), |
|
247 | + 'value' => $discount->get_required_items('edit'), |
|
248 | 248 | 'select2' => true, |
249 | 249 | 'multiple' => true, |
250 | 250 | 'data-allow-clear' => 'false', |
@@ -255,15 +255,15 @@ discard block |
||
255 | 255 | ?> |
256 | 256 | </div> |
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( 'Select all the items that are required to be in the cart before using this discount.', 'invoicing' ); ?>"></span> |
|
258 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are required to be in the cart before using this discount.', 'invoicing'); ?>"></span> |
|
259 | 259 | </div> |
260 | 260 | </div> |
261 | - <?php do_action( 'wpinv_discount_form_required_items', $discount ); ?> |
|
261 | + <?php do_action('wpinv_discount_form_required_items', $discount); ?> |
|
262 | 262 | |
263 | - <?php do_action( 'wpinv_discount_form_before_start', $discount ); ?> |
|
263 | + <?php do_action('wpinv_discount_form_before_start', $discount); ?> |
|
264 | 264 | <div class="form-group row"> |
265 | 265 | <label for="wpinv_discount_start" class="col-sm-3 col-form-label"> |
266 | - <?php esc_html_e( 'Start Date', 'invoicing' ); ?> |
|
266 | + <?php esc_html_e('Start Date', 'invoicing'); ?> |
|
267 | 267 | </label> |
268 | 268 | <div class="col-sm-8"> |
269 | 269 | <?php |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | 'type' => 'datepicker', |
273 | 273 | 'id' => 'wpinv_discount_start', |
274 | 274 | 'name' => 'wpinv_discount_start', |
275 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
275 | + 'label' => __('Start Date', 'invoicing'), |
|
276 | 276 | 'placeholder' => 'YYYY-MM-DD 00:00', |
277 | 277 | 'class' => 'form-control-sm', |
278 | - 'value' => $discount->get_start_date( 'edit' ), |
|
278 | + 'value' => $discount->get_start_date('edit'), |
|
279 | 279 | 'extra_attributes' => array( |
280 | 280 | 'data-enable-time' => 'true', |
281 | 281 | 'data-time_24hr' => 'true', |
@@ -287,15 +287,15 @@ discard block |
||
287 | 287 | ?> |
288 | 288 | </div> |
289 | 289 | <div class="col-sm-1 pt-2 pl-0"> |
290 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?>"></span> |
|
290 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?>"></span> |
|
291 | 291 | </div> |
292 | 292 | </div> |
293 | - <?php do_action( 'wpinv_discount_form_start', $discount ); ?> |
|
293 | + <?php do_action('wpinv_discount_form_start', $discount); ?> |
|
294 | 294 | |
295 | - <?php do_action( 'wpinv_discount_form_before_expiration', $discount ); ?> |
|
295 | + <?php do_action('wpinv_discount_form_before_expiration', $discount); ?> |
|
296 | 296 | <div class="form-group row"> |
297 | 297 | <label for="wpinv_discount_expiration" class="col-sm-3 col-form-label"> |
298 | - <?php esc_html_e( 'Expiration Date', 'invoicing' ); ?> |
|
298 | + <?php esc_html_e('Expiration Date', 'invoicing'); ?> |
|
299 | 299 | </label> |
300 | 300 | <div class="col-sm-8"> |
301 | 301 | <?php |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | 'type' => 'datepicker', |
305 | 305 | 'id' => 'wpinv_discount_expiration', |
306 | 306 | 'name' => 'wpinv_discount_expiration', |
307 | - 'label' => __( 'Expiration Date', 'invoicing' ), |
|
307 | + 'label' => __('Expiration Date', 'invoicing'), |
|
308 | 308 | 'placeholder' => 'YYYY-MM-DD 00:00', |
309 | 309 | 'class' => 'form-control-sm', |
310 | - 'value' => $discount->get_end_date( 'edit' ), |
|
310 | + 'value' => $discount->get_end_date('edit'), |
|
311 | 311 | 'extra_attributes' => array( |
312 | 312 | 'data-enable-time' => 'true', |
313 | 313 | 'data-time_24hr' => 'true', |
@@ -321,86 +321,86 @@ discard block |
||
321 | 321 | ?> |
322 | 322 | </div> |
323 | 323 | <div class="col-sm-1 pt-2 pl-0"> |
324 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the date after which the discount will expire.', 'invoicing' ); ?>"></span> |
|
324 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the date after which the discount will expire.', 'invoicing'); ?>"></span> |
|
325 | 325 | </div> |
326 | 326 | </div> |
327 | - <?php do_action( 'wpinv_discount_form_expiration', $discount ); ?> |
|
327 | + <?php do_action('wpinv_discount_form_expiration', $discount); ?> |
|
328 | 328 | |
329 | - <?php do_action( 'wpinv_discount_form_before_min_total', $discount ); ?> |
|
329 | + <?php do_action('wpinv_discount_form_before_min_total', $discount); ?> |
|
330 | 330 | <div class="form-group row"> |
331 | 331 | <label for="wpinv_discount_min_total" class="col-sm-3 col-form-label"> |
332 | - <?php esc_html_e( 'Minimum Amount', 'invoicing' ); ?> |
|
332 | + <?php esc_html_e('Minimum Amount', 'invoicing'); ?> |
|
333 | 333 | </label> |
334 | 334 | <div class="col-sm-8"> |
335 | 335 | <div class="input-group input-group-sm"> |
336 | - <?php if ( 'left' == $position ) : ?> |
|
336 | + <?php if ('left' == $position) : ?> |
|
337 | 337 | <div class="input-group-prepend"> |
338 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
338 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
339 | 339 | </div> |
340 | 340 | <?php endif; ?> |
341 | 341 | |
342 | - <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr( $discount->get_minimum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No minimum', 'invoicing' ); ?>" class="form-control"> |
|
342 | + <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr($discount->get_minimum_total('edit')); ?>" placeholder="<?php esc_attr_e('No minimum', 'invoicing'); ?>" class="form-control"> |
|
343 | 343 | |
344 | - <?php if ( 'left' != $position ) : ?> |
|
344 | + <?php if ('left' != $position) : ?> |
|
345 | 345 | <div class="input-group-append"> |
346 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
346 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
347 | 347 | </div> |
348 | 348 | <?php endif; ?> |
349 | 349 | </div> |
350 | 350 | </div> |
351 | 351 | <div class="col-sm-1 pt-2 pl-0"> |
352 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing' ); ?>"></span> |
|
352 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing'); ?>"></span> |
|
353 | 353 | </div> |
354 | 354 | </div> |
355 | - <?php do_action( 'wpinv_discount_form_min_total', $discount ); ?> |
|
355 | + <?php do_action('wpinv_discount_form_min_total', $discount); ?> |
|
356 | 356 | |
357 | - <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?> |
|
357 | + <?php do_action('wpinv_discount_form_before_max_total', $discount); ?> |
|
358 | 358 | <div class="form-group row"> |
359 | 359 | <label for="wpinv_discount_max_total" class="col-sm-3 col-form-label"> |
360 | - <?php esc_html_e( 'Maximum Amount', 'invoicing' ); ?> |
|
360 | + <?php esc_html_e('Maximum Amount', 'invoicing'); ?> |
|
361 | 361 | </label> |
362 | 362 | <div class="col-sm-8"> |
363 | 363 | <div class="input-group input-group-sm"> |
364 | - <?php if ( 'left' == $position ) : ?> |
|
364 | + <?php if ('left' == $position) : ?> |
|
365 | 365 | <div class="input-group-prepend"> |
366 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
366 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
367 | 367 | </div> |
368 | 368 | <?php endif; ?> |
369 | 369 | |
370 | - <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr( $discount->get_maximum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No maximum', 'invoicing' ); ?>" class="form-control"> |
|
370 | + <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr($discount->get_maximum_total('edit')); ?>" placeholder="<?php esc_attr_e('No maximum', 'invoicing'); ?>" class="form-control"> |
|
371 | 371 | |
372 | - <?php if ( 'left' != $position ) : ?> |
|
372 | + <?php if ('left' != $position) : ?> |
|
373 | 373 | <div class="input-group-append"> |
374 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
374 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
375 | 375 | </div> |
376 | 376 | <?php endif; ?> |
377 | 377 | </div> |
378 | 378 | </div> |
379 | 379 | <div class="col-sm-1 pt-2 pl-0"> |
380 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing' ); ?>"></span> |
|
380 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing'); ?>"></span> |
|
381 | 381 | </div> |
382 | 382 | </div> |
383 | - <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?> |
|
383 | + <?php do_action('wpinv_discount_form_before_max_total', $discount); ?> |
|
384 | 384 | |
385 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $discount ); ?> |
|
385 | + <?php do_action('wpinv_discount_form_before_max_uses', $discount); ?> |
|
386 | 386 | <div class="form-group row"> |
387 | 387 | <label for="wpinv_discount_max_uses" class="col-sm-3 col-form-label"> |
388 | - <?php esc_html_e( 'Maximum Uses', 'invoicing' ); ?> |
|
388 | + <?php esc_html_e('Maximum Uses', 'invoicing'); ?> |
|
389 | 389 | </label> |
390 | 390 | <div class="col-sm-8"> |
391 | - <input type="text" value="<?php echo esc_attr( $discount->get_max_uses( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'invoicing' ); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" /> |
|
391 | + <input type="text" value="<?php echo esc_attr($discount->get_max_uses('edit')); ?>" placeholder="<?php esc_attr_e('Unlimited', 'invoicing'); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" /> |
|
392 | 392 | </div> |
393 | 393 | <div class="col-sm-1 pt-2 pl-0"> |
394 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum number of times that this discount code can be used.', 'invoicing' ); ?>"></span> |
|
394 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum number of times that this discount code can be used.', 'invoicing'); ?>"></span> |
|
395 | 395 | </div> |
396 | 396 | </div> |
397 | - <?php do_action( 'wpinv_discount_form_max_uses', $discount ); ?> |
|
397 | + <?php do_action('wpinv_discount_form_max_uses', $discount); ?> |
|
398 | 398 | |
399 | - <?php do_action( 'wpinv_discount_form_last', $discount ); ?> |
|
399 | + <?php do_action('wpinv_discount_form_last', $discount); ?> |
|
400 | 400 | |
401 | 401 | </div> |
402 | 402 | <?php |
403 | - do_action( 'wpinv_discount_form_bottom', $post ); |
|
403 | + do_action('wpinv_discount_form_bottom', $post); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
@@ -408,31 +408,31 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @param int $post_id |
410 | 410 | */ |
411 | - public static function save( $post_id ) { |
|
411 | + public static function save($post_id) { |
|
412 | 412 | |
413 | 413 | // Prepare the discount. |
414 | - $discount = new WPInv_Discount( $post_id ); |
|
414 | + $discount = new WPInv_Discount($post_id); |
|
415 | 415 | |
416 | 416 | // Load new data. |
417 | 417 | $discount->set_props( |
418 | 418 | array( |
419 | - 'code' => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null, |
|
420 | - 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null, |
|
421 | - 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, |
|
422 | - 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, |
|
423 | - 'is_single_use' => ! empty( $_POST['wpinv_discount_single_use'] ), |
|
424 | - 'type' => isset( $_POST['wpinv_discount_type'] ) ? wpinv_clean( $_POST['wpinv_discount_type'] ) : null, |
|
425 | - 'is_recurring' => ! empty( $_POST['wpinv_discount_recurring'] ), |
|
426 | - 'items' => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(), |
|
427 | - 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(), |
|
428 | - 'required_items' => isset( $_POST['wpinv_discount_required_items'] ) ? wpinv_clean( $_POST['wpinv_discount_required_items'] ) : array(), |
|
429 | - 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null, |
|
430 | - 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null, |
|
431 | - 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null, |
|
419 | + 'code' => isset($_POST['wpinv_discount_code']) ? wpinv_clean($_POST['wpinv_discount_code']) : null, |
|
420 | + 'amount' => isset($_POST['wpinv_discount_amount']) ? floatval($_POST['wpinv_discount_amount']) : null, |
|
421 | + 'start' => isset($_POST['wpinv_discount_start']) ? wpinv_clean($_POST['wpinv_discount_start']) : null, |
|
422 | + 'expiration' => isset($_POST['wpinv_discount_expiration']) ? wpinv_clean($_POST['wpinv_discount_expiration']) : null, |
|
423 | + 'is_single_use' => !empty($_POST['wpinv_discount_single_use']), |
|
424 | + 'type' => isset($_POST['wpinv_discount_type']) ? wpinv_clean($_POST['wpinv_discount_type']) : null, |
|
425 | + 'is_recurring' => !empty($_POST['wpinv_discount_recurring']), |
|
426 | + 'items' => isset($_POST['wpinv_discount_items']) ? wpinv_clean($_POST['wpinv_discount_items']) : array(), |
|
427 | + 'excluded_items' => isset($_POST['wpinv_discount_excluded_items']) ? wpinv_clean($_POST['wpinv_discount_excluded_items']) : array(), |
|
428 | + 'required_items' => isset($_POST['wpinv_discount_required_items']) ? wpinv_clean($_POST['wpinv_discount_required_items']) : array(), |
|
429 | + 'max_uses' => isset($_POST['wpinv_discount_max_uses']) ? intval($_POST['wpinv_discount_max_uses']) : null, |
|
430 | + 'min_total' => isset($_POST['wpinv_discount_min_total']) ? floatval($_POST['wpinv_discount_min_total']) : null, |
|
431 | + 'max_total' => isset($_POST['wpinv_discount_max_total']) ? floatval($_POST['wpinv_discount_max_total']) : null, |
|
432 | 432 | ) |
433 | 433 | ); |
434 | 434 | |
435 | 435 | $discount->save(); |
436 | - do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); |
|
436 | + do_action('getpaid_discount_metabox_save', $post_id, $discount); |
|
437 | 437 | } |
438 | 438 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -16,82 +16,82 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class GetPaid_Meta_Box_Invoice_Items { |
18 | 18 | |
19 | - public static function get_columns( $invoice ) { |
|
19 | + public static function get_columns($invoice) { |
|
20 | 20 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
21 | 21 | $columns = array( |
22 | - 'id' => __( 'ID', 'invoicing' ), |
|
23 | - 'title' => __( 'Item', 'invoicing' ), |
|
22 | + 'id' => __('ID', 'invoicing'), |
|
23 | + 'title' => __('Item', 'invoicing'), |
|
24 | 24 | 'price' => sprintf( |
25 | 25 | '<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span> |
26 | 26 | <span class="getpaid-hide-if-hours hide-if-amount">%s</span> |
27 | 27 | <span class="getpaid-hide-if-quantity hide-if-amount">%s</span>', |
28 | - __( 'Amount', 'invoicing' ), |
|
29 | - __( 'Price', 'invoicing' ), |
|
30 | - __( 'Rate', 'invoicing' ) |
|
28 | + __('Amount', 'invoicing'), |
|
29 | + __('Price', 'invoicing'), |
|
30 | + __('Rate', 'invoicing') |
|
31 | 31 | ), |
32 | 32 | 'qty' => sprintf( |
33 | 33 | '<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>', |
34 | - __( 'Quantity', 'invoicing' ), |
|
35 | - __( 'Hours', 'invoicing' ) |
|
34 | + __('Quantity', 'invoicing'), |
|
35 | + __('Hours', 'invoicing') |
|
36 | 36 | ), |
37 | - 'total' => __( 'Total', 'invoicing' ), |
|
38 | - 'tax' => __( 'Tax (%)', 'invoicing' ), |
|
37 | + 'total' => __('Total', 'invoicing'), |
|
38 | + 'tax' => __('Tax (%)', 'invoicing'), |
|
39 | 39 | 'action' => '', |
40 | 40 | ); |
41 | 41 | |
42 | - if ( ! $use_taxes ) { |
|
43 | - unset( $columns['tax'] ); |
|
42 | + if (!$use_taxes) { |
|
43 | + unset($columns['tax']); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | return $columns; |
47 | 47 | } |
48 | 48 | |
49 | - public static function output( $post, $invoice = false ) { |
|
49 | + public static function output($post, $invoice = false) { |
|
50 | 50 | |
51 | - if ( apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) { |
|
52 | - return self::output2( $post ); |
|
51 | + if (apply_filters('getpaid_use_new_invoice_items_metabox', false)) { |
|
52 | + return self::output2($post); |
|
53 | 53 | } |
54 | 54 | |
55 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
56 | - $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id ); |
|
55 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
56 | + $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id); |
|
57 | 57 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
58 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
59 | - $columns = self::get_columns( $invoice ); |
|
60 | - $cols = count( $columns ); |
|
58 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
59 | + $columns = self::get_columns($invoice); |
|
60 | + $cols = count($columns); |
|
61 | 61 | $class = ''; |
62 | 62 | |
63 | - unset( $item_types['adv'] ); |
|
64 | - unset( $item_types['package'] ); |
|
63 | + unset($item_types['adv']); |
|
64 | + unset($item_types['package']); |
|
65 | 65 | |
66 | - if ( $invoice->is_paid() ) { |
|
66 | + if ($invoice->is_paid()) { |
|
67 | 67 | $class .= ' wpinv-paid'; |
68 | 68 | } |
69 | 69 | |
70 | - if ( $invoice->is_refunded() ) { |
|
70 | + if ($invoice->is_refunded()) { |
|
71 | 71 | $class .= ' wpinv-refunded'; |
72 | 72 | } |
73 | 73 | |
74 | - if ( $invoice->is_recurring() ) { |
|
74 | + if ($invoice->is_recurring()) { |
|
75 | 75 | $class .= ' wpi-recurring'; |
76 | 76 | } |
77 | 77 | |
78 | 78 | ?> |
79 | 79 | |
80 | - <div class="wpinv-items-wrap<?php echo esc_attr( $class ); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>"> |
|
80 | + <div class="wpinv-items-wrap<?php echo esc_attr($class); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>"> |
|
81 | 81 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
82 | 82 | |
83 | 83 | <thead> |
84 | 84 | <tr> |
85 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
86 | - <th class="<?php echo esc_attr( $key ); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post( $label ); ?></th> |
|
85 | + <?php foreach ($columns as $key => $label) : ?> |
|
86 | + <th class="<?php echo esc_attr($key); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post($label); ?></th> |
|
87 | 87 | <?php endforeach; ?> |
88 | 88 | </tr> |
89 | 89 | </thead> |
90 | 90 | |
91 | 91 | <tbody class="wpinv-line-items"> |
92 | 92 | <?php |
93 | - foreach ( $invoice->get_items() as $int => $item ) { |
|
94 | - self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' ); |
|
93 | + foreach ($invoice->get_items() as $int => $item) { |
|
94 | + self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd'); |
|
95 | 95 | } |
96 | 96 | ?> |
97 | 97 | </tbody> |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | <div class="wp-clearfix"> |
109 | 109 | <label class="wpi-item-name"> |
110 | 110 | <span class="input-text-wrap"> |
111 | - <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' );?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
111 | + <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
112 | 112 | </span> |
113 | 113 | </label> |
114 | 114 | </div> |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | <div class="wp-clearfix"> |
117 | 117 | <label class="wpi-item-price"> |
118 | 118 | <span class="input-text-wrap"> |
119 | - <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' );?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
120 | - × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' );?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
119 | + <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
120 | + × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
121 | 121 | </span> |
122 | 122 | </label> |
123 | 123 | </div> |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | <div class="wp-clearfix"> |
126 | 126 | <label class="wpi-item-name"> |
127 | 127 | <span class="input-text-wrap"> |
128 | - <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' );?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
128 | + <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
129 | 129 | </span> |
130 | 130 | </label> |
131 | 131 | </div> |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | <div class="wp-clearfix"> |
134 | 134 | <label class="wpi-item-type"> |
135 | 135 | <span class="input-text-wrap"> |
136 | - <?php wpinv_html_select( array( |
|
136 | + <?php wpinv_html_select(array( |
|
137 | 137 | 'options' => $item_types, |
138 | 138 | 'name' => '_wpinv_quick[type]', |
139 | 139 | 'id' => '_wpinv_quick_type', |
@@ -141,19 +141,19 @@ discard block |
||
141 | 141 | 'show_option_all' => false, |
142 | 142 | 'show_option_none' => false, |
143 | 143 | 'class' => 'gdmbx2-text-medium wpinv-quick-type', |
144 | - ) ); ?> |
|
144 | + )); ?> |
|
145 | 145 | </span> |
146 | 146 | </label> |
147 | 147 | </div> |
148 | 148 | |
149 | - <?php if ( $use_taxes ) : ?> |
|
149 | + <?php if ($use_taxes) : ?> |
|
150 | 150 | <div class="wp-clearfix"> |
151 | 151 | <label class="wpi-vat-rule"> |
152 | 152 | <span class="input-text-wrap"> |
153 | 153 | <?php |
154 | - wpinv_html_select( array( |
|
154 | + wpinv_html_select(array( |
|
155 | 155 | 'options' => array_merge( |
156 | - array( '' => __( 'Select VAT Rule', 'invoicing' ) ), |
|
156 | + array('' => __('Select VAT Rule', 'invoicing')), |
|
157 | 157 | getpaid_get_tax_rules() |
158 | 158 | ), |
159 | 159 | 'name' => '_wpinv_quick[vat_rule]', |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | 'show_option_all' => false, |
162 | 162 | 'show_option_none' => false, |
163 | 163 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule', |
164 | - ) ); |
|
164 | + )); |
|
165 | 165 | ?> |
166 | 166 | </span> |
167 | 167 | </label> |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | <label class="wpi-vat-class"> |
171 | 171 | <span class="input-text-wrap"> |
172 | 172 | <?php |
173 | - wpinv_html_select( array( |
|
173 | + wpinv_html_select(array( |
|
174 | 174 | 'options' => array_merge( |
175 | - array( '' => __( 'Select VAT Class', 'invoicing' ) ), |
|
175 | + array('' => __('Select VAT Class', 'invoicing')), |
|
176 | 176 | getpaid_get_tax_classes() |
177 | 177 | ), |
178 | 178 | 'name' => '_wpinv_quick[vat_class]', |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | 'show_option_all' => false, |
181 | 181 | 'show_option_none' => false, |
182 | 182 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class', |
183 | - ) ); |
|
183 | + )); |
|
184 | 184 | ?> |
185 | 185 | </span> |
186 | 186 | </label> |
@@ -201,29 +201,29 @@ discard block |
||
201 | 201 | </td> |
202 | 202 | </tr> |
203 | 203 | <tr class="totals"> |
204 | - <td colspan="<?php echo ( (int) $cols - 4 ); ?>"></td> |
|
204 | + <td colspan="<?php echo ((int) $cols - 4); ?>"></td> |
|
205 | 205 | <td colspan="4"> |
206 | 206 | <table cellspacing="0" cellpadding="0"> |
207 | 207 | <tr class="subtotal"> |
208 | - <td class="name"><?php esc_html_e( 'Sub Total:', 'invoicing' );?></td> |
|
209 | - <td class="total"><?php wpinv_the_price( $invoice->get_subtotal(), $invoice->get_currency() );?></td> |
|
208 | + <td class="name"><?php esc_html_e('Sub Total:', 'invoicing'); ?></td> |
|
209 | + <td class="total"><?php wpinv_the_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td> |
|
210 | 210 | <td class="action"></td> |
211 | 211 | </tr> |
212 | 212 | <tr class="discount"> |
213 | - <td class="name"><?php esc_html_e( 'Discount:', 'invoicing' ) ; ?></td> |
|
214 | - <td class="total"><?php wpinv_the_price( $invoice->get_total_discount(), $invoice->get_currency() );?></td> |
|
213 | + <td class="name"><?php esc_html_e('Discount:', 'invoicing'); ?></td> |
|
214 | + <td class="total"><?php wpinv_the_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td> |
|
215 | 215 | <td class="action"></td> |
216 | 216 | </tr> |
217 | - <?php if ( $use_taxes ) : ?> |
|
217 | + <?php if ($use_taxes) : ?> |
|
218 | 218 | <tr class="tax"> |
219 | - <td class="name"><?php esc_html_e( 'Tax:', 'invoicing' );?></td> |
|
220 | - <td class="total"><?php wpinv_the_price( $invoice->get_total_tax(), $invoice->get_currency() );?></td> |
|
219 | + <td class="name"><?php esc_html_e('Tax:', 'invoicing'); ?></td> |
|
220 | + <td class="total"><?php wpinv_the_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td> |
|
221 | 221 | <td class="action"></td> |
222 | 222 | </tr> |
223 | 223 | <?php endif; ?> |
224 | 224 | <tr class="total"> |
225 | - <td class="name"><?php esc_html_e( 'Total:', 'invoicing' );?></td> |
|
226 | - <td class="total"><?php wpinv_the_price( $invoice->get_total(), $invoice->get_currency() );?></td> |
|
225 | + <td class="name"><?php esc_html_e('Total:', 'invoicing'); ?></td> |
|
226 | + <td class="total"><?php wpinv_the_price($invoice->get_total(), $invoice->get_currency()); ?></td> |
|
227 | 227 | <td class="action"></td> |
228 | 228 | </tr> |
229 | 229 | </table> |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | </table> |
235 | 235 | <div class="wpinv-actions"> |
236 | 236 | <?php |
237 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
237 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
238 | 238 | wpinv_item_dropdown( |
239 | 239 | array( |
240 | 240 | 'name' => 'wpinv_invoice_item', |
@@ -244,61 +244,61 @@ discard block |
||
244 | 244 | ) |
245 | 245 | ); |
246 | 246 | |
247 | - echo " " . '<button class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), $invoice->get_label() ) . '</button>'; |
|
248 | - echo " " . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>'; |
|
249 | - echo " " . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>'; |
|
247 | + echo " " . '<button class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), $invoice->get_label()) . '</button>'; |
|
248 | + echo " " . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>'; |
|
249 | + echo " " . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>'; |
|
250 | 250 | |
251 | 251 | } |
252 | 252 | ?> |
253 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
253 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
254 | 254 | </div> |
255 | 255 | </div> |
256 | 256 | <?php |
257 | 257 | } |
258 | 258 | |
259 | - public static function output_row( $columns, $item, $invoice, $class='even' ) { |
|
259 | + public static function output_row($columns, $item, $invoice, $class = 'even') { |
|
260 | 260 | |
261 | 261 | ?> |
262 | - <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>"> |
|
263 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
264 | - <td class="<?php echo esc_attr( $column ); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>"> |
|
262 | + <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>"> |
|
263 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
264 | + <td class="<?php echo esc_attr($column); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>"> |
|
265 | 265 | <?php |
266 | - switch ( $column ) { |
|
266 | + switch ($column) { |
|
267 | 267 | case 'id': |
268 | 268 | echo (int) $item->get_id(); |
269 | 269 | break; |
270 | 270 | case 'title': |
271 | 271 | printf( |
272 | 272 | '<a href="%s" target="_blank">%s</a>', |
273 | - get_edit_post_link( $item->get_id() ), |
|
274 | - esc_html( $item->get_raw_name() ) |
|
273 | + get_edit_post_link($item->get_id()), |
|
274 | + esc_html($item->get_raw_name()) |
|
275 | 275 | ); |
276 | 276 | |
277 | - $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
278 | - if ( $summary !== '' ) { |
|
277 | + $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice); |
|
278 | + if ($summary !== '') { |
|
279 | 279 | printf( |
280 | 280 | '<span class="meta">%s</span>', |
281 | - wp_kses_post( wpautop( $summary ) ) |
|
281 | + wp_kses_post(wpautop($summary)) |
|
282 | 282 | ); |
283 | 283 | } |
284 | 284 | |
285 | 285 | printf( |
286 | 286 | '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />', |
287 | - esc_attr( $item->get_raw_name() ), |
|
287 | + esc_attr($item->get_raw_name()), |
|
288 | 288 | (int) $item->get_id() |
289 | 289 | ); |
290 | 290 | |
291 | 291 | printf( |
292 | 292 | '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>', |
293 | 293 | (int) $item->get_id(), |
294 | - esc_attr( $item->get_description() ) |
|
294 | + esc_attr($item->get_description()) |
|
295 | 295 | ); |
296 | 296 | |
297 | 297 | break; |
298 | 298 | case 'price': |
299 | 299 | printf( |
300 | 300 | '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />', |
301 | - esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ), |
|
301 | + esc_attr(getpaid_unstandardize_amount($item->get_price())), |
|
302 | 302 | (int) $item->get_id() |
303 | 303 | ); |
304 | 304 | |
@@ -306,26 +306,26 @@ discard block |
||
306 | 306 | case 'qty': |
307 | 307 | printf( |
308 | 308 | '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />', |
309 | - floatval( $item->get_quantity() ), |
|
309 | + floatval($item->get_quantity()), |
|
310 | 310 | (int) $item->get_id() |
311 | 311 | ); |
312 | 312 | |
313 | 313 | break; |
314 | 314 | case 'total': |
315 | - wpinv_the_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
315 | + wpinv_the_price($item->get_sub_total(), $invoice->get_currency()); |
|
316 | 316 | |
317 | 317 | break; |
318 | 318 | case 'tax': |
319 | - echo floatval( wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
319 | + echo floatval(wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2)) . '%'; |
|
320 | 320 | |
321 | 321 | break; |
322 | 322 | case 'action': |
323 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
323 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
324 | 324 | echo '<i class="fa fa-trash wpinv-item-remove"></i>'; |
325 | 325 | } |
326 | 326 | break; |
327 | 327 | } |
328 | - do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice ); |
|
328 | + do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice); |
|
329 | 329 | ?> |
330 | 330 | </td> |
331 | 331 | <?php endforeach; ?> |
@@ -338,10 +338,10 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @param WP_Post $post |
340 | 340 | */ |
341 | - public static function output2( $post ) { |
|
341 | + public static function output2($post) { |
|
342 | 342 | |
343 | 343 | // Prepare the invoice. |
344 | - $invoice = new WPInv_Invoice( $post ); |
|
344 | + $invoice = new WPInv_Invoice($post); |
|
345 | 345 | |
346 | 346 | // Invoice items. |
347 | 347 | $items = $invoice->get_items(); |
@@ -349,28 +349,28 @@ discard block |
||
349 | 349 | $totals = array( |
350 | 350 | |
351 | 351 | 'subtotal' => array( |
352 | - 'label' => __( 'Items Subtotal', 'invoicing' ), |
|
353 | - 'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
352 | + 'label' => __('Items Subtotal', 'invoicing'), |
|
353 | + 'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
354 | 354 | ), |
355 | 355 | |
356 | 356 | 'discount' => array( |
357 | - 'label' => __( 'Total Discount', 'invoicing' ), |
|
358 | - 'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
357 | + 'label' => __('Total Discount', 'invoicing'), |
|
358 | + 'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
359 | 359 | ), |
360 | 360 | |
361 | 361 | 'tax' => array( |
362 | - 'label' => __( 'Total Tax', 'invoicing' ), |
|
363 | - 'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
362 | + 'label' => __('Total Tax', 'invoicing'), |
|
363 | + 'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
364 | 364 | ), |
365 | 365 | |
366 | 366 | 'total' => array( |
367 | - 'label' => __( 'Invoice Total', 'invoicing' ), |
|
368 | - 'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
|
367 | + 'label' => __('Invoice Total', 'invoicing'), |
|
368 | + 'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()), |
|
369 | 369 | ) |
370 | 370 | ); |
371 | 371 | |
372 | - if ( ! wpinv_use_taxes() ) { |
|
373 | - unset( $totals['tax'] ); |
|
372 | + if (!wpinv_use_taxes()) { |
|
373 | + unset($totals['tax']); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | $item_args = array( |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | 'orderby' => 'title', |
379 | 379 | 'order' => 'ASC', |
380 | 380 | 'posts_per_page' => -1, |
381 | - 'post_status' => array( 'publish' ), |
|
381 | + 'post_status' => array('publish'), |
|
382 | 382 | 'meta_query' => array( |
383 | 383 | array( |
384 | 384 | 'key' => '_wpinv_type', |
@@ -402,10 +402,10 @@ discard block |
||
402 | 402 | } |
403 | 403 | </style> |
404 | 404 | |
405 | - <div class="bsui getpaid-invoice-items-inner <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
|
405 | + <div class="bsui getpaid-invoice-items-inner <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
|
406 | 406 | |
407 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
408 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
407 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
408 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
409 | 409 | |
410 | 410 | <div class="row"> |
411 | 411 | <div class="col-12 col-sm-6"> |
@@ -414,15 +414,15 @@ discard block |
||
414 | 414 | array( |
415 | 415 | 'id' => 'wpinv_template', |
416 | 416 | 'name' => 'wpinv_template', |
417 | - 'label' => __( 'Template', 'invoicing' ), |
|
417 | + 'label' => __('Template', 'invoicing'), |
|
418 | 418 | 'label_type' => 'vertical', |
419 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
419 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
420 | 420 | 'class' => 'form-control-sm', |
421 | - 'value' => $invoice->get_template( 'edit' ), |
|
421 | + 'value' => $invoice->get_template('edit'), |
|
422 | 422 | 'options' => array( |
423 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
424 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
425 | - 'amount' => __( 'Amount Only', 'invoicing' ), |
|
423 | + 'quantity' => __('Quantity', 'invoicing'), |
|
424 | + 'hours' => __('Hours', 'invoicing'), |
|
425 | + 'amount' => __('Amount Only', 'invoicing'), |
|
426 | 426 | ), |
427 | 427 | 'data-allow-clear' => 'false', |
428 | 428 | 'select2' => true, |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | array( |
440 | 440 | 'id' => 'wpinv_currency', |
441 | 441 | 'name' => 'wpinv_currency', |
442 | - 'label' => __( 'Currency', 'invoicing' ), |
|
442 | + 'label' => __('Currency', 'invoicing'), |
|
443 | 443 | 'label_type' => 'vertical', |
444 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
444 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
445 | 445 | 'class' => 'form-control-sm', |
446 | - 'value' => $invoice->get_currency( 'edit' ), |
|
446 | + 'value' => $invoice->get_currency('edit'), |
|
447 | 447 | 'required' => false, |
448 | 448 | 'data-allow-clear' => 'false', |
449 | 449 | 'select2' => true, |
@@ -456,24 +456,24 @@ discard block |
||
456 | 456 | </div> |
457 | 457 | </div> |
458 | 458 | |
459 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
459 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
460 | 460 | <?php endif; ?> |
461 | 461 | |
462 | 462 | <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items"> |
463 | 463 | <thead> |
464 | 464 | <tr> |
465 | - <th class="getpaid-item" colspan="2"><?php esc_html_e( 'Item', 'invoicing' ) ?></th> |
|
465 | + <th class="getpaid-item" colspan="2"><?php esc_html_e('Item', 'invoicing') ?></th> |
|
466 | 466 | <th class="getpaid-quantity hide-if-amount text-right"> |
467 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ) ?></span> |
|
468 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ) ?></span> |
|
467 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing') ?></span> |
|
468 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing') ?></span> |
|
469 | 469 | </th> |
470 | 470 | <th class="getpaid-price hide-if-amount text-right"> |
471 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Price', 'invoicing' ) ?></span> |
|
472 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Rate', 'invoicing' ) ?></span> |
|
471 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Price', 'invoicing') ?></span> |
|
472 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Rate', 'invoicing') ?></span> |
|
473 | 473 | </th> |
474 | 474 | <th class="getpaid-item-subtotal text-right"> |
475 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e( 'Amount', 'invoicing' ) ?></span> |
|
476 | - <span class="hide-if-amount"><?php esc_html_e( 'Total', 'invoicing' ) ?></span> |
|
475 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e('Amount', 'invoicing') ?></span> |
|
476 | + <span class="hide-if-amount"><?php esc_html_e('Total', 'invoicing') ?></span> |
|
477 | 477 | </th> |
478 | 478 | <th class="getpaid-item-actions hide-if-not-editable" width="70px"> </th> |
479 | 479 | </tr> |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | <tbody class="getpaid_invoice_line_items"> |
482 | 482 | <tr class="hide-if-has-items hide-if-not-editable"> |
483 | 483 | <td colspan="2" class="pt-4 pb-4"> |
484 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Items', 'invoicing' ) ?></button> |
|
485 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ) ?></button> |
|
484 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Items', 'invoicing') ?></button> |
|
485 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing') ?></button> |
|
486 | 486 | </td> |
487 | 487 | <td class="hide-if-amount"> </th> |
488 | 488 | <td class="hide-if-amount"> </th> |
@@ -514,11 +514,11 @@ discard block |
||
514 | 514 | <div class="col-12 col-sm-6 offset-sm-6"> |
515 | 515 | <table class="getpaid-invoice-totals text-right w-100"> |
516 | 516 | <tbody> |
517 | - <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?> |
|
518 | - <tr class="getpaid-totals-<?php echo sanitize_html_class( $key ); ?>"> |
|
519 | - <td class="label"><?php echo esc_html( $data['label'] ) ?>:</td> |
|
517 | + <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?> |
|
518 | + <tr class="getpaid-totals-<?php echo sanitize_html_class($key); ?>"> |
|
519 | + <td class="label"><?php echo esc_html($data['label']) ?>:</td> |
|
520 | 520 | <td width="1%"></td> |
521 | - <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td> |
|
521 | + <td class="value"><?php echo wp_kses_post($data['value']) ?></td> |
|
522 | 522 | </tr> |
523 | 523 | <?php endforeach; ?> |
524 | 524 | </tbody> |
@@ -531,18 +531,18 @@ discard block |
||
531 | 531 | <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable"> |
532 | 532 | <div class="row"> |
533 | 533 | <div class="text-left col-12 col-sm-8"> |
534 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Item', 'invoicing' ) ?></button> |
|
535 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ) ?></button> |
|
536 | - <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?> |
|
534 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Item', 'invoicing') ?></button> |
|
535 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing') ?></button> |
|
536 | + <?php do_action('getpaid-invoice-items-actions', $invoice); ?> |
|
537 | 537 | </div> |
538 | 538 | <div class="text-right col-12 col-sm-4"> |
539 | - <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e( 'Recalculate Totals', 'invoicing' ) ?></button> |
|
539 | + <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e('Recalculate Totals', 'invoicing') ?></button> |
|
540 | 540 | </div> |
541 | 541 | </div> |
542 | 542 | </div> |
543 | 543 | |
544 | 544 | <div class="getpaid-invoice-item-actions hide-if-editable"> |
545 | - <p class="description m-2 text-right text-muted"><?php esc_html_e( 'This invoice is no longer editable', 'invoicing' ); ?></p> |
|
545 | + <p class="description m-2 text-right text-muted"><?php esc_html_e('This invoice is no longer editable', 'invoicing'); ?></p> |
|
546 | 546 | </div> |
547 | 547 | |
548 | 548 | <!-- Add items to an invoice --> |
@@ -550,8 +550,8 @@ discard block |
||
550 | 550 | <div class="modal-dialog modal-dialog-centered" role="document"> |
551 | 551 | <div class="modal-content"> |
552 | 552 | <div class="modal-header"> |
553 | - <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e( "Add Item(s)", 'invoicing' ); ?></h5> |
|
554 | - <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>"> |
|
553 | + <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e("Add Item(s)", 'invoicing'); ?></h5> |
|
554 | + <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>"> |
|
555 | 555 | <span aria-hidden="true">×</span> |
556 | 556 | </button> |
557 | 557 | </div> |
@@ -559,10 +559,10 @@ discard block |
||
559 | 559 | <table class="widefat"> |
560 | 560 | <thead> |
561 | 561 | <tr> |
562 | - <th class="pl-0 text-left"><?php esc_html_e( 'Item', 'invoicing' ) ?></th> |
|
562 | + <th class="pl-0 text-left"><?php esc_html_e('Item', 'invoicing') ?></th> |
|
563 | 563 | <th class="pr-0 text-right hide-if-amount"> |
564 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ) ?></span> |
|
565 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ) ?></span> |
|
564 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing') ?></span> |
|
565 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing') ?></span> |
|
566 | 566 | </th> |
567 | 567 | </tr> |
568 | 568 | </thead> |
@@ -570,9 +570,9 @@ discard block |
||
570 | 570 | <tr> |
571 | 571 | <td class="pl-0 text-left"> |
572 | 572 | <select class="regular-text getpaid-add-invoice-item-select"> |
573 | - <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option> |
|
574 | - <?php foreach ( get_posts( $item_args ) as $item ) : ?> |
|
575 | - <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html( $item->post_title ); ?></option> |
|
573 | + <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option> |
|
574 | + <?php foreach (get_posts($item_args) as $item) : ?> |
|
575 | + <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html($item->post_title); ?></option> |
|
576 | 576 | <?php endforeach; ?> |
577 | 577 | </select> |
578 | 578 | </td> |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | </table> |
585 | 585 | </div> |
586 | 586 | <div class="modal-footer"> |
587 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
588 | - <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e( 'Add', 'invoicing' ); ?></button> |
|
587 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
588 | + <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e('Add', 'invoicing'); ?></button> |
|
589 | 589 | </div> |
590 | 590 | </div> |
591 | 591 | </div> |
@@ -596,8 +596,8 @@ discard block |
||
596 | 596 | <div class="modal-dialog modal-dialog-centered" role="document"> |
597 | 597 | <div class="modal-content"> |
598 | 598 | <div class="modal-header"> |
599 | - <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e( "Create Item", 'invoicing' ); ?></h5> |
|
600 | - <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>"> |
|
599 | + <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e("Create Item", 'invoicing'); ?></h5> |
|
600 | + <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>"> |
|
601 | 601 | <span aria-hidden="true">×</span> |
602 | 602 | </button> |
603 | 603 | </div> |
@@ -605,27 +605,27 @@ discard block |
||
605 | 605 | <div class="getpaid-create-item-div"> |
606 | 606 | <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id"> |
607 | 607 | <label class="form-group w-100"> |
608 | - <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span> |
|
609 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
608 | + <span><?php esc_html_e('Name', 'invoicing'); ?></span> |
|
609 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
610 | 610 | </label> |
611 | 611 | <label class="form-group w-100"> |
612 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
613 | - <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
614 | - <input type="text" name="price" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control form-control-sm item-price"> |
|
612 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
613 | + <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
614 | + <input type="text" name="price" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control form-control-sm item-price"> |
|
615 | 615 | </label> |
616 | 616 | <label class="form-group w-100 hide-if-amount"> |
617 | - <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
617 | + <span><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
618 | 618 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
619 | 619 | </label> |
620 | 620 | <label class="form-group w-100"> |
621 | - <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span> |
|
622 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
621 | + <span><?php esc_html_e('Item Description', 'invoicing'); ?></span> |
|
622 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
623 | 623 | </label> |
624 | 624 | </div> |
625 | 625 | </div> |
626 | 626 | <div class="modal-footer"> |
627 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
628 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Create', 'invoicing' ); ?></button> |
|
627 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
628 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Create', 'invoicing'); ?></button> |
|
629 | 629 | </div> |
630 | 630 | </div> |
631 | 631 | </div> |
@@ -636,8 +636,8 @@ discard block |
||
636 | 636 | <div class="modal-dialog modal-dialog-centered" role="document"> |
637 | 637 | <div class="modal-content"> |
638 | 638 | <div class="modal-header"> |
639 | - <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e( "Edit Item", 'invoicing' ); ?></h5> |
|
640 | - <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>"> |
|
639 | + <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e("Edit Item", 'invoicing'); ?></h5> |
|
640 | + <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>"> |
|
641 | 641 | <span aria-hidden="true">×</span> |
642 | 642 | </button> |
643 | 643 | </div> |
@@ -645,27 +645,27 @@ discard block |
||
645 | 645 | <div class="getpaid-edit-item-div"> |
646 | 646 | <input type="hidden" name="id" class="form-control form-control-sm item-id"> |
647 | 647 | <label class="form-group w-100"> |
648 | - <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span> |
|
649 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
648 | + <span><?php esc_html_e('Name', 'invoicing'); ?></span> |
|
649 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
650 | 650 | </label> |
651 | 651 | <label class="form-group w-100"> |
652 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
653 | - <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
654 | - <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price"> |
|
652 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
653 | + <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
654 | + <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price"> |
|
655 | 655 | </label> |
656 | 656 | <label class="form-group w-100 hide-if-amount"> |
657 | - <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
657 | + <span><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
658 | 658 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
659 | 659 | </label> |
660 | 660 | <label class="form-group w-100"> |
661 | - <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span> |
|
662 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
661 | + <span><?php esc_html_e('Item Description', 'invoicing'); ?></span> |
|
662 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
663 | 663 | </label> |
664 | 664 | </div> |
665 | 665 | </div> |
666 | 666 | <div class="modal-footer"> |
667 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
668 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Save', 'invoicing' ); ?></button> |
|
667 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
668 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Save', 'invoicing'); ?></button> |
|
669 | 669 | </div> |
670 | 670 | </div> |
671 | 671 | </div> |
@@ -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,23 +55,23 @@ 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 esc_html_e( 'Item Price', 'invoicing' ); ?></span></label> |
|
60 | + <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php esc_html_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 | - <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
67 | + <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wp_kses_post(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 | - <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
74 | + <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
75 | 75 | </div> |
76 | 76 | <?php endif; ?> |
77 | 77 | </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 | true |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | <?php |
113 | 113 | |
114 | 114 | // Dynamic pricing. |
115 | - if ( $item->supports_dynamic_pricing() ) { |
|
115 | + if ($item->supports_dynamic_pricing()) { |
|
116 | 116 | |
117 | - do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
117 | + do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item); |
|
118 | 118 | |
119 | 119 | // NYP toggle. |
120 | 120 | aui()->input( |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | 'id' => 'wpinv_name_your_price', |
123 | 123 | 'name' => 'wpinv_name_your_price', |
124 | 124 | 'type' => 'checkbox', |
125 | - 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
125 | + 'label' => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')), |
|
126 | 126 | 'value' => '1', |
127 | 127 | 'checked' => $item->user_can_set_their_price(), |
128 | 128 | 'no_wrap' => true, |
@@ -130,105 +130,105 @@ discard block |
||
130 | 130 | true |
131 | 131 | ); |
132 | 132 | |
133 | - do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
133 | + do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item); |
|
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | 137 | // Subscriptions. |
138 | - do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item ); |
|
138 | + do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item); |
|
139 | 139 | aui()->input( |
140 | 140 | array( |
141 | 141 | 'id' => 'wpinv_is_recurring', |
142 | 142 | 'name' => 'wpinv_is_recurring', |
143 | 143 | 'type' => 'checkbox', |
144 | - 'label' => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ), |
|
144 | + 'label' => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')), |
|
145 | 145 | 'value' => '1', |
146 | 146 | 'checked' => $item->is_recurring(), |
147 | 147 | 'no_wrap' => true, |
148 | 148 | ), |
149 | 149 | true |
150 | 150 | ); |
151 | - do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item ); |
|
151 | + do_action('wpinv_item_details_metabox_subscription_checkbox', $item); |
|
152 | 152 | |
153 | 153 | ?> |
154 | 154 | <div class="wpinv_show_if_recurring"> |
155 | - <em><?php echo wp_kses_post( wpinv_get_recurring_gateways_text() ); ?></em> |
|
155 | + <em><?php echo wp_kses_post(wpinv_get_recurring_gateways_text()); ?></em> |
|
156 | 156 | </div> |
157 | 157 | </div> |
158 | 158 | </div> |
159 | 159 | </div> |
160 | 160 | <div class="col-sm-1 pt-2 pl-0"> |
161 | - <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> |
|
161 | + <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> |
|
162 | 162 | </div> |
163 | 163 | </div> |
164 | - <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?> |
|
164 | + <?php do_action('wpinv_item_details_metabox_after_price', $item); ?> |
|
165 | 165 | |
166 | - <?php if ( $item->supports_dynamic_pricing() ) : ?> |
|
167 | - <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?> |
|
166 | + <?php if ($item->supports_dynamic_pricing()) : ?> |
|
167 | + <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?> |
|
168 | 168 | <div class="wpinv_show_if_dynamic wpinv_minimum_price"> |
169 | 169 | |
170 | 170 | <div class="form-group row"> |
171 | 171 | <label for="wpinv_minimum_price" class="col-sm-3 col-form-label"> |
172 | - <?php esc_html_e( 'Minimum Price', 'invoicing' ); ?> |
|
172 | + <?php esc_html_e('Minimum Price', 'invoicing'); ?> |
|
173 | 173 | </label> |
174 | 174 | <div class="col-sm-8"> |
175 | 175 | <div class="input-group input-group-sm"> |
176 | - <?php if ( 'left' == $position ) : ?> |
|
176 | + <?php if ('left' == $position) : ?> |
|
177 | 177 | <div class="input-group-prepend"> |
178 | - <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
178 | + <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
179 | 179 | </div> |
180 | 180 | <?php endif; ?> |
181 | 181 | |
182 | - <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"> |
|
182 | + <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"> |
|
183 | 183 | |
184 | - <?php if ( 'left' != $position ) : ?> |
|
184 | + <?php if ('left' != $position) : ?> |
|
185 | 185 | <div class="input-group-append"> |
186 | - <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
186 | + <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
187 | 187 | </div> |
188 | 188 | <?php endif; ?> |
189 | 189 | </div> |
190 | 190 | </div> |
191 | 191 | |
192 | 192 | <div class="col-sm-1 pt-2 pl-0"> |
193 | - <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> |
|
193 | + <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> |
|
194 | 194 | </div> |
195 | 195 | </div> |
196 | 196 | |
197 | 197 | </div> |
198 | - <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?> |
|
198 | + <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?> |
|
199 | 199 | <?php endif; ?> |
200 | 200 | |
201 | - <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?> |
|
201 | + <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?> |
|
202 | 202 | <div class="wpinv_show_if_recurring wpinv_maximum_renewals"> |
203 | 203 | |
204 | 204 | <div class="form-group row"> |
205 | 205 | <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label"> |
206 | - <?php esc_html_e( 'Maximum Renewals', 'invoicing' ); ?> |
|
206 | + <?php esc_html_e('Maximum Renewals', 'invoicing'); ?> |
|
207 | 207 | </label> |
208 | 208 | <div class="col-sm-8"> |
209 | - <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%;" /> |
|
209 | + <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%;" /> |
|
210 | 210 | </div> |
211 | 211 | <div class="col-sm-1 pt-2 pl-0"> |
212 | - <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> |
|
212 | + <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> |
|
213 | 213 | </div> |
214 | 214 | </div> |
215 | 215 | |
216 | 216 | </div> |
217 | - <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?> |
|
217 | + <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?> |
|
218 | 218 | |
219 | - <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?> |
|
219 | + <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?> |
|
220 | 220 | <div class="wpinv_show_if_recurring wpinv_free_trial"> |
221 | 221 | |
222 | 222 | <div class="form-group row"> |
223 | - <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> |
|
223 | + <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> |
|
224 | 224 | |
225 | 225 | <div class="col-sm-8"> |
226 | 226 | <div class="row"> |
227 | 227 | <div class="col-sm-6"> |
228 | - <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0; ?> |
|
228 | + <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?> |
|
229 | 229 | |
230 | 230 | <div> |
231 | - <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" > |
|
231 | + <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" > |
|
232 | 232 | </div> |
233 | 233 | </div> |
234 | 234 | <div class="col-sm-6"> |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | array( |
238 | 238 | 'id' => 'wpinv_trial_period', |
239 | 239 | 'name' => 'wpinv_trial_period', |
240 | - 'label' => __( 'Trial Period', 'invoicing' ), |
|
241 | - 'placeholder' => __( 'Trial Period', 'invoicing' ), |
|
242 | - 'value' => $item->get_trial_period( 'edit' ), |
|
240 | + 'label' => __('Trial Period', 'invoicing'), |
|
241 | + 'placeholder' => __('Trial Period', 'invoicing'), |
|
242 | + 'value' => $item->get_trial_period('edit'), |
|
243 | 243 | 'select2' => true, |
244 | 244 | 'data-allow-clear' => 'false', |
245 | 245 | 'no_wrap' => true, |
246 | 246 | 'options' => array( |
247 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
248 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
249 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
250 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
247 | + 'D' => __('day(s)', 'invoicing'), |
|
248 | + 'W' => __('week(s)', 'invoicing'), |
|
249 | + 'M' => __('month(s)', 'invoicing'), |
|
250 | + 'Y' => __('year(s)', 'invoicing'), |
|
251 | 251 | ), |
252 | 252 | ), |
253 | 253 | true |
@@ -259,15 +259,15 @@ discard block |
||
259 | 259 | </div> |
260 | 260 | |
261 | 261 | <div class="col-sm-1 pt-2 pl-0"> |
262 | - <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> |
|
262 | + <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> |
|
263 | 263 | </div> |
264 | 264 | |
265 | 265 | </div> |
266 | 266 | |
267 | 267 | </div> |
268 | - <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?> |
|
268 | + <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?> |
|
269 | 269 | |
270 | - <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?> |
|
270 | + <?php do_action('wpinv_item_details_metabox_item_details', $item); ?> |
|
271 | 271 | </div> |
272 | 272 | <?php |
273 | 273 | |
@@ -278,31 +278,31 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @param int $post_id |
280 | 280 | */ |
281 | - public static function save( $post_id ) { |
|
281 | + public static function save($post_id) { |
|
282 | 282 | |
283 | 283 | // Prepare the item. |
284 | - $item = new WPInv_Item( $post_id ); |
|
284 | + $item = new WPInv_Item($post_id); |
|
285 | 285 | |
286 | 286 | // Load new data. |
287 | 287 | $item->set_props( |
288 | 288 | array( |
289 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null, |
|
290 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
291 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
292 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
293 | - 'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ), |
|
294 | - 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null, |
|
295 | - 'is_recurring' => ! empty( $_POST['wpinv_is_recurring'] ), |
|
296 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
297 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
298 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
299 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
300 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
301 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
289 | + 'price' => isset($_POST['wpinv_item_price']) ? getpaid_standardize_amount($_POST['wpinv_item_price']) : null, |
|
290 | + 'vat_rule' => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null, |
|
291 | + 'vat_class' => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null, |
|
292 | + 'type' => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null, |
|
293 | + 'is_dynamic_pricing' => !empty($_POST['wpinv_name_your_price']), |
|
294 | + 'minimum_price' => isset($_POST['wpinv_minimum_price']) ? getpaid_standardize_amount($_POST['wpinv_minimum_price']) : null, |
|
295 | + 'is_recurring' => !empty($_POST['wpinv_is_recurring']), |
|
296 | + 'recurring_period' => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null, |
|
297 | + 'recurring_interval' => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
298 | + 'recurring_limit' => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
299 | + 'is_free_trial' => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null, |
|
300 | + 'trial_period' => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null, |
|
301 | + 'trial_interval' => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
302 | 302 | ) |
303 | 303 | ); |
304 | 304 | |
305 | 305 | $item->save(); |
306 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
306 | + do_action('getpaid_item_metabox_save', $post_id, $item); |
|
307 | 307 | } |
308 | 308 | } |
@@ -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,28 +22,28 @@ 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 | - aui()->alert( |
|
28 | + aui()->alert( |
|
29 | 29 | array( |
30 | - 'type' => 'danger', |
|
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | - ), |
|
33 | - true |
|
30 | + 'type' => 'danger', |
|
31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | + ), |
|
33 | + true |
|
34 | 34 | ); |
35 | 35 | |
36 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
36 | + } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
37 | 37 | |
38 | - // Display a single subscription. |
|
39 | - wpinv_recurring_subscription_details(); |
|
40 | - } else { |
|
38 | + // Display a single subscription. |
|
39 | + wpinv_recurring_subscription_details(); |
|
40 | + } else { |
|
41 | 41 | |
42 | - // Display a list of available subscriptions. |
|
43 | - getpaid_print_subscriptions_list(); |
|
44 | - } |
|
42 | + // Display a list of available subscriptions. |
|
43 | + getpaid_print_subscriptions_list(); |
|
44 | + } |
|
45 | 45 | |
46 | - ?> |
|
46 | + ?> |
|
47 | 47 | |
48 | 48 | </div> |
49 | 49 | </div> |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | */ |
61 | 61 | function getpaid_print_subscriptions_list() { |
62 | 62 | |
63 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
64 | - $subscribers_table->prepare_items(); |
|
63 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
64 | + $subscribers_table->prepare_items(); |
|
65 | 65 | |
66 | - ?> |
|
66 | + ?> |
|
67 | 67 | <?php $subscribers_table->views(); ?> |
68 | 68 | <form id="subscribers-filter" class="bsui" method="get"> |
69 | 69 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
@@ -82,42 +82,42 @@ discard block |
||
82 | 82 | */ |
83 | 83 | function wpinv_recurring_subscription_details() { |
84 | 84 | |
85 | - // Fetch the subscription. |
|
86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
87 | - if ( ! $sub->exists() ) { |
|
85 | + // Fetch the subscription. |
|
86 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
87 | + if ( ! $sub->exists() ) { |
|
88 | 88 | |
89 | - aui()->alert( |
|
90 | - array( |
|
91 | - 'type' => 'danger', |
|
92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
93 | - ), |
|
94 | - true |
|
95 | - ); |
|
89 | + aui()->alert( |
|
90 | + array( |
|
91 | + 'type' => 'danger', |
|
92 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
93 | + ), |
|
94 | + true |
|
95 | + ); |
|
96 | 96 | |
97 | - return; |
|
98 | - } |
|
97 | + return; |
|
98 | + } |
|
99 | 99 | |
100 | - // Use metaboxes to display the subscription details. |
|
101 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
102 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | + // Use metaboxes to display the subscription details. |
|
101 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
102 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
103 | 103 | |
104 | - $subscription_id = $sub->get_id(); |
|
105 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
106 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
104 | + $subscription_id = $sub->get_id(); |
|
105 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
106 | + $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
107 | 107 | |
108 | - if ( 1 < count( $subscription_groups ) ) { |
|
109 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
110 | - } |
|
108 | + if ( 1 < count( $subscription_groups ) ) { |
|
109 | + add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
110 | + } |
|
111 | 111 | |
112 | - if ( ! empty( $subscription_group ) ) { |
|
113 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
114 | - } |
|
112 | + if ( ! empty( $subscription_group ) ) { |
|
113 | + add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
114 | + } |
|
115 | 115 | |
116 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
116 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
117 | 117 | |
118 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
118 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
119 | 119 | |
120 | - ?> |
|
120 | + ?> |
|
121 | 121 | |
122 | 122 | <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
123 | 123 | |
@@ -157,44 +157,44 @@ discard block |
||
157 | 157 | */ |
158 | 158 | function getpaid_admin_subscription_details_metabox( $sub ) { |
159 | 159 | |
160 | - // Subscription items. |
|
161 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
162 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
163 | - |
|
164 | - // Prepare subscription detail columns. |
|
165 | - $fields = apply_filters( |
|
166 | - 'getpaid_subscription_admin_page_fields', |
|
167 | - array( |
|
168 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
169 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
170 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
171 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
172 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
173 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
174 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
177 | - 'status' => __( 'Status', 'invoicing' ), |
|
178 | - ) |
|
179 | - ); |
|
180 | - |
|
181 | - if ( ! $sub->is_active() ) { |
|
182 | - |
|
183 | - if ( isset( $fields['renews_on'] ) ) { |
|
184 | - unset( $fields['renews_on'] ); |
|
185 | - } |
|
186 | - |
|
187 | - if ( isset( $fields['gateway'] ) ) { |
|
188 | - unset( $fields['gateway'] ); |
|
189 | - } |
|
160 | + // Subscription items. |
|
161 | + $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
162 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
163 | + |
|
164 | + // Prepare subscription detail columns. |
|
165 | + $fields = apply_filters( |
|
166 | + 'getpaid_subscription_admin_page_fields', |
|
167 | + array( |
|
168 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
169 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
170 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
171 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
172 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
173 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
174 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
175 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
176 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
177 | + 'status' => __( 'Status', 'invoicing' ), |
|
178 | + ) |
|
179 | + ); |
|
180 | + |
|
181 | + if ( ! $sub->is_active() ) { |
|
182 | + |
|
183 | + if ( isset( $fields['renews_on'] ) ) { |
|
184 | + unset( $fields['renews_on'] ); |
|
185 | + } |
|
186 | + |
|
187 | + if ( isset( $fields['gateway'] ) ) { |
|
188 | + unset( $fields['gateway'] ); |
|
189 | + } |
|
190 | 190 | } |
191 | 191 | |
192 | - $profile_id = $sub->get_profile_id(); |
|
193 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
194 | - unset( $fields['profile_id'] ); |
|
195 | - } |
|
192 | + $profile_id = $sub->get_profile_id(); |
|
193 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
194 | + unset( $fields['profile_id'] ); |
|
195 | + } |
|
196 | 196 | |
197 | - ?> |
|
197 | + ?> |
|
198 | 198 | |
199 | 199 | <table class="table table-borderless" style="font-size: 14px;"> |
200 | 200 | <tbody> |
@@ -228,20 +228,20 @@ discard block |
||
228 | 228 | */ |
229 | 229 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
230 | 230 | |
231 | - $username = __( '(Missing User)', 'invoicing' ); |
|
231 | + $username = __( '(Missing User)', 'invoicing' ); |
|
232 | 232 | |
233 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
234 | - if ( $user ) { |
|
233 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
234 | + if ( $user ) { |
|
235 | 235 | |
236 | - $username = sprintf( |
|
237 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
238 | - absint( $user->ID ), |
|
239 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
240 | - ); |
|
236 | + $username = sprintf( |
|
237 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
238 | + absint( $user->ID ), |
|
239 | + ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
240 | + ); |
|
241 | 241 | |
242 | - } |
|
242 | + } |
|
243 | 243 | |
244 | - echo wp_kses_post( $username ); |
|
244 | + echo wp_kses_post( $username ); |
|
245 | 245 | } |
246 | 246 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
247 | 247 | |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * @param WPInv_Subscription $subscription |
252 | 252 | */ |
253 | 253 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
254 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
255 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
254 | + $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
255 | + echo wp_kses_post( "<span>$amount</span>" ); |
|
256 | 256 | } |
257 | 257 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
258 | 258 | |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | */ |
264 | 264 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
265 | 265 | |
266 | - printf( |
|
267 | - '<a href="%s">#%s</a>', |
|
268 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
269 | - absint( $subscription->get_id() ) |
|
270 | - ); |
|
266 | + printf( |
|
267 | + '<a href="%s">#%s</a>', |
|
268 | + esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
269 | + absint( $subscription->get_id() ) |
|
270 | + ); |
|
271 | 271 | |
272 | 272 | } |
273 | 273 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param WPInv_Subscription $subscription |
279 | 279 | */ |
280 | 280 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
281 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
281 | + echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
282 | 282 | } |
283 | 283 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
284 | 284 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param WPInv_Subscription $subscription |
289 | 289 | */ |
290 | 290 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
291 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
291 | + echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
292 | 292 | } |
293 | 293 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
294 | 294 | |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | * @param WPInv_Subscription $subscription |
299 | 299 | */ |
300 | 300 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
301 | - $max_bills = $subscription->get_bill_times(); |
|
302 | - echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
301 | + $max_bills = $subscription->get_bill_times(); |
|
302 | + echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
303 | 303 | } |
304 | 304 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
305 | 305 | /** |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | */ |
311 | 311 | function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
312 | 312 | |
313 | - if ( empty( $subscription_group ) ) { |
|
314 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
315 | - return; |
|
316 | - } |
|
313 | + if ( empty( $subscription_group ) ) { |
|
314 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
315 | + return; |
|
316 | + } |
|
317 | 317 | |
318 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
319 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
318 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
319 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
320 | 320 | |
321 | 321 | } |
322 | 322 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | */ |
329 | 329 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
330 | 330 | |
331 | - $gateway = $subscription->get_gateway(); |
|
331 | + $gateway = $subscription->get_gateway(); |
|
332 | 332 | |
333 | - if ( ! empty( $gateway ) ) { |
|
334 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
335 | - } else { |
|
336 | - echo '—'; |
|
337 | - } |
|
333 | + if ( ! empty( $gateway ) ) { |
|
334 | + echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
335 | + } else { |
|
336 | + echo '—'; |
|
337 | + } |
|
338 | 338 | |
339 | 339 | } |
340 | 340 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @param WPInv_Subscription $subscription |
346 | 346 | */ |
347 | 347 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
348 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
348 | + echo wp_kses_post( $subscription->get_status_label_html() ); |
|
349 | 349 | } |
350 | 350 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
351 | 351 | |
@@ -356,27 +356,27 @@ discard block |
||
356 | 356 | */ |
357 | 357 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
358 | 358 | |
359 | - $profile_id = $subscription->get_profile_id(); |
|
360 | - |
|
361 | - aui()->input( |
|
362 | - array( |
|
363 | - 'type' => 'text', |
|
364 | - 'id' => 'wpinv_subscription_profile_id', |
|
365 | - 'name' => 'wpinv_subscription_profile_id', |
|
366 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
367 | - 'label_type' => 'hidden', |
|
368 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
369 | - 'value' => esc_attr( $profile_id ), |
|
370 | - 'input_group_right' => '', |
|
371 | - 'no_wrap' => true, |
|
372 | - ), |
|
373 | - true |
|
374 | - ); |
|
375 | - |
|
376 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
377 | - if ( ! empty( $url ) ) { |
|
378 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
379 | - } |
|
359 | + $profile_id = $subscription->get_profile_id(); |
|
360 | + |
|
361 | + aui()->input( |
|
362 | + array( |
|
363 | + 'type' => 'text', |
|
364 | + 'id' => 'wpinv_subscription_profile_id', |
|
365 | + 'name' => 'wpinv_subscription_profile_id', |
|
366 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
367 | + 'label_type' => 'hidden', |
|
368 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
369 | + 'value' => esc_attr( $profile_id ), |
|
370 | + 'input_group_right' => '', |
|
371 | + 'no_wrap' => true, |
|
372 | + ), |
|
373 | + true |
|
374 | + ); |
|
375 | + |
|
376 | + $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
377 | + if ( ! empty( $url ) ) { |
|
378 | + echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
379 | + } |
|
380 | 380 | |
381 | 381 | } |
382 | 382 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -388,40 +388,40 @@ discard block |
||
388 | 388 | */ |
389 | 389 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
390 | 390 | |
391 | - ?> |
|
391 | + ?> |
|
392 | 392 | <div class="mt-3"> |
393 | 393 | |
394 | 394 | <?php |
395 | - aui()->select( |
|
396 | - array( |
|
397 | - 'options' => getpaid_get_subscription_statuses(), |
|
398 | - 'name' => 'subscription_status', |
|
399 | - 'id' => 'subscription_status_update_select', |
|
400 | - 'required' => true, |
|
401 | - 'no_wrap' => false, |
|
402 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
403 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
404 | - 'select2' => true, |
|
405 | - 'value' => $subscription->get_status( 'edit' ), |
|
406 | - ), |
|
407 | - true |
|
408 | - ); |
|
409 | - ?> |
|
395 | + aui()->select( |
|
396 | + array( |
|
397 | + 'options' => getpaid_get_subscription_statuses(), |
|
398 | + 'name' => 'subscription_status', |
|
399 | + 'id' => 'subscription_status_update_select', |
|
400 | + 'required' => true, |
|
401 | + 'no_wrap' => false, |
|
402 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
403 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
404 | + 'select2' => true, |
|
405 | + 'value' => $subscription->get_status( 'edit' ), |
|
406 | + ), |
|
407 | + true |
|
408 | + ); |
|
409 | + ?> |
|
410 | 410 | |
411 | 411 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
412 | 412 | |
413 | 413 | <?php |
414 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
414 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
415 | 415 | |
416 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
417 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
418 | - $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' ); |
|
416 | + $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
417 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
418 | + $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' ); |
|
419 | 419 | |
420 | - if ( $subscription->is_active() ) { |
|
421 | - echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
422 | - } |
|
420 | + if ( $subscription->is_active() ) { |
|
421 | + echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
422 | + } |
|
423 | 423 | |
424 | - echo '</div></div>'; |
|
424 | + echo '</div></div>'; |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
@@ -432,33 +432,33 @@ discard block |
||
432 | 432 | */ |
433 | 433 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
434 | 434 | |
435 | - $columns = apply_filters( |
|
436 | - 'getpaid_subscription_related_invoices_columns', |
|
437 | - array( |
|
438 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
439 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
440 | - 'date' => __( 'Date', 'invoicing' ), |
|
441 | - 'status' => __( 'Status', 'invoicing' ), |
|
442 | - 'total' => __( 'Total', 'invoicing' ), |
|
443 | - ), |
|
444 | - $subscription |
|
445 | - ); |
|
446 | - |
|
447 | - // Prepare the invoices. |
|
448 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
449 | - $parent = $subscription->get_parent_invoice(); |
|
450 | - |
|
451 | - if ( $parent->exists() ) { |
|
452 | - $payments = array_merge( array( $parent ), $payments ); |
|
453 | - } |
|
454 | - |
|
455 | - $table_class = 'w-100 bg-white'; |
|
456 | - |
|
457 | - if ( ! is_admin() ) { |
|
458 | - $table_class = 'table table-bordered'; |
|
459 | - } |
|
460 | - |
|
461 | - ?> |
|
435 | + $columns = apply_filters( |
|
436 | + 'getpaid_subscription_related_invoices_columns', |
|
437 | + array( |
|
438 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
439 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
440 | + 'date' => __( 'Date', 'invoicing' ), |
|
441 | + 'status' => __( 'Status', 'invoicing' ), |
|
442 | + 'total' => __( 'Total', 'invoicing' ), |
|
443 | + ), |
|
444 | + $subscription |
|
445 | + ); |
|
446 | + |
|
447 | + // Prepare the invoices. |
|
448 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
449 | + $parent = $subscription->get_parent_invoice(); |
|
450 | + |
|
451 | + if ( $parent->exists() ) { |
|
452 | + $payments = array_merge( array( $parent ), $payments ); |
|
453 | + } |
|
454 | + |
|
455 | + $table_class = 'w-100 bg-white'; |
|
456 | + |
|
457 | + if ( ! is_admin() ) { |
|
458 | + $table_class = 'table table-bordered'; |
|
459 | + } |
|
460 | + |
|
461 | + ?> |
|
462 | 462 | <div class="m-0" style="overflow: auto;"> |
463 | 463 | |
464 | 464 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -466,10 +466,10 @@ discard block |
||
466 | 466 | <thead> |
467 | 467 | <tr> |
468 | 468 | <?php |
469 | - foreach ( $columns as $key => $label ) { |
|
470 | - echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
471 | - } |
|
472 | - ?> |
|
469 | + foreach ( $columns as $key => $label ) { |
|
470 | + echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
471 | + } |
|
472 | + ?> |
|
473 | 473 | </tr> |
474 | 474 | </thead> |
475 | 475 | |
@@ -485,72 +485,72 @@ discard block |
||
485 | 485 | |
486 | 486 | <?php |
487 | 487 | |
488 | - foreach ( $payments as $payment ) : |
|
488 | + foreach ( $payments as $payment ) : |
|
489 | 489 | |
490 | - // Ensure that we have an invoice. |
|
491 | - $payment = new WPInv_Invoice( $payment ); |
|
490 | + // Ensure that we have an invoice. |
|
491 | + $payment = new WPInv_Invoice( $payment ); |
|
492 | 492 | |
493 | - // Abort if the invoice is invalid... |
|
494 | - if ( ! $payment->exists() ) { |
|
495 | - continue; |
|
496 | - } |
|
493 | + // Abort if the invoice is invalid... |
|
494 | + if ( ! $payment->exists() ) { |
|
495 | + continue; |
|
496 | + } |
|
497 | 497 | |
498 | - // ... or belongs to a different subscription. |
|
499 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
500 | - continue; |
|
501 | - } |
|
498 | + // ... or belongs to a different subscription. |
|
499 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
500 | + continue; |
|
501 | + } |
|
502 | 502 | |
503 | - echo '<tr>'; |
|
503 | + echo '<tr>'; |
|
504 | 504 | |
505 | - foreach ( array_keys( $columns ) as $key ) { |
|
505 | + foreach ( array_keys( $columns ) as $key ) { |
|
506 | 506 | |
507 | - echo "<td class='p-2 text-left'>"; |
|
507 | + echo "<td class='p-2 text-left'>"; |
|
508 | 508 | |
509 | - switch ( $key ) { |
|
509 | + switch ( $key ) { |
|
510 | 510 | |
511 | - case 'total': |
|
512 | - echo '<strong>'; |
|
513 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
514 | - echo '</strong>'; |
|
515 | - break; |
|
511 | + case 'total': |
|
512 | + echo '<strong>'; |
|
513 | + wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
514 | + echo '</strong>'; |
|
515 | + break; |
|
516 | 516 | |
517 | - case 'relationship': |
|
518 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
519 | - break; |
|
517 | + case 'relationship': |
|
518 | + echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
519 | + break; |
|
520 | 520 | |
521 | - case 'date': |
|
522 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
523 | - break; |
|
521 | + case 'date': |
|
522 | + echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
523 | + break; |
|
524 | 524 | |
525 | - case 'status': |
|
526 | - $status = $payment->get_status_nicename(); |
|
527 | - if ( is_admin() ) { |
|
528 | - $status = $payment->get_status_label_html(); |
|
529 | - } |
|
525 | + case 'status': |
|
526 | + $status = $payment->get_status_nicename(); |
|
527 | + if ( is_admin() ) { |
|
528 | + $status = $payment->get_status_label_html(); |
|
529 | + } |
|
530 | 530 | |
531 | - echo wp_kses_post( $status ); |
|
532 | - break; |
|
531 | + echo wp_kses_post( $status ); |
|
532 | + break; |
|
533 | 533 | |
534 | - case 'invoice': |
|
535 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
534 | + case 'invoice': |
|
535 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
536 | 536 | |
537 | - if ( ! is_admin() ) { |
|
538 | - $link = esc_url( $payment->get_view_url() ); |
|
539 | - } |
|
537 | + if ( ! is_admin() ) { |
|
538 | + $link = esc_url( $payment->get_view_url() ); |
|
539 | + } |
|
540 | 540 | |
541 | - $invoice = esc_html( $payment->get_number() ); |
|
542 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
543 | - break; |
|
544 | - } |
|
541 | + $invoice = esc_html( $payment->get_number() ); |
|
542 | + echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
543 | + break; |
|
544 | + } |
|
545 | 545 | |
546 | - echo '</td>'; |
|
546 | + echo '</td>'; |
|
547 | 547 | |
548 | - } |
|
548 | + } |
|
549 | 549 | |
550 | - echo '</tr>'; |
|
550 | + echo '</tr>'; |
|
551 | 551 | |
552 | - endforeach; |
|
553 | - ?> |
|
552 | + endforeach; |
|
553 | + ?> |
|
554 | 554 | |
555 | 555 | </tbody> |
556 | 556 | |
@@ -568,42 +568,42 @@ discard block |
||
568 | 568 | */ |
569 | 569 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
570 | 570 | |
571 | - // Fetch the subscription group. |
|
572 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
571 | + // Fetch the subscription group. |
|
572 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
573 | 573 | |
574 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
575 | - return; |
|
576 | - } |
|
574 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
575 | + return; |
|
576 | + } |
|
577 | 577 | |
578 | - // Prepare table columns. |
|
579 | - $columns = apply_filters( |
|
580 | - 'getpaid_subscription_item_details_columns', |
|
581 | - array( |
|
582 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
583 | - 'price' => __( 'Price', 'invoicing' ), |
|
584 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
585 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
586 | - //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
587 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
588 | - ), |
|
589 | - $subscription |
|
590 | - ); |
|
578 | + // Prepare table columns. |
|
579 | + $columns = apply_filters( |
|
580 | + 'getpaid_subscription_item_details_columns', |
|
581 | + array( |
|
582 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
583 | + 'price' => __( 'Price', 'invoicing' ), |
|
584 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
585 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
586 | + //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
587 | + 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
588 | + ), |
|
589 | + $subscription |
|
590 | + ); |
|
591 | 591 | |
592 | - // Prepare the invoices. |
|
592 | + // Prepare the invoices. |
|
593 | 593 | |
594 | - $invoice = $subscription->get_parent_invoice(); |
|
594 | + $invoice = $subscription->get_parent_invoice(); |
|
595 | 595 | |
596 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
597 | - unset( $columns['tax'] ); |
|
598 | - } |
|
596 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
597 | + unset( $columns['tax'] ); |
|
598 | + } |
|
599 | 599 | |
600 | - $table_class = 'w-100 bg-white'; |
|
600 | + $table_class = 'w-100 bg-white'; |
|
601 | 601 | |
602 | - if ( ! is_admin() ) { |
|
603 | - $table_class = 'table table-bordered'; |
|
604 | - } |
|
602 | + if ( ! is_admin() ) { |
|
603 | + $table_class = 'table table-bordered'; |
|
604 | + } |
|
605 | 605 | |
606 | - ?> |
|
606 | + ?> |
|
607 | 607 | <div class="m-0" style="overflow: auto;"> |
608 | 608 | |
609 | 609 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -612,10 +612,10 @@ discard block |
||
612 | 612 | <tr> |
613 | 613 | <?php |
614 | 614 | |
615 | - foreach ( $columns as $key => $label ) { |
|
616 | - echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
617 | - } |
|
618 | - ?> |
|
615 | + foreach ( $columns as $key => $label ) { |
|
616 | + echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
617 | + } |
|
618 | + ?> |
|
619 | 619 | </tr> |
620 | 620 | </thead> |
621 | 621 | |
@@ -623,106 +623,106 @@ discard block |
||
623 | 623 | |
624 | 624 | <?php |
625 | 625 | |
626 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
626 | + foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
627 | 627 | |
628 | - echo '<tr>'; |
|
628 | + echo '<tr>'; |
|
629 | 629 | |
630 | - foreach ( array_keys( $columns ) as $key ) { |
|
630 | + foreach ( array_keys( $columns ) as $key ) { |
|
631 | 631 | |
632 | - $class = 'text-left'; |
|
632 | + $class = 'text-left'; |
|
633 | 633 | |
634 | - echo "<td class='p-2 text-left'>"; |
|
634 | + echo "<td class='p-2 text-left'>"; |
|
635 | 635 | |
636 | - switch ( $key ) { |
|
636 | + switch ( $key ) { |
|
637 | 637 | |
638 | - case 'item_name': |
|
639 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
640 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
638 | + case 'item_name': |
|
639 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
640 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
641 | 641 | |
642 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
643 | - echo esc_html( $item_name ); |
|
644 | - } else { |
|
645 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
646 | - } |
|
642 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
643 | + echo esc_html( $item_name ); |
|
644 | + } else { |
|
645 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
646 | + } |
|
647 | 647 | |
648 | - break; |
|
648 | + break; |
|
649 | 649 | |
650 | - case 'price': |
|
651 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
652 | - break; |
|
650 | + case 'price': |
|
651 | + wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
652 | + break; |
|
653 | 653 | |
654 | - case 'tax': |
|
655 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
656 | - break; |
|
654 | + case 'tax': |
|
655 | + wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
656 | + break; |
|
657 | 657 | |
658 | - case 'discount': |
|
659 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
660 | - break; |
|
658 | + case 'discount': |
|
659 | + wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
660 | + break; |
|
661 | 661 | |
662 | - case 'initial': |
|
663 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
664 | - break; |
|
662 | + case 'initial': |
|
663 | + wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
664 | + break; |
|
665 | 665 | |
666 | - case 'recurring': |
|
667 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
668 | - break; |
|
666 | + case 'recurring': |
|
667 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
668 | + break; |
|
669 | 669 | |
670 | - } |
|
670 | + } |
|
671 | 671 | |
672 | - echo '</td>'; |
|
672 | + echo '</td>'; |
|
673 | 673 | |
674 | - } |
|
674 | + } |
|
675 | 675 | |
676 | - echo '</tr>'; |
|
676 | + echo '</tr>'; |
|
677 | 677 | |
678 | - endforeach; |
|
678 | + endforeach; |
|
679 | 679 | |
680 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
680 | + foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
681 | 681 | |
682 | - echo '<tr>'; |
|
682 | + echo '<tr>'; |
|
683 | 683 | |
684 | - foreach ( array_keys( $columns ) as $key ) { |
|
684 | + foreach ( array_keys( $columns ) as $key ) { |
|
685 | 685 | |
686 | - $class = 'text-left'; |
|
686 | + $class = 'text-left'; |
|
687 | 687 | |
688 | - echo "<td class='p-2 text-left'>"; |
|
688 | + echo "<td class='p-2 text-left'>"; |
|
689 | 689 | |
690 | - switch ( $key ) { |
|
690 | + switch ( $key ) { |
|
691 | 691 | |
692 | - case 'item_name': |
|
693 | - echo esc_html( $subscription_group_fee['name'] ); |
|
694 | - break; |
|
692 | + case 'item_name': |
|
693 | + echo esc_html( $subscription_group_fee['name'] ); |
|
694 | + break; |
|
695 | 695 | |
696 | - case 'price': |
|
697 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
698 | - break; |
|
696 | + case 'price': |
|
697 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
698 | + break; |
|
699 | 699 | |
700 | - case 'tax': |
|
701 | - echo '—'; |
|
702 | - break; |
|
700 | + case 'tax': |
|
701 | + echo '—'; |
|
702 | + break; |
|
703 | 703 | |
704 | - case 'discount': |
|
705 | - echo '—'; |
|
706 | - break; |
|
704 | + case 'discount': |
|
705 | + echo '—'; |
|
706 | + break; |
|
707 | 707 | |
708 | - case 'initial': |
|
709 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
710 | - break; |
|
708 | + case 'initial': |
|
709 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
710 | + break; |
|
711 | 711 | |
712 | - case 'recurring': |
|
713 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
714 | - break; |
|
712 | + case 'recurring': |
|
713 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
714 | + break; |
|
715 | 715 | |
716 | - } |
|
716 | + } |
|
717 | 717 | |
718 | - echo '</td>'; |
|
718 | + echo '</td>'; |
|
719 | 719 | |
720 | - } |
|
720 | + } |
|
721 | 721 | |
722 | - echo '</tr>'; |
|
722 | + echo '</tr>'; |
|
723 | 723 | |
724 | - endforeach; |
|
725 | - ?> |
|
724 | + endforeach; |
|
725 | + ?> |
|
726 | 726 | |
727 | 727 | </tbody> |
728 | 728 | |
@@ -741,38 +741,38 @@ discard block |
||
741 | 741 | */ |
742 | 742 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
743 | 743 | |
744 | - // Fetch the subscription groups. |
|
745 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
746 | - |
|
747 | - if ( empty( $subscription_groups ) ) { |
|
748 | - return; |
|
749 | - } |
|
750 | - |
|
751 | - // Prepare table columns. |
|
752 | - $columns = apply_filters( |
|
753 | - 'getpaid_subscription_related_subscriptions_columns', |
|
754 | - array( |
|
755 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
756 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
757 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
758 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
759 | - 'item' => __( 'Items', 'invoicing' ), |
|
760 | - 'status' => __( 'Status', 'invoicing' ), |
|
761 | - ), |
|
762 | - $subscription |
|
763 | - ); |
|
764 | - |
|
765 | - if ( $subscription->get_status() == 'pending' ) { |
|
766 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
767 | - } |
|
768 | - |
|
769 | - $table_class = 'w-100 bg-white'; |
|
770 | - |
|
771 | - if ( ! is_admin() ) { |
|
772 | - $table_class = 'table table-bordered'; |
|
773 | - } |
|
774 | - |
|
775 | - ?> |
|
744 | + // Fetch the subscription groups. |
|
745 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
746 | + |
|
747 | + if ( empty( $subscription_groups ) ) { |
|
748 | + return; |
|
749 | + } |
|
750 | + |
|
751 | + // Prepare table columns. |
|
752 | + $columns = apply_filters( |
|
753 | + 'getpaid_subscription_related_subscriptions_columns', |
|
754 | + array( |
|
755 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
756 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
757 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
758 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
759 | + 'item' => __( 'Items', 'invoicing' ), |
|
760 | + 'status' => __( 'Status', 'invoicing' ), |
|
761 | + ), |
|
762 | + $subscription |
|
763 | + ); |
|
764 | + |
|
765 | + if ( $subscription->get_status() == 'pending' ) { |
|
766 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
767 | + } |
|
768 | + |
|
769 | + $table_class = 'w-100 bg-white'; |
|
770 | + |
|
771 | + if ( ! is_admin() ) { |
|
772 | + $table_class = 'table table-bordered'; |
|
773 | + } |
|
774 | + |
|
775 | + ?> |
|
776 | 776 | <div class="m-0" style="overflow: auto;"> |
777 | 777 | |
778 | 778 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -781,14 +781,14 @@ discard block |
||
781 | 781 | <tr> |
782 | 782 | <?php |
783 | 783 | |
784 | - foreach ( $columns as $key => $label ) { |
|
785 | - $key = esc_attr( $key ); |
|
786 | - $label = esc_html( $label ); |
|
787 | - $class = 'text-left'; |
|
784 | + foreach ( $columns as $key => $label ) { |
|
785 | + $key = esc_attr( $key ); |
|
786 | + $label = esc_html( $label ); |
|
787 | + $class = 'text-left'; |
|
788 | 788 | |
789 | - echo "<th class='related-subscription-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
790 | - } |
|
791 | - ?> |
|
789 | + echo "<th class='related-subscription-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
790 | + } |
|
791 | + ?> |
|
792 | 792 | </tr> |
793 | 793 | </thead> |
794 | 794 | |
@@ -796,74 +796,74 @@ discard block |
||
796 | 796 | |
797 | 797 | <?php |
798 | 798 | |
799 | - foreach ( $subscription_groups as $subscription_group ) : |
|
799 | + foreach ( $subscription_groups as $subscription_group ) : |
|
800 | 800 | |
801 | - // Do not list current subscription. |
|
802 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
803 | - continue; |
|
804 | - } |
|
801 | + // Do not list current subscription. |
|
802 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
803 | + continue; |
|
804 | + } |
|
805 | 805 | |
806 | - // Ensure the subscription exists. |
|
807 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
806 | + // Ensure the subscription exists. |
|
807 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
808 | 808 | |
809 | - if ( ! $_suscription->exists() ) { |
|
810 | - continue; |
|
811 | - } |
|
809 | + if ( ! $_suscription->exists() ) { |
|
810 | + continue; |
|
811 | + } |
|
812 | 812 | |
813 | - echo '<tr>'; |
|
813 | + echo '<tr>'; |
|
814 | 814 | |
815 | - foreach ( array_keys( $columns ) as $key ) { |
|
815 | + foreach ( array_keys( $columns ) as $key ) { |
|
816 | 816 | |
817 | - $class = 'text-left'; |
|
817 | + $class = 'text-left'; |
|
818 | 818 | |
819 | - echo "<td class='p-2 text-left'>"; |
|
819 | + echo "<td class='p-2 text-left'>"; |
|
820 | 820 | |
821 | - switch ( $key ) { |
|
821 | + switch ( $key ) { |
|
822 | 822 | |
823 | - case 'status': |
|
824 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
825 | - break; |
|
823 | + case 'status': |
|
824 | + echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
825 | + break; |
|
826 | 826 | |
827 | - case 'item': |
|
828 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
829 | - echo implode( ' | ', $markup ); |
|
830 | - break; |
|
827 | + case 'item': |
|
828 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
829 | + echo implode( ' | ', $markup ); |
|
830 | + break; |
|
831 | 831 | |
832 | - case 'renewals': |
|
833 | - $max_bills = $_suscription->get_bill_times(); |
|
834 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
835 | - break; |
|
832 | + case 'renewals': |
|
833 | + $max_bills = $_suscription->get_bill_times(); |
|
834 | + echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
835 | + break; |
|
836 | 836 | |
837 | - case 'renewal_date': |
|
838 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
839 | - break; |
|
837 | + case 'renewal_date': |
|
838 | + echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
839 | + break; |
|
840 | 840 | |
841 | - case 'start_date': |
|
842 | - echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
843 | - break; |
|
841 | + case 'start_date': |
|
842 | + echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
843 | + break; |
|
844 | 844 | |
845 | - case 'subscription': |
|
846 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
847 | - printf( |
|
845 | + case 'subscription': |
|
846 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
847 | + printf( |
|
848 | 848 | '%1$s#%2$s%3$s', |
849 | 849 | '<a href="' . esc_url( $url ) . '">', |
850 | 850 | '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
851 | - '</a>' |
|
851 | + '</a>' |
|
852 | 852 | ); |
853 | 853 | |
854 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
855 | - break; |
|
854 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
855 | + break; |
|
856 | 856 | |
857 | - } |
|
857 | + } |
|
858 | 858 | |
859 | - echo '</td>'; |
|
859 | + echo '</td>'; |
|
860 | 860 | |
861 | - } |
|
861 | + } |
|
862 | 862 | |
863 | - echo '</tr>'; |
|
863 | + echo '</tr>'; |
|
864 | 864 | |
865 | - endforeach; |
|
866 | - ?> |
|
865 | + endforeach; |
|
866 | + ?> |
|
867 | 867 | |
868 | 868 | </tbody> |
869 | 869 |
@@ -508,39 +508,39 @@ discard block |
||
508 | 508 | |
509 | 509 | switch ( $key ) { |
510 | 510 | |
511 | - case 'total': |
|
512 | - echo '<strong>'; |
|
513 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
514 | - echo '</strong>'; |
|
515 | - break; |
|
516 | - |
|
517 | - case 'relationship': |
|
518 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
519 | - break; |
|
520 | - |
|
521 | - case 'date': |
|
522 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
523 | - break; |
|
524 | - |
|
525 | - case 'status': |
|
526 | - $status = $payment->get_status_nicename(); |
|
527 | - if ( is_admin() ) { |
|
528 | - $status = $payment->get_status_label_html(); |
|
529 | - } |
|
530 | - |
|
531 | - echo wp_kses_post( $status ); |
|
532 | - break; |
|
533 | - |
|
534 | - case 'invoice': |
|
535 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
536 | - |
|
537 | - if ( ! is_admin() ) { |
|
538 | - $link = esc_url( $payment->get_view_url() ); |
|
539 | - } |
|
540 | - |
|
541 | - $invoice = esc_html( $payment->get_number() ); |
|
542 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
543 | - break; |
|
511 | + case 'total': |
|
512 | + echo '<strong>'; |
|
513 | + wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
514 | + echo '</strong>'; |
|
515 | + break; |
|
516 | + |
|
517 | + case 'relationship': |
|
518 | + echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
519 | + break; |
|
520 | + |
|
521 | + case 'date': |
|
522 | + echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
523 | + break; |
|
524 | + |
|
525 | + case 'status': |
|
526 | + $status = $payment->get_status_nicename(); |
|
527 | + if ( is_admin() ) { |
|
528 | + $status = $payment->get_status_label_html(); |
|
529 | + } |
|
530 | + |
|
531 | + echo wp_kses_post( $status ); |
|
532 | + break; |
|
533 | + |
|
534 | + case 'invoice': |
|
535 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
536 | + |
|
537 | + if ( ! is_admin() ) { |
|
538 | + $link = esc_url( $payment->get_view_url() ); |
|
539 | + } |
|
540 | + |
|
541 | + $invoice = esc_html( $payment->get_number() ); |
|
542 | + echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
543 | + break; |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | echo '</td>'; |
@@ -635,37 +635,37 @@ discard block |
||
635 | 635 | |
636 | 636 | switch ( $key ) { |
637 | 637 | |
638 | - case 'item_name': |
|
639 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
640 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
638 | + case 'item_name': |
|
639 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
640 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
641 | 641 | |
642 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
643 | - echo esc_html( $item_name ); |
|
644 | - } else { |
|
645 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
646 | - } |
|
642 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
643 | + echo esc_html( $item_name ); |
|
644 | + } else { |
|
645 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
646 | + } |
|
647 | 647 | |
648 | - break; |
|
648 | + break; |
|
649 | 649 | |
650 | - case 'price': |
|
651 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
652 | - break; |
|
650 | + case 'price': |
|
651 | + wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
652 | + break; |
|
653 | 653 | |
654 | - case 'tax': |
|
655 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
656 | - break; |
|
654 | + case 'tax': |
|
655 | + wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
656 | + break; |
|
657 | 657 | |
658 | - case 'discount': |
|
659 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
660 | - break; |
|
658 | + case 'discount': |
|
659 | + wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
660 | + break; |
|
661 | 661 | |
662 | - case 'initial': |
|
663 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
664 | - break; |
|
662 | + case 'initial': |
|
663 | + wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
664 | + break; |
|
665 | 665 | |
666 | - case 'recurring': |
|
667 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
668 | - break; |
|
666 | + case 'recurring': |
|
667 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
668 | + break; |
|
669 | 669 | |
670 | 670 | } |
671 | 671 | |
@@ -689,29 +689,29 @@ discard block |
||
689 | 689 | |
690 | 690 | switch ( $key ) { |
691 | 691 | |
692 | - case 'item_name': |
|
693 | - echo esc_html( $subscription_group_fee['name'] ); |
|
694 | - break; |
|
692 | + case 'item_name': |
|
693 | + echo esc_html( $subscription_group_fee['name'] ); |
|
694 | + break; |
|
695 | 695 | |
696 | - case 'price': |
|
697 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
698 | - break; |
|
696 | + case 'price': |
|
697 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
698 | + break; |
|
699 | 699 | |
700 | - case 'tax': |
|
701 | - echo '—'; |
|
702 | - break; |
|
700 | + case 'tax': |
|
701 | + echo '—'; |
|
702 | + break; |
|
703 | 703 | |
704 | - case 'discount': |
|
705 | - echo '—'; |
|
706 | - break; |
|
704 | + case 'discount': |
|
705 | + echo '—'; |
|
706 | + break; |
|
707 | 707 | |
708 | - case 'initial': |
|
709 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
710 | - break; |
|
708 | + case 'initial': |
|
709 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
710 | + break; |
|
711 | 711 | |
712 | - case 'recurring': |
|
713 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
714 | - break; |
|
712 | + case 'recurring': |
|
713 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
714 | + break; |
|
715 | 715 | |
716 | 716 | } |
717 | 717 | |
@@ -820,39 +820,39 @@ discard block |
||
820 | 820 | |
821 | 821 | switch ( $key ) { |
822 | 822 | |
823 | - case 'status': |
|
824 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
825 | - break; |
|
826 | - |
|
827 | - case 'item': |
|
828 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
829 | - echo implode( ' | ', $markup ); |
|
830 | - break; |
|
831 | - |
|
832 | - case 'renewals': |
|
833 | - $max_bills = $_suscription->get_bill_times(); |
|
834 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
835 | - break; |
|
836 | - |
|
837 | - case 'renewal_date': |
|
838 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
839 | - break; |
|
840 | - |
|
841 | - case 'start_date': |
|
842 | - echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
843 | - break; |
|
844 | - |
|
845 | - case 'subscription': |
|
846 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
847 | - printf( |
|
848 | - '%1$s#%2$s%3$s', |
|
849 | - '<a href="' . esc_url( $url ) . '">', |
|
850 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
851 | - '</a>' |
|
852 | - ); |
|
853 | - |
|
854 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
855 | - break; |
|
823 | + case 'status': |
|
824 | + echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
825 | + break; |
|
826 | + |
|
827 | + case 'item': |
|
828 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
829 | + echo implode( ' | ', $markup ); |
|
830 | + break; |
|
831 | + |
|
832 | + case 'renewals': |
|
833 | + $max_bills = $_suscription->get_bill_times(); |
|
834 | + echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
835 | + break; |
|
836 | + |
|
837 | + case 'renewal_date': |
|
838 | + echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
839 | + break; |
|
840 | + |
|
841 | + case 'start_date': |
|
842 | + echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
843 | + break; |
|
844 | + |
|
845 | + case 'subscription': |
|
846 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
847 | + printf( |
|
848 | + '%1$s#%2$s%3$s', |
|
849 | + '<a href="' . esc_url( $url ) . '">', |
|
850 | + '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
851 | + '</a>' |
|
852 | + ); |
|
853 | + |
|
854 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
855 | + break; |
|
856 | 856 | |
857 | 857 | } |
858 | 858 |
@@ -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,23 +17,23 @@ 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 | 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 | true |
34 | 34 | ); |
35 | 35 | |
36 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
36 | + } elseif (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
37 | 37 | |
38 | 38 | // Display a single subscription. |
39 | 39 | wpinv_recurring_subscription_details(); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | <?php $subscribers_table->views(); ?> |
68 | 68 | <form id="subscribers-filter" class="bsui" method="get"> |
69 | 69 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
70 | - <?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?> |
|
70 | + <?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?> |
|
71 | 71 | <?php $subscribers_table->display(); ?> |
72 | 72 | </form> |
73 | 73 | <?php |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | function wpinv_recurring_subscription_details() { |
84 | 84 | |
85 | 85 | // Fetch the subscription. |
86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
87 | - if ( ! $sub->exists() ) { |
|
86 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
87 | + if (!$sub->exists()) { |
|
88 | 88 | |
89 | 89 | aui()->alert( |
90 | 90 | array( |
91 | 91 | 'type' => 'danger', |
92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
92 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
93 | 93 | ), |
94 | 94 | true |
95 | 95 | ); |
@@ -98,32 +98,32 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | // Use metaboxes to display the subscription details. |
101 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
102 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
101 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
102 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
103 | 103 | |
104 | 104 | $subscription_id = $sub->get_id(); |
105 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
106 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
105 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
106 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
107 | 107 | |
108 | - if ( 1 < count( $subscription_groups ) ) { |
|
109 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
108 | + if (1 < count($subscription_groups)) { |
|
109 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
110 | 110 | } |
111 | 111 | |
112 | - if ( ! empty( $subscription_group ) ) { |
|
113 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
112 | + if (!empty($subscription_group)) { |
|
113 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
114 | 114 | } |
115 | 115 | |
116 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
116 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
117 | 117 | |
118 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
118 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
119 | 119 | |
120 | 120 | ?> |
121 | 121 | |
122 | - <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
|
122 | + <form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id()))); ?>"> |
|
123 | 123 | |
124 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
125 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
126 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
124 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
125 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
126 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
127 | 127 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
128 | 128 | <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
129 | 129 | |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
132 | 132 | |
133 | 133 | <div id="postbox-container-1" class="postbox-container"> |
134 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
134 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
135 | 135 | </div> |
136 | 136 | |
137 | 137 | <div id="postbox-container-2" class="postbox-container"> |
138 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
139 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
138 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
139 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
140 | 140 | </div> |
141 | 141 | |
142 | 142 | </div> |
@@ -155,43 +155,43 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @param WPInv_Subscription $sub |
157 | 157 | */ |
158 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
158 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
159 | 159 | |
160 | 160 | // Subscription items. |
161 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
162 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
161 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
162 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
163 | 163 | |
164 | 164 | // Prepare subscription detail columns. |
165 | 165 | $fields = apply_filters( |
166 | 166 | 'getpaid_subscription_admin_page_fields', |
167 | 167 | array( |
168 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
169 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
170 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
171 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
172 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
173 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
174 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
177 | - 'status' => __( 'Status', 'invoicing' ), |
|
168 | + 'subscription' => __('Subscription', 'invoicing'), |
|
169 | + 'customer' => __('Customer', 'invoicing'), |
|
170 | + 'amount' => __('Amount', 'invoicing'), |
|
171 | + 'start_date' => __('Start Date', 'invoicing'), |
|
172 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
173 | + 'renewals' => __('Payments', 'invoicing'), |
|
174 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
175 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
176 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
177 | + 'status' => __('Status', 'invoicing'), |
|
178 | 178 | ) |
179 | 179 | ); |
180 | 180 | |
181 | - if ( ! $sub->is_active() ) { |
|
181 | + if (!$sub->is_active()) { |
|
182 | 182 | |
183 | - if ( isset( $fields['renews_on'] ) ) { |
|
184 | - unset( $fields['renews_on'] ); |
|
183 | + if (isset($fields['renews_on'])) { |
|
184 | + unset($fields['renews_on']); |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( isset( $fields['gateway'] ) ) { |
|
188 | - unset( $fields['gateway'] ); |
|
187 | + if (isset($fields['gateway'])) { |
|
188 | + unset($fields['gateway']); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
192 | 192 | $profile_id = $sub->get_profile_id(); |
193 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
194 | - unset( $fields['profile_id'] ); |
|
193 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
194 | + unset($fields['profile_id']); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | ?> |
@@ -199,16 +199,16 @@ discard block |
||
199 | 199 | <table class="table table-borderless" style="font-size: 14px;"> |
200 | 200 | <tbody> |
201 | 201 | |
202 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
202 | + <?php foreach ($fields as $key => $label) : ?> |
|
203 | 203 | |
204 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
204 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
205 | 205 | |
206 | 206 | <th class="w-25" style="font-weight: 500;"> |
207 | - <?php echo esc_html( $label ); ?> |
|
207 | + <?php echo esc_html($label); ?> |
|
208 | 208 | </th> |
209 | 209 | |
210 | 210 | <td class="w-75 text-muted"> |
211 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?> |
|
211 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?> |
|
212 | 212 | </td> |
213 | 213 | |
214 | 214 | </tr> |
@@ -226,135 +226,135 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @param WPInv_Subscription $subscription |
228 | 228 | */ |
229 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
229 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
230 | 230 | |
231 | - $username = __( '(Missing User)', 'invoicing' ); |
|
231 | + $username = __('(Missing User)', 'invoicing'); |
|
232 | 232 | |
233 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
234 | - if ( $user ) { |
|
233 | + $user = get_userdata($subscription->get_customer_id()); |
|
234 | + if ($user) { |
|
235 | 235 | |
236 | 236 | $username = sprintf( |
237 | 237 | '<a href="user-edit.php?user_id=%s">%s</a>', |
238 | - absint( $user->ID ), |
|
239 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
238 | + absint($user->ID), |
|
239 | + !empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email) |
|
240 | 240 | ); |
241 | 241 | |
242 | 242 | } |
243 | 243 | |
244 | - echo wp_kses_post( $username ); |
|
244 | + echo wp_kses_post($username); |
|
245 | 245 | } |
246 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
246 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
247 | 247 | |
248 | 248 | /** |
249 | 249 | * Displays the subscription amount. |
250 | 250 | * |
251 | 251 | * @param WPInv_Subscription $subscription |
252 | 252 | */ |
253 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
254 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
255 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
253 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
254 | + $amount = getpaid_get_formatted_subscription_amount($subscription); |
|
255 | + echo wp_kses_post("<span>$amount</span>"); |
|
256 | 256 | } |
257 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
257 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Displays the subscription id. |
261 | 261 | * |
262 | 262 | * @param WPInv_Subscription $subscription |
263 | 263 | */ |
264 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
264 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
265 | 265 | |
266 | 266 | printf( |
267 | 267 | '<a href="%s">#%s</a>', |
268 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
269 | - absint( $subscription->get_id() ) |
|
268 | + esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))), |
|
269 | + absint($subscription->get_id()) |
|
270 | 270 | ); |
271 | 271 | |
272 | 272 | } |
273 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
273 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
274 | 274 | |
275 | 275 | /** |
276 | 276 | * Displays the subscription renewal date. |
277 | 277 | * |
278 | 278 | * @param WPInv_Subscription $subscription |
279 | 279 | */ |
280 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
281 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
280 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
281 | + echo esc_html(getpaid_format_date_value($subscription->get_date_created())); |
|
282 | 282 | } |
283 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
283 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
284 | 284 | |
285 | 285 | /** |
286 | 286 | * Displays the subscription renewal date. |
287 | 287 | * |
288 | 288 | * @param WPInv_Subscription $subscription |
289 | 289 | */ |
290 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
291 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
290 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
291 | + echo esc_html(getpaid_format_date_value($subscription->get_expiration())); |
|
292 | 292 | } |
293 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
293 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
294 | 294 | |
295 | 295 | /** |
296 | 296 | * Displays the subscription renewal count. |
297 | 297 | * |
298 | 298 | * @param WPInv_Subscription $subscription |
299 | 299 | */ |
300 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
300 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
301 | 301 | $max_bills = $subscription->get_bill_times(); |
302 | - echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
302 | + echo ((int) $subscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
303 | 303 | } |
304 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
304 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
305 | 305 | /** |
306 | 306 | * Displays the subscription item. |
307 | 307 | * |
308 | 308 | * @param WPInv_Subscription $subscription |
309 | 309 | * @param false|array $subscription_group |
310 | 310 | */ |
311 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
311 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
312 | 312 | |
313 | - if ( empty( $subscription_group ) ) { |
|
314 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
313 | + if (empty($subscription_group)) { |
|
314 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id())); |
|
315 | 315 | return; |
316 | 316 | } |
317 | 317 | |
318 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
319 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
318 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
319 | + echo wp_kses_post(implode(' | ', $markup)); |
|
320 | 320 | |
321 | 321 | } |
322 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
322 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
323 | 323 | |
324 | 324 | /** |
325 | 325 | * Displays the subscription gateway. |
326 | 326 | * |
327 | 327 | * @param WPInv_Subscription $subscription |
328 | 328 | */ |
329 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
329 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
330 | 330 | |
331 | 331 | $gateway = $subscription->get_gateway(); |
332 | 332 | |
333 | - if ( ! empty( $gateway ) ) { |
|
334 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
333 | + if (!empty($gateway)) { |
|
334 | + echo esc_html(wpinv_get_gateway_admin_label($gateway)); |
|
335 | 335 | } else { |
336 | 336 | echo '—'; |
337 | 337 | } |
338 | 338 | |
339 | 339 | } |
340 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
340 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
341 | 341 | |
342 | 342 | /** |
343 | 343 | * Displays the subscription status. |
344 | 344 | * |
345 | 345 | * @param WPInv_Subscription $subscription |
346 | 346 | */ |
347 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
348 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
347 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
348 | + echo wp_kses_post($subscription->get_status_label_html()); |
|
349 | 349 | } |
350 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
350 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
351 | 351 | |
352 | 352 | /** |
353 | 353 | * Displays the subscription profile id. |
354 | 354 | * |
355 | 355 | * @param WPInv_Subscription $subscription |
356 | 356 | */ |
357 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
357 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
358 | 358 | |
359 | 359 | $profile_id = $subscription->get_profile_id(); |
360 | 360 | |
@@ -363,30 +363,30 @@ discard block |
||
363 | 363 | 'type' => 'text', |
364 | 364 | 'id' => 'wpinv_subscription_profile_id', |
365 | 365 | 'name' => 'wpinv_subscription_profile_id', |
366 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
366 | + 'label' => __('Profile Id', 'invoicing'), |
|
367 | 367 | 'label_type' => 'hidden', |
368 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
369 | - 'value' => esc_attr( $profile_id ), |
|
368 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
369 | + 'value' => esc_attr($profile_id), |
|
370 | 370 | 'input_group_right' => '', |
371 | 371 | 'no_wrap' => true, |
372 | 372 | ), |
373 | 373 | true |
374 | 374 | ); |
375 | 375 | |
376 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
377 | - if ( ! empty( $url ) ) { |
|
378 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
376 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
377 | + if (!empty($url)) { |
|
378 | + echo ' <a href="' . esc_url_raw($url) . '" title="' . esc_attr__('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | } |
382 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
382 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
383 | 383 | |
384 | 384 | /** |
385 | 385 | * Displays the subscriptions update metabox. |
386 | 386 | * |
387 | 387 | * @param WPInv_Subscription $subscription |
388 | 388 | */ |
389 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
389 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
390 | 390 | |
391 | 391 | ?> |
392 | 392 | <div class="mt-3"> |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | 'id' => 'subscription_status_update_select', |
400 | 400 | 'required' => true, |
401 | 401 | 'no_wrap' => false, |
402 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
403 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
402 | + 'label' => __('Subscription Status', 'invoicing'), |
|
403 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
404 | 404 | 'select2' => true, |
405 | - 'value' => $subscription->get_status( 'edit' ), |
|
405 | + 'value' => $subscription->get_status('edit'), |
|
406 | 406 | ), |
407 | 407 | true |
408 | 408 | ); |
@@ -411,14 +411,14 @@ discard block |
||
411 | 411 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
412 | 412 | |
413 | 413 | <?php |
414 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
414 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
415 | 415 | |
416 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
417 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
418 | - $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' ); |
|
416 | + $url = wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'); |
|
417 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
418 | + $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'); |
|
419 | 419 | |
420 | - if ( $subscription->is_active() ) { |
|
421 | - echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
420 | + if ($subscription->is_active()) { |
|
421 | + echo "<a href='" . esc_url($url) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr($title) . "\")'>" . esc_html($anchor) . "</a>"; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | echo '</div></div>'; |
@@ -430,44 +430,44 @@ discard block |
||
430 | 430 | * @param WPInv_Subscription $subscription |
431 | 431 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
432 | 432 | */ |
433 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
433 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
434 | 434 | |
435 | 435 | $columns = apply_filters( |
436 | 436 | 'getpaid_subscription_related_invoices_columns', |
437 | 437 | array( |
438 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
439 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
440 | - 'date' => __( 'Date', 'invoicing' ), |
|
441 | - 'status' => __( 'Status', 'invoicing' ), |
|
442 | - 'total' => __( 'Total', 'invoicing' ), |
|
438 | + 'invoice' => __('Invoice', 'invoicing'), |
|
439 | + 'relationship' => __('Relationship', 'invoicing'), |
|
440 | + 'date' => __('Date', 'invoicing'), |
|
441 | + 'status' => __('Status', 'invoicing'), |
|
442 | + 'total' => __('Total', 'invoicing'), |
|
443 | 443 | ), |
444 | 444 | $subscription |
445 | 445 | ); |
446 | 446 | |
447 | 447 | // Prepare the invoices. |
448 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
448 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
449 | 449 | $parent = $subscription->get_parent_invoice(); |
450 | 450 | |
451 | - if ( $parent->exists() ) { |
|
452 | - $payments = array_merge( array( $parent ), $payments ); |
|
451 | + if ($parent->exists()) { |
|
452 | + $payments = array_merge(array($parent), $payments); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | $table_class = 'w-100 bg-white'; |
456 | 456 | |
457 | - if ( ! is_admin() ) { |
|
457 | + if (!is_admin()) { |
|
458 | 458 | $table_class = 'table table-bordered'; |
459 | 459 | } |
460 | 460 | |
461 | 461 | ?> |
462 | 462 | <div class="m-0" style="overflow: auto;"> |
463 | 463 | |
464 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
464 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
465 | 465 | |
466 | 466 | <thead> |
467 | 467 | <tr> |
468 | 468 | <?php |
469 | - foreach ( $columns as $key => $label ) { |
|
470 | - echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
469 | + foreach ($columns as $key => $label) { |
|
470 | + echo "<th class='subscription-invoice-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
471 | 471 | } |
472 | 472 | ?> |
473 | 473 | </tr> |
@@ -475,71 +475,71 @@ discard block |
||
475 | 475 | |
476 | 476 | <tbody> |
477 | 477 | |
478 | - <?php if ( empty( $payments ) ) : ?> |
|
478 | + <?php if (empty($payments)) : ?> |
|
479 | 479 | <tr> |
480 | - <td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted"> |
|
481 | - <?php esc_html_e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
480 | + <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
|
481 | + <?php esc_html_e('This subscription has no invoices.', 'invoicing'); ?> |
|
482 | 482 | </td> |
483 | 483 | </tr> |
484 | 484 | <?php endif; ?> |
485 | 485 | |
486 | 486 | <?php |
487 | 487 | |
488 | - foreach ( $payments as $payment ) : |
|
488 | + foreach ($payments as $payment) : |
|
489 | 489 | |
490 | 490 | // Ensure that we have an invoice. |
491 | - $payment = new WPInv_Invoice( $payment ); |
|
491 | + $payment = new WPInv_Invoice($payment); |
|
492 | 492 | |
493 | 493 | // Abort if the invoice is invalid... |
494 | - if ( ! $payment->exists() ) { |
|
494 | + if (!$payment->exists()) { |
|
495 | 495 | continue; |
496 | 496 | } |
497 | 497 | |
498 | 498 | // ... or belongs to a different subscription. |
499 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
499 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
500 | 500 | continue; |
501 | 501 | } |
502 | 502 | |
503 | 503 | echo '<tr>'; |
504 | 504 | |
505 | - foreach ( array_keys( $columns ) as $key ) { |
|
505 | + foreach (array_keys($columns) as $key) { |
|
506 | 506 | |
507 | 507 | echo "<td class='p-2 text-left'>"; |
508 | 508 | |
509 | - switch ( $key ) { |
|
509 | + switch ($key) { |
|
510 | 510 | |
511 | 511 | case 'total': |
512 | 512 | echo '<strong>'; |
513 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
513 | + wpinv_the_price($payment->get_total(), $payment->get_currency()); |
|
514 | 514 | echo '</strong>'; |
515 | 515 | break; |
516 | 516 | |
517 | 517 | case 'relationship': |
518 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
518 | + echo $payment->is_renewal() ? esc_html__('Renewal Invoice', 'invoicing') : esc_html__('Initial Invoice', 'invoicing'); |
|
519 | 519 | break; |
520 | 520 | |
521 | 521 | case 'date': |
522 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
522 | + echo esc_html(getpaid_format_date_value($payment->get_date_created())); |
|
523 | 523 | break; |
524 | 524 | |
525 | 525 | case 'status': |
526 | 526 | $status = $payment->get_status_nicename(); |
527 | - if ( is_admin() ) { |
|
527 | + if (is_admin()) { |
|
528 | 528 | $status = $payment->get_status_label_html(); |
529 | 529 | } |
530 | 530 | |
531 | - echo wp_kses_post( $status ); |
|
531 | + echo wp_kses_post($status); |
|
532 | 532 | break; |
533 | 533 | |
534 | 534 | case 'invoice': |
535 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
535 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
536 | 536 | |
537 | - if ( ! is_admin() ) { |
|
538 | - $link = esc_url( $payment->get_view_url() ); |
|
537 | + if (!is_admin()) { |
|
538 | + $link = esc_url($payment->get_view_url()); |
|
539 | 539 | } |
540 | 540 | |
541 | - $invoice = esc_html( $payment->get_number() ); |
|
542 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
541 | + $invoice = esc_html($payment->get_number()); |
|
542 | + echo wp_kses_post("<a href='$link'>$invoice</a>"); |
|
543 | 543 | break; |
544 | 544 | } |
545 | 545 | |
@@ -566,12 +566,12 @@ discard block |
||
566 | 566 | * |
567 | 567 | * @param WPInv_Subscription $subscription |
568 | 568 | */ |
569 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
569 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
570 | 570 | |
571 | 571 | // Fetch the subscription group. |
572 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
572 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
573 | 573 | |
574 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
574 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
575 | 575 | return; |
576 | 576 | } |
577 | 577 | |
@@ -579,12 +579,12 @@ discard block |
||
579 | 579 | $columns = apply_filters( |
580 | 580 | 'getpaid_subscription_item_details_columns', |
581 | 581 | array( |
582 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
583 | - 'price' => __( 'Price', 'invoicing' ), |
|
584 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
585 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
582 | + 'item_name' => __('Item', 'invoicing'), |
|
583 | + 'price' => __('Price', 'invoicing'), |
|
584 | + 'tax' => __('Tax', 'invoicing'), |
|
585 | + 'discount' => __('Discount', 'invoicing'), |
|
586 | 586 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
587 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
587 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
588 | 588 | ), |
589 | 589 | $subscription |
590 | 590 | ); |
@@ -593,27 +593,27 @@ discard block |
||
593 | 593 | |
594 | 594 | $invoice = $subscription->get_parent_invoice(); |
595 | 595 | |
596 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
597 | - unset( $columns['tax'] ); |
|
596 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
597 | + unset($columns['tax']); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | $table_class = 'w-100 bg-white'; |
601 | 601 | |
602 | - if ( ! is_admin() ) { |
|
602 | + if (!is_admin()) { |
|
603 | 603 | $table_class = 'table table-bordered'; |
604 | 604 | } |
605 | 605 | |
606 | 606 | ?> |
607 | 607 | <div class="m-0" style="overflow: auto;"> |
608 | 608 | |
609 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
609 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
610 | 610 | |
611 | 611 | <thead> |
612 | 612 | <tr> |
613 | 613 | <?php |
614 | 614 | |
615 | - foreach ( $columns as $key => $label ) { |
|
616 | - echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
615 | + foreach ($columns as $key => $label) { |
|
616 | + echo "<th class='subscription-item-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
617 | 617 | } |
618 | 618 | ?> |
619 | 619 | </tr> |
@@ -623,48 +623,48 @@ discard block |
||
623 | 623 | |
624 | 624 | <?php |
625 | 625 | |
626 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
626 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
627 | 627 | |
628 | 628 | echo '<tr>'; |
629 | 629 | |
630 | - foreach ( array_keys( $columns ) as $key ) { |
|
630 | + foreach (array_keys($columns) as $key) { |
|
631 | 631 | |
632 | 632 | $class = 'text-left'; |
633 | 633 | |
634 | 634 | echo "<td class='p-2 text-left'>"; |
635 | 635 | |
636 | - switch ( $key ) { |
|
636 | + switch ($key) { |
|
637 | 637 | |
638 | 638 | case 'item_name': |
639 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
640 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
639 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
640 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
641 | 641 | |
642 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
643 | - echo esc_html( $item_name ); |
|
642 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
643 | + echo esc_html($item_name); |
|
644 | 644 | } else { |
645 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
645 | + printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | break; |
649 | 649 | |
650 | 650 | case 'price': |
651 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
651 | + wpinv_the_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
652 | 652 | break; |
653 | 653 | |
654 | 654 | case 'tax': |
655 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
655 | + wpinv_the_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
656 | 656 | break; |
657 | 657 | |
658 | 658 | case 'discount': |
659 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
659 | + wpinv_the_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
660 | 660 | break; |
661 | 661 | |
662 | 662 | case 'initial': |
663 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
663 | + wpinv_the_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
664 | 664 | break; |
665 | 665 | |
666 | 666 | case 'recurring': |
667 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
667 | + echo wp_kses_post('<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'); |
|
668 | 668 | break; |
669 | 669 | |
670 | 670 | } |
@@ -677,24 +677,24 @@ discard block |
||
677 | 677 | |
678 | 678 | endforeach; |
679 | 679 | |
680 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
680 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
681 | 681 | |
682 | 682 | echo '<tr>'; |
683 | 683 | |
684 | - foreach ( array_keys( $columns ) as $key ) { |
|
684 | + foreach (array_keys($columns) as $key) { |
|
685 | 685 | |
686 | 686 | $class = 'text-left'; |
687 | 687 | |
688 | 688 | echo "<td class='p-2 text-left'>"; |
689 | 689 | |
690 | - switch ( $key ) { |
|
690 | + switch ($key) { |
|
691 | 691 | |
692 | 692 | case 'item_name': |
693 | - echo esc_html( $subscription_group_fee['name'] ); |
|
693 | + echo esc_html($subscription_group_fee['name']); |
|
694 | 694 | break; |
695 | 695 | |
696 | 696 | case 'price': |
697 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
697 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
698 | 698 | break; |
699 | 699 | |
700 | 700 | case 'tax': |
@@ -706,11 +706,11 @@ discard block |
||
706 | 706 | break; |
707 | 707 | |
708 | 708 | case 'initial': |
709 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
709 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
710 | 710 | break; |
711 | 711 | |
712 | 712 | case 'recurring': |
713 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
713 | + echo wp_kses_post('<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'); |
|
714 | 714 | break; |
715 | 715 | |
716 | 716 | } |
@@ -739,12 +739,12 @@ discard block |
||
739 | 739 | * @param WPInv_Subscription $subscription |
740 | 740 | * @param bool $skip_current |
741 | 741 | */ |
742 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
742 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
743 | 743 | |
744 | 744 | // Fetch the subscription groups. |
745 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
745 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
746 | 746 | |
747 | - if ( empty( $subscription_groups ) ) { |
|
747 | + if (empty($subscription_groups)) { |
|
748 | 748 | return; |
749 | 749 | } |
750 | 750 | |
@@ -752,38 +752,38 @@ discard block |
||
752 | 752 | $columns = apply_filters( |
753 | 753 | 'getpaid_subscription_related_subscriptions_columns', |
754 | 754 | array( |
755 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
756 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
757 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
758 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
759 | - 'item' => __( 'Items', 'invoicing' ), |
|
760 | - 'status' => __( 'Status', 'invoicing' ), |
|
755 | + 'subscription' => __('Subscription', 'invoicing'), |
|
756 | + 'start_date' => __('Start Date', 'invoicing'), |
|
757 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
758 | + 'renewals' => __('Payments', 'invoicing'), |
|
759 | + 'item' => __('Items', 'invoicing'), |
|
760 | + 'status' => __('Status', 'invoicing'), |
|
761 | 761 | ), |
762 | 762 | $subscription |
763 | 763 | ); |
764 | 764 | |
765 | - if ( $subscription->get_status() == 'pending' ) { |
|
766 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
765 | + if ($subscription->get_status() == 'pending') { |
|
766 | + unset($columns['start_date'], $columns['renewal_date']); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | $table_class = 'w-100 bg-white'; |
770 | 770 | |
771 | - if ( ! is_admin() ) { |
|
771 | + if (!is_admin()) { |
|
772 | 772 | $table_class = 'table table-bordered'; |
773 | 773 | } |
774 | 774 | |
775 | 775 | ?> |
776 | 776 | <div class="m-0" style="overflow: auto;"> |
777 | 777 | |
778 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
778 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
779 | 779 | |
780 | 780 | <thead> |
781 | 781 | <tr> |
782 | 782 | <?php |
783 | 783 | |
784 | - foreach ( $columns as $key => $label ) { |
|
785 | - $key = esc_attr( $key ); |
|
786 | - $label = esc_html( $label ); |
|
784 | + foreach ($columns as $key => $label) { |
|
785 | + $key = esc_attr($key); |
|
786 | + $label = esc_html($label); |
|
787 | 787 | $class = 'text-left'; |
788 | 788 | |
789 | 789 | echo "<th class='related-subscription-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
@@ -796,62 +796,62 @@ discard block |
||
796 | 796 | |
797 | 797 | <?php |
798 | 798 | |
799 | - foreach ( $subscription_groups as $subscription_group ) : |
|
799 | + foreach ($subscription_groups as $subscription_group) : |
|
800 | 800 | |
801 | 801 | // Do not list current subscription. |
802 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
802 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
803 | 803 | continue; |
804 | 804 | } |
805 | 805 | |
806 | 806 | // Ensure the subscription exists. |
807 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
807 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
808 | 808 | |
809 | - if ( ! $_suscription->exists() ) { |
|
809 | + if (!$_suscription->exists()) { |
|
810 | 810 | continue; |
811 | 811 | } |
812 | 812 | |
813 | 813 | echo '<tr>'; |
814 | 814 | |
815 | - foreach ( array_keys( $columns ) as $key ) { |
|
815 | + foreach (array_keys($columns) as $key) { |
|
816 | 816 | |
817 | 817 | $class = 'text-left'; |
818 | 818 | |
819 | 819 | echo "<td class='p-2 text-left'>"; |
820 | 820 | |
821 | - switch ( $key ) { |
|
821 | + switch ($key) { |
|
822 | 822 | |
823 | 823 | case 'status': |
824 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
824 | + echo wp_kses_post($_suscription->get_status_label_html()); |
|
825 | 825 | break; |
826 | 826 | |
827 | 827 | case 'item': |
828 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
829 | - echo implode( ' | ', $markup ); |
|
828 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
829 | + echo implode(' | ', $markup); |
|
830 | 830 | break; |
831 | 831 | |
832 | 832 | case 'renewals': |
833 | 833 | $max_bills = $_suscription->get_bill_times(); |
834 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
834 | + echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
835 | 835 | break; |
836 | 836 | |
837 | 837 | case 'renewal_date': |
838 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
838 | + echo $_suscription->is_active() ? getpaid_format_date_value($_suscription->get_expiration()) : '—'; |
|
839 | 839 | break; |
840 | 840 | |
841 | 841 | case 'start_date': |
842 | - echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
842 | + echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value($_suscription->get_date_created()); |
|
843 | 843 | break; |
844 | 844 | |
845 | 845 | case 'subscription': |
846 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
846 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
847 | 847 | printf( |
848 | 848 | '%1$s#%2$s%3$s', |
849 | - '<a href="' . esc_url( $url ) . '">', |
|
850 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
849 | + '<a href="' . esc_url($url) . '">', |
|
850 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
851 | 851 | '</a>' |
852 | 852 | ); |
853 | 853 | |
854 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
854 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::column_amount($_suscription)); |
|
855 | 855 | break; |
856 | 856 | |
857 | 857 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @var array $tax_rate |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | ?> |
12 | 12 | |
@@ -18,13 +18,13 @@ discard block |
||
18 | 18 | aui()->select( |
19 | 19 | array( |
20 | 20 | 'options' => array_merge( |
21 | - array( '' => __( 'All Countries', 'invoicing' ) ), |
|
21 | + array('' => __('All Countries', 'invoicing')), |
|
22 | 22 | wpinv_get_country_list() |
23 | 23 | ), |
24 | 24 | 'name' => "tax_rates[$key][country]", |
25 | - 'id' => uniqid( 'tax_rate_country' ), |
|
26 | - 'value' => esc_html( $tax_rate['country'] ), |
|
27 | - 'label' => __( 'Country', 'invoicing' ), |
|
25 | + 'id' => uniqid('tax_rate_country'), |
|
26 | + 'value' => esc_html($tax_rate['country']), |
|
27 | + 'label' => __('Country', 'invoicing'), |
|
28 | 28 | 'class' => 'wpinv_country', |
29 | 29 | 'no_wrap' => true, |
30 | 30 | ), |
@@ -37,35 +37,35 @@ discard block |
||
37 | 37 | <td class="wpinv_tax_state"> |
38 | 38 | |
39 | 39 | <label class="w-100"> |
40 | - <span class="screen-reader-text"><?php esc_html_e( 'States', 'invoicing' ); ?></span> |
|
41 | - <input type="text" placeholder="<?php esc_attr_e( 'Apply to whole country', 'invoicing' ); ?>" name="tax_rates[<?php echo esc_attr( $key ); ?>][state]" value="<?php echo empty( $tax_rate['global'] ) ? esc_attr( $tax_rate['state'] ) : ''; ?>"/> |
|
40 | + <span class="screen-reader-text"><?php esc_html_e('States', 'invoicing'); ?></span> |
|
41 | + <input type="text" placeholder="<?php esc_attr_e('Apply to whole country', 'invoicing'); ?>" name="tax_rates[<?php echo esc_attr($key); ?>][state]" value="<?php echo empty($tax_rate['global']) ? esc_attr($tax_rate['state']) : ''; ?>"/> |
|
42 | 42 | </label> |
43 | 43 | |
44 | 44 | </td> |
45 | 45 | |
46 | 46 | <td class="wpinv_standard_rate"> |
47 | 47 | <label class="w-100"> |
48 | - <span class="screen-reader-text"><?php esc_html_e( 'Standard Rate', 'invoicing' ); ?></span> |
|
49 | - <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ); ?>][rate]" value="<?php echo esc_attr( $tax_rate['rate'] ); ?>"/> |
|
48 | + <span class="screen-reader-text"><?php esc_html_e('Standard Rate', 'invoicing'); ?></span> |
|
49 | + <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key); ?>][rate]" value="<?php echo esc_attr($tax_rate['rate']); ?>"/> |
|
50 | 50 | </label> |
51 | 51 | </td> |
52 | 52 | |
53 | 53 | <td class="wpinv_reduced_rate"> |
54 | 54 | <label class="w-100"> |
55 | - <span class="screen-reader-text"><?php esc_html_e( 'Reduced Rate', 'invoicing' ); ?></span> |
|
56 | - <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ); ?>][reduced_rate]" value="<?php echo esc_attr( $tax_rate['reduced_rate'] ); ?>"/> |
|
55 | + <span class="screen-reader-text"><?php esc_html_e('Reduced Rate', 'invoicing'); ?></span> |
|
56 | + <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key); ?>][reduced_rate]" value="<?php echo esc_attr($tax_rate['reduced_rate']); ?>"/> |
|
57 | 57 | </label> |
58 | 58 | </td> |
59 | 59 | |
60 | 60 | <td class="wpinv_tax_name"> |
61 | 61 | <label class="w-100"> |
62 | - <span class="screen-reader-text"><?php esc_html_e( 'Tax Name', 'invoicing' ); ?></span> |
|
63 | - <input type="text" name="tax_rates[<?php echo esc_attr( $key ); ?>][name]" value="<?php echo esc_attr( $tax_rate['name'] ); ?>"/> |
|
62 | + <span class="screen-reader-text"><?php esc_html_e('Tax Name', 'invoicing'); ?></span> |
|
63 | + <input type="text" name="tax_rates[<?php echo esc_attr($key); ?>][name]" value="<?php echo esc_attr($tax_rate['name']); ?>"/> |
|
64 | 64 | </label> |
65 | 65 | </td> |
66 | 66 | |
67 | 67 | <td class="wpinv_tax_remove"> |
68 | - <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>" title="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>"> |
|
68 | + <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e('Delete', 'invoicing'); ?>" title="<?php esc_attr_e('Delete', 'invoicing'); ?>"> |
|
69 | 69 | <span aria-hidden="true">×</span> |
70 | 70 | </button> |
71 | 71 | </td> |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | $aui_settings = AyeCode_UI_Settings::instance(); |
10 | 10 | $aui_settings->enqueue_scripts(); |
@@ -17,15 +17,15 @@ discard block |
||
17 | 17 | <head> |
18 | 18 | <meta name="viewport" content="width=device-width"/> |
19 | 19 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> |
20 | - <title><?php esc_html_e( 'GetPaid › Setup Wizard', 'invoicing' ); ?></title> |
|
20 | + <title><?php esc_html_e('GetPaid › Setup Wizard', 'invoicing'); ?></title> |
|
21 | 21 | <?php |
22 | 22 | getpaid_admin()->enqeue_scripts(); |
23 | - wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' ); |
|
24 | - wp_print_styles( 'select2' ); |
|
25 | - wp_print_scripts( 'select2' ); |
|
26 | - wp_print_scripts( 'wpinv-admin-script' ); |
|
27 | - do_action( 'admin_print_styles' ); |
|
28 | - do_action( 'admin_head' ); |
|
23 | + wp_enqueue_style('font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0'); |
|
24 | + wp_print_styles('select2'); |
|
25 | + wp_print_scripts('select2'); |
|
26 | + wp_print_scripts('wpinv-admin-script'); |
|
27 | + do_action('admin_print_styles'); |
|
28 | + do_action('admin_head'); |
|
29 | 29 | ?> |
30 | 30 | <style> |
31 | 31 | body, p{ |
@@ -37,23 +37,23 @@ discard block |
||
37 | 37 | font-weight: 500; |
38 | 38 | margin-bottom: .1rem; |
39 | 39 | } |
40 | - <?php echo esc_html( $aui_settings::css_primary( '#009874', true ) ); ?> |
|
40 | + <?php echo esc_html($aui_settings::css_primary('#009874', true)); ?> |
|
41 | 41 | </style> |
42 | 42 | </head> |
43 | 43 | |
44 | 44 | <body class="gp-setup wp-core-ui bg-lightx mx-auto text-dark scrollbars-ios" style="background: #f3f6ff;"> |
45 | 45 | |
46 | - <?php if ( isset( $_REQUEST['step'] ) ) : ?> |
|
46 | + <?php if (isset($_REQUEST['step'])) : ?> |
|
47 | 47 | <ol class="gp-setup-steps mb-0 pb-4 mw-100 list-group list-group-horizontal text-center"> |
48 | - <?php foreach ( $steps as $step => $data ) : ?> |
|
48 | + <?php foreach ($steps as $step => $data) : ?> |
|
49 | 49 | <li class="list-group-item flex-fill rounded-0 |
50 | 50 | <?php |
51 | 51 | echo $step == $current ? 'active' : 'd-none d-md-block'; |
52 | - echo array_search( $current, array_keys( $steps ) ) > array_search( $step, array_keys( $steps ) ) ? ' done' : ''; |
|
52 | + echo array_search($current, array_keys($steps)) > array_search($step, array_keys($steps)) ? ' done' : ''; |
|
53 | 53 | ?> |
54 | 54 | "> |
55 | - <i class="far fa-check-circle <?php echo array_search( $current, array_keys( $steps ) ) > array_search( $step, array_keys( $steps ) ) ? 'text-success' : ''; ?>"></i> |
|
56 | - <?php echo esc_html( $data['name'] ); ?> |
|
55 | + <i class="far fa-check-circle <?php echo array_search($current, array_keys($steps)) > array_search($step, array_keys($steps)) ? 'text-success' : ''; ?>"></i> |
|
56 | + <?php echo esc_html($data['name']); ?> |
|
57 | 57 | </li> |
58 | 58 | <?php endforeach; ?> |
59 | 59 | </ol> |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | <div class="text-center pb-3 mt-5"> |
65 | 65 | <a class=" text-decoration-none" href="https://wpgetpaid.com/"> |
66 | 66 | <span class="text-black-50"> |
67 | - <img class="ml-n3x" src="<?php echo esc_url( WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png' ); ?>" /> |
|
67 | + <img class="ml-n3x" src="<?php echo esc_url(WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png'); ?>" /> |
|
68 | 68 | </span> |
69 | 69 | </a> |
70 | 70 | </div> |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | ?> |
10 | 10 | |
@@ -12,25 +12,25 @@ discard block |
||
12 | 12 | |
13 | 13 | <form method="post" class="text-center card-body"> |
14 | 14 | <div class="gp-wizard-payments"> |
15 | - <h2 class="gd-settings-title h3 "><?php esc_html_e( 'Gateway Setup', 'invoicing' ); ?></h2> |
|
16 | - <p><?php esc_html_e( 'Below are a few gateways that can be setup in a few seconds.', 'invoicing' ); ?> |
|
15 | + <h2 class="gd-settings-title h3 "><?php esc_html_e('Gateway Setup', 'invoicing'); ?></h2> |
|
16 | + <p><?php esc_html_e('Below are a few gateways that can be setup in a few seconds.', 'invoicing'); ?> |
|
17 | 17 | <br> |
18 | - <?php esc_html_e( 'We have 20+ Gateways that can be setup later.', 'invoicing' ); ?> |
|
18 | + <?php esc_html_e('We have 20+ Gateways that can be setup later.', 'invoicing'); ?> |
|
19 | 19 | </p> |
20 | 20 | |
21 | 21 | <ul class="list-group"> |
22 | 22 | |
23 | 23 | <li class="list-group-item d-flex justify-content-between align-items-center"> |
24 | - <span class="mr-auto"><img src="<?php echo esc_url( WPINV_PLUGIN_URL . 'assets/images/stripe-verified.svg' ); ?>" class="ml-n2" alt="Stripe"></span> |
|
25 | - <?php if ( false === wpinv_get_option( 'stripe_live_connect_account_id' ) ) : ?> |
|
24 | + <span class="mr-auto"><img src="<?php echo esc_url(WPINV_PLUGIN_URL . 'assets/images/stripe-verified.svg'); ?>" class="ml-n2" alt="Stripe"></span> |
|
25 | + <?php if (false === wpinv_get_option('stripe_live_connect_account_id')) : ?> |
|
26 | 26 | <a href=" |
27 | 27 | <?php |
28 | - echo esc_url( wp_nonce_url( |
|
28 | + echo esc_url(wp_nonce_url( |
|
29 | 29 | add_query_arg( |
30 | 30 | array( |
31 | 31 | 'getpaid-admin-action' => 'connect_gateway', |
32 | 32 | 'plugin' => 'stripe', |
33 | - 'redirect' => urlencode( add_query_arg( 'step', 'payments' ) ), |
|
33 | + 'redirect' => urlencode(add_query_arg('step', 'payments')), |
|
34 | 34 | ), |
35 | 35 | admin_url() |
36 | 36 | ), |
@@ -39,31 +39,31 @@ discard block |
||
39 | 39 | )); |
40 | 40 | ?> |
41 | 41 | " |
42 | - class="btn btn-sm btn-outline-primary"><?php esc_html_e( 'Connect', 'invoicing' ); ?></a> |
|
42 | + class="btn btn-sm btn-outline-primary"><?php esc_html_e('Connect', 'invoicing'); ?></a> |
|
43 | 43 | <?php else : ?> |
44 | - <span class="btn btn-sm btn-success"><?php esc_html_e( 'Connected', 'invoicing' ); ?></span> |
|
44 | + <span class="btn btn-sm btn-success"><?php esc_html_e('Connected', 'invoicing'); ?></span> |
|
45 | 45 | <?php endif; ?> |
46 | 46 | </li> |
47 | 47 | |
48 | 48 | <li class="list-group-item"> |
49 | 49 | <div class="d-flex justify-content-between align-items-center"> |
50 | 50 | <span class="mr-auto"> |
51 | - <img src="<?php echo esc_url( WPINV_PLUGIN_URL . 'assets/images/pp-logo-150px.webp' ); ?>" class="" alt="PayPal" height="25"> |
|
51 | + <img src="<?php echo esc_url(WPINV_PLUGIN_URL . 'assets/images/pp-logo-150px.webp'); ?>" class="" alt="PayPal" height="25"> |
|
52 | 52 | </span> |
53 | 53 | <a |
54 | 54 | href="#" |
55 | 55 | onclick="jQuery('.getpaid-setup-paypal-input').toggleClass('d-none'); return false;" |
56 | - class="getpaid-setup-paypal btn btn-sm btn-outline-primary"><?php esc_html_e( 'Set-up', 'invoicing' ); ?></a> |
|
56 | + class="getpaid-setup-paypal btn btn-sm btn-outline-primary"><?php esc_html_e('Set-up', 'invoicing'); ?></a> |
|
57 | 57 | </div> |
58 | 58 | <div class="mt-4 getpaid-setup-paypal-input d-none"> |
59 | - <input type="text" placeholder="<?php esc_attr_e( 'PayPal Email', 'invoicing' ); ?>" name="paypal-email" class="form-control" value="<?php echo esc_attr( wpinv_get_option( 'paypal_email' ) ); ?>"> |
|
59 | + <input type="text" placeholder="<?php esc_attr_e('PayPal Email', 'invoicing'); ?>" name="paypal-email" class="form-control" value="<?php echo esc_attr(wpinv_get_option('paypal_email')); ?>"> |
|
60 | 60 | </div> |
61 | 61 | </li> |
62 | 62 | |
63 | 63 | <li class="list-group-item d-flex justify-content-between align-items-center"> |
64 | - <span class="mr-auto"><?php esc_html_e( 'Test Gateway', 'invoicing' ); ?></span> |
|
64 | + <span class="mr-auto"><?php esc_html_e('Test Gateway', 'invoicing'); ?></span> |
|
65 | 65 | <div class="custom-control custom-switch"> |
66 | - <input type="checkbox" name="enable-manual-gateway" class="custom-control-input" id="enable-manual-gateway" <?php checked( wpinv_is_gateway_active( 'manual' ) ); ?>> |
|
66 | + <input type="checkbox" name="enable-manual-gateway" class="custom-control-input" id="enable-manual-gateway" <?php checked(wpinv_is_gateway_active('manual')); ?>> |
|
67 | 67 | <label class="custom-control-label" for="enable-manual-gateway"></label> |
68 | 68 | </div> |
69 | 69 | </li> |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | </div> |
73 | 73 | |
74 | 74 | <p class="gp-setup-actions step text-center mt-4"> |
75 | - <input type="submit" class="btn btn-primary" value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" /> |
|
75 | + <input type="submit" class="btn btn-primary" value="<?php esc_attr_e('Continue', 'invoicing'); ?>" /> |
|
76 | 76 | </p> |
77 | 77 | |
78 | - <?php getpaid_hidden_field( 'save_step', 1 ); ?> |
|
79 | - <?php wp_nonce_field( 'getpaid-setup-wizard', 'getpaid-setup-wizard' ); ?> |
|
78 | + <?php getpaid_hidden_field('save_step', 1); ?> |
|
79 | + <?php wp_nonce_field('getpaid-setup-wizard', 'getpaid-setup-wizard'); ?> |
|
80 | 80 | </form> |
81 | 81 | </div> |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | $tax_rates = GetPaid_Tax::get_all_tax_rates(); |
10 | 10 | $dummy_rate = array( |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | 'global' => true, |
14 | 14 | 'rate' => wpinv_get_default_tax_rate(), |
15 | 15 | 'reduced_rate' => 5, |
16 | - 'name' => __( 'VAT', 'invoicing' ), |
|
16 | + 'name' => __('VAT', 'invoicing'), |
|
17 | 17 | ); |
18 | 18 | |
19 | 19 | $reset_url = wp_nonce_url( |
20 | - add_query_arg( 'getpaid-admin-action', 'reset_tax_rates' ), |
|
20 | + add_query_arg('getpaid-admin-action', 'reset_tax_rates'), |
|
21 | 21 | 'getpaid-nonce', |
22 | 22 | 'getpaid-nonce' |
23 | 23 | ); |
@@ -25,34 +25,34 @@ discard block |
||
25 | 25 | ?> |
26 | 26 | <div class="table-responsive"> |
27 | 27 | <table id="wpinv_tax_rates" class="widefat fixed table"> |
28 | - <caption><?php echo esc_html_e( 'Enter tax rates for specific regions.', 'invoicing' ); ?></caption> |
|
28 | + <caption><?php echo esc_html_e('Enter tax rates for specific regions.', 'invoicing'); ?></caption> |
|
29 | 29 | |
30 | 30 | <thead> |
31 | 31 | <tr class="table-light"> |
32 | 32 | |
33 | 33 | <th scope="col" class="border-bottom border-top"> |
34 | - <?php esc_html_e( 'Country', 'invoicing' ); ?> |
|
35 | - <?php getpaid_get_help_tip( __( 'Optionally limit this tax rate to a specific country.', 'invoicing' ), 'position-static', true ); ?> |
|
34 | + <?php esc_html_e('Country', 'invoicing'); ?> |
|
35 | + <?php getpaid_get_help_tip(__('Optionally limit this tax rate to a specific country.', 'invoicing'), 'position-static', true); ?> |
|
36 | 36 | </th> |
37 | 37 | |
38 | 38 | <th scope="col" class="border-bottom border-top"> |
39 | - <?php esc_html_e( 'State', 'invoicing' ); ?> |
|
40 | - <?php getpaid_get_help_tip( __( 'Separate state codes using a comma or leave blank to apply country wide.', 'invoicing' ), 'position-static', true ); ?> |
|
39 | + <?php esc_html_e('State', 'invoicing'); ?> |
|
40 | + <?php getpaid_get_help_tip(__('Separate state codes using a comma or leave blank to apply country wide.', 'invoicing'), 'position-static', true); ?> |
|
41 | 41 | </th> |
42 | 42 | |
43 | 43 | <th scope="col" class="border-bottom border-top"> |
44 | - <?php esc_html_e( 'Standard Rate %', 'invoicing' ); ?> |
|
45 | - <?php getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing' ), 'position-static', true ); ?> |
|
44 | + <?php esc_html_e('Standard Rate %', 'invoicing'); ?> |
|
45 | + <?php getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing'), 'position-static', true); ?> |
|
46 | 46 | </th> |
47 | 47 | |
48 | 48 | <th scope="col" class="border-bottom border-top"> |
49 | - <?php esc_html_e( 'Reduced Rate %', 'invoicing' ); ?> |
|
50 | - <?php getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing' ), 'position-static', true ); ?> |
|
49 | + <?php esc_html_e('Reduced Rate %', 'invoicing'); ?> |
|
50 | + <?php getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing'), 'position-static', true); ?> |
|
51 | 51 | </th> |
52 | 52 | |
53 | 53 | <th scope="col" class="border-bottom border-top"> |
54 | - <?php esc_html_e( 'Tax Name', 'invoicing' ); ?> |
|
55 | - <?php getpaid_get_help_tip( __( 'The name of this tax, e.g VAT.', 'invoicing' ), 'position-static', true ); ?> |
|
54 | + <?php esc_html_e('Tax Name', 'invoicing'); ?> |
|
55 | + <?php getpaid_get_help_tip(__('The name of this tax, e.g VAT.', 'invoicing'), 'position-static', true); ?> |
|
56 | 56 | </th> |
57 | 57 | |
58 | 58 | <th scope="col" class="border-bottom border-top" style="width:32px"> </th> |
@@ -61,19 +61,19 @@ discard block |
||
61 | 61 | </thead> |
62 | 62 | |
63 | 63 | <tbody> |
64 | - <?php array_walk( $tax_rates, 'wpinv_tax_rate_callback' ); ?> |
|
64 | + <?php array_walk($tax_rates, 'wpinv_tax_rate_callback'); ?> |
|
65 | 65 | </tbody> |
66 | 66 | |
67 | 67 | <tfoot> |
68 | 68 | <tr class="table-light"> |
69 | 69 | <td colspan="6" class="border-top"> |
70 | 70 | |
71 | - <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e( 'Add Tax Rate', 'invoicing' ); ?>"> |
|
72 | - <span><?php esc_html_e( 'Add Tax Rate', 'invoicing' ); ?></span> |
|
71 | + <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e('Add Tax Rate', 'invoicing'); ?>"> |
|
72 | + <span><?php esc_html_e('Add Tax Rate', 'invoicing'); ?></span> |
|
73 | 73 | </button> |
74 | 74 | |
75 | - <a href="<?php echo esc_url( $reset_url ); ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e( 'Reset Tax Rates', 'invoicing' ); ?>"> |
|
76 | - <span><?php esc_html_e( 'Reset Tax Rates', 'invoicing' ); ?></span> |
|
75 | + <a href="<?php echo esc_url($reset_url); ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e('Reset Tax Rates', 'invoicing'); ?>"> |
|
76 | + <span><?php esc_html_e('Reset Tax Rates', 'invoicing'); ?></span> |
|
77 | 77 | </a> |
78 | 78 | </td> |
79 | 79 | </tr> |
@@ -82,6 +82,6 @@ discard block |
||
82 | 82 | </div> |
83 | 83 | |
84 | 84 | <script type="text/html" id="tmpl-wpinv-tax-rate-row"> |
85 | - <?php wpinv_tax_rate_callback( $dummy_rate, 0, true ); ?> |
|
85 | + <?php wpinv_tax_rate_callback($dummy_rate, 0, true); ?> |
|
86 | 86 | </script> |
87 | 87 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | global $wpinv_options; |
42 | 42 | |
43 | 43 | // Try fetching the saved options. |
44 | - if ( empty( $wpinv_options ) ) { |
|
45 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
44 | + if (empty($wpinv_options)) { |
|
45 | + $wpinv_options = get_option('wpinv_settings'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // If that fails, don't fetch the default settings to prevent a loop. |
49 | - if ( ! is_array( $wpinv_options ) ) { |
|
49 | + if (!is_array($wpinv_options)) { |
|
50 | 50 | $wpinv_options = array(); |
51 | 51 | } |
52 | 52 | |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * @param mixed $default The default value to use if the setting has not been set. |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | -function wpinv_get_option( $key = '', $default = false ) { |
|
63 | +function wpinv_get_option($key = '', $default = false) { |
|
64 | 64 | |
65 | 65 | $options = wpinv_get_options(); |
66 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
67 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
66 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
67 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
68 | 68 | |
69 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
69 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @param array $options the new options. |
76 | 76 | * @return bool |
77 | 77 | */ |
78 | -function wpinv_update_options( $options ) { |
|
78 | +function wpinv_update_options($options) { |
|
79 | 79 | global $wpinv_options; |
80 | 80 | |
81 | 81 | // update the option. |
82 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
82 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
83 | 83 | $wpinv_options = $options; |
84 | 84 | return true; |
85 | 85 | } |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | * @param mixed $value The setting value. |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | -function wpinv_update_option( $key = '', $value = false ) { |
|
97 | +function wpinv_update_option($key = '', $value = false) { |
|
98 | 98 | |
99 | 99 | // If no key, exit. |
100 | - if ( empty( $key ) ) { |
|
100 | + if (empty($key)) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // Maybe delete the option instead. |
105 | - if ( is_null( $value ) ) { |
|
106 | - return wpinv_delete_option( $key ); |
|
105 | + if (is_null($value)) { |
|
106 | + return wpinv_delete_option($key); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Prepare the new options. |
110 | 110 | $options = wpinv_get_options(); |
111 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
111 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
112 | 112 | |
113 | 113 | // Save the new options. |
114 | - return wpinv_update_options( $options ); |
|
114 | + return wpinv_update_options($options); |
|
115 | 115 | |
116 | 116 | } |
117 | 117 | |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * @param string $key the setting key. |
122 | 122 | * @return bool |
123 | 123 | */ |
124 | -function wpinv_delete_option( $key = '' ) { |
|
124 | +function wpinv_delete_option($key = '') { |
|
125 | 125 | |
126 | 126 | // If no key, exit |
127 | - if ( empty( $key ) ) { |
|
127 | + if (empty($key)) { |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
131 | 131 | $options = wpinv_get_options(); |
132 | 132 | |
133 | - if ( isset( $options[ $key ] ) ) { |
|
134 | - unset( $options[ $key ] ); |
|
135 | - return wpinv_update_options( $options ); |
|
133 | + if (isset($options[$key])) { |
|
134 | + unset($options[$key]); |
|
135 | + return wpinv_update_options($options); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return true; |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | function wpinv_register_settings() { |
147 | 147 | |
148 | 148 | // Loop through all tabs. |
149 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
149 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
150 | 150 | |
151 | 151 | // In each tab, loop through sections. |
152 | - foreach ( $sections as $section => $settings ) { |
|
152 | + foreach ($sections as $section => $settings) { |
|
153 | 153 | |
154 | 154 | // Check for backwards compatibility |
155 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
156 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
155 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
156 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
157 | 157 | $section = 'main'; |
158 | 158 | $settings = $sections; |
159 | 159 | } |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | 'wpinv_settings_' . $tab . '_' . $section |
167 | 167 | ); |
168 | 168 | |
169 | - foreach ( $settings as $option ) { |
|
170 | - if ( ! empty( $option['id'] ) ) { |
|
171 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
169 | + foreach ($settings as $option) { |
|
170 | + if (!empty($option['id'])) { |
|
171 | + wpinv_register_settings_option($tab, $section, $option); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | 177 | // Creates our settings in the options table. |
178 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
178 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
179 | 179 | } |
180 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
180 | +add_action('admin_init', 'wpinv_register_settings'); |
|
181 | 181 | |
182 | 182 | /** |
183 | 183 | * Register a single settings option. |
@@ -187,49 +187,49 @@ discard block |
||
187 | 187 | * @param string $option |
188 | 188 | * |
189 | 189 | */ |
190 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
190 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
191 | 191 | |
192 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
192 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
193 | 193 | $cb = "wpinv_{$option['type']}_callback"; |
194 | 194 | $section = "wpinv_settings_{$tab}_$section"; |
195 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
195 | + $is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page']; |
|
196 | 196 | |
197 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
198 | - $tip = wpinv_clean( $option['desc'] ); |
|
197 | + if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) { |
|
198 | + $tip = wpinv_clean($option['desc']); |
|
199 | 199 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
200 | - unset( $option['desc'] ); |
|
200 | + unset($option['desc']); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | // Loop through all tabs. |
204 | 204 | add_settings_field( |
205 | 205 | 'wpinv_settings[' . $option['id'] . ']', |
206 | 206 | $name, |
207 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
207 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
208 | 208 | $section, |
209 | 209 | $section, |
210 | 210 | array( |
211 | 211 | 'section' => $section, |
212 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
213 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
212 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
213 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
214 | 214 | 'name' => $name, |
215 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
216 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
217 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
218 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
219 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
220 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
221 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
222 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
223 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
224 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
225 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
226 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
227 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
228 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
229 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
230 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
231 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
215 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
216 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
217 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
218 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
219 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
220 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
221 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
222 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
223 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
224 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
225 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
226 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
227 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
228 | + 'default_content' => isset($option['default_content']) ? $option['default_content'] : '', |
|
229 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
230 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
231 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
233 | 233 | ) |
234 | 234 | ); |
235 | 235 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return array |
242 | 242 | */ |
243 | 243 | function wpinv_get_registered_settings() { |
244 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
244 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @return array |
251 | 251 | */ |
252 | 252 | function getpaid_get_integration_settings() { |
253 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
253 | + return apply_filters('getpaid_integration_settings', array()); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -258,126 +258,126 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return array |
260 | 260 | */ |
261 | -function wpinv_settings_sanitize( $input = array() ) { |
|
261 | +function wpinv_settings_sanitize($input = array()) { |
|
262 | 262 | |
263 | 263 | $wpinv_options = wpinv_get_options(); |
264 | 264 | $raw_referrer = wp_get_raw_referer(); |
265 | 265 | |
266 | - if ( empty( $raw_referrer ) ) { |
|
267 | - return array_merge( $wpinv_options, $input ); |
|
266 | + if (empty($raw_referrer)) { |
|
267 | + return array_merge($wpinv_options, $input); |
|
268 | 268 | } |
269 | 269 | |
270 | - wp_parse_str( $raw_referrer, $referrer ); |
|
270 | + wp_parse_str($raw_referrer, $referrer); |
|
271 | 271 | |
272 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
273 | - return array_merge( $wpinv_options, $input ); |
|
272 | + if (in_array('gp-setup', $referrer)) { |
|
273 | + return array_merge($wpinv_options, $input); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | $settings = wpinv_get_registered_settings(); |
277 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
278 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
277 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
278 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
279 | 279 | |
280 | 280 | $input = $input ? $input : array(); |
281 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
282 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
281 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
282 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
283 | 283 | |
284 | 284 | // Loop through each setting being saved and pass it through a sanitization filter |
285 | - foreach ( $input as $key => $value ) { |
|
285 | + foreach ($input as $key => $value) { |
|
286 | 286 | |
287 | 287 | // Get the setting type (checkbox, select, etc) |
288 | - $type = isset( $settings[ $tab ][ $section ][ $key ]['type'] ) ? $settings[ $tab ][ $section ][ $key ]['type'] : false; |
|
288 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
289 | 289 | |
290 | - if ( $type ) { |
|
290 | + if ($type) { |
|
291 | 291 | // Field type specific filter |
292 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key ); |
|
292 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | // General filter |
296 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
296 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
297 | 297 | |
298 | 298 | // Key specific filter. |
299 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
299 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | // Loop through the whitelist and unset any that are empty for the tab being saved |
303 | - $main_settings = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
304 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
303 | + $main_settings = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
304 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
305 | 305 | |
306 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
306 | + $found_settings = array_merge($main_settings, $section_settings); |
|
307 | 307 | |
308 | - if ( ! empty( $found_settings ) ) { |
|
309 | - foreach ( $found_settings as $key => $value ) { |
|
308 | + if (!empty($found_settings)) { |
|
309 | + foreach ($found_settings as $key => $value) { |
|
310 | 310 | |
311 | 311 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
312 | - if ( is_numeric( $key ) ) { |
|
312 | + if (is_numeric($key)) { |
|
313 | 313 | $key = $value['id']; |
314 | 314 | } |
315 | 315 | |
316 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
317 | - unset( $wpinv_options[ $key ] ); |
|
316 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
317 | + unset($wpinv_options[$key]); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Merge our new settings with the existing |
323 | - $output = array_merge( $wpinv_options, $input ); |
|
323 | + $output = array_merge($wpinv_options, $input); |
|
324 | 324 | |
325 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
325 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
326 | 326 | |
327 | 327 | return $output; |
328 | 328 | } |
329 | -add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 ); |
|
330 | -add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' ); |
|
329 | +add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1); |
|
330 | +add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount'); |
|
331 | 331 | |
332 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
333 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
332 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
333 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
334 | 334 | return $input; |
335 | 335 | } |
336 | 336 | |
337 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array(); |
|
337 | + $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array(); |
|
338 | 338 | $tax_rates = array(); |
339 | 339 | |
340 | - foreach ( $new_rates as $rate ) { |
|
340 | + foreach ($new_rates as $rate) { |
|
341 | 341 | |
342 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
343 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
344 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
345 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
346 | - $rate['global'] = empty( $rate['state'] ); |
|
342 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
343 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
344 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
345 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
346 | + $rate['global'] = empty($rate['state']); |
|
347 | 347 | $tax_rates[] = $rate; |
348 | 348 | |
349 | 349 | } |
350 | 350 | |
351 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
351 | + update_option('wpinv_tax_rates', $tax_rates); |
|
352 | 352 | |
353 | 353 | return $input; |
354 | 354 | } |
355 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
355 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
356 | 356 | |
357 | 357 | function wpinv_get_settings_tabs() { |
358 | 358 | $tabs = array(); |
359 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
360 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
361 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
362 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
359 | + $tabs['general'] = __('General', 'invoicing'); |
|
360 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
361 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
362 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
363 | 363 | |
364 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
365 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
364 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
365 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
366 | 366 | } |
367 | 367 | |
368 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
369 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
370 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
368 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
369 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
370 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
371 | 371 | |
372 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
372 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
373 | 373 | } |
374 | 374 | |
375 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
375 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
376 | 376 | $tabs = false; |
377 | 377 | $sections = wpinv_get_registered_settings_sections(); |
378 | 378 | |
379 | - if ( $tab && ! empty( $sections[ $tab ] ) ) { |
|
380 | - $tabs = $sections[ $tab ]; |
|
379 | + if ($tab && !empty($sections[$tab])) { |
|
380 | + $tabs = $sections[$tab]; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | return $tabs; |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | function wpinv_get_registered_settings_sections() { |
387 | 387 | static $sections = false; |
388 | 388 | |
389 | - if ( false !== $sections ) { |
|
389 | + if (false !== $sections) { |
|
390 | 390 | return $sections; |
391 | 391 | } |
392 | 392 | |
@@ -394,230 +394,230 @@ discard block |
||
394 | 394 | 'general' => apply_filters( |
395 | 395 | 'wpinv_settings_sections_general', |
396 | 396 | array( |
397 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
398 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
399 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
400 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
397 | + 'main' => __('General Settings', 'invoicing'), |
|
398 | + 'page_section' => __('Page Settings', 'invoicing'), |
|
399 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
400 | + 'labels' => __('Label Texts', 'invoicing'), |
|
401 | 401 | ) |
402 | 402 | ), |
403 | 403 | 'gateways' => apply_filters( |
404 | 404 | 'wpinv_settings_sections_gateways', |
405 | 405 | array( |
406 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
406 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
407 | 407 | ) |
408 | 408 | ), |
409 | 409 | 'taxes' => apply_filters( |
410 | 410 | 'wpinv_settings_sections_taxes', |
411 | 411 | array( |
412 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
413 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
414 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
412 | + 'main' => __('Tax Settings', 'invoicing'), |
|
413 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
414 | + 'vat' => __('EU VAT Settings', 'invoicing'), |
|
415 | 415 | ) |
416 | 416 | ), |
417 | 417 | 'emails' => apply_filters( |
418 | 418 | 'wpinv_settings_sections_emails', |
419 | 419 | array( |
420 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
420 | + 'main' => __('Email Settings', 'invoicing'), |
|
421 | 421 | ) |
422 | 422 | ), |
423 | 423 | |
424 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
424 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
425 | 425 | |
426 | 426 | 'privacy' => apply_filters( |
427 | 427 | 'wpinv_settings_sections_privacy', |
428 | 428 | array( |
429 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
429 | + 'main' => __('Privacy policy', 'invoicing'), |
|
430 | 430 | ) |
431 | 431 | ), |
432 | 432 | 'misc' => apply_filters( |
433 | 433 | 'wpinv_settings_sections_misc', |
434 | 434 | array( |
435 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
436 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
435 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
436 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
437 | 437 | ) |
438 | 438 | ), |
439 | 439 | 'tools' => apply_filters( |
440 | 440 | 'wpinv_settings_sections_tools', |
441 | 441 | array( |
442 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
442 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
443 | 443 | ) |
444 | 444 | ), |
445 | 445 | ); |
446 | 446 | |
447 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
447 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
448 | 448 | |
449 | 449 | return $sections; |
450 | 450 | } |
451 | 451 | |
452 | -function wpinv_get_pages( $with_slug = false, $default_label = null ) { |
|
452 | +function wpinv_get_pages($with_slug = false, $default_label = null) { |
|
453 | 453 | $pages_options = array(); |
454 | 454 | |
455 | - if ( $default_label !== null && $default_label !== false ) { |
|
456 | - $pages_options = array( '' => $default_label ); // Blank option |
|
455 | + if ($default_label !== null && $default_label !== false) { |
|
456 | + $pages_options = array('' => $default_label); // Blank option |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | $pages = get_pages(); |
460 | - if ( $pages ) { |
|
461 | - foreach ( $pages as $page ) { |
|
460 | + if ($pages) { |
|
461 | + foreach ($pages as $page) { |
|
462 | 462 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
463 | - $pages_options[ $page->ID ] = $title; |
|
463 | + $pages_options[$page->ID] = $title; |
|
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | 467 | return $pages_options; |
468 | 468 | } |
469 | 469 | |
470 | -function wpinv_header_callback( $args ) { |
|
471 | - if ( ! empty( $args['desc'] ) ) { |
|
472 | - echo wp_kses_post( $args['desc'] ); |
|
470 | +function wpinv_header_callback($args) { |
|
471 | + if (!empty($args['desc'])) { |
|
472 | + echo wp_kses_post($args['desc']); |
|
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
476 | -function wpinv_hidden_callback( $args ) { |
|
476 | +function wpinv_hidden_callback($args) { |
|
477 | 477 | |
478 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
479 | - $value = wpinv_get_option( $args['id'], $std ); |
|
478 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
479 | + $value = wpinv_get_option($args['id'], $std); |
|
480 | 480 | |
481 | - if ( isset( $args['set_value'] ) ) { |
|
481 | + if (isset($args['set_value'])) { |
|
482 | 482 | $value = $args['set_value']; |
483 | 483 | } |
484 | 484 | |
485 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
485 | + if (isset($args['faux']) && true === $args['faux']) { |
|
486 | 486 | $args['readonly'] = true; |
487 | - $name = ''; |
|
487 | + $name = ''; |
|
488 | 488 | } else { |
489 | - $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']'; |
|
489 | + $name = 'wpinv_settings[' . esc_attr($args['id']) . ']'; |
|
490 | 490 | } |
491 | 491 | |
492 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
492 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" name="' . esc_attr($name) . '" value="' . esc_attr(stripslashes($value)) . '" />'; |
|
493 | 493 | |
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
497 | 497 | * Displays a checkbox settings callback. |
498 | 498 | */ |
499 | -function wpinv_checkbox_callback( $args ) { |
|
499 | +function wpinv_checkbox_callback($args) { |
|
500 | 500 | |
501 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
502 | - $std = wpinv_get_option( $args['id'], $std ); |
|
503 | - $id = esc_attr( $args['id'] ); |
|
501 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
502 | + $std = wpinv_get_option($args['id'], $std); |
|
503 | + $id = esc_attr($args['id']); |
|
504 | 504 | |
505 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
505 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
506 | 506 | ?> |
507 | 507 | <fieldset> |
508 | 508 | <label> |
509 | - <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
|
510 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
509 | + <input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox"> |
|
510 | + <?php echo wp_kses_post($args['desc']); ?> |
|
511 | 511 | </label> |
512 | 512 | </fieldset> |
513 | 513 | <?php |
514 | 514 | } |
515 | 515 | |
516 | -function wpinv_multicheck_callback( $args ) { |
|
516 | +function wpinv_multicheck_callback($args) { |
|
517 | 517 | |
518 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
519 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
518 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
519 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
520 | 520 | |
521 | - if ( ! empty( $args['options'] ) ) { |
|
521 | + if (!empty($args['options'])) { |
|
522 | 522 | |
523 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
524 | - $value = wpinv_get_option( $args['id'], $std ); |
|
523 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
524 | + $value = wpinv_get_option($args['id'], $std); |
|
525 | 525 | |
526 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">'; |
|
527 | - foreach ( $args['options'] as $key => $option ) : |
|
528 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
529 | - if ( in_array( $sanitize_key, $value ) ) { |
|
526 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr($sanitize_id . $class) . '">'; |
|
527 | + foreach ($args['options'] as $key => $option) : |
|
528 | + $sanitize_key = esc_attr(wpinv_sanitize_key($key)); |
|
529 | + if (in_array($sanitize_key, $value)) { |
|
530 | 530 | $enabled = $sanitize_key; |
531 | 531 | } else { |
532 | 532 | $enabled = null; |
533 | 533 | } |
534 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
535 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
534 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
535 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']">' . wp_kses_post($option) . '</label></div>'; |
|
536 | 536 | endforeach; |
537 | 537 | echo '</div>'; |
538 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
538 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
539 | 539 | } |
540 | 540 | } |
541 | 541 | |
542 | -function wpinv_payment_icons_callback( $args ) { |
|
542 | +function wpinv_payment_icons_callback($args) { |
|
543 | 543 | |
544 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
545 | - $value = wpinv_get_option( $args['id'], false ); |
|
544 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
545 | + $value = wpinv_get_option($args['id'], false); |
|
546 | 546 | |
547 | - if ( ! empty( $args['options'] ) ) { |
|
548 | - foreach ( $args['options'] as $key => $option ) { |
|
549 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
547 | + if (!empty($args['options'])) { |
|
548 | + foreach ($args['options'] as $key => $option) { |
|
549 | + $sanitize_key = wpinv_sanitize_key($key); |
|
550 | 550 | |
551 | - if ( empty( $value ) ) { |
|
551 | + if (empty($value)) { |
|
552 | 552 | $enabled = $option; |
553 | 553 | } else { |
554 | 554 | $enabled = null; |
555 | 555 | } |
556 | 556 | |
557 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
557 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
558 | 558 | |
559 | - echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
559 | + echo '<input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
560 | 560 | |
561 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
562 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
561 | + if (wpinv_string_is_image_url($key)) { |
|
562 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
563 | 563 | } else { |
564 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
564 | + $card = strtolower(str_replace(' ', '', $option)); |
|
565 | 565 | |
566 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
567 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
566 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
567 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
568 | 568 | } else { |
569 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
569 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
570 | 570 | $content_dir = WP_CONTENT_DIR; |
571 | 571 | |
572 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
572 | + if (function_exists('wp_normalize_path')) { |
|
573 | 573 | // Replaces backslashes with forward slashes for Windows systems |
574 | - $image = wp_normalize_path( $image ); |
|
575 | - $content_dir = wp_normalize_path( $content_dir ); |
|
574 | + $image = wp_normalize_path($image); |
|
575 | + $content_dir = wp_normalize_path($content_dir); |
|
576 | 576 | } |
577 | 577 | |
578 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
578 | + $image = str_replace($content_dir, content_url(), $image); |
|
579 | 579 | } |
580 | 580 | |
581 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
581 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
582 | 582 | } |
583 | - echo wp_kses_post( $option ) . '</label>'; |
|
583 | + echo wp_kses_post($option) . '</label>'; |
|
584 | 584 | } |
585 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
585 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
586 | 586 | } |
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
590 | 590 | * Displays a radio settings field. |
591 | 591 | */ |
592 | -function wpinv_radio_callback( $args ) { |
|
592 | +function wpinv_radio_callback($args) { |
|
593 | 593 | |
594 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
595 | - $std = wpinv_get_option( $args['id'], $std ); |
|
594 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
595 | + $std = wpinv_get_option($args['id'], $std); |
|
596 | 596 | ?> |
597 | 597 | <fieldset> |
598 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
599 | - <?php foreach ( $args['options'] as $key => $option ) : ?> |
|
598 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
599 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
600 | 600 | <li> |
601 | 601 | <label> |
602 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
603 | - <?php echo wp_kses_post( $option ); ?> |
|
602 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
603 | + <?php echo wp_kses_post($option); ?> |
|
604 | 604 | </label> |
605 | 605 | </li> |
606 | 606 | <?php endforeach; ?> |
607 | 607 | </ul> |
608 | 608 | </fieldset> |
609 | 609 | <?php |
610 | - getpaid_settings_description_callback( $args ); |
|
610 | + getpaid_settings_description_callback($args); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
614 | 614 | * Displays a description if available. |
615 | 615 | */ |
616 | -function getpaid_settings_description_callback( $args ) { |
|
616 | +function getpaid_settings_description_callback($args) { |
|
617 | 617 | |
618 | - if ( ! empty( $args['desc'] ) ) { |
|
618 | + if (!empty($args['desc'])) { |
|
619 | 619 | $description = $args['desc']; |
620 | - echo wp_kses_post( "<p class='description'>$description</p>" ); |
|
620 | + echo wp_kses_post("<p class='description'>$description</p>"); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | } |
@@ -632,35 +632,35 @@ discard block |
||
632 | 632 | </tr> |
633 | 633 | <tr class="bsui"> |
634 | 634 | <td colspan="2" class="p-0"> |
635 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?> |
|
635 | + <?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?> |
|
636 | 636 | |
637 | 637 | <?php |
638 | 638 | } |
639 | 639 | |
640 | -function wpinv_gateway_select_callback( $args ) { |
|
640 | +function wpinv_gateway_select_callback($args) { |
|
641 | 641 | |
642 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
643 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
644 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
645 | - $value = wpinv_get_option( $args['id'], $std ); |
|
642 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
643 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
644 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
645 | + $value = wpinv_get_option($args['id'], $std); |
|
646 | 646 | |
647 | - echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >'; |
|
647 | + echo '<select name="wpinv_settings[' . esc_attr($sanitize_id) . ']"" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" class="' . esc_attr($class) . '" >'; |
|
648 | 648 | |
649 | - foreach ( $args['options'] as $key => $option ) : |
|
649 | + foreach ($args['options'] as $key => $option) : |
|
650 | 650 | |
651 | - echo '<option value="' . esc_attr( $key ) . '" '; |
|
651 | + echo '<option value="' . esc_attr($key) . '" '; |
|
652 | 652 | |
653 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
654 | - selected( $key, $args['selected'] ); |
|
653 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
654 | + selected($key, $args['selected']); |
|
655 | 655 | } else { |
656 | - selected( $key, $value ); |
|
656 | + selected($key, $value); |
|
657 | 657 | } |
658 | 658 | |
659 | - echo '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
659 | + echo '>' . esc_html($option['admin_label']) . '</option>'; |
|
660 | 660 | endforeach; |
661 | 661 | |
662 | 662 | echo '</select>'; |
663 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
663 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -669,16 +669,16 @@ discard block |
||
669 | 669 | * @param array $args |
670 | 670 | * @return string |
671 | 671 | */ |
672 | -function wpinv_settings_attrs_helper( $args ) { |
|
672 | +function wpinv_settings_attrs_helper($args) { |
|
673 | 673 | |
674 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
675 | - $id = esc_attr( $args['id'] ); |
|
676 | - $value = is_scalar( $value ) ? $value : ''; |
|
674 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
675 | + $id = esc_attr($args['id']); |
|
676 | + $value = is_scalar($value) ? $value : ''; |
|
677 | 677 | |
678 | 678 | $attrs = array( |
679 | - 'name' => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]", |
|
680 | - 'readonly' => ! empty( $args['faux'] ), |
|
681 | - 'value' => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ), |
|
679 | + 'name' => !empty($args['faux']) ? false : "wpinv_settings[$id]", |
|
680 | + 'readonly' => !empty($args['faux']), |
|
681 | + 'value' => !empty($args['faux']) ? $value : wpinv_get_option($args['id'], $value), |
|
682 | 682 | 'id' => 'wpinv-settings-' . $args['id'], |
683 | 683 | 'style' => $args['style'], |
684 | 684 | 'class' => $args['class'], |
@@ -686,20 +686,20 @@ discard block |
||
686 | 686 | 'data-placeholder' => $args['placeholder'], |
687 | 687 | ); |
688 | 688 | |
689 | - if ( ! empty( $args['onchange'] ) ) { |
|
689 | + if (!empty($args['onchange'])) { |
|
690 | 690 | $attrs['onchange'] = $args['onchange']; |
691 | 691 | } |
692 | 692 | |
693 | - foreach ( $attrs as $key => $value ) { |
|
693 | + foreach ($attrs as $key => $value) { |
|
694 | 694 | |
695 | - if ( false === $value ) { |
|
695 | + if (false === $value) { |
|
696 | 696 | continue; |
697 | 697 | } |
698 | 698 | |
699 | - if ( true === $value ) { |
|
700 | - echo ' ' . esc_attr( $key ); |
|
699 | + if (true === $value) { |
|
700 | + echo ' ' . esc_attr($key); |
|
701 | 701 | } else { |
702 | - echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
702 | + echo ' ' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | } |
@@ -709,14 +709,14 @@ discard block |
||
709 | 709 | /** |
710 | 710 | * Displays a text input settings callback. |
711 | 711 | */ |
712 | -function wpinv_text_callback( $args ) { |
|
712 | +function wpinv_text_callback($args) { |
|
713 | 713 | |
714 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
714 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
715 | 715 | |
716 | 716 | ?> |
717 | 717 | <label style="width: 100%;"> |
718 | - <input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>> |
|
719 | - <?php echo wp_kses_post( $desc ); ?> |
|
718 | + <input type="text" <?php wpinv_settings_attrs_helper($args); ?>> |
|
719 | + <?php echo wp_kses_post($desc); ?> |
|
720 | 720 | </label> |
721 | 721 | <?php |
722 | 722 | |
@@ -725,48 +725,48 @@ discard block |
||
725 | 725 | /** |
726 | 726 | * Displays a number input settings callback. |
727 | 727 | */ |
728 | -function wpinv_number_callback( $args ) { |
|
728 | +function wpinv_number_callback($args) { |
|
729 | 729 | |
730 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
730 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
731 | 731 | |
732 | 732 | ?> |
733 | 733 | <label style="width: 100%;"> |
734 | - <input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>> |
|
735 | - <?php echo wp_kses_post( $desc ); ?> |
|
734 | + <input type="number" step="<?php echo floatval($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php wpinv_settings_attrs_helper($args); ?>> |
|
735 | + <?php echo wp_kses_post($desc); ?> |
|
736 | 736 | </label> |
737 | 737 | <?php |
738 | 738 | |
739 | 739 | } |
740 | 740 | |
741 | -function wpinv_textarea_callback( $args ) { |
|
741 | +function wpinv_textarea_callback($args) { |
|
742 | 742 | |
743 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
744 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
745 | - $value = wpinv_get_option( $args['id'], $std ); |
|
743 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
744 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
745 | + $value = wpinv_get_option($args['id'], $std); |
|
746 | 746 | |
747 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
748 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
747 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
748 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
749 | 749 | |
750 | - echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
751 | - echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
750 | + echo '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
751 | + echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
752 | 752 | |
753 | 753 | } |
754 | 754 | |
755 | -function wpinv_password_callback( $args ) { |
|
755 | +function wpinv_password_callback($args) { |
|
756 | 756 | |
757 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
758 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
759 | - $value = wpinv_get_option( $args['id'], $std ); |
|
757 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
758 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
759 | + $value = wpinv_get_option($args['id'], $std); |
|
760 | 760 | |
761 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
762 | - echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
763 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
761 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
762 | + echo '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
763 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
764 | 764 | |
765 | 765 | } |
766 | 766 | |
767 | -function wpinv_missing_callback( $args ) { |
|
767 | +function wpinv_missing_callback($args) { |
|
768 | 768 | printf( |
769 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
769 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
770 | 770 | '<strong>' . $args['id'] . '</strong>' |
771 | 771 | ); |
772 | 772 | } |
@@ -774,34 +774,34 @@ discard block |
||
774 | 774 | /** |
775 | 775 | * Displays a number input settings callback. |
776 | 776 | */ |
777 | -function wpinv_select_callback( $args ) { |
|
777 | +function wpinv_select_callback($args) { |
|
778 | 778 | |
779 | - $desc = wp_kses_post( $args['desc'] ); |
|
780 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
781 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
782 | - $value = wpinv_get_option( $args['id'], $value ); |
|
783 | - $rand = uniqid( 'random_id' ); |
|
779 | + $desc = wp_kses_post($args['desc']); |
|
780 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
781 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
782 | + $value = wpinv_get_option($args['id'], $value); |
|
783 | + $rand = uniqid('random_id'); |
|
784 | 784 | |
785 | 785 | ?> |
786 | 786 | <label style="width: 100%;"> |
787 | - <select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true"> |
|
788 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
789 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo esc_html( $name ); ?></option> |
|
787 | + <select <?php wpinv_settings_attrs_helper($args); ?> data-allow-clear="true"> |
|
788 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
789 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo esc_html($name); ?></option> |
|
790 | 790 | <?php endforeach; ?> |
791 | 791 | </select> |
792 | 792 | |
793 | - <?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?> |
|
794 | - <a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e( 'Edit Page', 'invoicing' ); ?></a> |
|
793 | + <?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?> |
|
794 | + <a href="<?php echo get_edit_post_link($value); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e('Edit Page', 'invoicing'); ?></a> |
|
795 | 795 | <?php endif; ?> |
796 | 796 | |
797 | - <?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?> |
|
798 | - <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e( 'View Default Content', 'invoicing' ); ?></a> |
|
797 | + <?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?> |
|
798 | + <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e('View Default Content', 'invoicing'); ?></a> |
|
799 | 799 | <div id='<?php echo $rand; ?>' style='display:none;'> |
800 | 800 | <div> |
801 | - <h3><?php esc_html_e( 'Original Content', 'invoicing' ); ?></h3> |
|
802 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea> |
|
803 | - <h3><?php esc_html_e( 'Current Content', 'invoicing' ); ?></h3> |
|
804 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea> |
|
801 | + <h3><?php esc_html_e('Original Content', 'invoicing'); ?></h3> |
|
802 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines(wp_kses_post($args['default_content'])); ?></textarea> |
|
803 | + <h3><?php esc_html_e('Current Content', 'invoicing'); ?></h3> |
|
804 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : gepaid_trim_lines(wp_kses_post($_post->post_content)); ?></textarea> |
|
805 | 805 | </div> |
806 | 806 | </div> |
807 | 807 | <?php endif; ?> |
@@ -812,89 +812,89 @@ discard block |
||
812 | 812 | |
813 | 813 | } |
814 | 814 | |
815 | -function wpinv_color_select_callback( $args ) { |
|
815 | +function wpinv_color_select_callback($args) { |
|
816 | 816 | |
817 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
818 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
819 | - $value = wpinv_get_option( $args['id'], $std ); |
|
817 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
818 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
819 | + $value = wpinv_get_option($args['id'], $std); |
|
820 | 820 | |
821 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
821 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
822 | 822 | |
823 | - foreach ( $args['options'] as $option => $color ) { |
|
824 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
823 | + foreach ($args['options'] as $option => $color) { |
|
824 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>'; |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | echo '</select>'; |
828 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
828 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
829 | 829 | |
830 | 830 | } |
831 | 831 | |
832 | -function wpinv_rich_editor_callback( $args ) { |
|
832 | +function wpinv_rich_editor_callback($args) { |
|
833 | 833 | global $wp_version; |
834 | 834 | |
835 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
835 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
836 | 836 | |
837 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
838 | - $value = wpinv_get_option( $args['id'], $std ); |
|
837 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
838 | + $value = wpinv_get_option($args['id'], $std); |
|
839 | 839 | |
840 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
840 | + if (!empty($args['allow_blank']) && empty($value)) { |
|
841 | 841 | $value = $std; |
842 | 842 | } |
843 | 843 | |
844 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
844 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
845 | 845 | |
846 | 846 | echo '<div class="getpaid-settings-editor-input">'; |
847 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
847 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
848 | 848 | wp_editor( |
849 | - stripslashes( $value ), |
|
850 | - 'wpinv_settings_' . esc_attr( $args['id'] ), |
|
849 | + stripslashes($value), |
|
850 | + 'wpinv_settings_' . esc_attr($args['id']), |
|
851 | 851 | array( |
852 | - 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
853 | - 'textarea_rows' => absint( $rows ), |
|
852 | + 'textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', |
|
853 | + 'textarea_rows' => absint($rows), |
|
854 | 854 | 'media_buttons' => false, |
855 | 855 | ) |
856 | 856 | ); |
857 | 857 | } else { |
858 | - echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
858 | + echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
859 | 859 | } |
860 | 860 | |
861 | - echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
861 | + echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
862 | 862 | |
863 | 863 | } |
864 | 864 | |
865 | -function wpinv_upload_callback( $args ) { |
|
865 | +function wpinv_upload_callback($args) { |
|
866 | 866 | |
867 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
867 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
868 | 868 | |
869 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
870 | - $value = wpinv_get_option( $args['id'], $std ); |
|
869 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
870 | + $value = wpinv_get_option($args['id'], $std); |
|
871 | 871 | |
872 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
873 | - echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
874 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
875 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
872 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
873 | + echo '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
874 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
875 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
876 | 876 | |
877 | 877 | } |
878 | 878 | |
879 | -function wpinv_color_callback( $args ) { |
|
879 | +function wpinv_color_callback($args) { |
|
880 | 880 | |
881 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
882 | - $value = wpinv_get_option( $args['id'], $std ); |
|
883 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
881 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
882 | + $value = wpinv_get_option($args['id'], $std); |
|
883 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
884 | 884 | |
885 | - echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
886 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
885 | + echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />'; |
|
886 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
887 | 887 | |
888 | 888 | } |
889 | 889 | |
890 | -function wpinv_country_states_callback( $args ) { |
|
890 | +function wpinv_country_states_callback($args) { |
|
891 | 891 | |
892 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
893 | - $value = wpinv_get_option( $args['id'], $std ); |
|
892 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
893 | + $value = wpinv_get_option($args['id'], $std); |
|
894 | 894 | |
895 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
895 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
896 | 896 | |
897 | - if ( isset( $args['placeholder'] ) ) { |
|
897 | + if (isset($args['placeholder'])) { |
|
898 | 898 | $placeholder = $args['placeholder']; |
899 | 899 | } else { |
900 | 900 | $placeholder = ''; |
@@ -902,15 +902,15 @@ discard block |
||
902 | 902 | |
903 | 903 | $states = wpinv_get_country_states(); |
904 | 904 | |
905 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
906 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
905 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
906 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
907 | 907 | |
908 | - foreach ( $states as $option => $name ) { |
|
909 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
908 | + foreach ($states as $option => $name) { |
|
909 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>'; |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | echo '</select>'; |
913 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
913 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
914 | 914 | |
915 | 915 | } |
916 | 916 | |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | </tr> |
925 | 925 | <tr class="bsui"> |
926 | 926 | <td colspan="2" class="p-0"> |
927 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
927 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
928 | 928 | |
929 | 929 | <?php |
930 | 930 | |
@@ -933,14 +933,14 @@ discard block |
||
933 | 933 | /** |
934 | 934 | * Displays a tax rate' edit row. |
935 | 935 | */ |
936 | -function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
|
936 | +function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) { |
|
937 | 937 | ob_start(); |
938 | 938 | |
939 | - $key = sanitize_key( $key ); |
|
940 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
941 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
939 | + $key = sanitize_key($key); |
|
940 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
941 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
942 | 942 | |
943 | - if ( $echo ) { |
|
943 | + if ($echo) { |
|
944 | 944 | echo ob_get_clean(); |
945 | 945 | } else { |
946 | 946 | return ob_get_clean(); |
@@ -949,152 +949,152 @@ discard block |
||
949 | 949 | } |
950 | 950 | |
951 | 951 | |
952 | -function wpinv_tools_callback( $args ) { |
|
952 | +function wpinv_tools_callback($args) { |
|
953 | 953 | ?> |
954 | 954 | </td><tr> |
955 | 955 | <td colspan="2" class="wpinv_tools_tdbox"> |
956 | 956 | <?php |
957 | - if ( $args['desc'] ) { |
|
957 | + if ($args['desc']) { |
|
958 | 958 | ?> |
959 | 959 | <p><?php echo $args['desc']; ?></p><?php } ?> |
960 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
960 | + <?php do_action('wpinv_tools_before'); ?> |
|
961 | 961 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
962 | 962 | <thead> |
963 | 963 | <tr> |
964 | - <th scope="col" class="wpinv-th-tool"><?php esc_html_e( 'Tool', 'invoicing' ); ?></th> |
|
965 | - <th scope="col" class="wpinv-th-desc"><?php esc_html_e( 'Description', 'invoicing' ); ?></th> |
|
966 | - <th scope="col" class="wpinv-th-action"><?php esc_html_e( 'Action', 'invoicing' ); ?></th> |
|
964 | + <th scope="col" class="wpinv-th-tool"><?php esc_html_e('Tool', 'invoicing'); ?></th> |
|
965 | + <th scope="col" class="wpinv-th-desc"><?php esc_html_e('Description', 'invoicing'); ?></th> |
|
966 | + <th scope="col" class="wpinv-th-action"><?php esc_html_e('Action', 'invoicing'); ?></th> |
|
967 | 967 | </tr> |
968 | 968 | </thead> |
969 | 969 | |
970 | 970 | <tbody> |
971 | 971 | <tr> |
972 | - <td><?php esc_html_e( 'Check Pages', 'invoicing' ); ?></td> |
|
972 | + <td><?php esc_html_e('Check Pages', 'invoicing'); ?></td> |
|
973 | 973 | <td> |
974 | - <small><?php esc_html_e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small> |
|
974 | + <small><?php esc_html_e('Creates any missing GetPaid pages.', 'invoicing'); ?></small> |
|
975 | 975 | </td> |
976 | 976 | <td> |
977 | 977 | <a href=" |
978 | 978 | <?php |
979 | 979 | echo esc_url( |
980 | 980 | wp_nonce_url( |
981 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
981 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
982 | 982 | 'getpaid-nonce', |
983 | 983 | 'getpaid-nonce' |
984 | 984 | ) |
985 | 985 | ); |
986 | 986 | ?> |
987 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
987 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
988 | 988 | </td> |
989 | 989 | </tr> |
990 | 990 | <tr> |
991 | - <td><?php esc_html_e( 'Create Database Tables', 'invoicing' ); ?></td> |
|
991 | + <td><?php esc_html_e('Create Database Tables', 'invoicing'); ?></td> |
|
992 | 992 | <td> |
993 | - <small><?php esc_html_e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small> |
|
993 | + <small><?php esc_html_e('Run this tool to create any missing database tables.', 'invoicing'); ?></small> |
|
994 | 994 | </td> |
995 | 995 | <td> |
996 | 996 | <a href=" |
997 | 997 | <?php |
998 | 998 | echo esc_url( |
999 | 999 | wp_nonce_url( |
1000 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
1000 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
1001 | 1001 | 'getpaid-nonce', |
1002 | 1002 | 'getpaid-nonce' |
1003 | 1003 | ) |
1004 | 1004 | ); |
1005 | 1005 | ?> |
1006 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1006 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1007 | 1007 | </td> |
1008 | 1008 | </tr> |
1009 | 1009 | <tr> |
1010 | - <td><?php esc_html_e( 'Migrate old invoices', 'invoicing' ); ?></td> |
|
1010 | + <td><?php esc_html_e('Migrate old invoices', 'invoicing'); ?></td> |
|
1011 | 1011 | <td> |
1012 | - <small><?php esc_html_e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small> |
|
1012 | + <small><?php esc_html_e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small> |
|
1013 | 1013 | </td> |
1014 | 1014 | <td> |
1015 | 1015 | <a href=" |
1016 | 1016 | <?php |
1017 | 1017 | echo esc_url( |
1018 | 1018 | wp_nonce_url( |
1019 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1019 | + add_query_arg('getpaid-admin-action', 'migrate_old_invoices'), |
|
1020 | 1020 | 'getpaid-nonce', |
1021 | 1021 | 'getpaid-nonce' |
1022 | 1022 | ) |
1023 | 1023 | ); |
1024 | 1024 | ?> |
1025 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1025 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1026 | 1026 | </td> |
1027 | 1027 | </tr> |
1028 | 1028 | |
1029 | 1029 | <tr> |
1030 | - <td><?php esc_html_e( 'Recalculate Discounts', 'invoicing' ); ?></td> |
|
1030 | + <td><?php esc_html_e('Recalculate Discounts', 'invoicing'); ?></td> |
|
1031 | 1031 | <td> |
1032 | - <small><?php esc_html_e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small> |
|
1032 | + <small><?php esc_html_e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small> |
|
1033 | 1033 | </td> |
1034 | 1034 | <td> |
1035 | 1035 | <a href=" |
1036 | 1036 | <?php |
1037 | 1037 | echo esc_url( |
1038 | 1038 | wp_nonce_url( |
1039 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1039 | + add_query_arg('getpaid-admin-action', 'recalculate_discounts'), |
|
1040 | 1040 | 'getpaid-nonce', |
1041 | 1041 | 'getpaid-nonce' |
1042 | 1042 | ) |
1043 | 1043 | ); |
1044 | 1044 | ?> |
1045 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1045 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1046 | 1046 | </td> |
1047 | 1047 | </tr> |
1048 | 1048 | |
1049 | 1049 | <tr> |
1050 | - <td><?php esc_html_e( 'Set-up Wizard', 'invoicing' ); ?></td> |
|
1050 | + <td><?php esc_html_e('Set-up Wizard', 'invoicing'); ?></td> |
|
1051 | 1051 | <td> |
1052 | - <small><?php esc_html_e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small> |
|
1052 | + <small><?php esc_html_e('Launch the quick set-up wizard.', 'invoicing'); ?></small> |
|
1053 | 1053 | </td> |
1054 | 1054 | <td> |
1055 | 1055 | <a href=" |
1056 | 1056 | <?php |
1057 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
1057 | + echo esc_url(admin_url('index.php?page=gp-setup')); |
|
1058 | 1058 | ?> |
1059 | - " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a> |
|
1059 | + " class="button button-primary"><?php esc_html_e('Launch', 'invoicing'); ?></a> |
|
1060 | 1060 | </td> |
1061 | 1061 | </tr> |
1062 | 1062 | |
1063 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1063 | + <?php do_action('wpinv_tools_row'); ?> |
|
1064 | 1064 | </tbody> |
1065 | 1065 | </table> |
1066 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1066 | + <?php do_action('wpinv_tools_after'); ?> |
|
1067 | 1067 | <?php |
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | |
1071 | -function wpinv_descriptive_text_callback( $args ) { |
|
1072 | - echo wp_kses_post( $args['desc'] ); |
|
1071 | +function wpinv_descriptive_text_callback($args) { |
|
1072 | + echo wp_kses_post($args['desc']); |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | -function wpinv_raw_html_callback( $args ) { |
|
1076 | - echo wp_kses_post( $args['desc'] ); |
|
1075 | +function wpinv_raw_html_callback($args) { |
|
1076 | + echo wp_kses_post($args['desc']); |
|
1077 | 1077 | } |
1078 | 1078 | |
1079 | -function wpinv_hook_callback( $args ) { |
|
1080 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1079 | +function wpinv_hook_callback($args) { |
|
1080 | + do_action('wpinv_' . $args['id'], $args); |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | function wpinv_set_settings_cap() { |
1084 | 1084 | return wpinv_get_capability(); |
1085 | 1085 | } |
1086 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1086 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1087 | 1087 | |
1088 | 1088 | |
1089 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1090 | - $old = ! empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1091 | - $new = ! empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1089 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1090 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1091 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1092 | 1092 | |
1093 | - if ( $old != $new ) { |
|
1094 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1093 | + if ($old != $new) { |
|
1094 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1095 | 1095 | } |
1096 | 1096 | } |
1097 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1097 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1098 | 1098 | |
1099 | 1099 | /** |
1100 | 1100 | * Returns the merge tags help text. |
@@ -1103,16 +1103,16 @@ discard block |
||
1103 | 1103 | * |
1104 | 1104 | * @return string |
1105 | 1105 | */ |
1106 | -function wpinv_get_merge_tags_help_text( $subscription = false ) { |
|
1106 | +function wpinv_get_merge_tags_help_text($subscription = false) { |
|
1107 | 1107 | |
1108 | 1108 | $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
1109 | 1109 | $link = sprintf( |
1110 | 1110 | '<strong><a href="%s" target="_blank">%s</a></strong>', |
1111 | 1111 | $url, |
1112 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1112 | + esc_html__('View available merge tags.', 'wpinv-quotes') |
|
1113 | 1113 | ); |
1114 | 1114 | |
1115 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1115 | + $description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing'); |
|
1116 | 1116 | |
1117 | 1117 | return "$description $link"; |
1118 | 1118 |