@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -82,30 +82,30 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @param int|object|WPInv_Item|WP_Post $item Item to read. |
84 | 84 | */ |
85 | - public function __construct( $item = 0 ) { |
|
86 | - parent::__construct( $item ); |
|
87 | - |
|
88 | - if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) { |
|
89 | - $this->set_id( $item ); |
|
90 | - } elseif ( $item instanceof self ) { |
|
91 | - $this->set_id( $item->get_id() ); |
|
92 | - } elseif ( ! empty( $item->ID ) ) { |
|
93 | - $this->set_id( $item->ID ); |
|
94 | - } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) { |
|
95 | - $this->set_id( $item_id ); |
|
96 | - } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) { |
|
97 | - $this->set_id( $item_id ); |
|
85 | + public function __construct($item = 0) { |
|
86 | + parent::__construct($item); |
|
87 | + |
|
88 | + if (!empty($item) && is_numeric($item) && 'wpi_item' == get_post_type($item)) { |
|
89 | + $this->set_id($item); |
|
90 | + } elseif ($item instanceof self) { |
|
91 | + $this->set_id($item->get_id()); |
|
92 | + } elseif (!empty($item->ID)) { |
|
93 | + $this->set_id($item->ID); |
|
94 | + } elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'custom_id')) { |
|
95 | + $this->set_id($item_id); |
|
96 | + } elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'name')) { |
|
97 | + $this->set_id($item_id); |
|
98 | 98 | } else { |
99 | - $this->set_object_read( true ); |
|
99 | + $this->set_object_read(true); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | // Load the datastore. |
103 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
103 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
104 | 104 | |
105 | - if ( $this->get_id() > 0 ) { |
|
106 | - $this->post = get_post( $this->get_id() ); |
|
105 | + if ($this->get_id() > 0) { |
|
106 | + $this->post = get_post($this->get_id()); |
|
107 | 107 | $this->ID = $this->get_id(); |
108 | - $this->data_store->read( $this ); |
|
108 | + $this->data_store->read($this); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param string $context View or edit context. |
132 | 132 | * @return int |
133 | 133 | */ |
134 | - public function get_parent_id( $context = 'view' ) { |
|
135 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
134 | + public function get_parent_id($context = 'view') { |
|
135 | + return (int) $this->get_prop('parent_id', $context); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | * @param string $context View or edit context. |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - public function get_status( $context = 'view' ) { |
|
146 | - return $this->get_prop( 'status', $context ); |
|
145 | + public function get_status($context = 'view') { |
|
146 | + return $this->get_prop('status', $context); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | * @param string $context View or edit context. |
154 | 154 | * @return string |
155 | 155 | */ |
156 | - public function get_version( $context = 'view' ) { |
|
157 | - return $this->get_prop( 'version', $context ); |
|
156 | + public function get_version($context = 'view') { |
|
157 | + return $this->get_prop('version', $context); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param string $context View or edit context. |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - public function get_date_created( $context = 'view' ) { |
|
168 | - return $this->get_prop( 'date_created', $context ); |
|
167 | + public function get_date_created($context = 'view') { |
|
168 | + return $this->get_prop('date_created', $context); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | * @param string $context View or edit context. |
176 | 176 | * @return string |
177 | 177 | */ |
178 | - public function get_date_created_gmt( $context = 'view' ) { |
|
179 | - $date = $this->get_date_created( $context ); |
|
178 | + public function get_date_created_gmt($context = 'view') { |
|
179 | + $date = $this->get_date_created($context); |
|
180 | 180 | |
181 | - if ( $date ) { |
|
182 | - $date = get_gmt_from_date( $date ); |
|
181 | + if ($date) { |
|
182 | + $date = get_gmt_from_date($date); |
|
183 | 183 | } |
184 | 184 | return $date; |
185 | 185 | } |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | * @param string $context View or edit context. |
192 | 192 | * @return string |
193 | 193 | */ |
194 | - public function get_date_modified( $context = 'view' ) { |
|
195 | - return $this->get_prop( 'date_modified', $context ); |
|
194 | + public function get_date_modified($context = 'view') { |
|
195 | + return $this->get_prop('date_modified', $context); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | * @param string $context View or edit context. |
203 | 203 | * @return string |
204 | 204 | */ |
205 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
206 | - $date = $this->get_date_modified( $context ); |
|
205 | + public function get_date_modified_gmt($context = 'view') { |
|
206 | + $date = $this->get_date_modified($context); |
|
207 | 207 | |
208 | - if ( $date ) { |
|
209 | - $date = get_gmt_from_date( $date ); |
|
208 | + if ($date) { |
|
209 | + $date = get_gmt_from_date($date); |
|
210 | 210 | } |
211 | 211 | return $date; |
212 | 212 | } |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | * @param string $context View or edit context. |
219 | 219 | * @return string |
220 | 220 | */ |
221 | - public function get_name( $context = 'view' ) { |
|
222 | - return $this->get_prop( 'name', $context ); |
|
221 | + public function get_name($context = 'view') { |
|
222 | + return $this->get_prop('name', $context); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -229,8 +229,8 @@ discard block |
||
229 | 229 | * @param string $context View or edit context. |
230 | 230 | * @return string |
231 | 231 | */ |
232 | - public function get_title( $context = 'view' ) { |
|
233 | - return $this->get_name( $context ); |
|
232 | + public function get_title($context = 'view') { |
|
233 | + return $this->get_name($context); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | * @param string $context View or edit context. |
241 | 241 | * @return string |
242 | 242 | */ |
243 | - public function get_description( $context = 'view' ) { |
|
244 | - return $this->get_prop( 'description', $context ); |
|
243 | + public function get_description($context = 'view') { |
|
244 | + return $this->get_prop('description', $context); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * @param string $context View or edit context. |
252 | 252 | * @return string |
253 | 253 | */ |
254 | - public function get_excerpt( $context = 'view' ) { |
|
255 | - return $this->get_description( $context ); |
|
254 | + public function get_excerpt($context = 'view') { |
|
255 | + return $this->get_description($context); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | * @param string $context View or edit context. |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public function get_summary( $context = 'view' ) { |
|
266 | - return $this->get_description( $context ); |
|
265 | + public function get_summary($context = 'view') { |
|
266 | + return $this->get_description($context); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | * @param string $context View or edit context. |
274 | 274 | * @return int |
275 | 275 | */ |
276 | - public function get_author( $context = 'view' ) { |
|
277 | - return (int) $this->get_prop( 'author', $context ); |
|
276 | + public function get_author($context = 'view') { |
|
277 | + return (int) $this->get_prop('author', $context); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | * @param string $context View or edit context. |
285 | 285 | * @return int |
286 | 286 | */ |
287 | - public function get_owner( $context = 'view' ) { |
|
288 | - return $this->get_author( $context ); |
|
287 | + public function get_owner($context = 'view') { |
|
288 | + return $this->get_author($context); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | * @param string $context View or edit context. |
296 | 296 | * @return float |
297 | 297 | */ |
298 | - public function get_price( $context = 'view' ) { |
|
299 | - return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) ); |
|
298 | + public function get_price($context = 'view') { |
|
299 | + return wpinv_sanitize_amount($this->get_prop('price', $context)); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -306,24 +306,24 @@ discard block |
||
306 | 306 | * @param string $context View or edit context. |
307 | 307 | * @return float |
308 | 308 | */ |
309 | - public function get_initial_price( $context = 'view', $price_id = null ) { |
|
309 | + public function get_initial_price($context = 'view', $price_id = null) { |
|
310 | 310 | $price = 0; |
311 | 311 | |
312 | - if ( null === $price_id ) { |
|
313 | - $price = (float) $this->get_price( $context ); |
|
312 | + if (null === $price_id) { |
|
313 | + $price = (float) $this->get_price($context); |
|
314 | 314 | |
315 | - if ( $this->has_free_trial() ) { |
|
315 | + if ($this->has_free_trial()) { |
|
316 | 316 | $price = 0; |
317 | 317 | } |
318 | 318 | } else { |
319 | 319 | $prices = $this->get_variable_prices(); |
320 | 320 | |
321 | - if ( isset( $prices[ $price_id ] ) ) { |
|
322 | - $price = (float) $prices[ $price_id ]['amount']; |
|
321 | + if (isset($prices[$price_id])) { |
|
322 | + $price = (float) $prices[$price_id]['amount']; |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
326 | - return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) ); |
|
326 | + return wpinv_sanitize_amount(apply_filters('wpinv_get_initial_item_price', $price, $this)); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @return string |
335 | 335 | */ |
336 | 336 | public function get_the_price() { |
337 | - return wpinv_price( $this->get_price() ); |
|
337 | + return wpinv_price($this->get_price()); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @return string |
346 | 346 | */ |
347 | 347 | public function get_the_initial_price() { |
348 | - return wpinv_price( $this->get_initial_price() ); |
|
348 | + return wpinv_price($this->get_initial_price()); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | /** |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | * @param string $context View or edit context. |
356 | 356 | * @return string |
357 | 357 | */ |
358 | - public function get_vat_rule( $context = 'view' ) { |
|
359 | - return $this->get_prop( 'vat_rule', $context ); |
|
358 | + public function get_vat_rule($context = 'view') { |
|
359 | + return $this->get_prop('vat_rule', $context); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | * @param string $context View or edit context. |
367 | 367 | * @return string |
368 | 368 | */ |
369 | - public function get_vat_class( $context = 'view' ) { |
|
370 | - return $this->get_prop( 'vat_class', $context ); |
|
369 | + public function get_vat_class($context = 'view') { |
|
370 | + return $this->get_prop('vat_class', $context); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | * @param string $context View or edit context. |
378 | 378 | * @return string |
379 | 379 | */ |
380 | - public function get_type( $context = 'view' ) { |
|
381 | - return $this->get_prop( 'type', $context ); |
|
380 | + public function get_type($context = 'view') { |
|
381 | + return $this->get_prop('type', $context); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -388,8 +388,8 @@ discard block |
||
388 | 388 | * @param string $context View or edit context. |
389 | 389 | * @return string |
390 | 390 | */ |
391 | - public function get_custom_id( $context = 'view' ) { |
|
392 | - return $this->get_prop( 'custom_id', $context ); |
|
391 | + public function get_custom_id($context = 'view') { |
|
392 | + return $this->get_prop('custom_id', $context); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -399,8 +399,8 @@ discard block |
||
399 | 399 | * @param string $context View or edit context. |
400 | 400 | * @return string |
401 | 401 | */ |
402 | - public function get_custom_name( $context = 'view' ) { |
|
403 | - return $this->get_prop( 'custom_name', $context ); |
|
402 | + public function get_custom_name($context = 'view') { |
|
403 | + return $this->get_prop('custom_name', $context); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | * @param string $context View or edit context. |
411 | 411 | * @return string |
412 | 412 | */ |
413 | - public function get_custom_singular_name( $context = 'view' ) { |
|
414 | - return $this->get_prop( 'custom_singular_name', $context ); |
|
413 | + public function get_custom_singular_name($context = 'view') { |
|
414 | + return $this->get_prop('custom_singular_name', $context); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | * @param string $context View or edit context. |
422 | 422 | * @return int |
423 | 423 | */ |
424 | - public function get_is_editable( $context = 'view' ) { |
|
425 | - return (int) $this->get_prop( 'is_editable', $context ); |
|
424 | + public function get_is_editable($context = 'view') { |
|
425 | + return (int) $this->get_prop('is_editable', $context); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -432,8 +432,8 @@ discard block |
||
432 | 432 | * @param string $context View or edit context. |
433 | 433 | * @return int |
434 | 434 | */ |
435 | - public function get_editable( $context = 'view' ) { |
|
436 | - return $this->get_is_editable( $context ); |
|
435 | + public function get_editable($context = 'view') { |
|
436 | + return $this->get_is_editable($context); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | /** |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * @param string $context View or edit context. |
444 | 444 | * @return int |
445 | 445 | */ |
446 | - public function get_is_dynamic_pricing( $context = 'view' ) { |
|
447 | - return (int) $this->get_prop( 'is_dynamic_pricing', $context ); |
|
446 | + public function get_is_dynamic_pricing($context = 'view') { |
|
447 | + return (int) $this->get_prop('is_dynamic_pricing', $context); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | * @param string $context View or edit context. |
455 | 455 | * @return float |
456 | 456 | */ |
457 | - public function get_minimum_price( $context = 'view' ) { |
|
458 | - return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) ); |
|
457 | + public function get_minimum_price($context = 'view') { |
|
458 | + return wpinv_sanitize_amount($this->get_prop('minimum_price', $context)); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | /** |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | * @param string $context View or edit context. |
466 | 466 | * @return int |
467 | 467 | */ |
468 | - public function get_is_multi_price_mode( $context = 'view' ) { |
|
469 | - return (bool) $this->get_prop( 'is_multi_price_mode', $context ); |
|
468 | + public function get_is_multi_price_mode($context = 'view') { |
|
469 | + return (bool) $this->get_prop('is_multi_price_mode', $context); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | /** |
@@ -487,8 +487,8 @@ discard block |
||
487 | 487 | * @param string $context View or edit context. |
488 | 488 | * @return int |
489 | 489 | */ |
490 | - public function get_has_variable_pricing( $context = 'view' ) { |
|
491 | - return (bool) $this->get_prop( 'has_variable_pricing', $context ); |
|
490 | + public function get_has_variable_pricing($context = 'view') { |
|
491 | + return (bool) $this->get_prop('has_variable_pricing', $context); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | /** |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | * @return int |
500 | 500 | */ |
501 | 501 | public function has_variable_pricing() { |
502 | - return $this->get_has_variable_pricing( 'view' ); |
|
502 | + return $this->get_has_variable_pricing('view'); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | /** |
@@ -509,20 +509,20 @@ discard block |
||
509 | 509 | * @since 2.8.9 |
510 | 510 | * @return int The Price ID to select by default |
511 | 511 | */ |
512 | - public function get_default_price_id( $context = 'view' ) { |
|
513 | - if ( ! $this->has_variable_pricing() ) { |
|
512 | + public function get_default_price_id($context = 'view') { |
|
513 | + if (!$this->has_variable_pricing()) { |
|
514 | 514 | return false; |
515 | 515 | } |
516 | 516 | |
517 | 517 | $prices = $this->get_variable_prices(); |
518 | 518 | |
519 | - $default_price_id = (int) $this->get_prop( 'default_price_id', $context ); |
|
519 | + $default_price_id = (int) $this->get_prop('default_price_id', $context); |
|
520 | 520 | |
521 | - if ( '' === $default_price_id || ! isset( $prices[ $default_price_id ] ) ) { |
|
522 | - $default_price_id = current( array_keys( $prices ) ); |
|
521 | + if ('' === $default_price_id || !isset($prices[$default_price_id])) { |
|
522 | + $default_price_id = current(array_keys($prices)); |
|
523 | 523 | } |
524 | 524 | |
525 | - return absint( $default_price_id ); |
|
525 | + return absint($default_price_id); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -534,8 +534,8 @@ discard block |
||
534 | 534 | public function get_variable_prices() { |
535 | 535 | $prices = array(); |
536 | 536 | |
537 | - if ( true === $this->has_variable_pricing() ) { |
|
538 | - $prices = $this->get_prop( 'variable_prices', 'view' ); |
|
537 | + if (true === $this->has_variable_pricing()) { |
|
538 | + $prices = $this->get_prop('variable_prices', 'view'); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | return $prices; |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | * @param string $context View or edit context. |
549 | 549 | * @return int |
550 | 550 | */ |
551 | - public function get_is_recurring( $context = 'view' ) { |
|
552 | - return (int) $this->get_prop( 'is_recurring', $context ); |
|
551 | + public function get_is_recurring($context = 'view') { |
|
552 | + return (int) $this->get_prop('is_recurring', $context); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | /** |
@@ -559,9 +559,9 @@ discard block |
||
559 | 559 | * @param string $context View or edit context. |
560 | 560 | * @return float |
561 | 561 | */ |
562 | - public function get_recurring_price( $context = 'view' ) { |
|
563 | - $price = $this->get_price( $context ); |
|
564 | - return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) ); |
|
562 | + public function get_recurring_price($context = 'view') { |
|
563 | + $price = $this->get_price($context); |
|
564 | + return wpinv_sanitize_amount(apply_filters('wpinv_get_recurring_item_price', $price, $this->ID)); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | /** |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | * @return string |
573 | 573 | */ |
574 | 574 | public function get_the_recurring_price() { |
575 | - return wpinv_price( $this->get_recurring_price() ); |
|
575 | + return wpinv_price($this->get_recurring_price()); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -593,15 +593,15 @@ discard block |
||
593 | 593 | $period = $this->get_recurring_period(); |
594 | 594 | $interval = $this->get_recurring_interval(); |
595 | 595 | |
596 | - if ( $this->has_free_trial() ) { |
|
596 | + if ($this->has_free_trial()) { |
|
597 | 597 | $period = $this->get_trial_period(); |
598 | 598 | $interval = $this->get_trial_interval(); |
599 | 599 | } |
600 | 600 | |
601 | - $period = $periods[ $period ]; |
|
602 | - $interval = empty( $interval ) ? 1 : $interval; |
|
603 | - $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) ); |
|
604 | - return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this ); |
|
601 | + $period = $periods[$period]; |
|
602 | + $interval = empty($interval) ? 1 : $interval; |
|
603 | + $next_renewal = strtotime("+$interval $period", current_time('timestamp')); |
|
604 | + return apply_filters('wpinv_get_first_renewal_date', $next_renewal, $this); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -611,14 +611,14 @@ discard block |
||
611 | 611 | * @param bool $full Return abbreviation or in full. |
612 | 612 | * @return string |
613 | 613 | */ |
614 | - public function get_recurring_period( $full = false ) { |
|
615 | - $period = $this->get_prop( 'recurring_period', 'view' ); |
|
614 | + public function get_recurring_period($full = false) { |
|
615 | + $period = $this->get_prop('recurring_period', 'view'); |
|
616 | 616 | |
617 | - if ( $full && ! is_bool( $full ) ) { |
|
617 | + if ($full && !is_bool($full)) { |
|
618 | 618 | $full = false; |
619 | 619 | } |
620 | 620 | |
621 | - return getpaid_sanitize_recurring_period( $period, $full ); |
|
621 | + return getpaid_sanitize_recurring_period($period, $full); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | * @param string $context View or edit context. |
629 | 629 | * @return int |
630 | 630 | */ |
631 | - public function get_recurring_interval( $context = 'view' ) { |
|
632 | - $interval = absint( $this->get_prop( 'recurring_interval', $context ) ); |
|
633 | - return max( 1, $interval ); |
|
631 | + public function get_recurring_interval($context = 'view') { |
|
632 | + $interval = absint($this->get_prop('recurring_interval', $context)); |
|
633 | + return max(1, $interval); |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | /** |
@@ -640,8 +640,8 @@ discard block |
||
640 | 640 | * @param string $context View or edit context. |
641 | 641 | * @return int |
642 | 642 | */ |
643 | - public function get_recurring_limit( $context = 'view' ) { |
|
644 | - return (int) $this->get_prop( 'recurring_limit', $context ); |
|
643 | + public function get_recurring_limit($context = 'view') { |
|
644 | + return (int) $this->get_prop('recurring_limit', $context); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
@@ -651,8 +651,8 @@ discard block |
||
651 | 651 | * @param string $context View or edit context. |
652 | 652 | * @return int |
653 | 653 | */ |
654 | - public function get_is_free_trial( $context = 'view' ) { |
|
655 | - return (int) $this->get_prop( 'is_free_trial', $context ); |
|
654 | + public function get_is_free_trial($context = 'view') { |
|
655 | + return (int) $this->get_prop('is_free_trial', $context); |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | /** |
@@ -662,8 +662,8 @@ discard block |
||
662 | 662 | * @param string $context View or edit context. |
663 | 663 | * @return int |
664 | 664 | */ |
665 | - public function get_free_trial( $context = 'view' ) { |
|
666 | - return $this->get_is_free_trial( $context ); |
|
665 | + public function get_free_trial($context = 'view') { |
|
666 | + return $this->get_is_free_trial($context); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | /** |
@@ -673,14 +673,14 @@ discard block |
||
673 | 673 | * @param bool $full Return abbreviation or in full. |
674 | 674 | * @return string |
675 | 675 | */ |
676 | - public function get_trial_period( $full = false ) { |
|
677 | - $period = $this->get_prop( 'trial_period', 'view' ); |
|
676 | + public function get_trial_period($full = false) { |
|
677 | + $period = $this->get_prop('trial_period', 'view'); |
|
678 | 678 | |
679 | - if ( $full && ! is_bool( $full ) ) { |
|
679 | + if ($full && !is_bool($full)) { |
|
680 | 680 | $full = false; |
681 | 681 | } |
682 | 682 | |
683 | - return getpaid_sanitize_recurring_period( $period, $full ); |
|
683 | + return getpaid_sanitize_recurring_period($period, $full); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | /** |
@@ -690,8 +690,8 @@ discard block |
||
690 | 690 | * @param string $context View or edit context. |
691 | 691 | * @return int |
692 | 692 | */ |
693 | - public function get_trial_interval( $context = 'view' ) { |
|
694 | - return (int) $this->get_prop( 'trial_interval', $context ); |
|
693 | + public function get_trial_interval($context = 'view') { |
|
694 | + return (int) $this->get_prop('trial_interval', $context); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | * @return string |
702 | 702 | */ |
703 | 703 | public function get_edit_url() { |
704 | - return get_edit_post_link( $this->get_id(), 'edit' ); |
|
704 | + return get_edit_post_link($this->get_id(), 'edit'); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | /** |
@@ -715,35 +715,35 @@ discard block |
||
715 | 715 | * @since 1.0.15 |
716 | 716 | * @return int |
717 | 717 | */ |
718 | - public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) { |
|
718 | + public static function get_item_id_by_field($value, $field = 'custom_id', $type = '') { |
|
719 | 719 | |
720 | 720 | // Trim the value. |
721 | - $value = sanitize_text_field( $value ); |
|
722 | - if ( empty( $value ) ) { |
|
721 | + $value = sanitize_text_field($value); |
|
722 | + if (empty($value)) { |
|
723 | 723 | return 0; |
724 | 724 | } |
725 | 725 | |
726 | 726 | // Valid fields. |
727 | - $fields = array( 'custom_id', 'name', 'slug' ); |
|
727 | + $fields = array('custom_id', 'name', 'slug'); |
|
728 | 728 | |
729 | 729 | // Ensure a field has been passed. |
730 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
730 | + if (empty($field) || !in_array($field, $fields)) { |
|
731 | 731 | return 0; |
732 | 732 | } |
733 | 733 | |
734 | - if ( $field == 'name' ) { |
|
734 | + if ($field == 'name') { |
|
735 | 735 | $field = 'slug'; |
736 | 736 | } |
737 | 737 | |
738 | 738 | // Maybe retrieve from the cache. |
739 | - $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
740 | - if ( ! empty( $item_id ) ) { |
|
739 | + $item_id = wp_cache_get($value, "getpaid_{$type}_item_{$field}s_to_item_ids"); |
|
740 | + if (!empty($item_id)) { |
|
741 | 741 | return $item_id; |
742 | 742 | } |
743 | 743 | |
744 | 744 | // Fetch from the db. |
745 | 745 | $items = array(); |
746 | - if ( $field == 'slug' ) { |
|
746 | + if ($field == 'slug') { |
|
747 | 747 | $items = get_posts( |
748 | 748 | array( |
749 | 749 | 'post_type' => 'wpi_item', |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | ); |
755 | 755 | } |
756 | 756 | |
757 | - if ( $field == 'custom_id' ) { |
|
757 | + if ($field == 'custom_id') { |
|
758 | 758 | $items = get_posts( |
759 | 759 | array( |
760 | 760 | 'post_type' => 'wpi_item', |
@@ -774,12 +774,12 @@ discard block |
||
774 | 774 | ); |
775 | 775 | } |
776 | 776 | |
777 | - if ( empty( $items ) ) { |
|
777 | + if (empty($items)) { |
|
778 | 778 | return 0; |
779 | 779 | } |
780 | 780 | |
781 | 781 | // Update the cache with our data |
782 | - wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
782 | + wp_cache_set($value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids"); |
|
783 | 783 | |
784 | 784 | return $items[0]->ID; |
785 | 785 | } |
@@ -787,19 +787,19 @@ discard block |
||
787 | 787 | /** |
788 | 788 | * Margic method for retrieving a property. |
789 | 789 | */ |
790 | - public function __get( $key ) { |
|
790 | + public function __get($key) { |
|
791 | 791 | |
792 | 792 | // Check if we have a helper method for that. |
793 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
794 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
793 | + if (method_exists($this, 'get_' . $key)) { |
|
794 | + return call_user_func(array($this, 'get_' . $key)); |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | // Check if the key is in the associated $post object. |
798 | - if ( ! empty( $this->post ) && isset( $this->post->$key ) ) { |
|
798 | + if (!empty($this->post) && isset($this->post->$key)) { |
|
799 | 799 | return $this->post->$key; |
800 | 800 | } |
801 | 801 | |
802 | - return $this->get_prop( $key ); |
|
802 | + return $this->get_prop($key); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | /* |
@@ -817,11 +817,11 @@ discard block |
||
817 | 817 | * |
818 | 818 | * @since 1.0.19 |
819 | 819 | */ |
820 | - public function set_parent_id( $value ) { |
|
821 | - if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) { |
|
820 | + public function set_parent_id($value) { |
|
821 | + if ($value && ($value === $this->get_id() || !get_post($value))) { |
|
822 | 822 | return; |
823 | 823 | } |
824 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
824 | + $this->set_prop('parent_id', absint($value)); |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | /** |
@@ -831,10 +831,10 @@ discard block |
||
831 | 831 | * @param string $status New status. |
832 | 832 | * @return array details of change. |
833 | 833 | */ |
834 | - public function set_status( $status ) { |
|
834 | + public function set_status($status) { |
|
835 | 835 | $old_status = $this->get_status(); |
836 | 836 | |
837 | - $this->set_prop( 'status', $status ); |
|
837 | + $this->set_prop('status', $status); |
|
838 | 838 | |
839 | 839 | return array( |
840 | 840 | 'from' => $old_status, |
@@ -847,8 +847,8 @@ discard block |
||
847 | 847 | * |
848 | 848 | * @since 1.0.19 |
849 | 849 | */ |
850 | - public function set_version( $value ) { |
|
851 | - $this->set_prop( 'version', $value ); |
|
850 | + public function set_version($value) { |
|
851 | + $this->set_prop('version', $value); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | /** |
@@ -858,11 +858,11 @@ discard block |
||
858 | 858 | * @param string $value Value to set. |
859 | 859 | * @return bool Whether or not the date was set. |
860 | 860 | */ |
861 | - public function set_date_created( $value ) { |
|
862 | - $date = strtotime( $value ); |
|
861 | + public function set_date_created($value) { |
|
862 | + $date = strtotime($value); |
|
863 | 863 | |
864 | - if ( $date ) { |
|
865 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
864 | + if ($date) { |
|
865 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
866 | 866 | return true; |
867 | 867 | } |
868 | 868 | |
@@ -876,11 +876,11 @@ discard block |
||
876 | 876 | * @param string $value Value to set. |
877 | 877 | * @return bool Whether or not the date was set. |
878 | 878 | */ |
879 | - public function set_date_modified( $value ) { |
|
880 | - $date = strtotime( $value ); |
|
879 | + public function set_date_modified($value) { |
|
880 | + $date = strtotime($value); |
|
881 | 881 | |
882 | - if ( $date ) { |
|
883 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
882 | + if ($date) { |
|
883 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
884 | 884 | return true; |
885 | 885 | } |
886 | 886 | |
@@ -893,9 +893,9 @@ discard block |
||
893 | 893 | * @since 1.0.19 |
894 | 894 | * @param string $value New name. |
895 | 895 | */ |
896 | - public function set_name( $value ) { |
|
897 | - $name = sanitize_text_field( $value ); |
|
898 | - $this->set_prop( 'name', $name ); |
|
896 | + public function set_name($value) { |
|
897 | + $name = sanitize_text_field($value); |
|
898 | + $this->set_prop('name', $name); |
|
899 | 899 | } |
900 | 900 | |
901 | 901 | /** |
@@ -904,8 +904,8 @@ discard block |
||
904 | 904 | * @since 1.0.19 |
905 | 905 | * @param string $value New name. |
906 | 906 | */ |
907 | - public function set_title( $value ) { |
|
908 | - $this->set_name( $value ); |
|
907 | + public function set_title($value) { |
|
908 | + $this->set_name($value); |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | /** |
@@ -914,9 +914,9 @@ discard block |
||
914 | 914 | * @since 1.0.19 |
915 | 915 | * @param string $value New description. |
916 | 916 | */ |
917 | - public function set_description( $value ) { |
|
918 | - $description = wp_kses_post( wp_unslash( $value ) ); |
|
919 | - return $this->set_prop( 'description', $description ); |
|
917 | + public function set_description($value) { |
|
918 | + $description = wp_kses_post(wp_unslash($value)); |
|
919 | + return $this->set_prop('description', $description); |
|
920 | 920 | } |
921 | 921 | |
922 | 922 | /** |
@@ -925,8 +925,8 @@ discard block |
||
925 | 925 | * @since 1.0.19 |
926 | 926 | * @param string $value New description. |
927 | 927 | */ |
928 | - public function set_excerpt( $value ) { |
|
929 | - $this->set_description( $value ); |
|
928 | + public function set_excerpt($value) { |
|
929 | + $this->set_description($value); |
|
930 | 930 | } |
931 | 931 | |
932 | 932 | /** |
@@ -935,8 +935,8 @@ discard block |
||
935 | 935 | * @since 1.0.19 |
936 | 936 | * @param string $value New description. |
937 | 937 | */ |
938 | - public function set_summary( $value ) { |
|
939 | - $this->set_description( $value ); |
|
938 | + public function set_summary($value) { |
|
939 | + $this->set_description($value); |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | /** |
@@ -945,8 +945,8 @@ discard block |
||
945 | 945 | * @since 1.0.19 |
946 | 946 | * @param int $value New author. |
947 | 947 | */ |
948 | - public function set_author( $value ) { |
|
949 | - $this->set_prop( 'author', (int) $value ); |
|
948 | + public function set_author($value) { |
|
949 | + $this->set_prop('author', (int) $value); |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | /** |
@@ -955,8 +955,8 @@ discard block |
||
955 | 955 | * @since 1.0.19 |
956 | 956 | * @param int $value New author. |
957 | 957 | */ |
958 | - public function set_owner( $value ) { |
|
959 | - $this->set_author( $value ); |
|
958 | + public function set_owner($value) { |
|
959 | + $this->set_author($value); |
|
960 | 960 | } |
961 | 961 | |
962 | 962 | /** |
@@ -965,8 +965,8 @@ discard block |
||
965 | 965 | * @since 1.0.19 |
966 | 966 | * @param float $value New price. |
967 | 967 | */ |
968 | - public function set_price( $value ) { |
|
969 | - $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) ); |
|
968 | + public function set_price($value) { |
|
969 | + $this->set_prop('price', (float) wpinv_sanitize_amount($value)); |
|
970 | 970 | } |
971 | 971 | |
972 | 972 | /** |
@@ -975,8 +975,8 @@ discard block |
||
975 | 975 | * @since 1.0.19 |
976 | 976 | * @param string $value new rule. |
977 | 977 | */ |
978 | - public function set_vat_rule( $value ) { |
|
979 | - $this->set_prop( 'vat_rule', $value ); |
|
978 | + public function set_vat_rule($value) { |
|
979 | + $this->set_prop('vat_rule', $value); |
|
980 | 980 | } |
981 | 981 | |
982 | 982 | /** |
@@ -985,8 +985,8 @@ discard block |
||
985 | 985 | * @since 1.0.19 |
986 | 986 | * @param string $value new class. |
987 | 987 | */ |
988 | - public function set_vat_class( $value ) { |
|
989 | - $this->set_prop( 'vat_class', $value ); |
|
988 | + public function set_vat_class($value) { |
|
989 | + $this->set_prop('vat_class', $value); |
|
990 | 990 | } |
991 | 991 | |
992 | 992 | /** |
@@ -996,13 +996,13 @@ discard block |
||
996 | 996 | * @param string $value new item type. |
997 | 997 | * @return string |
998 | 998 | */ |
999 | - public function set_type( $value ) { |
|
999 | + public function set_type($value) { |
|
1000 | 1000 | |
1001 | - if ( empty( $value ) ) { |
|
1001 | + if (empty($value)) { |
|
1002 | 1002 | $value = 'custom'; |
1003 | 1003 | } |
1004 | 1004 | |
1005 | - $this->set_prop( 'type', $value ); |
|
1005 | + $this->set_prop('type', $value); |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | /** |
@@ -1011,8 +1011,8 @@ discard block |
||
1011 | 1011 | * @since 1.0.19 |
1012 | 1012 | * @param string $value new custom id. |
1013 | 1013 | */ |
1014 | - public function set_custom_id( $value ) { |
|
1015 | - $this->set_prop( 'custom_id', $value ); |
|
1014 | + public function set_custom_id($value) { |
|
1015 | + $this->set_prop('custom_id', $value); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | /** |
@@ -1021,8 +1021,8 @@ discard block |
||
1021 | 1021 | * @since 1.0.19 |
1022 | 1022 | * @param string $value new custom name. |
1023 | 1023 | */ |
1024 | - public function set_custom_name( $value ) { |
|
1025 | - $this->set_prop( 'custom_name', $value ); |
|
1024 | + public function set_custom_name($value) { |
|
1025 | + $this->set_prop('custom_name', $value); |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | /** |
@@ -1031,8 +1031,8 @@ discard block |
||
1031 | 1031 | * @since 1.0.19 |
1032 | 1032 | * @param string $value new custom singular name. |
1033 | 1033 | */ |
1034 | - public function set_custom_singular_name( $value ) { |
|
1035 | - $this->set_prop( 'custom_singular_name', $value ); |
|
1034 | + public function set_custom_singular_name($value) { |
|
1035 | + $this->set_prop('custom_singular_name', $value); |
|
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | /** |
@@ -1041,8 +1041,8 @@ discard block |
||
1041 | 1041 | * @since 1.0.19 |
1042 | 1042 | * @param int|bool $value whether or not the item is editable. |
1043 | 1043 | */ |
1044 | - public function set_is_editable( $value ) { |
|
1045 | - $this->set_prop( 'is_editable', (int) $value ); |
|
1044 | + public function set_is_editable($value) { |
|
1045 | + $this->set_prop('is_editable', (int) $value); |
|
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | /** |
@@ -1051,8 +1051,8 @@ discard block |
||
1051 | 1051 | * @since 1.0.19 |
1052 | 1052 | * @param int|bool $value whether or not dynamic pricing is allowed. |
1053 | 1053 | */ |
1054 | - public function set_is_dynamic_pricing( $value ) { |
|
1055 | - $this->set_prop( 'is_dynamic_pricing', (int) $value ); |
|
1054 | + public function set_is_dynamic_pricing($value) { |
|
1055 | + $this->set_prop('is_dynamic_pricing', (int) $value); |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | /** |
@@ -1061,8 +1061,8 @@ discard block |
||
1061 | 1061 | * @since 1.0.19 |
1062 | 1062 | * @param float $value minimum price. |
1063 | 1063 | */ |
1064 | - public function set_minimum_price( $value ) { |
|
1065 | - $this->set_prop( 'minimum_price', (float) wpinv_sanitize_amount( $value ) ); |
|
1064 | + public function set_minimum_price($value) { |
|
1065 | + $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value)); |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | /** |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | * @since 1.0.19 |
1072 | 1072 | * @param int|bool $value whether or not dynamic pricing is allowed. |
1073 | 1073 | */ |
1074 | - public function set_is_multi_price_mode( $value ) { |
|
1075 | - $this->set_prop( 'is_multi_price_mode', (int) $value ); |
|
1074 | + public function set_is_multi_price_mode($value) { |
|
1075 | + $this->set_prop('is_multi_price_mode', (int) $value); |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | /** |
@@ -1081,8 +1081,8 @@ discard block |
||
1081 | 1081 | * @since 1.0.19 |
1082 | 1082 | * @param int|bool $value whether or not dynamic pricing is allowed. |
1083 | 1083 | */ |
1084 | - public function set_has_variable_pricing( $value ) { |
|
1085 | - $this->set_prop( 'has_variable_pricing', (int) $value ); |
|
1084 | + public function set_has_variable_pricing($value) { |
|
1085 | + $this->set_prop('has_variable_pricing', (int) $value); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | /** |
@@ -1091,8 +1091,8 @@ discard block |
||
1091 | 1091 | * @since 1.0.19 |
1092 | 1092 | * @param int $value default price ID. |
1093 | 1093 | */ |
1094 | - public function set_default_price_id( $value ) { |
|
1095 | - return $this->set_prop( 'default_price_id', (int) $value ); |
|
1094 | + public function set_default_price_id($value) { |
|
1095 | + return $this->set_prop('default_price_id', (int) $value); |
|
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | /** |
@@ -1101,23 +1101,23 @@ discard block |
||
1101 | 1101 | * @since 1.0.19 |
1102 | 1102 | * @param int $prices variable prices. |
1103 | 1103 | */ |
1104 | - public function set_variable_prices( $prices ) { |
|
1105 | - if ( ! is_array( $prices ) ) { |
|
1104 | + public function set_variable_prices($prices) { |
|
1105 | + if (!is_array($prices)) { |
|
1106 | 1106 | $prices = array(); |
1107 | 1107 | } |
1108 | 1108 | |
1109 | - foreach ( $prices as $id => $price ) { |
|
1110 | - if ( empty( $price['amount'] ) && empty( $price['name'] ) ) { |
|
1111 | - unset( $prices[ $id ] ); |
|
1109 | + foreach ($prices as $id => $price) { |
|
1110 | + if (empty($price['amount']) && empty($price['name'])) { |
|
1111 | + unset($prices[$id]); |
|
1112 | 1112 | continue; |
1113 | - } elseif ( empty( $price['amount'] ) ) { |
|
1113 | + } elseif (empty($price['amount'])) { |
|
1114 | 1114 | $price['amount'] = 0; |
1115 | 1115 | } |
1116 | 1116 | |
1117 | - $prices[ $id ]['amount'] = getpaid_standardize_amount( $price['amount'] ); |
|
1117 | + $prices[$id]['amount'] = getpaid_standardize_amount($price['amount']); |
|
1118 | 1118 | } |
1119 | 1119 | |
1120 | - return $this->set_prop( 'variable_prices', $prices ); |
|
1120 | + return $this->set_prop('variable_prices', $prices); |
|
1121 | 1121 | } |
1122 | 1122 | |
1123 | 1123 | /** |
@@ -1126,8 +1126,8 @@ discard block |
||
1126 | 1126 | * @since 1.0.19 |
1127 | 1127 | * @param int|bool $value whether or not dynamic pricing is allowed. |
1128 | 1128 | */ |
1129 | - public function set_is_recurring( $value ) { |
|
1130 | - $this->set_prop( 'is_recurring', (int) $value ); |
|
1129 | + public function set_is_recurring($value) { |
|
1130 | + $this->set_prop('is_recurring', (int) $value); |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | /** |
@@ -1136,8 +1136,8 @@ discard block |
||
1136 | 1136 | * @since 1.0.19 |
1137 | 1137 | * @param string $value new period. |
1138 | 1138 | */ |
1139 | - public function set_recurring_period( $value ) { |
|
1140 | - $this->set_prop( 'recurring_period', $value ); |
|
1139 | + public function set_recurring_period($value) { |
|
1140 | + $this->set_prop('recurring_period', $value); |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | /** |
@@ -1146,8 +1146,8 @@ discard block |
||
1146 | 1146 | * @since 1.0.19 |
1147 | 1147 | * @param int $value recurring interval. |
1148 | 1148 | */ |
1149 | - public function set_recurring_interval( $value ) { |
|
1150 | - return $this->set_prop( 'recurring_interval', (int) $value ); |
|
1149 | + public function set_recurring_interval($value) { |
|
1150 | + return $this->set_prop('recurring_interval', (int) $value); |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | /** |
@@ -1156,8 +1156,8 @@ discard block |
||
1156 | 1156 | * @param int $value The recurring limit. |
1157 | 1157 | * @return int |
1158 | 1158 | */ |
1159 | - public function set_recurring_limit( $value ) { |
|
1160 | - $this->set_prop( 'recurring_limit', (int) $value ); |
|
1159 | + public function set_recurring_limit($value) { |
|
1160 | + $this->set_prop('recurring_limit', (int) $value); |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | /** |
@@ -1166,8 +1166,8 @@ discard block |
||
1166 | 1166 | * @since 1.0.19 |
1167 | 1167 | * @param int|bool $value whether or not it has a free trial. |
1168 | 1168 | */ |
1169 | - public function set_is_free_trial( $value ) { |
|
1170 | - $this->set_prop( 'is_free_trial', (int) $value ); |
|
1169 | + public function set_is_free_trial($value) { |
|
1170 | + $this->set_prop('is_free_trial', (int) $value); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | /** |
@@ -1176,8 +1176,8 @@ discard block |
||
1176 | 1176 | * @since 1.0.19 |
1177 | 1177 | * @param string $value trial period. |
1178 | 1178 | */ |
1179 | - public function set_trial_period( $value ) { |
|
1180 | - $this->set_prop( 'trial_period', $value ); |
|
1179 | + public function set_trial_period($value) { |
|
1180 | + $this->set_prop('trial_period', $value); |
|
1181 | 1181 | } |
1182 | 1182 | |
1183 | 1183 | /** |
@@ -1186,8 +1186,8 @@ discard block |
||
1186 | 1186 | * @since 1.0.19 |
1187 | 1187 | * @param int $value trial interval. |
1188 | 1188 | */ |
1189 | - public function set_trial_interval( $value ) { |
|
1190 | - $this->set_prop( 'trial_interval', $value ); |
|
1189 | + public function set_trial_interval($value) { |
|
1190 | + $this->set_prop('trial_interval', $value); |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | /** |
@@ -1196,11 +1196,11 @@ discard block |
||
1196 | 1196 | * @deprecated |
1197 | 1197 | * @return int item id |
1198 | 1198 | */ |
1199 | - public function create( $data = array() ) { |
|
1199 | + public function create($data = array()) { |
|
1200 | 1200 | |
1201 | 1201 | // Set the properties. |
1202 | - if ( is_array( $data ) ) { |
|
1203 | - $this->set_props( $data ); |
|
1202 | + if (is_array($data)) { |
|
1203 | + $this->set_props($data); |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | 1206 | // Save the item. |
@@ -1213,8 +1213,8 @@ discard block |
||
1213 | 1213 | * @deprecated |
1214 | 1214 | * @return int item id |
1215 | 1215 | */ |
1216 | - public function update( $data = array() ) { |
|
1217 | - return $this->create( $data ); |
|
1216 | + public function update($data = array()) { |
|
1217 | + return $this->create($data); |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | /* |
@@ -1254,7 +1254,7 @@ discard block |
||
1254 | 1254 | */ |
1255 | 1255 | public function has_free_trial() { |
1256 | 1256 | $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false; |
1257 | - return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this ); |
|
1257 | + return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this); |
|
1258 | 1258 | } |
1259 | 1259 | |
1260 | 1260 | /** |
@@ -1264,8 +1264,8 @@ discard block |
||
1264 | 1264 | * @return bool |
1265 | 1265 | */ |
1266 | 1266 | public function is_free() { |
1267 | - $is_free = $this->get_price() == 0; |
|
1268 | - return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this ); |
|
1267 | + $is_free = $this->get_price() == 0; |
|
1268 | + return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this); |
|
1269 | 1269 | } |
1270 | 1270 | |
1271 | 1271 | /** |
@@ -1274,9 +1274,9 @@ discard block |
||
1274 | 1274 | * @param array|string $status Status to check. |
1275 | 1275 | * @return bool |
1276 | 1276 | */ |
1277 | - public function has_status( $status ) { |
|
1278 | - $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status; |
|
1279 | - return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status ); |
|
1277 | + public function has_status($status) { |
|
1278 | + $has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status; |
|
1279 | + return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status); |
|
1280 | 1280 | } |
1281 | 1281 | |
1282 | 1282 | /** |
@@ -1285,9 +1285,9 @@ discard block |
||
1285 | 1285 | * @param array|string $type Type to check. |
1286 | 1286 | * @return bool |
1287 | 1287 | */ |
1288 | - public function is_type( $type ) { |
|
1289 | - $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type; |
|
1290 | - return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type ); |
|
1288 | + public function is_type($type) { |
|
1289 | + $is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type; |
|
1290 | + return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type); |
|
1291 | 1291 | } |
1292 | 1292 | |
1293 | 1293 | /** |
@@ -1298,7 +1298,7 @@ discard block |
||
1298 | 1298 | */ |
1299 | 1299 | public function is_editable() { |
1300 | 1300 | $is_editable = $this->get_is_editable(); |
1301 | - return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this ); |
|
1301 | + return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this); |
|
1302 | 1302 | } |
1303 | 1303 | |
1304 | 1304 | /** |
@@ -1317,11 +1317,11 @@ discard block |
||
1317 | 1317 | public function can_purchase() { |
1318 | 1318 | $can_purchase = $this->exists(); |
1319 | 1319 | |
1320 | - if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) { |
|
1320 | + if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') { |
|
1321 | 1321 | $can_purchase = false; |
1322 | 1322 | } |
1323 | 1323 | |
1324 | - return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this ); |
|
1324 | + return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this); |
|
1325 | 1325 | } |
1326 | 1326 | |
1327 | 1327 | /** |
@@ -1331,6 +1331,6 @@ discard block |
||
1331 | 1331 | * @return bool |
1332 | 1332 | */ |
1333 | 1333 | public function supports_dynamic_pricing() { |
1334 | - return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this ); |
|
1334 | + return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this); |
|
1335 | 1335 | } |
1336 | 1336 | } |
@@ -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,12 +21,12 @@ 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 | // Prepare the item. |
26 | - $item = new WPInv_Item( $post ); |
|
26 | + $item = new WPInv_Item($post); |
|
27 | 27 | |
28 | 28 | // Nonce field. |
29 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
29 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
30 | 30 | |
31 | 31 | // Variable prices. |
32 | 32 | $variable_prices = $item->get_variable_prices(); |
@@ -34,16 +34,16 @@ discard block |
||
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 | |
45 | 45 | ?> |
46 | - <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" /> |
|
46 | + <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" /> |
|
47 | 47 | <style> |
48 | 48 | #poststuff .input-group-text, |
49 | 49 | #poststuff .form-control { |
@@ -56,37 +56,37 @@ discard block |
||
56 | 56 | </style> |
57 | 57 | <div class="bsui" style="max-width: 600px;padding-top: 10px;"> |
58 | 58 | |
59 | - <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?> |
|
59 | + <?php do_action('wpinv_item_details_metabox_before_price', $item); ?> |
|
60 | 60 | |
61 | 61 | <div class="form-group mb-3 row"> |
62 | - <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php esc_html_e( 'Item Price', 'invoicing' ); ?></span></label> |
|
62 | + <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php esc_html_e('Item Price', 'invoicing'); ?></span></label> |
|
63 | 63 | <div class="col-sm-8"> |
64 | 64 | <div class="row wpinv_hide_if_variable_pricing"> |
65 | 65 | <div class="col-sm-4 getpaid-price-input mb-3"> |
66 | 66 | <div class="input-group input-group-sm"> |
67 | 67 | |
68 | - <?php if ( 'left' == $position ) : ?> |
|
69 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
68 | + <?php if ('left' == $position) : ?> |
|
69 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
70 | 70 | <div class="input-group-prepend"> |
71 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
71 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
72 | 72 | </div> |
73 | 73 | <?php else : ?> |
74 | 74 | <span class="input-group-text"> |
75 | - <?php echo wp_kses_post( wpinv_currency_symbol() ); ?> |
|
75 | + <?php echo wp_kses_post(wpinv_currency_symbol()); ?> |
|
76 | 76 | </span> |
77 | 77 | <?php endif; ?> |
78 | 78 | <?php endif; ?> |
79 | 79 | |
80 | - <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 wpinv-force-integer" autocomplete="off"> |
|
80 | + <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 wpinv-force-integer" autocomplete="off"> |
|
81 | 81 | |
82 | - <?php if ( 'left' != $position ) : ?> |
|
83 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
82 | + <?php if ('left' != $position) : ?> |
|
83 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
84 | 84 | <div class="input-group-append"> |
85 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
85 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
86 | 86 | </div> |
87 | 87 | <?php else : ?> |
88 | 88 | <span class="input-group-text"> |
89 | - <?php echo wp_kses_post( wpinv_currency_symbol() ); ?> |
|
89 | + <?php echo wp_kses_post(wpinv_currency_symbol()); ?> |
|
90 | 90 | </span> |
91 | 91 | <?php endif; ?> |
92 | 92 | <?php endif; ?> |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | </div> |
95 | 95 | <div class="col-sm-4 wpinv_show_if_recurring"> |
96 | 96 | <?php |
97 | - esc_html_e( 'Every' ); |
|
97 | + esc_html_e('Every'); |
|
98 | 98 | echo ' '; |
99 | 99 | ?> |
100 | - <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" /> |
|
100 | + <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" /> |
|
101 | 101 | </div> |
102 | 102 | <div class="col-sm-4 wpinv_show_if_recurring"> |
103 | 103 | <?php |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | array( |
106 | 106 | 'id' => 'wpinv_recurring_period', |
107 | 107 | 'name' => 'wpinv_recurring_period', |
108 | - 'label' => __( 'Period', 'invoicing' ), |
|
109 | - 'placeholder' => __( 'Select Period', 'invoicing' ), |
|
110 | - 'value' => $item->get_recurring_period( 'edit' ), |
|
108 | + 'label' => __('Period', 'invoicing'), |
|
109 | + 'placeholder' => __('Select Period', 'invoicing'), |
|
110 | + 'value' => $item->get_recurring_period('edit'), |
|
111 | 111 | 'select2' => true, |
112 | 112 | 'data-allow-clear' => 'false', |
113 | 113 | 'options' => array( |
114 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
115 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
116 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
117 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
114 | + 'D' => __('day(s)', 'invoicing'), |
|
115 | + 'W' => __('week(s)', 'invoicing'), |
|
116 | + 'M' => __('month(s)', 'invoicing'), |
|
117 | + 'Y' => __('year(s)', 'invoicing'), |
|
118 | 118 | ), |
119 | 119 | ), |
120 | 120 | true |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | <div class="col-sm-12"> |
128 | 128 | <?php |
129 | 129 | // Variable pricing. |
130 | - do_action( 'wpinv_item_details_metabox_before_variable_pricing_checkbox', $item ); |
|
130 | + do_action('wpinv_item_details_metabox_before_variable_pricing_checkbox', $item); |
|
131 | 131 | |
132 | 132 | aui()->input( |
133 | 133 | array( |
134 | 134 | 'id' => 'wpinv_variable_pricing', |
135 | 135 | 'name' => 'wpinv_variable_pricing', |
136 | 136 | 'type' => 'checkbox', |
137 | - 'label' => apply_filters( 'wpinv_variable_pricing_toggle_text', __( 'Enable variable pricing', 'invoicing' ) ), |
|
137 | + 'label' => apply_filters('wpinv_variable_pricing_toggle_text', __('Enable variable pricing', 'invoicing')), |
|
138 | 138 | 'value' => '1', |
139 | 139 | 'checked' => $item->has_variable_pricing(), |
140 | 140 | 'no_wrap' => true, |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | true |
143 | 143 | ); |
144 | 144 | |
145 | - do_action( 'wpinv_item_details_metabox_variable_pricing_checkbox', $item ); |
|
145 | + do_action('wpinv_item_details_metabox_variable_pricing_checkbox', $item); |
|
146 | 146 | ?> |
147 | 147 | </div> |
148 | 148 | </div> |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | <?php |
153 | 153 | |
154 | 154 | // Dynamic pricing. |
155 | - if ( $item->supports_dynamic_pricing() ) { |
|
155 | + if ($item->supports_dynamic_pricing()) { |
|
156 | 156 | |
157 | - do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
157 | + do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item); |
|
158 | 158 | |
159 | 159 | // NYP toggle. |
160 | 160 | aui()->input( |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | 'id' => 'wpinv_name_your_price', |
163 | 163 | 'name' => 'wpinv_name_your_price', |
164 | 164 | 'type' => 'checkbox', |
165 | - 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
165 | + 'label' => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')), |
|
166 | 166 | 'value' => '1', |
167 | 167 | 'checked' => $item->user_can_set_their_price(), |
168 | 168 | 'no_wrap' => true, |
@@ -170,72 +170,72 @@ discard block |
||
170 | 170 | true |
171 | 171 | ); |
172 | 172 | |
173 | - do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
173 | + do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | // Subscriptions. |
177 | - do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item ); |
|
177 | + do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item); |
|
178 | 178 | |
179 | 179 | aui()->input( |
180 | 180 | array( |
181 | 181 | 'id' => 'wpinv_is_recurring', |
182 | 182 | 'name' => 'wpinv_is_recurring', |
183 | 183 | 'type' => 'checkbox', |
184 | - 'label' => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ), |
|
184 | + 'label' => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')), |
|
185 | 185 | 'value' => '1', |
186 | 186 | 'checked' => $item->is_recurring(), |
187 | 187 | 'no_wrap' => true, |
188 | 188 | ), |
189 | 189 | true |
190 | 190 | ); |
191 | - do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item ); |
|
191 | + do_action('wpinv_item_details_metabox_subscription_checkbox', $item); |
|
192 | 192 | |
193 | 193 | ?> |
194 | 194 | <div class="wpinv_show_if_recurring"> |
195 | - <em><?php echo wp_kses_post( wpinv_get_recurring_gateways_text() ); ?></em> |
|
195 | + <em><?php echo wp_kses_post(wpinv_get_recurring_gateways_text()); ?></em> |
|
196 | 196 | </div> |
197 | 197 | </div> |
198 | 198 | </div> |
199 | 199 | </div> |
200 | 200 | <div class="col-sm-1 pt-2 pl-0 wpinv_hide_if_variable_pricing"> |
201 | - <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> |
|
201 | + <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> |
|
202 | 202 | </div> |
203 | 203 | </div> |
204 | 204 | |
205 | - <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?> |
|
205 | + <?php do_action('wpinv_item_details_metabox_after_price', $item); ?> |
|
206 | 206 | |
207 | - <?php if ( $item->supports_dynamic_pricing() ) : ?> |
|
208 | - <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?> |
|
207 | + <?php if ($item->supports_dynamic_pricing()) : ?> |
|
208 | + <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?> |
|
209 | 209 | <div class="wpinv_show_if_dynamic wpinv_minimum_price wpinv_hide_if_variable_pricing"> |
210 | 210 | |
211 | 211 | <div class="form-group mb-3 row"> |
212 | 212 | <label for="wpinv_minimum_price" class="col-sm-3 col-form-label"> |
213 | - <?php esc_html_e( 'Minimum Price', 'invoicing' ); ?> |
|
213 | + <?php esc_html_e('Minimum Price', 'invoicing'); ?> |
|
214 | 214 | </label> |
215 | 215 | <div class="col-sm-8"> |
216 | 216 | <div class="input-group input-group-sm"> |
217 | - <?php if ( 'left' == $position ) : ?> |
|
218 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
217 | + <?php if ('left' == $position) : ?> |
|
218 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
219 | 219 | <div class="input-group-prepend"> |
220 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
220 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
221 | 221 | </div> |
222 | 222 | <?php else : ?> |
223 | 223 | <span class="input-group-text"> |
224 | - <?php echo wp_kses_post( wpinv_currency_symbol() ); ?> |
|
224 | + <?php echo wp_kses_post(wpinv_currency_symbol()); ?> |
|
225 | 225 | </span> |
226 | 226 | <?php endif; ?> |
227 | 227 | <?php endif; ?> |
228 | 228 | |
229 | - <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 wpinv-force-integer"> |
|
229 | + <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 wpinv-force-integer"> |
|
230 | 230 | |
231 | - <?php if ( 'left' != $position ) : ?> |
|
232 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
231 | + <?php if ('left' != $position) : ?> |
|
232 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
233 | 233 | <div class="input-group-append"> |
234 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
234 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
235 | 235 | </div> |
236 | 236 | <?php else : ?> |
237 | 237 | <span class="input-group-text"> |
238 | - <?php echo wp_kses_post( wpinv_currency_symbol() ); ?> |
|
238 | + <?php echo wp_kses_post(wpinv_currency_symbol()); ?> |
|
239 | 239 | </span> |
240 | 240 | <?php endif; ?> |
241 | 241 | <?php endif; ?> |
@@ -243,45 +243,45 @@ discard block |
||
243 | 243 | </div> |
244 | 244 | |
245 | 245 | <div class="col-sm-1 pt-2 pl-0"> |
246 | - <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> |
|
246 | + <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> |
|
247 | 247 | </div> |
248 | 248 | </div> |
249 | 249 | |
250 | 250 | </div> |
251 | - <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?> |
|
251 | + <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?> |
|
252 | 252 | <?php endif; ?> |
253 | 253 | |
254 | - <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?> |
|
254 | + <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?> |
|
255 | 255 | <div class="wpinv_show_if_recurring wpinv_hide_if_variable_pricing wpinv_maximum_renewals"> |
256 | 256 | |
257 | 257 | <div class="form-group mb-3 row"> |
258 | 258 | <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label"> |
259 | - <?php esc_html_e( 'Maximum Renewals', 'invoicing' ); ?> |
|
259 | + <?php esc_html_e('Maximum Renewals', 'invoicing'); ?> |
|
260 | 260 | </label> |
261 | 261 | <div class="col-sm-8"> |
262 | - <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%;" /> |
|
262 | + <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%;" /> |
|
263 | 263 | </div> |
264 | 264 | <div class="col-sm-1 pt-2 pl-0"> |
265 | - <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> |
|
265 | + <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> |
|
266 | 266 | </div> |
267 | 267 | </div> |
268 | 268 | |
269 | 269 | </div> |
270 | - <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?> |
|
270 | + <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?> |
|
271 | 271 | |
272 | - <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?> |
|
272 | + <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?> |
|
273 | 273 | <div class="wpinv_show_if_recurring wpinv_hide_if_variable_pricing wpinv_free_trial"> |
274 | 274 | |
275 | 275 | <div class="form-group mb-3 row"> |
276 | - <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined( 'GETPAID_PAID_TRIALS_VERSION' ) ? esc_html_e( 'Free/Paid Trial', 'invoicing' ) : esc_html_e( 'Free Trial', 'invoicing' ); ?></label> |
|
276 | + <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined('GETPAID_PAID_TRIALS_VERSION') ? esc_html_e('Free/Paid Trial', 'invoicing') : esc_html_e('Free Trial', 'invoicing'); ?></label> |
|
277 | 277 | |
278 | 278 | <div class="col-sm-8"> |
279 | 279 | <div class="row"> |
280 | 280 | <div class="col-sm-6"> |
281 | - <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0; ?> |
|
281 | + <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?> |
|
282 | 282 | |
283 | 283 | <div> |
284 | - <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>"> |
|
284 | + <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>"> |
|
285 | 285 | </div> |
286 | 286 | </div> |
287 | 287 | <div class="col-sm-6"> |
@@ -290,17 +290,17 @@ discard block |
||
290 | 290 | array( |
291 | 291 | 'id' => 'wpinv_trial_period', |
292 | 292 | 'name' => 'wpinv_trial_period', |
293 | - 'label' => __( 'Trial Period', 'invoicing' ), |
|
294 | - 'placeholder' => __( 'Trial Period', 'invoicing' ), |
|
295 | - 'value' => $item->get_trial_period( 'edit' ), |
|
293 | + 'label' => __('Trial Period', 'invoicing'), |
|
294 | + 'placeholder' => __('Trial Period', 'invoicing'), |
|
295 | + 'value' => $item->get_trial_period('edit'), |
|
296 | 296 | 'select2' => true, |
297 | 297 | 'data-allow-clear' => 'false', |
298 | 298 | 'no_wrap' => true, |
299 | 299 | 'options' => array( |
300 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
301 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
302 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
303 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
300 | + 'D' => __('day(s)', 'invoicing'), |
|
301 | + 'W' => __('week(s)', 'invoicing'), |
|
302 | + 'M' => __('month(s)', 'invoicing'), |
|
303 | + 'Y' => __('year(s)', 'invoicing'), |
|
304 | 304 | ), |
305 | 305 | ), |
306 | 306 | true |
@@ -312,17 +312,17 @@ discard block |
||
312 | 312 | </div> |
313 | 313 | |
314 | 314 | <div class="col-sm-1 pt-2 pl-0"> |
315 | - <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> |
|
315 | + <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> |
|
316 | 316 | </div> |
317 | 317 | |
318 | 318 | </div> |
319 | 319 | |
320 | 320 | </div> |
321 | - <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?> |
|
321 | + <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?> |
|
322 | 322 | </div> |
323 | 323 | |
324 | 324 | <div class="bsui"> |
325 | - <?php do_action( 'wpinv_item_details_metabox_before_variable_pricing', $item ); ?> |
|
325 | + <?php do_action('wpinv_item_details_metabox_before_variable_pricing', $item); ?> |
|
326 | 326 | |
327 | 327 | <div class="wpinv_show_if_variable_pricing wpinv_variable_pricing"> |
328 | 328 | |
@@ -331,47 +331,47 @@ discard block |
||
331 | 331 | |
332 | 332 | <div class="wpinv-price-option-fields getpaid-repeatables-wrap"> |
333 | 333 | <?php |
334 | - if ( ! empty( $variable_prices ) ) : |
|
334 | + if (!empty($variable_prices)) : |
|
335 | 335 | |
336 | - foreach ( $variable_prices as $key => $value ) : |
|
337 | - $name = (isset( $value['name'] ) && ! empty( $value['name'] )) ? $value['name'] : ''; |
|
338 | - $index = (isset( $value['index'] ) && $value['index'] !== '') ? $value['index'] : $key; |
|
339 | - $amount = isset( $value['amount'] ) ? $value['amount'] : ''; |
|
336 | + foreach ($variable_prices as $key => $value) : |
|
337 | + $name = (isset($value['name']) && !empty($value['name'])) ? $value['name'] : ''; |
|
338 | + $index = (isset($value['index']) && $value['index'] !== '') ? $value['index'] : $key; |
|
339 | + $amount = isset($value['amount']) ? $value['amount'] : ''; |
|
340 | 340 | |
341 | - $args = apply_filters( 'wpinv_price_row_args', compact( 'name', 'amount' ), $value ); |
|
342 | - $args = wp_parse_args( $args, $value ); |
|
341 | + $args = apply_filters('wpinv_price_row_args', compact('name', 'amount'), $value); |
|
342 | + $args = wp_parse_args($args, $value); |
|
343 | 343 | ?> |
344 | - <div class="wpinv_variable_prices_wrapper getpaid_repeatable_row" data-key="<?php echo esc_attr( $key ); ?>"> |
|
345 | - <?php self::render_price_row( $key, $args, $item, $index ); ?> |
|
344 | + <div class="wpinv_variable_prices_wrapper getpaid_repeatable_row" data-key="<?php echo esc_attr($key); ?>"> |
|
345 | + <?php self::render_price_row($key, $args, $item, $index); ?> |
|
346 | 346 | </div> |
347 | 347 | <?php |
348 | 348 | endforeach; |
349 | 349 | else : |
350 | 350 | ?> |
351 | 351 | <div class="wpinv_variable_prices_wrapper getpaid_repeatable_row" data-key="1"> |
352 | - <?php self::render_price_row( 1, array(), $item, 1 ); ?> |
|
352 | + <?php self::render_price_row(1, array(), $item, 1); ?> |
|
353 | 353 | </div> |
354 | 354 | <?php endif; ?> |
355 | 355 | |
356 | 356 | <div class="wpinv-add-repeatable-row"> |
357 | 357 | <div class="float-none pt-2 clear"> |
358 | - <button type="button" class="button-secondary getpaid-add-variable-price-row"><?php _e( 'Add New Price', 'invoicing' ); ?></button> |
|
358 | + <button type="button" class="button-secondary getpaid-add-variable-price-row"><?php _e('Add New Price', 'invoicing'); ?></button> |
|
359 | 359 | </div> |
360 | 360 | </div> |
361 | 361 | </div> |
362 | 362 | </div> |
363 | 363 | </div> |
364 | 364 | </div> |
365 | - <?php do_action( 'wpinv_item_details_metabox_variable_pricing', $item ); ?> |
|
365 | + <?php do_action('wpinv_item_details_metabox_variable_pricing', $item); ?> |
|
366 | 366 | </div> |
367 | 367 | |
368 | 368 | <div class="bsui" style="max-width: 600px;"> |
369 | - <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?> |
|
369 | + <?php do_action('wpinv_item_details_metabox_item_details', $item); ?> |
|
370 | 370 | </div> |
371 | 371 | |
372 | 372 | <script type="text/html" id="tmpl-getpaid-variable-price-row"> |
373 | 373 | <div class="wpinv_variable_prices_wrapper getpaid_repeatable_row" data-key="1"> |
374 | - <?php self::render_price_row( 1, array(), $item, 1 ); ?> |
|
374 | + <?php self::render_price_row(1, array(), $item, 1); ?> |
|
375 | 375 | </div> |
376 | 376 | </script> |
377 | 377 | |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | * @param WP_Post $item WPINV Itemm object. |
474 | 474 | * @param int $index The index of the price row. |
475 | 475 | */ |
476 | - public static function render_price_row( $key, $args = array(), $item, $index ) { |
|
476 | + public static function render_price_row($key, $args = array(), $item, $index) { |
|
477 | 477 | $defaults = array( |
478 | 478 | 'name' => null, |
479 | 479 | 'amount' => null, |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | 'recurring-limit' => 0, |
486 | 486 | ); |
487 | 487 | |
488 | - $args = wp_parse_args( $args, $defaults ); |
|
488 | + $args = wp_parse_args($args, $defaults); |
|
489 | 489 | |
490 | 490 | $default_price_id = $item->get_default_price_id(); |
491 | 491 | $is_recurring = ('yes' === $args['is-recurring']) ? true : false; |
@@ -498,22 +498,22 @@ discard block |
||
498 | 498 | 'style' => 'width: 70px', |
499 | 499 | ); |
500 | 500 | |
501 | - if ( ! $is_recurring ) { |
|
501 | + if (!$is_recurring) { |
|
502 | 502 | $extra_attributes['disabled'] = true; |
503 | 503 | } |
504 | 504 | ?> |
505 | 505 | <div class="getpaid-repeatable-row-header getpaid-draghandle-cursor"> |
506 | 506 | |
507 | - <span class="getpaid-repeatable-row-title" title="<?php _e( 'Click and drag to re-order price options', 'invoicing' ); ?>"> |
|
508 | - <?php printf( __( 'Price ID: %s', 'invoicing' ), '<span class="getpaid_price_id">' . $key . '</span>' ); ?> |
|
507 | + <span class="getpaid-repeatable-row-title" title="<?php _e('Click and drag to re-order price options', 'invoicing'); ?>"> |
|
508 | + <?php printf(__('Price ID: %s', 'invoicing'), '<span class="getpaid_price_id">' . $key . '</span>'); ?> |
|
509 | 509 | <input type="hidden" name="wpinv_variable_prices[<?php echo $key; ?>][index]" class="getpaid_repeatable_index" value="<?php echo $index; ?>"/> |
510 | 510 | </span> |
511 | 511 | |
512 | 512 | <span class="getpaid-repeatable-row-actions"> |
513 | - <a href="#" class="wpinv-toggle-custom-price-option-settings" data-show="<?php _e( 'Show advanced settings', 'invoicing' ); ?>" data-hide="<?php _e( 'Hide advanced settings', 'invoicing' ); ?>"><?php _e( 'Show advanced settings', 'invoicing' ); ?></a> |
|
513 | + <a href="#" class="wpinv-toggle-custom-price-option-settings" data-show="<?php _e('Show advanced settings', 'invoicing'); ?>" data-hide="<?php _e('Hide advanced settings', 'invoicing'); ?>"><?php _e('Show advanced settings', 'invoicing'); ?></a> |
|
514 | 514 | | |
515 | 515 | <a class="getpaid-remove-price-option-row text-danger"> |
516 | - <?php _e( 'Remove', 'invoicing' ); ?> <span class="screen-reader-text"><?php printf( __( 'Remove price option %s', 'invoicing' ), esc_attr( $key ) ); ?></span> |
|
516 | + <?php _e('Remove', 'invoicing'); ?> <span class="screen-reader-text"><?php printf(__('Remove price option %s', 'invoicing'), esc_attr($key)); ?></span> |
|
517 | 517 | </a> |
518 | 518 | </span> |
519 | 519 | </div> |
@@ -521,13 +521,13 @@ discard block |
||
521 | 521 | <div class="getpaid-repeatable-row-standard-fields"> |
522 | 522 | |
523 | 523 | <div class="getpaid-option-name"> |
524 | - <label class="form-label"><?php _e( 'Option Name', 'invoicing' ); ?></label> |
|
524 | + <label class="form-label"><?php _e('Option Name', 'invoicing'); ?></label> |
|
525 | 525 | <?php |
526 | 526 | aui()->input( |
527 | 527 | array( |
528 | 528 | 'name' => 'wpinv_variable_prices[' . $key . '][name]', |
529 | - 'placeholder' => __( 'Option Name', 'invoicing' ), |
|
530 | - 'value' => esc_attr( $args['name'] ), |
|
529 | + 'placeholder' => __('Option Name', 'invoicing'), |
|
530 | + 'value' => esc_attr($args['name']), |
|
531 | 531 | 'class' => 'wpinv_variable_price_name form-control-sm', |
532 | 532 | 'no_wrap' => true, |
533 | 533 | ), |
@@ -537,30 +537,30 @@ discard block |
||
537 | 537 | </div> |
538 | 538 | |
539 | 539 | <div class="getpaid-option-price"> |
540 | - <label class="form-label"><?php _e( 'Price', 'invoicing' ); ?></label> |
|
540 | + <label class="form-label"><?php _e('Price', 'invoicing'); ?></label> |
|
541 | 541 | <div class="input-group input-group-sm"> |
542 | - <?php if ( 'left' == $position ) : ?> |
|
543 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
542 | + <?php if ('left' == $position) : ?> |
|
543 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
544 | 544 | <div class="input-group-prepend"> |
545 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
545 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
546 | 546 | </div> |
547 | 547 | <?php else : ?> |
548 | 548 | <span class="input-group-text"> |
549 | - <?php echo wp_kses_post( wpinv_currency_symbol() ); ?> |
|
549 | + <?php echo wp_kses_post(wpinv_currency_symbol()); ?> |
|
550 | 550 | </span> |
551 | 551 | <?php endif; ?> |
552 | 552 | <?php endif; ?> |
553 | 553 | |
554 | - <input type="text" name="wpinv_variable_prices[<?php echo $key; ?>][amount]" id="wpinv_variable_prices[<?php echo $key; ?>][amount]" value="<?php echo esc_attr( getpaid_unstandardize_amount( $args['amount'] ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 9.99 ) ); ?>" class="form-control form-control-sm wpinv-force-integer getpaid-price-field" autocomplete="off"> |
|
554 | + <input type="text" name="wpinv_variable_prices[<?php echo $key; ?>][amount]" id="wpinv_variable_prices[<?php echo $key; ?>][amount]" value="<?php echo esc_attr(getpaid_unstandardize_amount($args['amount'])); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(9.99)); ?>" class="form-control form-control-sm wpinv-force-integer getpaid-price-field" autocomplete="off"> |
|
555 | 555 | |
556 | - <?php if ( 'left' != $position ) : ?> |
|
557 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
556 | + <?php if ('left' != $position) : ?> |
|
557 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
558 | 558 | <div class="input-group-append"> |
559 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
559 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
560 | 560 | </div> |
561 | 561 | <?php else : ?> |
562 | 562 | <span class="input-group-text"> |
563 | - <?php echo wp_kses_post( wpinv_currency_symbol() ); ?> |
|
563 | + <?php echo wp_kses_post(wpinv_currency_symbol()); ?> |
|
564 | 564 | </span> |
565 | 565 | <?php endif; ?> |
566 | 566 | <?php endif; ?> |
@@ -568,10 +568,10 @@ discard block |
||
568 | 568 | </div> |
569 | 569 | |
570 | 570 | <div class="getpaid_repeatable_default getpaid_repeatable_default_wrapper"> |
571 | - <label class="form-label d-block"><?php _e( 'Default', 'invoicing' ); ?></label> |
|
571 | + <label class="form-label d-block"><?php _e('Default', 'invoicing'); ?></label> |
|
572 | 572 | <label class="getpaid-default-price"> |
573 | - <input type="radio" <?php checked( $default_price_id, $key, true ); ?> class="getpaid_repeatable_default_input" name="_wpinv_default_price_id" value="<?php echo $key; ?>" /> |
|
574 | - <span class="screen-reader-text"><?php printf( __( 'Set ID %s as default price', 'invoicing' ), $key ); ?></span> |
|
573 | + <input type="radio" <?php checked($default_price_id, $key, true); ?> class="getpaid_repeatable_default_input" name="_wpinv_default_price_id" value="<?php echo $key; ?>" /> |
|
574 | + <span class="screen-reader-text"><?php printf(__('Set ID %s as default price', 'invoicing'), $key); ?></span> |
|
575 | 575 | </label> |
576 | 576 | </div> |
577 | 577 | |
@@ -581,20 +581,20 @@ discard block |
||
581 | 581 | <div class="wpinv-custom-price-option-settings"> |
582 | 582 | <div class="wpinv-custom-price-option-setting"> |
583 | 583 | |
584 | - <div class="wpinv-custom-price-option-setting-title"><?php _e( 'Recurring Payments Settings', 'invoicing' ); ?></div> |
|
584 | + <div class="wpinv-custom-price-option-setting-title"><?php _e('Recurring Payments Settings', 'invoicing'); ?></div> |
|
585 | 585 | |
586 | 586 | <div class="wpinv-recurring-enabled"> |
587 | - <label class="form-label"><?php _e( 'Recurring', 'invoicing' ); ?></label> |
|
587 | + <label class="form-label"><?php _e('Recurring', 'invoicing'); ?></label> |
|
588 | 588 | <?php |
589 | 589 | aui()->select( |
590 | 590 | array( |
591 | 591 | 'name' => 'wpinv_variable_prices[' . $key . '][is-recurring]', |
592 | - 'value' => esc_attr( $args['is-recurring'] ), |
|
592 | + 'value' => esc_attr($args['is-recurring']), |
|
593 | 593 | 'class' => 'custom-select-sm', |
594 | 594 | 'no_wrap' => true, |
595 | 595 | 'options' => array( |
596 | - 'no' => __( 'No', 'invoicing' ), |
|
597 | - 'yes' => __( 'Yes', 'invoicing' ), |
|
596 | + 'no' => __('No', 'invoicing'), |
|
597 | + 'yes' => __('Yes', 'invoicing'), |
|
598 | 598 | ), |
599 | 599 | ), |
600 | 600 | true |
@@ -603,14 +603,14 @@ discard block |
||
603 | 603 | </div> |
604 | 604 | |
605 | 605 | <div class="wpinv-recurring-free-trial"> |
606 | - <label class="form-label"><?php _e( 'Free Trial', 'invoicing' ); ?></label> |
|
606 | + <label class="form-label"><?php _e('Free Trial', 'invoicing'); ?></label> |
|
607 | 607 | <?php |
608 | 608 | aui()->input( |
609 | 609 | array( |
610 | 610 | 'type' => 'number', |
611 | 611 | 'id' => 'wpinv_variable_prices[' . $key . '][trial-interval]', |
612 | 612 | 'name' => 'wpinv_variable_prices[' . $key . '][trial-interval]', |
613 | - 'value' => absint( $args['trial-interval'] ), |
|
613 | + 'value' => absint($args['trial-interval']), |
|
614 | 614 | 'class' => 'form-control-sm d-inline-block', |
615 | 615 | 'no_wrap' => true, |
616 | 616 | 'extra_attributes' => $extra_attributes, |
@@ -624,15 +624,15 @@ discard block |
||
624 | 624 | array( |
625 | 625 | 'id' => 'wpinv_variable_prices[' . $key . '][trial-period]', |
626 | 626 | 'name' => 'wpinv_variable_prices[' . $key . '][trial-period]', |
627 | - 'value' => esc_attr( $args['trial-period'] ), |
|
627 | + 'value' => esc_attr($args['trial-period']), |
|
628 | 628 | 'class' => 'custom-select-sm w-auto d-inline-block', |
629 | 629 | 'no_wrap' => true, |
630 | - 'extra_attributes' => ( ! $is_recurring ? array( 'disabled' => true ) : array()), |
|
630 | + 'extra_attributes' => (!$is_recurring ? array('disabled' => true) : array()), |
|
631 | 631 | 'options' => array( |
632 | - 'D' => __( 'Day(s)', 'invoicing' ), |
|
633 | - 'W' => __( 'Week(s)', 'invoicing' ), |
|
634 | - 'M' => __( 'Month(s)', 'invoicing' ), |
|
635 | - 'Y' => __( 'Year(s)', 'invoicing' ), |
|
632 | + 'D' => __('Day(s)', 'invoicing'), |
|
633 | + 'W' => __('Week(s)', 'invoicing'), |
|
634 | + 'M' => __('Month(s)', 'invoicing'), |
|
635 | + 'Y' => __('Year(s)', 'invoicing'), |
|
636 | 636 | ), |
637 | 637 | ), |
638 | 638 | true |
@@ -641,14 +641,14 @@ discard block |
||
641 | 641 | </div> |
642 | 642 | |
643 | 643 | <div class="wpinv-recurring-interval"> |
644 | - <label class="form-label"><?php _e( 'Every', 'invoicing' ); ?></label> |
|
644 | + <label class="form-label"><?php _e('Every', 'invoicing'); ?></label> |
|
645 | 645 | <?php |
646 | 646 | aui()->input( |
647 | 647 | array( |
648 | 648 | 'type' => 'number', |
649 | 649 | 'id' => 'wpinv_variable_prices[' . $key . '][recurring-interval]', |
650 | 650 | 'name' => 'wpinv_variable_prices[' . $key . '][recurring-interval]', |
651 | - 'value' => absint( $args['recurring-interval'] ), |
|
651 | + 'value' => absint($args['recurring-interval']), |
|
652 | 652 | 'class' => 'form-control-sm', |
653 | 653 | 'no_wrap' => true, |
654 | 654 | 'extra_attributes' => $extra_attributes, |
@@ -659,21 +659,21 @@ discard block |
||
659 | 659 | </div> |
660 | 660 | |
661 | 661 | <div class="wpinv-recurring-period"> |
662 | - <label class="form-label"><?php _e( 'Period', 'invoicing' ); ?></label> |
|
662 | + <label class="form-label"><?php _e('Period', 'invoicing'); ?></label> |
|
663 | 663 | <?php |
664 | 664 | aui()->select( |
665 | 665 | array( |
666 | 666 | 'id' => 'wpinv_variable_prices[' . $key . '][recurring-period]', |
667 | 667 | 'name' => 'wpinv_variable_prices[' . $key . '][recurring-period]', |
668 | - 'value' => esc_attr( $args['recurring-period'] ), |
|
668 | + 'value' => esc_attr($args['recurring-period']), |
|
669 | 669 | 'class' => 'custom-select-sm', |
670 | - 'extra_attributes' => ( ! $is_recurring ? array( 'disabled' => true ) : array()), |
|
670 | + 'extra_attributes' => (!$is_recurring ? array('disabled' => true) : array()), |
|
671 | 671 | 'no_wrap' => true, |
672 | 672 | 'options' => array( |
673 | - 'D' => __( 'Day(s)', 'invoicing' ), |
|
674 | - 'W' => __( 'Week(s)', 'invoicing' ), |
|
675 | - 'M' => __( 'Month(s)', 'invoicing' ), |
|
676 | - 'Y' => __( 'Year(s)', 'invoicing' ), |
|
673 | + 'D' => __('Day(s)', 'invoicing'), |
|
674 | + 'W' => __('Week(s)', 'invoicing'), |
|
675 | + 'M' => __('Month(s)', 'invoicing'), |
|
676 | + 'Y' => __('Year(s)', 'invoicing'), |
|
677 | 677 | ), |
678 | 678 | ), |
679 | 679 | true |
@@ -682,19 +682,19 @@ discard block |
||
682 | 682 | </div> |
683 | 683 | |
684 | 684 | <div class="wpinv-recurring-limit"> |
685 | - <label class="form-label"><?php _e( 'Maximum Renewals', 'invoicing' ); ?></label> |
|
685 | + <label class="form-label"><?php _e('Maximum Renewals', 'invoicing'); ?></label> |
|
686 | 686 | <?php |
687 | 687 | aui()->input( |
688 | 688 | array( |
689 | 689 | 'type' => 'number', |
690 | 690 | 'id' => 'wpinv_variable_prices[' . $key . '][recurring-limit]', |
691 | 691 | 'name' => 'wpinv_variable_prices[' . $key . '][recurring-limit]', |
692 | - 'value' => esc_attr( $args['recurring-limit'] ), |
|
692 | + 'value' => esc_attr($args['recurring-limit']), |
|
693 | 693 | 'class' => 'form-control-sm', |
694 | 694 | 'no_wrap' => true, |
695 | 695 | 'extra_attributes' => array_merge( |
696 | 696 | $extra_attributes, |
697 | - array( 'size' => 4 ) |
|
697 | + array('size' => 4) |
|
698 | 698 | ), |
699 | 699 | ), |
700 | 700 | true |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | </div> |
704 | 704 | </div> |
705 | 705 | |
706 | - <?php do_action( 'wpinv_download_price_option_row', $item->ID, $key, $args ); ?> |
|
706 | + <?php do_action('wpinv_download_price_option_row', $item->ID, $key, $args); ?> |
|
707 | 707 | </div> |
708 | 708 | </div> |
709 | 709 | <?php |
@@ -714,43 +714,43 @@ discard block |
||
714 | 714 | * |
715 | 715 | * @param int $post_id |
716 | 716 | */ |
717 | - public static function save( $post_id ) { |
|
717 | + public static function save($post_id) { |
|
718 | 718 | |
719 | 719 | // Prepare the item. |
720 | - $item = new WPInv_Item( $post_id ); |
|
720 | + $item = new WPInv_Item($post_id); |
|
721 | 721 | |
722 | - $is_dynamic_pricing = ! empty( $_POST['wpinv_name_your_price'] ); |
|
723 | - $is_recurring = ! empty( $_POST['wpinv_is_recurring'] ); |
|
724 | - $is_free_trial = isset( $_POST['wpinv_trial_interval'] ) ? (0 != (int) $_POST['wpinv_trial_interval']) : null; |
|
722 | + $is_dynamic_pricing = !empty($_POST['wpinv_name_your_price']); |
|
723 | + $is_recurring = !empty($_POST['wpinv_is_recurring']); |
|
724 | + $is_free_trial = isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null; |
|
725 | 725 | |
726 | - $has_variable_pricing = ! empty( $_POST['wpinv_variable_pricing'] ); |
|
727 | - if ( true === $has_variable_pricing ) { |
|
726 | + $has_variable_pricing = !empty($_POST['wpinv_variable_pricing']); |
|
727 | + if (true === $has_variable_pricing) { |
|
728 | 728 | $is_dynamic_pricing = $is_recurring = $is_free_trial = false; |
729 | 729 | } |
730 | 730 | |
731 | 731 | // Load new data. |
732 | 732 | $item->set_props( |
733 | 733 | array( |
734 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null, |
|
735 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
736 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
737 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
734 | + 'price' => isset($_POST['wpinv_item_price']) ? getpaid_standardize_amount($_POST['wpinv_item_price']) : null, |
|
735 | + 'vat_rule' => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null, |
|
736 | + 'vat_class' => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null, |
|
737 | + 'type' => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null, |
|
738 | 738 | 'is_dynamic_pricing' => $is_dynamic_pricing, |
739 | - 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null, |
|
739 | + 'minimum_price' => isset($_POST['wpinv_minimum_price']) ? getpaid_standardize_amount($_POST['wpinv_minimum_price']) : null, |
|
740 | 740 | 'has_variable_pricing' => $has_variable_pricing, |
741 | - 'default_price_id' => isset( $_POST['_wpinv_default_price_id'] ) ? absint( $_POST['_wpinv_default_price_id'] ) : null, |
|
742 | - 'variable_prices' => isset( $_POST['wpinv_variable_prices'] ) ? wpinv_clean( $_POST['wpinv_variable_prices'] ) : array(), |
|
741 | + 'default_price_id' => isset($_POST['_wpinv_default_price_id']) ? absint($_POST['_wpinv_default_price_id']) : null, |
|
742 | + 'variable_prices' => isset($_POST['wpinv_variable_prices']) ? wpinv_clean($_POST['wpinv_variable_prices']) : array(), |
|
743 | 743 | 'is_recurring' => $is_recurring, |
744 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
745 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
746 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
744 | + 'recurring_period' => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null, |
|
745 | + 'recurring_interval' => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
746 | + 'recurring_limit' => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
747 | 747 | 'is_free_trial' => $is_free_trial, |
748 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
749 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
748 | + 'trial_period' => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null, |
|
749 | + 'trial_interval' => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
750 | 750 | ) |
751 | 751 | ); |
752 | 752 | |
753 | 753 | $item->save(); |
754 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
754 | + do_action('getpaid_item_metabox_save', $post_id, $item); |
|
755 | 755 | } |
756 | 756 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | * @param string $context View or edit context. |
103 | 103 | * @return string |
104 | 104 | */ |
105 | - public function get_name( $context = 'view' ) { |
|
106 | - $name = parent::get_name( $context ); |
|
107 | - return $name . wpinv_get_item_suffix( $this ); |
|
105 | + public function get_name($context = 'view') { |
|
106 | + $name = parent::get_name($context); |
|
107 | + return $name . wpinv_get_item_suffix($this); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @param string $context View or edit context. |
115 | 115 | * @return string |
116 | 116 | */ |
117 | - public function get_raw_name( $context = 'view' ) { |
|
118 | - return parent::get_name( $context ); |
|
117 | + public function get_raw_name($context = 'view') { |
|
118 | + return parent::get_name($context); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | * @param string $context View or edit context. |
126 | 126 | * @return string |
127 | 127 | */ |
128 | - public function get_description( $context = 'view' ) { |
|
128 | + public function get_description($context = 'view') { |
|
129 | 129 | |
130 | - if ( isset( $this->custom_description ) ) { |
|
130 | + if (isset($this->custom_description)) { |
|
131 | 131 | return $this->custom_description; |
132 | 132 | } |
133 | 133 | |
134 | - return parent::get_description( $context ); |
|
134 | + return parent::get_description($context); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | * @param string $context View or edit context. |
142 | 142 | * @return float |
143 | 143 | */ |
144 | - public function get_sub_total( $context = 'view', $price_id = null ) { |
|
145 | - return $this->get_quantity( $context ) * $this->get_initial_price( $context, $price_id ); |
|
144 | + public function get_sub_total($context = 'view', $price_id = null) { |
|
145 | + return $this->get_quantity($context) * $this->get_initial_price($context, $price_id); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | * @param string $context View or edit context. |
153 | 153 | * @return float |
154 | 154 | */ |
155 | - public function get_recurring_sub_total( $context = 'view' ) { |
|
155 | + public function get_recurring_sub_total($context = 'view') { |
|
156 | 156 | |
157 | - if ( $this->is_recurring() ) { |
|
158 | - return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
157 | + if ($this->is_recurring()) { |
|
158 | + return $this->get_quantity($context) * $this->get_price($context); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | return 0; |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | /** |
165 | 165 | * @deprecated |
166 | 166 | */ |
167 | - public function get_qantity( $context = 'view' ) { |
|
168 | - return $this->get_quantity( $context ); |
|
167 | + public function get_qantity($context = 'view') { |
|
168 | + return $this->get_quantity($context); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | * @param string $context View or edit context. |
176 | 176 | * @return float |
177 | 177 | */ |
178 | - public function get_quantity( $context = 'view' ) { |
|
178 | + public function get_quantity($context = 'view') { |
|
179 | 179 | $quantity = (float) $this->quantity; |
180 | 180 | |
181 | - if ( 'view' === $context ) { |
|
182 | - return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
181 | + if ('view' === $context) { |
|
182 | + return apply_filters('getpaid_payment_form_item_quantity', $quantity, $this); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | return $quantity; |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | * @param string $context View or edit context. |
193 | 193 | * @return meta |
194 | 194 | */ |
195 | - public function get_item_meta( $context = 'view' ) { |
|
195 | + public function get_item_meta($context = 'view') { |
|
196 | 196 | $meta = $this->meta; |
197 | 197 | |
198 | - if ( 'view' === $context ) { |
|
199 | - return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
198 | + if ('view' === $context) { |
|
199 | + return apply_filters('getpaid_payment_form_item_meta', $meta, $this); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | return $meta; |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | * @param string $context View or edit context. |
210 | 210 | * @return bool |
211 | 211 | */ |
212 | - public function get_allow_quantities( $context = 'view' ) { |
|
212 | + public function get_allow_quantities($context = 'view') { |
|
213 | 213 | $allow_quantities = (bool) $this->allow_quantities; |
214 | 214 | |
215 | - if ( 'view' === $context ) { |
|
216 | - return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
215 | + if ('view' === $context) { |
|
216 | + return apply_filters('getpaid_payment_form_item_allow_quantities', $allow_quantities, $this); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | return $allow_quantities; |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | * @param string $context View or edit context. |
227 | 227 | * @return bool |
228 | 228 | */ |
229 | - public function get_is_required( $context = 'view' ) { |
|
229 | + public function get_is_required($context = 'view') { |
|
230 | 230 | $is_required = (bool) $this->is_required; |
231 | 231 | |
232 | - if ( 'view' === $context ) { |
|
233 | - return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
232 | + if ('view' === $context) { |
|
233 | + return apply_filters('getpaid_payment_form_item_is_required', $is_required, $this); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | return $is_required; |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | * @param string $context View or edit context. |
244 | 244 | * @return int |
245 | 245 | */ |
246 | - public function get_price_id( $context = 'view' ) { |
|
246 | + public function get_price_id($context = 'view') { |
|
247 | 247 | $price_id = (int) $this->price_id; |
248 | 248 | |
249 | - if ( 'view' === $context ) { |
|
250 | - return apply_filters( 'getpaid_payment_form_item_price_id', $price_id, $this ); |
|
249 | + if ('view' === $context) { |
|
250 | + return apply_filters('getpaid_payment_form_item_price_id', $price_id, $this); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | return $price_id; |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | * @since 1.0.19 |
260 | 260 | * @return array |
261 | 261 | */ |
262 | - public function prepare_data_for_use( $required = null ) { |
|
262 | + public function prepare_data_for_use($required = null) { |
|
263 | 263 | |
264 | - $required = is_null( $required ) ? $this->is_required() : $required; |
|
264 | + $required = is_null($required) ? $this->is_required() : $required; |
|
265 | 265 | return array( |
266 | - 'title' => wp_strip_all_tags( $this->get_name() ), |
|
266 | + 'title' => wp_strip_all_tags($this->get_name()), |
|
267 | 267 | 'id' => $this->get_id(), |
268 | 268 | 'price' => $this->get_price(), |
269 | 269 | 'recurring' => $this->is_recurring(), |
@@ -280,30 +280,30 @@ discard block |
||
280 | 280 | * @since 1.0.19 |
281 | 281 | * @return array |
282 | 282 | */ |
283 | - public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) { |
|
283 | + public function prepare_data_for_invoice_edit_ajax($currency = '', $is_renewal = false) { |
|
284 | 284 | |
285 | - $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
285 | + $description = getpaid_item_recurring_price_help_text($this, $currency); |
|
286 | 286 | |
287 | - if ( $description ) { |
|
287 | + if ($description) { |
|
288 | 288 | $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
289 | 289 | } |
290 | 290 | |
291 | - $price = ! $is_renewal ? $this->get_price() : $this->get_recurring_price(); |
|
292 | - $subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total(); |
|
291 | + $price = !$is_renewal ? $this->get_price() : $this->get_recurring_price(); |
|
292 | + $subtotal = !$is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total(); |
|
293 | 293 | return array( |
294 | 294 | 'id' => $this->get_id(), |
295 | 295 | 'texts' => array( |
296 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
297 | - 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
298 | - 'item-quantity' => floatval( $this->get_quantity() ), |
|
299 | - 'item-price' => wpinv_price( $price, $currency ), |
|
300 | - 'item-total' => wpinv_price( $subtotal, $currency ), |
|
296 | + 'item-name' => sanitize_text_field($this->get_name()), |
|
297 | + 'item-description' => wp_kses_post($this->get_description()) . $description, |
|
298 | + 'item-quantity' => floatval($this->get_quantity()), |
|
299 | + 'item-price' => wpinv_price($price, $currency), |
|
300 | + 'item-total' => wpinv_price($subtotal, $currency), |
|
301 | 301 | ), |
302 | 302 | 'inputs' => array( |
303 | 303 | 'item-id' => $this->get_id(), |
304 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
305 | - 'item-description' => wp_kses_post( $this->get_description() ), |
|
306 | - 'item-quantity' => floatval( $this->get_quantity() ), |
|
304 | + 'item-name' => sanitize_text_field($this->get_name()), |
|
305 | + 'item-description' => wp_kses_post($this->get_description()), |
|
306 | + 'item-quantity' => floatval($this->get_quantity()), |
|
307 | 307 | 'item-price' => $price, |
308 | 308 | ), |
309 | 309 | ); |
@@ -320,16 +320,16 @@ discard block |
||
320 | 320 | return array( |
321 | 321 | 'post_id' => $this->invoice_id, |
322 | 322 | 'item_id' => $this->get_id(), |
323 | - 'item_name' => sanitize_text_field( $this->get_raw_name( 'edit' ) ), |
|
324 | - 'item_description' => $this->get_description( 'edit' ), |
|
323 | + 'item_name' => sanitize_text_field($this->get_raw_name('edit')), |
|
324 | + 'item_description' => $this->get_description('edit'), |
|
325 | 325 | 'tax' => $this->item_tax, |
326 | - 'item_price' => $this->get_price( 'edit' ), |
|
327 | - 'quantity' => (float) $this->get_quantity( 'edit' ), |
|
326 | + 'item_price' => $this->get_price('edit'), |
|
327 | + 'quantity' => (float) $this->get_quantity('edit'), |
|
328 | 328 | 'discount' => $this->item_discount, |
329 | - 'subtotal' => $this->get_sub_total( 'edit' ), |
|
330 | - 'price' => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount, |
|
331 | - 'price_id' => (int) $this->get_price_id( 'edit' ), |
|
332 | - 'meta' => $this->get_item_meta( 'edit' ), |
|
329 | + 'subtotal' => $this->get_sub_total('edit'), |
|
330 | + 'price' => $this->get_sub_total('edit') + $this->item_tax - $this->item_discount, |
|
331 | + 'price_id' => (int) $this->get_price_id('edit'), |
|
332 | + 'meta' => $this->get_item_meta('edit'), |
|
333 | 333 | ); |
334 | 334 | } |
335 | 335 | |
@@ -349,9 +349,9 @@ discard block |
||
349 | 349 | * @since 1.0.19 |
350 | 350 | * @param float $quantity The item quantity. |
351 | 351 | */ |
352 | - public function set_quantity( $quantity ) { |
|
352 | + public function set_quantity($quantity) { |
|
353 | 353 | |
354 | - if ( ! is_numeric( $quantity ) ) { |
|
354 | + if (!is_numeric($quantity)) { |
|
355 | 355 | $quantity = 1; |
356 | 356 | } |
357 | 357 | |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | * @since 1.0.19 |
365 | 365 | * @param float $price_id The item price ID. |
366 | 366 | */ |
367 | - public function set_price_id( $price_id ) { |
|
367 | + public function set_price_id($price_id) { |
|
368 | 368 | |
369 | - if ( ! is_numeric( $price_id ) ) { |
|
369 | + if (!is_numeric($price_id)) { |
|
370 | 370 | $price_id = $this->get_default_price_id(); |
371 | 371 | } |
372 | 372 | |
@@ -379,8 +379,8 @@ discard block |
||
379 | 379 | * @since 1.0.19 |
380 | 380 | * @param array $meta The item meta data. |
381 | 381 | */ |
382 | - public function set_item_meta( $meta ) { |
|
383 | - $this->meta = maybe_unserialize( $meta ); |
|
382 | + public function set_item_meta($meta) { |
|
383 | + $this->meta = maybe_unserialize($meta); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * @since 1.0.19 |
390 | 390 | * @param bool $allow_quantities |
391 | 391 | */ |
392 | - public function set_allow_quantities( $allow_quantities ) { |
|
392 | + public function set_allow_quantities($allow_quantities) { |
|
393 | 393 | $this->allow_quantities = (bool) $allow_quantities; |
394 | 394 | } |
395 | 395 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @since 1.0.19 |
400 | 400 | * @param bool $is_required |
401 | 401 | */ |
402 | - public function set_is_required( $is_required ) { |
|
402 | + public function set_is_required($is_required) { |
|
403 | 403 | $this->is_required = (bool) $is_required; |
404 | 404 | } |
405 | 405 | |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * @since 1.0.19 |
410 | 410 | * @param string $description |
411 | 411 | */ |
412 | - public function set_custom_description( $description ) { |
|
412 | + public function set_custom_description($description) { |
|
413 | 413 | $this->custom_description = $description; |
414 | 414 | } |
415 | 415 | |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @return int item id |
420 | 420 | */ |
421 | - public function save( $data = array() ) { |
|
421 | + public function save($data = array()) { |
|
422 | 422 | return $this->get_id(); |
423 | 423 | } |
424 | 424 |
@@ -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 | * Main Checkout Class. |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param GetPaid_Payment_Form_Submission $submission |
24 | 24 | */ |
25 | - public function __construct( $submission ) { |
|
25 | + public function __construct($submission) { |
|
26 | 26 | $this->payment_form_submission = $submission; |
27 | 27 | } |
28 | 28 | |
@@ -38,22 +38,22 @@ discard block |
||
38 | 38 | // Prepare the invoice. |
39 | 39 | $items = $this->get_submission_items(); |
40 | 40 | $invoice = $this->get_submission_invoice(); |
41 | - $invoice = $this->process_submission_invoice( $invoice, $items ); |
|
41 | + $invoice = $this->process_submission_invoice($invoice, $items); |
|
42 | 42 | $prepared = $this->prepare_submission_data_for_saving(); |
43 | 43 | |
44 | - $this->prepare_billing_info( $invoice ); |
|
44 | + $this->prepare_billing_info($invoice); |
|
45 | 45 | |
46 | - $shipping = $this->prepare_shipping_info( $invoice ); |
|
46 | + $shipping = $this->prepare_shipping_info($invoice); |
|
47 | 47 | |
48 | 48 | // Save the invoice. |
49 | - $invoice->set_is_viewed( true ); |
|
49 | + $invoice->set_is_viewed(true); |
|
50 | 50 | $invoice->recalculate_total(); |
51 | 51 | $invoice->save(); |
52 | 52 | |
53 | - do_action( 'getpaid_checkout_invoice_updated', $invoice ); |
|
53 | + do_action('getpaid_checkout_invoice_updated', $invoice); |
|
54 | 54 | |
55 | 55 | // Send to the gateway. |
56 | - $this->post_process_submission( $invoice, $prepared, $shipping ); |
|
56 | + $this->post_process_submission($invoice, $prepared, $shipping); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -66,34 +66,34 @@ discard block |
||
66 | 66 | $data = $submission->get_data(); |
67 | 67 | |
68 | 68 | // Do we have an error? |
69 | - if ( ! empty( $submission->last_error ) ) { |
|
70 | - wp_send_json_error( $submission->last_error ); |
|
69 | + if (!empty($submission->last_error)) { |
|
70 | + wp_send_json_error($submission->last_error); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // We need a billing email. |
74 | - if ( ! $submission->has_billing_email() ) { |
|
75 | - wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) ); |
|
74 | + if (!$submission->has_billing_email()) { |
|
75 | + wp_send_json_error(__('Provide a valid billing email.', 'invoicing')); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | // Non-recurring gateways should not be allowed to process recurring invoices. |
79 | - if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) { |
|
80 | - wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) ); |
|
79 | + if ($submission->should_collect_payment_details() && $submission->has_recurring && !wpinv_gateway_support_subscription($data['wpi-gateway'])) { |
|
80 | + wp_send_json_error(__('The selected payment gateway does not support subscription payments.', 'invoicing')); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | // Ensure the gateway is active. |
84 | - if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) { |
|
85 | - wp_send_json_error( __( 'The selected payment gateway is not active', 'invoicing' ) ); |
|
84 | + if ($submission->should_collect_payment_details() && !wpinv_is_gateway_active($data['wpi-gateway'])) { |
|
85 | + wp_send_json_error(__('The selected payment gateway is not active', 'invoicing')); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | // Clear any existing errors. |
89 | 89 | wpinv_clear_errors(); |
90 | 90 | |
91 | 91 | // Allow themes and plugins to hook to errors |
92 | - do_action( 'getpaid_checkout_error_checks', $submission ); |
|
92 | + do_action('getpaid_checkout_error_checks', $submission); |
|
93 | 93 | |
94 | 94 | // Do we have any errors? |
95 | - if ( wpinv_get_errors() ) { |
|
96 | - wp_send_json_error( getpaid_get_errors_html() ); |
|
95 | + if (wpinv_get_errors()) { |
|
96 | + wp_send_json_error(getpaid_get_errors_html()); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | } |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | $items = $this->payment_form_submission->get_items(); |
109 | 109 | |
110 | 110 | // Ensure that we have items. |
111 | - if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) { |
|
112 | - wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) ); |
|
111 | + if (empty($items) && !$this->payment_form_submission->has_fees()) { |
|
112 | + wp_send_json_error(__('Please provide at least one item or amount.', 'invoicing')); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | return $items; |
@@ -123,17 +123,17 @@ discard block |
||
123 | 123 | protected function get_submission_invoice() { |
124 | 124 | $submission = $this->payment_form_submission; |
125 | 125 | |
126 | - if ( ! $submission->has_invoice() ) { |
|
126 | + if (!$submission->has_invoice()) { |
|
127 | 127 | $invoice = new WPInv_Invoice(); |
128 | - $invoice->set_created_via( 'payment_form' ); |
|
128 | + $invoice->set_created_via('payment_form'); |
|
129 | 129 | return $invoice; |
130 | 130 | } |
131 | 131 | |
132 | 132 | $invoice = $submission->get_invoice(); |
133 | 133 | |
134 | 134 | // Make sure that it is neither paid or refunded. |
135 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
136 | - wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) ); |
|
135 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
136 | + wp_send_json_error(__('This invoice has already been paid for.', 'invoicing')); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | return $invoice; |
@@ -146,34 +146,34 @@ discard block |
||
146 | 146 | * @param GetPaid_Form_Item[] $items |
147 | 147 | * @return WPInv_Invoice |
148 | 148 | */ |
149 | - protected function process_submission_invoice( $invoice, $items ) { |
|
149 | + protected function process_submission_invoice($invoice, $items) { |
|
150 | 150 | |
151 | 151 | $submission = $this->payment_form_submission; |
152 | 152 | |
153 | 153 | // Set-up the invoice details. |
154 | - $invoice->set_email( sanitize_email( $submission->get_billing_email() ) ); |
|
155 | - $invoice->set_user_id( $this->get_submission_customer() ); |
|
156 | - $invoice->set_submission_id( $submission->id ); |
|
157 | - $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) ); |
|
158 | - $invoice->set_items( $items ); |
|
159 | - $invoice->set_fees( $submission->get_fees() ); |
|
160 | - $invoice->set_taxes( $submission->get_taxes() ); |
|
161 | - $invoice->set_discounts( $submission->get_discounts() ); |
|
162 | - $invoice->set_gateway( $submission->get_field( 'wpi-gateway' ) ); |
|
163 | - $invoice->set_currency( $submission->get_currency() ); |
|
164 | - |
|
165 | - if ( $submission->has_shipping() ) { |
|
166 | - $invoice->set_shipping( $submission->get_shipping() ); |
|
154 | + $invoice->set_email(sanitize_email($submission->get_billing_email())); |
|
155 | + $invoice->set_user_id($this->get_submission_customer()); |
|
156 | + $invoice->set_submission_id($submission->id); |
|
157 | + $invoice->set_payment_form(absint($submission->get_payment_form()->get_id())); |
|
158 | + $invoice->set_items($items); |
|
159 | + $invoice->set_fees($submission->get_fees()); |
|
160 | + $invoice->set_taxes($submission->get_taxes()); |
|
161 | + $invoice->set_discounts($submission->get_discounts()); |
|
162 | + $invoice->set_gateway($submission->get_field('wpi-gateway')); |
|
163 | + $invoice->set_currency($submission->get_currency()); |
|
164 | + |
|
165 | + if ($submission->has_shipping()) { |
|
166 | + $invoice->set_shipping($submission->get_shipping()); |
|
167 | 167 | } |
168 | 168 | |
169 | - $address_confirmed = $submission->get_field( 'confirm-address' ); |
|
170 | - $invoice->set_address_confirmed( ! empty( $address_confirmed ) ); |
|
169 | + $address_confirmed = $submission->get_field('confirm-address'); |
|
170 | + $invoice->set_address_confirmed(!empty($address_confirmed)); |
|
171 | 171 | |
172 | - if ( $submission->has_discount_code() ) { |
|
173 | - $invoice->set_discount_code( $submission->get_discount_code() ); |
|
172 | + if ($submission->has_discount_code()) { |
|
173 | + $invoice->set_discount_code($submission->get_discount_code()); |
|
174 | 174 | } |
175 | 175 | |
176 | - getpaid_maybe_add_default_address( $invoice ); |
|
176 | + getpaid_maybe_add_default_address($invoice); |
|
177 | 177 | return $invoice; |
178 | 178 | } |
179 | 179 | |
@@ -186,34 +186,34 @@ discard block |
||
186 | 186 | $submission = $this->payment_form_submission; |
187 | 187 | |
188 | 188 | // If this is an existing invoice... |
189 | - if ( $submission->has_invoice() ) { |
|
189 | + if ($submission->has_invoice()) { |
|
190 | 190 | return $submission->get_invoice()->get_user_id(); |
191 | 191 | } |
192 | 192 | |
193 | 193 | // (Maybe) create the user. |
194 | 194 | $user = get_current_user_id(); |
195 | 195 | |
196 | - if ( empty( $user ) ) { |
|
197 | - $user = get_user_by( 'email', $submission->get_billing_email() ); |
|
196 | + if (empty($user)) { |
|
197 | + $user = get_user_by('email', $submission->get_billing_email()); |
|
198 | 198 | } |
199 | 199 | |
200 | - if ( empty( $user ) ) { |
|
201 | - $name = array( $submission->get_field( 'wpinv_first_name', 'billing' ), $submission->get_field( 'wpinv_last_name', 'billing' ) ); |
|
202 | - $name = implode( '', array_filter( $name ) ); |
|
203 | - $user = wpinv_create_user( $submission->get_billing_email(), $name ); |
|
200 | + if (empty($user)) { |
|
201 | + $name = array($submission->get_field('wpinv_first_name', 'billing'), $submission->get_field('wpinv_last_name', 'billing')); |
|
202 | + $name = implode('', array_filter($name)); |
|
203 | + $user = wpinv_create_user($submission->get_billing_email(), $name); |
|
204 | 204 | |
205 | 205 | // (Maybe) send new user notification. |
206 | - $should_send_notification = wpinv_get_option( 'disable_new_user_emails' ); |
|
207 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ), $user ) ) { |
|
208 | - wp_send_new_user_notifications( $user, 'user' ); |
|
206 | + $should_send_notification = wpinv_get_option('disable_new_user_emails'); |
|
207 | + if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification), $user)) { |
|
208 | + wp_send_new_user_notifications($user, 'user'); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - if ( is_wp_error( $user ) ) { |
|
213 | - wp_send_json_error( $user->get_error_message() ); |
|
212 | + if (is_wp_error($user)) { |
|
213 | + wp_send_json_error($user->get_error_message()); |
|
214 | 214 | } |
215 | 215 | |
216 | - if ( is_numeric( $user ) ) { |
|
216 | + if (is_numeric($user)) { |
|
217 | 217 | return $user; |
218 | 218 | } |
219 | 219 | |
@@ -237,72 +237,72 @@ discard block |
||
237 | 237 | ); |
238 | 238 | |
239 | 239 | // Raw submission details. |
240 | - $data = $submission->get_data(); |
|
240 | + $data = $submission->get_data(); |
|
241 | 241 | |
242 | 242 | // Loop through the submitted details. |
243 | - foreach ( $submission->get_payment_form()->get_elements() as $field ) { |
|
243 | + foreach ($submission->get_payment_form()->get_elements() as $field) { |
|
244 | 244 | |
245 | 245 | // Skip premade fields. |
246 | - if ( ! empty( $field['premade'] ) ) { |
|
246 | + if (!empty($field['premade'])) { |
|
247 | 247 | continue; |
248 | 248 | } |
249 | 249 | |
250 | 250 | // Ensure address is provided. |
251 | - if ( 'address' === $field['type'] ) { |
|
252 | - $address_type = isset( $field['address_type'] ) && 'shipping' === $field['address_type'] ? 'shipping' : 'billing'; |
|
251 | + if ('address' === $field['type']) { |
|
252 | + $address_type = isset($field['address_type']) && 'shipping' === $field['address_type'] ? 'shipping' : 'billing'; |
|
253 | 253 | |
254 | - foreach ( $field['fields'] as $address_field ) { |
|
254 | + foreach ($field['fields'] as $address_field) { |
|
255 | 255 | |
256 | - if ( ! empty( $address_field['visible'] ) && ! empty( $address_field['required'] ) && '' === trim( $_POST[ $address_type ][ $address_field['name'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
257 | - wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) ); |
|
256 | + if (!empty($address_field['visible']) && !empty($address_field['required']) && '' === trim($_POST[$address_type][$address_field['name']])) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
257 | + wp_send_json_error(__('Please fill all required fields.', 'invoicing')); |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | 262 | // If it is required and not set, abort. |
263 | - if ( ! $submission->is_required_field_set( $field ) ) { |
|
264 | - wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) ); |
|
263 | + if (!$submission->is_required_field_set($field)) { |
|
264 | + wp_send_json_error(__('Please fill all required fields.', 'invoicing')); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | // Handle misc fields. |
268 | - if ( isset( $data[ $field['id'] ] ) ) { |
|
268 | + if (isset($data[$field['id']])) { |
|
269 | 269 | |
270 | 270 | // Uploads. |
271 | - if ( 'file_upload' === $field['type'] ) { |
|
272 | - $max_file_num = empty( $field['max_file_num'] ) ? 1 : absint( $field['max_file_num'] ); |
|
271 | + if ('file_upload' === $field['type']) { |
|
272 | + $max_file_num = empty($field['max_file_num']) ? 1 : absint($field['max_file_num']); |
|
273 | 273 | |
274 | - if ( count( $data[ $field['id'] ] ) > $max_file_num ) { |
|
275 | - wp_send_json_error( __( 'Maximum number of allowed files exceeded.', 'invoicing' ) ); |
|
274 | + if (count($data[$field['id']]) > $max_file_num) { |
|
275 | + wp_send_json_error(__('Maximum number of allowed files exceeded.', 'invoicing')); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | $value = array(); |
279 | 279 | |
280 | - foreach ( $data[ $field['id'] ] as $url => $name ) { |
|
280 | + foreach ($data[$field['id']] as $url => $name) { |
|
281 | 281 | $value[] = sprintf( |
282 | 282 | '<a href="%s" target="_blank">%s</a>', |
283 | - esc_url_raw( $url ), |
|
284 | - esc_html( $name ) |
|
283 | + esc_url_raw($url), |
|
284 | + esc_html($name) |
|
285 | 285 | ); |
286 | 286 | } |
287 | 287 | |
288 | - $value = implode( ' | ', $value ); |
|
288 | + $value = implode(' | ', $value); |
|
289 | 289 | |
290 | - } elseif ( 'checkbox' === $field['type'] ) { |
|
291 | - $value = ! empty( $data[ $field['id'] ] ) ? __( 'Yes', 'invoicing' ) : __( 'No', 'invoicing' ); |
|
290 | + } elseif ('checkbox' === $field['type']) { |
|
291 | + $value = !empty($data[$field['id']]) ? __('Yes', 'invoicing') : __('No', 'invoicing'); |
|
292 | 292 | } else { |
293 | - $value = wp_kses_post( $data[ $field['id'] ] ); |
|
293 | + $value = wp_kses_post($data[$field['id']]); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | $label = $field['id']; |
297 | 297 | |
298 | - if ( isset( $field['label'] ) ) { |
|
298 | + if (isset($field['label'])) { |
|
299 | 299 | $label = $field['label']; |
300 | 300 | } |
301 | 301 | |
302 | - if ( ! empty( $field['add_meta'] ) ) { |
|
303 | - $prepared['meta'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value ); |
|
302 | + if (!empty($field['add_meta'])) { |
|
303 | + $prepared['meta'][wpinv_clean($label)] = wp_kses_post_deep($value); |
|
304 | 304 | } |
305 | - $prepared['all'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value ); |
|
305 | + $prepared['all'][wpinv_clean($label)] = wp_kses_post_deep($value); |
|
306 | 306 | |
307 | 307 | } |
308 | 308 | } |
@@ -318,30 +318,30 @@ discard block |
||
318 | 318 | * @param WPInv_Invoice $invoice |
319 | 319 | * @param string $type |
320 | 320 | */ |
321 | - public function prepare_address_details( $invoice, $type = 'billing' ) { |
|
321 | + public function prepare_address_details($invoice, $type = 'billing') { |
|
322 | 322 | |
323 | 323 | $data = $this->payment_form_submission->get_data(); |
324 | - $type = sanitize_key( $type ); |
|
324 | + $type = sanitize_key($type); |
|
325 | 325 | $address = array(); |
326 | 326 | $prepared = array(); |
327 | 327 | |
328 | - if ( ! empty( $data[ $type ] ) ) { |
|
329 | - $address = $data[ $type ]; |
|
328 | + if (!empty($data[$type])) { |
|
329 | + $address = $data[$type]; |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | // Clean address details. |
333 | - foreach ( $address as $key => $value ) { |
|
334 | - $key = sanitize_key( $key ); |
|
335 | - $key = str_replace( 'wpinv_', '', $key ); |
|
336 | - $value = wpinv_clean( $value ); |
|
337 | - $prepared[ $key ] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice ); |
|
333 | + foreach ($address as $key => $value) { |
|
334 | + $key = sanitize_key($key); |
|
335 | + $key = str_replace('wpinv_', '', $key); |
|
336 | + $value = wpinv_clean($value); |
|
337 | + $prepared[$key] = apply_filters("getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | // Filter address details. |
341 | - $prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice ); |
|
341 | + $prepared = apply_filters("getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice); |
|
342 | 342 | |
343 | 343 | // Remove non-whitelisted values. |
344 | - return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY ); |
|
344 | + return array_filter($prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY); |
|
345 | 345 | |
346 | 346 | } |
347 | 347 | |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | * @return array |
352 | 352 | * @param WPInv_Invoice $invoice |
353 | 353 | */ |
354 | - protected function prepare_billing_info( &$invoice ) { |
|
354 | + protected function prepare_billing_info(&$invoice) { |
|
355 | 355 | |
356 | - $billing_address = $this->prepare_address_details( $invoice, 'billing' ); |
|
356 | + $billing_address = $this->prepare_address_details($invoice, 'billing'); |
|
357 | 357 | |
358 | 358 | // Update the invoice with the billing details. |
359 | - $invoice->set_props( $billing_address ); |
|
359 | + $invoice->set_props($billing_address); |
|
360 | 360 | |
361 | 361 | } |
362 | 362 | |
@@ -366,15 +366,15 @@ discard block |
||
366 | 366 | * @return array |
367 | 367 | * @param WPInv_Invoice $invoice |
368 | 368 | */ |
369 | - protected function prepare_shipping_info( $invoice ) { |
|
369 | + protected function prepare_shipping_info($invoice) { |
|
370 | 370 | |
371 | 371 | $data = $this->payment_form_submission->get_data(); |
372 | 372 | |
373 | - if ( empty( $data['same-shipping-address'] ) ) { |
|
374 | - return $this->prepare_address_details( $invoice, 'shipping' ); |
|
373 | + if (empty($data['same-shipping-address'])) { |
|
374 | + return $this->prepare_address_details($invoice, 'shipping'); |
|
375 | 375 | } |
376 | 376 | |
377 | - return $this->prepare_address_details( $invoice, 'billing' ); |
|
377 | + return $this->prepare_address_details($invoice, 'billing'); |
|
378 | 378 | |
379 | 379 | } |
380 | 380 | |
@@ -385,45 +385,45 @@ discard block |
||
385 | 385 | * @param array $prepared_payment_form_data |
386 | 386 | * @param array $shipping |
387 | 387 | */ |
388 | - protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) { |
|
388 | + protected function post_process_submission($invoice, $prepared_payment_form_data, $shipping) { |
|
389 | 389 | |
390 | 390 | // Ensure the invoice exists. |
391 | - if ( ! $invoice->exists() ) { |
|
392 | - wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) ); |
|
391 | + if (!$invoice->exists()) { |
|
392 | + wp_send_json_error(__('An error occured while saving your invoice. Please try again.', 'invoicing')); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | // Save payment form data. |
396 | - $prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice ); |
|
397 | - delete_post_meta( $invoice->get_id(), 'payment_form_data' ); |
|
398 | - delete_post_meta( $invoice->get_id(), 'additional_meta_data' ); |
|
399 | - if ( ! empty( $prepared_payment_form_data ) ) { |
|
396 | + $prepared_payment_form_data = apply_filters('getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice); |
|
397 | + delete_post_meta($invoice->get_id(), 'payment_form_data'); |
|
398 | + delete_post_meta($invoice->get_id(), 'additional_meta_data'); |
|
399 | + if (!empty($prepared_payment_form_data)) { |
|
400 | 400 | |
401 | - if ( ! empty( $prepared_payment_form_data['all'] ) ) { |
|
402 | - update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all'] ); |
|
401 | + if (!empty($prepared_payment_form_data['all'])) { |
|
402 | + update_post_meta($invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all']); |
|
403 | 403 | } |
404 | 404 | |
405 | - if ( ! empty( $prepared_payment_form_data['meta'] ) ) { |
|
406 | - update_post_meta( $invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta'] ); |
|
405 | + if (!empty($prepared_payment_form_data['meta'])) { |
|
406 | + update_post_meta($invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta']); |
|
407 | 407 | } |
408 | 408 | } |
409 | 409 | |
410 | 410 | // Save payment form data. |
411 | - $shipping = apply_filters( 'getpaid_checkout_shipping_details', $shipping, $this->payment_form_submission ); |
|
412 | - if ( ! empty( $shipping ) ) { |
|
413 | - update_post_meta( $invoice->get_id(), 'shipping_address', $shipping ); |
|
411 | + $shipping = apply_filters('getpaid_checkout_shipping_details', $shipping, $this->payment_form_submission); |
|
412 | + if (!empty($shipping)) { |
|
413 | + update_post_meta($invoice->get_id(), 'shipping_address', $shipping); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | // Backwards compatibility. |
417 | - add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) ); |
|
417 | + add_filter('wp_redirect', array($this, 'send_redirect_response')); |
|
418 | 418 | |
419 | 419 | try { |
420 | - $this->process_payment( $invoice ); |
|
421 | - } catch ( Exception $e ) { |
|
422 | - wpinv_set_error( 'payment_error', $e->getMessage() ); |
|
420 | + $this->process_payment($invoice); |
|
421 | + } catch (Exception $e) { |
|
422 | + wpinv_set_error('payment_error', $e->getMessage()); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | // If we are here, there was an error. |
426 | - wpinv_send_back_to_checkout( $invoice ); |
|
426 | + wpinv_send_back_to_checkout($invoice); |
|
427 | 427 | |
428 | 428 | } |
429 | 429 | |
@@ -432,41 +432,41 @@ discard block |
||
432 | 432 | * |
433 | 433 | * @param WPInv_Invoice $invoice |
434 | 434 | */ |
435 | - protected function process_payment( $invoice ) { |
|
435 | + protected function process_payment($invoice) { |
|
436 | 436 | |
437 | 437 | // Clear any checkout errors. |
438 | 438 | wpinv_clear_errors(); |
439 | 439 | |
440 | 440 | // No need to send free invoices to the gateway. |
441 | - if ( $invoice->is_free() ) { |
|
442 | - $this->process_free_payment( $invoice ); |
|
441 | + if ($invoice->is_free()) { |
|
442 | + $this->process_free_payment($invoice); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | $submission = $this->payment_form_submission; |
446 | 446 | |
447 | 447 | // Fires before sending to the gateway. |
448 | - do_action( 'getpaid_checkout_before_gateway', $invoice, $submission ); |
|
448 | + do_action('getpaid_checkout_before_gateway', $invoice, $submission); |
|
449 | 449 | |
450 | 450 | // Allow the sumission data to be modified before it is sent to the gateway. |
451 | 451 | $submission_data = $submission->get_data(); |
452 | - $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice ); |
|
453 | - $submission_data = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice ); |
|
452 | + $submission_gateway = apply_filters('getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice); |
|
453 | + $submission_data = apply_filters('getpaid_gateway_submission_data', $submission_data, $submission, $invoice); |
|
454 | 454 | |
455 | 455 | // Validate the currency. |
456 | - if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) { |
|
457 | - wpinv_set_error( 'invalid_currency' ); |
|
456 | + if (!apply_filters("getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency())) { |
|
457 | + wpinv_set_error('invalid_currency'); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | // Check to see if we have any errors. |
461 | - if ( wpinv_get_errors() ) { |
|
462 | - wpinv_send_back_to_checkout( $invoice ); |
|
461 | + if (wpinv_get_errors()) { |
|
462 | + wpinv_send_back_to_checkout($invoice); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | // Send info to the gateway for payment processing |
466 | - do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission ); |
|
466 | + do_action("getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission); |
|
467 | 467 | |
468 | 468 | // Backwards compatibility. |
469 | - wpinv_send_to_gateway( $submission_gateway, $invoice ); |
|
469 | + wpinv_send_to_gateway($submission_gateway, $invoice); |
|
470 | 470 | |
471 | 471 | } |
472 | 472 | |
@@ -475,12 +475,12 @@ discard block |
||
475 | 475 | * |
476 | 476 | * @param WPInv_Invoice $invoice |
477 | 477 | */ |
478 | - protected function process_free_payment( $invoice ) { |
|
478 | + protected function process_free_payment($invoice) { |
|
479 | 479 | |
480 | - $invoice->set_gateway( 'none' ); |
|
481 | - $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true ); |
|
480 | + $invoice->set_gateway('none'); |
|
481 | + $invoice->add_note(__("This is a free invoice and won't be sent to the payment gateway", 'invoicing'), false, false, true); |
|
482 | 482 | $invoice->mark_paid(); |
483 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
483 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
484 | 484 | |
485 | 485 | } |
486 | 486 | |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | * Sends a redrect response to payment details. |
489 | 489 | * |
490 | 490 | */ |
491 | - public function send_redirect_response( $url ) { |
|
492 | - $url = rawurlencode( $url ); |
|
493 | - wp_send_json_success( $url ); |
|
491 | + public function send_redirect_response($url) { |
|
492 | + $url = rawurlencode($url); |
|
493 | + wp_send_json_success($url); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | } |
@@ -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 | * Payment form submission itemss class |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param GetPaid_Payment_Form_Submission $submission |
25 | 25 | */ |
26 | - public function __construct( $submission ) { |
|
26 | + public function __construct($submission) { |
|
27 | 27 | |
28 | 28 | $data = $submission->get_data(); |
29 | 29 | $payment_form = $submission->get_payment_form(); |
@@ -32,59 +32,59 @@ discard block |
||
32 | 32 | |
33 | 33 | // Prepare the selected items. |
34 | 34 | $selected_items = array(); |
35 | - if ( ! empty( $data['getpaid-items'] ) ) { |
|
36 | - $selected_items = wpinv_clean( $data['getpaid-items'] ); |
|
35 | + if (!empty($data['getpaid-items'])) { |
|
36 | + $selected_items = wpinv_clean($data['getpaid-items']); |
|
37 | 37 | |
38 | - if ( is_array( $submission->get_field( 'getpaid-variable-items' ) ) ) { |
|
39 | - $selected_prices = $submission->get_field( 'getpaid-variable-items' ); |
|
38 | + if (is_array($submission->get_field('getpaid-variable-items'))) { |
|
39 | + $selected_prices = $submission->get_field('getpaid-variable-items'); |
|
40 | 40 | |
41 | 41 | $selected_items = array_filter( |
42 | 42 | $selected_items, |
43 | - function ( $item ) use ( $selected_prices ) { |
|
44 | - return isset( $item['price_id'] ) && in_array( (int) $item['price_id'], $selected_prices ); |
|
43 | + function($item) use ($selected_prices) { |
|
44 | + return isset($item['price_id']) && in_array((int) $item['price_id'], $selected_prices); |
|
45 | 45 | } |
46 | 46 | ); |
47 | 47 | } |
48 | 48 | |
49 | - if ( ! empty( $invoice ) && $submission->is_initial_fetch() ) { |
|
50 | - foreach ( $invoice->get_items() as $invoice_item ) { |
|
51 | - if ( ! $invoice_item->has_variable_pricing() && isset( $selected_items[ $invoice_item->get_id() ] ) ) { |
|
52 | - $selected_items[ $invoice_item->get_id() ]['quantity'] = $invoice_item->get_quantity(); |
|
53 | - $selected_items[ $invoice_item->get_id() ]['price'] = $invoice_item->get_price(); |
|
49 | + if (!empty($invoice) && $submission->is_initial_fetch()) { |
|
50 | + foreach ($invoice->get_items() as $invoice_item) { |
|
51 | + if (!$invoice_item->has_variable_pricing() && isset($selected_items[$invoice_item->get_id()])) { |
|
52 | + $selected_items[$invoice_item->get_id()]['quantity'] = $invoice_item->get_quantity(); |
|
53 | + $selected_items[$invoice_item->get_id()]['price'] = $invoice_item->get_price(); |
|
54 | 54 | |
55 | - $force_prices[ $invoice_item->get_id() ] = $invoice_item->get_price(); |
|
55 | + $force_prices[$invoice_item->get_id()] = $invoice_item->get_price(); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | 61 | // (Maybe) set form items. |
62 | - if ( isset( $data['getpaid-form-items'] ) ) { |
|
62 | + if (isset($data['getpaid-form-items'])) { |
|
63 | 63 | |
64 | 64 | // Confirm items key. |
65 | - $form_items = wpinv_clean( $data['getpaid-form-items'] ); |
|
66 | - if ( ! isset( $data['getpaid-form-items-key'] ) || md5( NONCE_KEY . AUTH_KEY . $form_items ) !== $data['getpaid-form-items-key'] ) { |
|
67 | - throw new Exception( __( 'We could not validate the form items. Please reload the page and try again.', 'invoicing' ) ); |
|
65 | + $form_items = wpinv_clean($data['getpaid-form-items']); |
|
66 | + if (!isset($data['getpaid-form-items-key']) || md5(NONCE_KEY . AUTH_KEY . $form_items) !== $data['getpaid-form-items-key']) { |
|
67 | + throw new Exception(__('We could not validate the form items. Please reload the page and try again.', 'invoicing')); |
|
68 | 68 | } |
69 | 69 | |
70 | - $items = array(); |
|
70 | + $items = array(); |
|
71 | 71 | $item_ids = array(); |
72 | 72 | |
73 | - foreach ( getpaid_convert_items_to_array( $form_items ) as $item_id => $qty ) { |
|
74 | - if ( ! in_array( $item_id, $item_ids ) ) { |
|
75 | - $item = new GetPaid_Form_Item( $item_id ); |
|
73 | + foreach (getpaid_convert_items_to_array($form_items) as $item_id => $qty) { |
|
74 | + if (!in_array($item_id, $item_ids)) { |
|
75 | + $item = new GetPaid_Form_Item($item_id); |
|
76 | 76 | |
77 | - if ( ! $item->has_variable_pricing() ) { |
|
78 | - $item->set_quantity( $qty ); |
|
77 | + if (!$item->has_variable_pricing()) { |
|
78 | + $item->set_quantity($qty); |
|
79 | 79 | |
80 | - if ( empty( $qty ) ) { |
|
81 | - $item->set_allow_quantities( true ); |
|
82 | - $item->set_is_required( false ); |
|
80 | + if (empty($qty)) { |
|
81 | + $item->set_allow_quantities(true); |
|
82 | + $item->set_is_required(false); |
|
83 | 83 | } |
84 | 84 | |
85 | - if ( ! $item->user_can_set_their_price() && isset( $force_prices[ $item_id ] ) ) { |
|
86 | - $item->set_is_dynamic_pricing( true ); |
|
87 | - $item->set_minimum_price( 0 ); |
|
85 | + if (!$item->user_can_set_their_price() && isset($force_prices[$item_id])) { |
|
86 | + $item->set_is_dynamic_pricing(true); |
|
87 | + $item->set_minimum_price(0); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
@@ -93,22 +93,22 @@ discard block |
||
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | - if ( ! $payment_form->is_default() ) { |
|
96 | + if (!$payment_form->is_default()) { |
|
97 | 97 | |
98 | - foreach ( $payment_form->get_items() as $item ) { |
|
99 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
98 | + foreach ($payment_form->get_items() as $item) { |
|
99 | + if (!in_array($item->get_id(), $item_ids)) { |
|
100 | 100 | $item_ids[] = $item->get_id(); |
101 | 101 | $items[] = $item; |
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | - $payment_form->set_items( $items ); |
|
106 | + $payment_form->set_items($items); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Process each individual item. |
110 | - foreach ( $payment_form->get_items() as $item ) { |
|
111 | - $this->process_item( $item, $selected_items, $submission ); |
|
110 | + foreach ($payment_form->get_items() as $item) { |
|
111 | + $this->process_item($item, $selected_items, $submission); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
@@ -119,83 +119,83 @@ discard block |
||
119 | 119 | * @param array $selected_items |
120 | 120 | * @param GetPaid_Payment_Form_Submission $submission |
121 | 121 | */ |
122 | - public function process_item( $item, $selected_items, $submission ) { |
|
122 | + public function process_item($item, $selected_items, $submission) { |
|
123 | 123 | |
124 | - if ( $item->has_variable_pricing() ) { |
|
124 | + if ($item->has_variable_pricing()) { |
|
125 | 125 | |
126 | 126 | $selected_items = array_filter( |
127 | 127 | $selected_items, |
128 | - function ( $selected_item ) use ( $item ) { |
|
128 | + function($selected_item) use ($item) { |
|
129 | 129 | return (int) $selected_item['item_id'] === (int) $item->get_id(); |
130 | 130 | } |
131 | 131 | ); |
132 | 132 | |
133 | - if ( ! $item->is_required() && ! count( $selected_items ) ) { |
|
133 | + if (!$item->is_required() && !count($selected_items)) { |
|
134 | 134 | return; |
135 | 135 | } |
136 | 136 | |
137 | 137 | $price_options = $item->get_variable_prices(); |
138 | - $price = current( $selected_items ); |
|
138 | + $price = current($selected_items); |
|
139 | 139 | |
140 | - $item->set_price_id( $price['price_id'] ); |
|
141 | - $item->set_quantity( $price['quantity'] ); |
|
140 | + $item->set_price_id($price['price_id']); |
|
141 | + $item->set_quantity($price['quantity']); |
|
142 | 142 | |
143 | - $price = isset( $price_options[ $price['price_id'] ] ) ? $price_options[ $price['price_id'] ] : $price; |
|
144 | - $item->set_price( (float) $price['amount'] ); |
|
143 | + $price = isset($price_options[$price['price_id']]) ? $price_options[$price['price_id']] : $price; |
|
144 | + $item->set_price((float) $price['amount']); |
|
145 | 145 | |
146 | - if ( isset( $price['is-recurring'] ) && 'yes' === $price['is-recurring'] ) { |
|
147 | - if ( isset( $price['trial-interval'], $price['trial-period'] ) && $price['trial-interval'] > 0 ) { |
|
146 | + if (isset($price['is-recurring']) && 'yes' === $price['is-recurring']) { |
|
147 | + if (isset($price['trial-interval'], $price['trial-period']) && $price['trial-interval'] > 0) { |
|
148 | 148 | $trial_interval = (int) $price['trial-interval']; |
149 | 149 | $trial_period = $price['trial-period']; |
150 | 150 | |
151 | - $item->set_is_free_trial( 1 ); |
|
152 | - $item->set_trial_interval( $trial_interval ); |
|
153 | - $item->set_trial_period( $trial_period ); |
|
151 | + $item->set_is_free_trial(1); |
|
152 | + $item->set_trial_interval($trial_interval); |
|
153 | + $item->set_trial_period($trial_period); |
|
154 | 154 | } |
155 | 155 | |
156 | - if ( isset( $price['recurring-interval'], $price['recurring-period'] ) && $price['recurring-interval'] > 0 ) { |
|
156 | + if (isset($price['recurring-interval'], $price['recurring-period']) && $price['recurring-interval'] > 0) { |
|
157 | 157 | $recurring_interval = (int) $price['recurring-interval']; |
158 | 158 | $recurring_period = $price['recurring-period']; |
159 | - $recurring_limit = isset( $price['recurring-limit'] ) ? (int) $price['recurring-limit'] : 0; |
|
159 | + $recurring_limit = isset($price['recurring-limit']) ? (int) $price['recurring-limit'] : 0; |
|
160 | 160 | |
161 | - $item->set_is_recurring( 1 ); |
|
162 | - $item->set_recurring_interval( $recurring_interval ); |
|
163 | - $item->set_recurring_period( $recurring_period ); |
|
164 | - $item->set_recurring_limit( $recurring_limit ); |
|
161 | + $item->set_is_recurring(1); |
|
162 | + $item->set_recurring_interval($recurring_interval); |
|
163 | + $item->set_recurring_period($recurring_period); |
|
164 | + $item->set_recurring_limit($recurring_limit); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | } else { |
168 | 168 | // Abort if this is an optional item and it has not been selected. |
169 | - if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) { |
|
169 | + if (!$item->is_required() && !isset($selected_items[$item->get_id()])) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
173 | 173 | // (maybe) let customers change the quantities and prices. |
174 | - if ( isset( $selected_items[ $item->get_id() ] ) ) { |
|
174 | + if (isset($selected_items[$item->get_id()])) { |
|
175 | 175 | |
176 | 176 | // Maybe change the quantities. |
177 | - if ( $item->allows_quantities() ) { |
|
178 | - $item->set_quantity( (float) $selected_items[ $item->get_id() ]['quantity'] ); |
|
177 | + if ($item->allows_quantities()) { |
|
178 | + $item->set_quantity((float) $selected_items[$item->get_id()]['quantity']); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | // Maybe change the price. |
182 | - if ( $item->user_can_set_their_price() ) { |
|
183 | - $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] ); |
|
182 | + if ($item->user_can_set_their_price()) { |
|
183 | + $price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']); |
|
184 | 184 | |
185 | - if ( $item->get_minimum_price() > $price ) { |
|
186 | - throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), getpaid_unstandardize_amount( $item->get_minimum_price() ) ) ); |
|
185 | + if ($item->get_minimum_price() > $price) { |
|
186 | + throw new Exception(sprintf(__('The minimum allowed amount is %s', 'invoicing'), getpaid_unstandardize_amount($item->get_minimum_price()))); |
|
187 | 187 | } |
188 | 188 | |
189 | - $item->set_price( $price ); |
|
189 | + $item->set_price($price); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | - if ( 0 == $item->get_quantity() ) { |
|
194 | + if (0 == $item->get_quantity()) { |
|
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
198 | 198 | // Save the item. |
199 | - $this->items[] = apply_filters( 'getpaid_payment_form_submission_processed_item', $item, $submission ); |
|
199 | + $this->items[] = apply_filters('getpaid_payment_form_submission_processed_item', $item, $submission); |
|
200 | 200 | } |
201 | 201 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | $this->state = wpinv_get_default_state(); |
147 | 147 | |
148 | 148 | // Do we have an actual submission? |
149 | - if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
150 | - $this->load_data( wp_kses_post_deep( wp_unslash( $_POST ) ) ); |
|
149 | + if (isset($_POST['getpaid_payment_form_submission'])) { |
|
150 | + $this->load_data(wp_kses_post_deep(wp_unslash($_POST))); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @param array $data |
158 | 158 | */ |
159 | - public function load_data( $data ) { |
|
159 | + public function load_data($data) { |
|
160 | 160 | |
161 | 161 | // Allow plugins to filter the data. |
162 | - $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
162 | + $data = apply_filters('getpaid_submission_data', $data, $this); |
|
163 | 163 | |
164 | 164 | // Cache it... |
165 | 165 | $this->data = $data; |
166 | 166 | |
167 | 167 | // Then generate a unique id from the data. |
168 | - $this->id = md5( wp_json_encode( $data ) ); |
|
168 | + $this->id = md5(wp_json_encode($data)); |
|
169 | 169 | |
170 | 170 | // Finally, process the submission. |
171 | 171 | try { |
@@ -175,29 +175,29 @@ discard block |
||
175 | 175 | $processors = apply_filters( |
176 | 176 | 'getpaid_payment_form_submission_processors', |
177 | 177 | array( |
178 | - array( $this, 'process_payment_form' ), |
|
179 | - array( $this, 'process_invoice' ), |
|
180 | - array( $this, 'process_fees' ), |
|
181 | - array( $this, 'process_items' ), |
|
182 | - array( $this, 'process_discount' ), |
|
183 | - array( $this, 'process_taxes' ), |
|
178 | + array($this, 'process_payment_form'), |
|
179 | + array($this, 'process_invoice'), |
|
180 | + array($this, 'process_fees'), |
|
181 | + array($this, 'process_items'), |
|
182 | + array($this, 'process_discount'), |
|
183 | + array($this, 'process_taxes'), |
|
184 | 184 | ), |
185 | 185 | $this |
186 | 186 | ); |
187 | 187 | |
188 | - foreach ( $processors as $processor ) { |
|
189 | - call_user_func_array( $processor, array( &$this ) ); |
|
188 | + foreach ($processors as $processor) { |
|
189 | + call_user_func_array($processor, array(&$this)); |
|
190 | 190 | } |
191 | - } catch ( GetPaid_Payment_Exception $e ) { |
|
191 | + } catch (GetPaid_Payment_Exception $e) { |
|
192 | 192 | $this->last_error = $e->getMessage(); |
193 | 193 | $this->last_error_code = $e->getErrorCode(); |
194 | - } catch ( Exception $e ) { |
|
194 | + } catch (Exception $e) { |
|
195 | 195 | $this->last_error = $e->getMessage(); |
196 | 196 | $this->last_error_code = $e->getCode(); |
197 | 197 | } |
198 | 198 | |
199 | 199 | // Fired when we are done processing a submission. |
200 | - do_action_ref_array( 'getpaid_process_submission', array( &$this ) ); |
|
200 | + do_action_ref_array('getpaid_process_submission', array(&$this)); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /* |
@@ -217,18 +217,18 @@ discard block |
||
217 | 217 | public function process_payment_form() { |
218 | 218 | |
219 | 219 | // Every submission needs an active payment form. |
220 | - if ( empty( $this->data['form_id'] ) ) { |
|
221 | - throw new Exception( __( 'Missing payment form', 'invoicing' ) ); |
|
220 | + if (empty($this->data['form_id'])) { |
|
221 | + throw new Exception(__('Missing payment form', 'invoicing')); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | // Fetch the payment form. |
225 | - $this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] ); |
|
225 | + $this->payment_form = new GetPaid_Payment_Form($this->data['form_id']); |
|
226 | 226 | |
227 | - if ( ! $this->payment_form->is_active() ) { |
|
228 | - throw new Exception( __( 'Payment form not active', 'invoicing' ) ); |
|
227 | + if (!$this->payment_form->is_active()) { |
|
228 | + throw new Exception(__('Payment form not active', 'invoicing')); |
|
229 | 229 | } |
230 | 230 | |
231 | - do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) ); |
|
231 | + do_action_ref_array('getpaid_submissions_process_payment_form', array(&$this)); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -258,64 +258,64 @@ discard block |
||
258 | 258 | public function process_invoice() { |
259 | 259 | |
260 | 260 | // Abort if there is no invoice. |
261 | - if ( empty( $this->data['invoice_id'] ) ) { |
|
261 | + if (empty($this->data['invoice_id'])) { |
|
262 | 262 | |
263 | 263 | // Check if we are resuming a payment. |
264 | - if ( empty( $this->data['maybe_use_invoice'] ) ) { |
|
264 | + if (empty($this->data['maybe_use_invoice'])) { |
|
265 | 265 | return; |
266 | 266 | } |
267 | 267 | |
268 | - $invoice = wpinv_get_invoice( $this->data['maybe_use_invoice'] ); |
|
269 | - if ( empty( $invoice ) || ! $invoice->has_status( 'draft, auto-draft, wpi-pending' ) ) { |
|
268 | + $invoice = wpinv_get_invoice($this->data['maybe_use_invoice']); |
|
269 | + if (empty($invoice) || !$invoice->has_status('draft, auto-draft, wpi-pending')) { |
|
270 | 270 | return; |
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
274 | 274 | // If the submission is for an existing invoice, ensure that it exists |
275 | 275 | // and that it is not paid for. |
276 | - if ( empty( $invoice ) ) { |
|
277 | - $invoice = wpinv_get_invoice( $this->data['invoice_id'] ); |
|
276 | + if (empty($invoice)) { |
|
277 | + $invoice = wpinv_get_invoice($this->data['invoice_id']); |
|
278 | 278 | } |
279 | 279 | |
280 | - if ( empty( $invoice ) ) { |
|
281 | - throw new Exception( __( 'Invalid invoice', 'invoicing' ) ); |
|
280 | + if (empty($invoice)) { |
|
281 | + throw new Exception(__('Invalid invoice', 'invoicing')); |
|
282 | 282 | } |
283 | 283 | |
284 | - if ( $invoice->is_paid() ) { |
|
285 | - throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) ); |
|
284 | + if ($invoice->is_paid()) { |
|
285 | + throw new Exception(__('This invoice is already paid for.', 'invoicing')); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | $this->payment_form->invoice = $invoice; |
289 | - if ( ! $this->payment_form->is_default() ) { |
|
289 | + if (!$this->payment_form->is_default()) { |
|
290 | 290 | |
291 | 291 | $items = array(); |
292 | 292 | $item_ids = array(); |
293 | 293 | |
294 | - foreach ( $invoice->get_items() as $item ) { |
|
295 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
294 | + foreach ($invoice->get_items() as $item) { |
|
295 | + if (!in_array($item->get_id(), $item_ids)) { |
|
296 | 296 | $item_ids[] = $item->get_id(); |
297 | 297 | $items[] = $item; |
298 | 298 | } |
299 | 299 | } |
300 | 300 | |
301 | - foreach ( $this->payment_form->get_items() as $item ) { |
|
302 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
301 | + foreach ($this->payment_form->get_items() as $item) { |
|
302 | + if (!in_array($item->get_id(), $item_ids)) { |
|
303 | 303 | $item_ids[] = $item->get_id(); |
304 | 304 | $items[] = $item; |
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
308 | - $this->payment_form->set_items( $items ); |
|
308 | + $this->payment_form->set_items($items); |
|
309 | 309 | |
310 | 310 | } else { |
311 | - $this->payment_form->set_items( $invoice->get_items() ); |
|
311 | + $this->payment_form->set_items($invoice->get_items()); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | $this->country = $invoice->get_country(); |
315 | 315 | $this->state = $invoice->get_state(); |
316 | 316 | $this->invoice = $invoice; |
317 | 317 | |
318 | - do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) ); |
|
318 | + do_action_ref_array('getpaid_submissions_process_invoice', array(&$this)); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | * @return bool |
336 | 336 | */ |
337 | 337 | public function has_invoice() { |
338 | - return ! empty( $this->invoice ); |
|
338 | + return !empty($this->invoice); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /* |
@@ -354,13 +354,13 @@ discard block |
||
354 | 354 | */ |
355 | 355 | public function process_items() { |
356 | 356 | |
357 | - $processor = new GetPaid_Payment_Form_Submission_Items( $this ); |
|
357 | + $processor = new GetPaid_Payment_Form_Submission_Items($this); |
|
358 | 358 | |
359 | - foreach ( $processor->items as $item ) { |
|
360 | - $this->add_item( $item ); |
|
359 | + foreach ($processor->items as $item) { |
|
360 | + $this->add_item($item); |
|
361 | 361 | } |
362 | 362 | |
363 | - do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) ); |
|
363 | + do_action_ref_array('getpaid_submissions_process_items', array(&$this)); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -369,20 +369,20 @@ discard block |
||
369 | 369 | * @since 1.0.19 |
370 | 370 | * @param GetPaid_Form_Item $item |
371 | 371 | */ |
372 | - public function add_item( $item ) { |
|
372 | + public function add_item($item) { |
|
373 | 373 | |
374 | 374 | // Make sure that it is available for purchase. |
375 | - if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) { |
|
375 | + if (!$item->can_purchase() || isset($this->items[$item->get_id()])) { |
|
376 | 376 | return; |
377 | 377 | } |
378 | 378 | |
379 | 379 | // Each submission can only contain one recurring item. |
380 | - if ( $item->is_recurring() ) { |
|
380 | + if ($item->is_recurring()) { |
|
381 | 381 | $this->has_recurring = $item->get_id(); |
382 | 382 | } |
383 | 383 | |
384 | 384 | // Update the items and totals. |
385 | - $this->items[ $item->get_id() ] = $item; |
|
385 | + $this->items[$item->get_id()] = $item; |
|
386 | 386 | $this->totals['subtotal']['initial'] += $item->get_sub_total(); |
387 | 387 | $this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total(); |
388 | 388 | } |
@@ -395,17 +395,17 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @since 1.0.19 |
397 | 397 | */ |
398 | - public function remove_item( $item_id ) { |
|
398 | + public function remove_item($item_id) { |
|
399 | 399 | |
400 | - if ( isset( $this->items[ $item_id ] ) ) { |
|
401 | - $this->totals['subtotal']['initial'] -= $this->items[ $item_id ]->get_sub_total(); |
|
402 | - $this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total(); |
|
400 | + if (isset($this->items[$item_id])) { |
|
401 | + $this->totals['subtotal']['initial'] -= $this->items[$item_id]->get_sub_total(); |
|
402 | + $this->totals['subtotal']['recurring'] -= $this->items[$item_id]->get_recurring_sub_total(); |
|
403 | 403 | |
404 | - if ( $this->items[ $item_id ]->is_recurring() ) { |
|
404 | + if ($this->items[$item_id]->is_recurring()) { |
|
405 | 405 | $this->has_recurring = 0; |
406 | 406 | } |
407 | 407 | |
408 | - unset( $this->items[ $item_id ] ); |
|
408 | + unset($this->items[$item_id]); |
|
409 | 409 | } |
410 | 410 | } |
411 | 411 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | */ |
417 | 417 | public function get_subtotal() { |
418 | 418 | |
419 | - if ( wpinv_prices_include_tax() ) { |
|
419 | + if (wpinv_prices_include_tax()) { |
|
420 | 420 | return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial']; |
421 | 421 | } |
422 | 422 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | */ |
431 | 431 | public function get_recurring_subtotal() { |
432 | 432 | |
433 | - if ( wpinv_prices_include_tax() ) { |
|
433 | + if (wpinv_prices_include_tax()) { |
|
434 | 434 | return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring']; |
435 | 435 | } |
436 | 436 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * @return bool |
455 | 455 | */ |
456 | 456 | public function has_subscription_group() { |
457 | - return $this->has_recurring && getpaid_should_group_subscriptions( $this ) && 1 == count( getpaid_get_subscription_groups( $this ) ); |
|
457 | + return $this->has_recurring && getpaid_should_group_subscriptions($this) && 1 == count(getpaid_get_subscription_groups($this)); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | * @return bool |
465 | 465 | */ |
466 | 466 | public function has_multiple_subscription_groups() { |
467 | - return $this->has_recurring && 1 < count( getpaid_get_subscription_groups( $this ) ); |
|
467 | + return $this->has_recurring && 1 < count(getpaid_get_subscription_groups($this)); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /* |
@@ -484,39 +484,39 @@ discard block |
||
484 | 484 | public function process_taxes() { |
485 | 485 | |
486 | 486 | // Abort if we're not using taxes. |
487 | - if ( ! $this->use_taxes() ) { |
|
487 | + if (!$this->use_taxes()) { |
|
488 | 488 | return; |
489 | 489 | } |
490 | 490 | |
491 | 491 | // If a custom country && state has been passed in, use it to calculate taxes. |
492 | - $country = $this->get_field( 'wpinv_country', 'billing' ); |
|
493 | - if ( ! empty( $country ) ) { |
|
492 | + $country = $this->get_field('wpinv_country', 'billing'); |
|
493 | + if (!empty($country)) { |
|
494 | 494 | $this->country = $country; |
495 | 495 | } |
496 | 496 | |
497 | - $state = $this->get_field( 'wpinv_state', 'billing' ); |
|
498 | - if ( ! empty( $state ) ) { |
|
497 | + $state = $this->get_field('wpinv_state', 'billing'); |
|
498 | + if (!empty($state)) { |
|
499 | 499 | $this->state = $state; |
500 | 500 | } |
501 | 501 | |
502 | 502 | // Confirm if the provided country and the ip country are similar. |
503 | - $address_confirmed = $this->get_field( 'confirm-address' ); |
|
504 | - if ( isset( $_POST['billing']['country'] ) && wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty( $address_confirmed ) ) { |
|
505 | - throw new Exception( __( 'The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing' ) ); |
|
503 | + $address_confirmed = $this->get_field('confirm-address'); |
|
504 | + if (isset($_POST['billing']['country']) && wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty($address_confirmed)) { |
|
505 | + throw new Exception(__('The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing')); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | // Abort if the country is not taxable. |
509 | - if ( ! wpinv_is_country_taxable( $this->country ) ) { |
|
509 | + if (!wpinv_is_country_taxable($this->country)) { |
|
510 | 510 | return; |
511 | 511 | } |
512 | 512 | |
513 | - $processor = new GetPaid_Payment_Form_Submission_Taxes( $this ); |
|
513 | + $processor = new GetPaid_Payment_Form_Submission_Taxes($this); |
|
514 | 514 | |
515 | - foreach ( $processor->taxes as $tax ) { |
|
516 | - $this->add_tax( $tax ); |
|
515 | + foreach ($processor->taxes as $tax) { |
|
516 | + $this->add_tax($tax); |
|
517 | 517 | } |
518 | 518 | |
519 | - do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) ); |
|
519 | + do_action_ref_array('getpaid_submissions_process_taxes', array(&$this)); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -525,16 +525,16 @@ discard block |
||
525 | 525 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
526 | 526 | * @since 1.0.19 |
527 | 527 | */ |
528 | - public function add_tax( $tax ) { |
|
528 | + public function add_tax($tax) { |
|
529 | 529 | |
530 | - if ( wpinv_round_tax_per_tax_rate() ) { |
|
531 | - $tax['initial_tax'] = wpinv_round_amount( $tax['initial_tax'] ); |
|
532 | - $tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] ); |
|
530 | + if (wpinv_round_tax_per_tax_rate()) { |
|
531 | + $tax['initial_tax'] = wpinv_round_amount($tax['initial_tax']); |
|
532 | + $tax['recurring_tax'] = wpinv_round_amount($tax['recurring_tax']); |
|
533 | 533 | } |
534 | 534 | |
535 | - $this->taxes[ $tax['name'] ] = $tax; |
|
536 | - $this->totals['taxes']['initial'] += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
537 | - $this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] ); |
|
535 | + $this->taxes[$tax['name']] = $tax; |
|
536 | + $this->totals['taxes']['initial'] += wpinv_sanitize_amount($tax['initial_tax']); |
|
537 | + $this->totals['taxes']['recurring'] += wpinv_sanitize_amount($tax['recurring_tax']); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | /** |
@@ -542,12 +542,12 @@ discard block |
||
542 | 542 | * |
543 | 543 | * @since 1.0.19 |
544 | 544 | */ |
545 | - public function remove_tax( $tax_name ) { |
|
545 | + public function remove_tax($tax_name) { |
|
546 | 546 | |
547 | - if ( isset( $this->taxes[ $tax_name ] ) ) { |
|
548 | - $this->totals['taxes']['initial'] -= $this->taxes[ $tax_name ]['initial_tax']; |
|
549 | - $this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax']; |
|
550 | - unset( $this->taxes[ $tax_name ] ); |
|
547 | + if (isset($this->taxes[$tax_name])) { |
|
548 | + $this->totals['taxes']['initial'] -= $this->taxes[$tax_name]['initial_tax']; |
|
549 | + $this->totals['taxes']['recurring'] -= $this->taxes[$tax_name]['recurring_tax']; |
|
550 | + unset($this->taxes[$tax_name]); |
|
551 | 551 | } |
552 | 552 | } |
553 | 553 | |
@@ -560,11 +560,11 @@ discard block |
||
560 | 560 | |
561 | 561 | $use_taxes = wpinv_use_taxes(); |
562 | 562 | |
563 | - if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) { |
|
563 | + if ($this->has_invoice() && !$this->invoice->is_taxable()) { |
|
564 | 564 | $use_taxes = false; |
565 | 565 | } |
566 | 566 | |
567 | - return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
567 | + return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | /** |
@@ -612,13 +612,13 @@ discard block |
||
612 | 612 | |
613 | 613 | $initial_total = $this->get_subtotal() + $this->get_fee() + $this->get_tax(); |
614 | 614 | $recurring_total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax(); |
615 | - $processor = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total ); |
|
615 | + $processor = new GetPaid_Payment_Form_Submission_Discount($this, $initial_total, $recurring_total); |
|
616 | 616 | |
617 | - foreach ( $processor->discounts as $discount ) { |
|
618 | - $this->add_discount( $discount ); |
|
617 | + foreach ($processor->discounts as $discount) { |
|
618 | + $this->add_discount($discount); |
|
619 | 619 | } |
620 | 620 | |
621 | - do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) ); |
|
621 | + do_action_ref_array('getpaid_submissions_process_discounts', array(&$this)); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -627,10 +627,10 @@ discard block |
||
627 | 627 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
628 | 628 | * @since 1.0.19 |
629 | 629 | */ |
630 | - public function add_discount( $discount ) { |
|
631 | - $this->discounts[ $discount['name'] ] = $discount; |
|
632 | - $this->totals['discount']['initial'] += wpinv_sanitize_amount( $discount['initial_discount'] ); |
|
633 | - $this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] ); |
|
630 | + public function add_discount($discount) { |
|
631 | + $this->discounts[$discount['name']] = $discount; |
|
632 | + $this->totals['discount']['initial'] += wpinv_sanitize_amount($discount['initial_discount']); |
|
633 | + $this->totals['discount']['recurring'] += wpinv_sanitize_amount($discount['recurring_discount']); |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | /** |
@@ -638,12 +638,12 @@ discard block |
||
638 | 638 | * |
639 | 639 | * @since 1.0.19 |
640 | 640 | */ |
641 | - public function remove_discount( $name ) { |
|
641 | + public function remove_discount($name) { |
|
642 | 642 | |
643 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
644 | - $this->totals['discount']['initial'] -= $this->discounts[ $name ]['initial_discount']; |
|
645 | - $this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount']; |
|
646 | - unset( $this->discounts[ $name ] ); |
|
643 | + if (isset($this->discounts[$name])) { |
|
644 | + $this->totals['discount']['initial'] -= $this->discounts[$name]['initial_discount']; |
|
645 | + $this->totals['discount']['recurring'] -= $this->discounts[$name]['recurring_discount']; |
|
646 | + unset($this->discounts[$name]); |
|
647 | 647 | } |
648 | 648 | } |
649 | 649 | |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | * @return bool |
655 | 655 | */ |
656 | 656 | public function has_discount_code() { |
657 | - return ! empty( $this->discounts['discount_code'] ); |
|
657 | + return !empty($this->discounts['discount_code']); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | /** |
@@ -711,13 +711,13 @@ discard block |
||
711 | 711 | */ |
712 | 712 | public function process_fees() { |
713 | 713 | |
714 | - $fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this ); |
|
714 | + $fees_processor = new GetPaid_Payment_Form_Submission_Fees($this); |
|
715 | 715 | |
716 | - foreach ( $fees_processor->fees as $fee ) { |
|
717 | - $this->add_fee( $fee ); |
|
716 | + foreach ($fees_processor->fees as $fee) { |
|
717 | + $this->add_fee($fee); |
|
718 | 718 | } |
719 | 719 | |
720 | - do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) ); |
|
720 | + do_action_ref_array('getpaid_submissions_process_fees', array(&$this)); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | /** |
@@ -726,17 +726,17 @@ discard block |
||
726 | 726 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
727 | 727 | * @since 1.0.19 |
728 | 728 | */ |
729 | - public function add_fee( $fee ) { |
|
729 | + public function add_fee($fee) { |
|
730 | 730 | |
731 | - if ( $fee['name'] == 'shipping' ) { |
|
732 | - $this->totals['shipping']['initial'] += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
733 | - $this->totals['shipping']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] ); |
|
731 | + if ($fee['name'] == 'shipping') { |
|
732 | + $this->totals['shipping']['initial'] += wpinv_sanitize_amount($fee['initial_fee']); |
|
733 | + $this->totals['shipping']['recurring'] += wpinv_sanitize_amount($fee['recurring_fee']); |
|
734 | 734 | return; |
735 | 735 | } |
736 | 736 | |
737 | - $this->fees[ $fee['name'] ] = $fee; |
|
738 | - $this->totals['fees']['initial'] += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
739 | - $this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] ); |
|
737 | + $this->fees[$fee['name']] = $fee; |
|
738 | + $this->totals['fees']['initial'] += wpinv_sanitize_amount($fee['initial_fee']); |
|
739 | + $this->totals['fees']['recurring'] += wpinv_sanitize_amount($fee['recurring_fee']); |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | /** |
@@ -744,15 +744,15 @@ discard block |
||
744 | 744 | * |
745 | 745 | * @since 1.0.19 |
746 | 746 | */ |
747 | - public function remove_fee( $name ) { |
|
747 | + public function remove_fee($name) { |
|
748 | 748 | |
749 | - if ( isset( $this->fees[ $name ] ) ) { |
|
750 | - $this->totals['fees']['initial'] -= $this->fees[ $name ]['initial_fee']; |
|
751 | - $this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee']; |
|
752 | - unset( $this->fees[ $name ] ); |
|
749 | + if (isset($this->fees[$name])) { |
|
750 | + $this->totals['fees']['initial'] -= $this->fees[$name]['initial_fee']; |
|
751 | + $this->totals['fees']['recurring'] -= $this->fees[$name]['recurring_fee']; |
|
752 | + unset($this->fees[$name]); |
|
753 | 753 | } |
754 | 754 | |
755 | - if ( 'shipping' == $name ) { |
|
755 | + if ('shipping' == $name) { |
|
756 | 756 | $this->totals['shipping']['initial'] = 0; |
757 | 757 | $this->totals['shipping']['recurring'] = 0; |
758 | 758 | } |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | * @since 1.0.19 |
793 | 793 | */ |
794 | 794 | public function has_fees() { |
795 | - return count( $this->fees ) !== 0; |
|
795 | + return count($this->fees) !== 0; |
|
796 | 796 | } |
797 | 797 | |
798 | 798 | /* |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | * @since 1.0.19 |
829 | 829 | */ |
830 | 830 | public function has_shipping() { |
831 | - return apply_filters( 'getpaid_payment_form_has_shipping', false, $this ); |
|
831 | + return apply_filters('getpaid_payment_form_has_shipping', false, $this); |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | /** |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | * @since 1.0.19 |
839 | 839 | */ |
840 | 840 | public function is_initial_fetch() { |
841 | - return isset( $this->data['initial_state'] ) && empty( $this->data['initial_state'] ); |
|
841 | + return isset($this->data['initial_state']) && empty($this->data['initial_state']); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | /** |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | */ |
849 | 849 | public function get_total() { |
850 | 850 | $total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() + $this->get_shipping() - $this->get_discount(); |
851 | - return max( $total, 0 ); |
|
851 | + return max($total, 0); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | /** |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | */ |
859 | 859 | public function get_recurring_total() { |
860 | 860 | $total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() + $this->get_recurring_shipping() - $this->get_recurring_discount(); |
861 | - return max( $total, 0 ); |
|
861 | + return max($total, 0); |
|
862 | 862 | } |
863 | 863 | |
864 | 864 | /** |
@@ -870,12 +870,12 @@ discard block |
||
870 | 870 | $initial = $this->get_total(); |
871 | 871 | $recurring = $this->get_recurring_total(); |
872 | 872 | |
873 | - if ( $this->has_recurring == 0 ) { |
|
873 | + if ($this->has_recurring == 0) { |
|
874 | 874 | $recurring = 0; |
875 | 875 | } |
876 | 876 | |
877 | 877 | $collect = $initial > 0 || $recurring > 0; |
878 | - return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this ); |
|
878 | + return apply_filters('getpaid_submission_should_collect_payment_details', $collect, $this); |
|
879 | 879 | } |
880 | 880 | |
881 | 881 | /** |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | * @since 1.0.19 |
885 | 885 | */ |
886 | 886 | public function get_billing_email() { |
887 | - return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this ); |
|
887 | + return apply_filters('getpaid_get_submission_billing_email', $this->get_field('billing_email'), $this); |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | /** |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | */ |
895 | 895 | public function has_billing_email() { |
896 | 896 | $billing_email = $this->get_billing_email(); |
897 | - return ! empty( $billing_email ) && is_email( $billing_email ); |
|
897 | + return !empty($billing_email) && is_email($billing_email); |
|
898 | 898 | } |
899 | 899 | |
900 | 900 | /** |
@@ -924,8 +924,8 @@ discard block |
||
924 | 924 | * @since 1.0.19 |
925 | 925 | * @return mixed|null |
926 | 926 | */ |
927 | - public function get_field( $field, $sub_array_key = null ) { |
|
928 | - return getpaid_get_array_field( $this->data, $field, $sub_array_key ); |
|
927 | + public function get_field($field, $sub_array_key = null) { |
|
928 | + return getpaid_get_array_field($this->data, $field, $sub_array_key); |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | /** |
@@ -933,8 +933,8 @@ discard block |
||
933 | 933 | * |
934 | 934 | * @since 1.0.19 |
935 | 935 | */ |
936 | - public function is_required_field_set( $field ) { |
|
937 | - return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
936 | + public function is_required_field_set($field) { |
|
937 | + return empty($field['required']) || !empty($this->data[$field['id']]); |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | /** |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | * |
943 | 943 | * @since 1.0.19 |
944 | 944 | */ |
945 | - public function format_amount( $amount ) { |
|
946 | - return wpinv_price( $amount, $this->get_currency() ); |
|
945 | + public function format_amount($amount) { |
|
946 | + return wpinv_price($amount, $this->get_currency()); |
|
947 | 947 | } |
948 | 948 | } |
@@ -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 | * Payment form submission refresh prices class |
@@ -23,29 +23,29 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param GetPaid_Payment_Form_Submission $submission |
25 | 25 | */ |
26 | - public function __construct( $submission ) { |
|
26 | + public function __construct($submission) { |
|
27 | 27 | |
28 | 28 | $this->response = array( |
29 | 29 | 'submission_id' => $submission->id, |
30 | 30 | 'has_recurring' => $submission->has_recurring, |
31 | 31 | 'has_subscription_group' => $submission->has_subscription_group(), |
32 | 32 | 'has_multiple_subscription_groups' => $submission->has_multiple_subscription_groups(), |
33 | - 'is_free' => ! $submission->should_collect_payment_details(), |
|
33 | + 'is_free' => !$submission->should_collect_payment_details(), |
|
34 | 34 | ); |
35 | 35 | |
36 | 36 | $payment_form = $submission->get_payment_form(); |
37 | - if ( ! empty( $payment_form->invoice ) ) { |
|
37 | + if (!empty($payment_form->invoice)) { |
|
38 | 38 | $this->response['invoice'] = $payment_form->invoice->get_id(); |
39 | 39 | } |
40 | 40 | |
41 | - $this->add_totals( $submission ); |
|
42 | - $this->add_texts( $submission ); |
|
43 | - $this->add_items( $submission ); |
|
44 | - $this->add_fees( $submission ); |
|
45 | - $this->add_discounts( $submission ); |
|
46 | - $this->add_taxes( $submission ); |
|
47 | - $this->add_gateways( $submission ); |
|
48 | - $this->add_data( $submission ); |
|
41 | + $this->add_totals($submission); |
|
42 | + $this->add_texts($submission); |
|
43 | + $this->add_items($submission); |
|
44 | + $this->add_fees($submission); |
|
45 | + $this->add_discounts($submission); |
|
46 | + $this->add_taxes($submission); |
|
47 | + $this->add_gateways($submission); |
|
48 | + $this->add_data($submission); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -53,30 +53,30 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @param GetPaid_Payment_Form_Submission $submission |
55 | 55 | */ |
56 | - public function add_totals( $submission ) { |
|
56 | + public function add_totals($submission) { |
|
57 | 57 | |
58 | 58 | $this->response = array_merge( |
59 | 59 | $this->response, |
60 | 60 | array( |
61 | 61 | |
62 | 62 | 'totals' => array( |
63 | - 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
64 | - 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
65 | - 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
66 | - 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
67 | - 'total' => $submission->format_amount( $submission->get_total() ), |
|
68 | - 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
63 | + 'subtotal' => $submission->format_amount($submission->get_subtotal()), |
|
64 | + 'discount' => $submission->format_amount($submission->get_discount()), |
|
65 | + 'fees' => $submission->format_amount($submission->get_fee()), |
|
66 | + 'tax' => $submission->format_amount($submission->get_tax()), |
|
67 | + 'total' => $submission->format_amount($submission->get_total()), |
|
68 | + 'raw_total' => html_entity_decode(sanitize_text_field($submission->format_amount($submission->get_total())), ENT_QUOTES), |
|
69 | 69 | ), |
70 | 70 | |
71 | 71 | 'recurring' => array( |
72 | - 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
73 | - 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
74 | - 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
75 | - 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
76 | - 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
72 | + 'subtotal' => $submission->format_amount($submission->get_recurring_subtotal()), |
|
73 | + 'discount' => $submission->format_amount($submission->get_recurring_discount()), |
|
74 | + 'fees' => $submission->format_amount($submission->get_recurring_fee()), |
|
75 | + 'tax' => $submission->format_amount($submission->get_recurring_tax()), |
|
76 | + 'total' => $submission->format_amount($submission->get_recurring_total()), |
|
77 | 77 | ), |
78 | 78 | |
79 | - 'initial_amt' => wpinv_round_amount( $submission->get_total(), null, true ), |
|
79 | + 'initial_amt' => wpinv_round_amount($submission->get_total(), null, true), |
|
80 | 80 | 'currency' => $submission->get_currency(), |
81 | 81 | |
82 | 82 | ) |
@@ -88,53 +88,53 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @param GetPaid_Payment_Form_Submission $submission |
90 | 90 | */ |
91 | - public function add_texts( $submission ) { |
|
91 | + public function add_texts($submission) { |
|
92 | 92 | |
93 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
94 | - $groups = getpaid_get_subscription_groups( $submission ); |
|
93 | + $payable = $submission->format_amount($submission->get_total()); |
|
94 | + $groups = getpaid_get_subscription_groups($submission); |
|
95 | 95 | |
96 | - if ( $submission->has_recurring && 2 > count( $groups ) ) { |
|
96 | + if ($submission->has_recurring && 2 > count($groups)) { |
|
97 | 97 | |
98 | - $recurring = new WPInv_Item( $submission->has_recurring ); |
|
99 | - $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
100 | - $main_item = reset( $groups ); |
|
98 | + $recurring = new WPInv_Item($submission->has_recurring); |
|
99 | + $period = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), ''); |
|
100 | + $main_item = reset($groups); |
|
101 | 101 | |
102 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
102 | + if ($submission->get_total() == $submission->get_recurring_total()) { |
|
103 | 103 | $payable = "$payable / $period"; |
104 | - } elseif ( $main_item ) { |
|
104 | + } elseif ($main_item) { |
|
105 | 105 | |
106 | - $main_item = reset( $main_item ); |
|
106 | + $main_item = reset($main_item); |
|
107 | 107 | |
108 | 108 | // Calculate the next renewal date. |
109 | - $_period = $main_item->get_recurring_period( true ); |
|
109 | + $_period = $main_item->get_recurring_period(true); |
|
110 | 110 | $_interval = $main_item->get_recurring_interval(); |
111 | 111 | |
112 | 112 | // If the subscription item has a trial period... |
113 | - if ( $main_item->has_free_trial() ) { |
|
114 | - $_period = $main_item->get_trial_period( true ); |
|
113 | + if ($main_item->has_free_trial()) { |
|
114 | + $_period = $main_item->get_trial_period(true); |
|
115 | 115 | $_interval = $main_item->get_trial_interval(); |
116 | 116 | } |
117 | 117 | |
118 | 118 | $payable = sprintf( |
119 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
120 | - $submission->format_amount( $submission->get_total() ), |
|
121 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
119 | + __('%1$s (renews at %2$s / %3$s)', 'invoicing'), |
|
120 | + $submission->format_amount($submission->get_total()), |
|
121 | + $submission->format_amount($submission->get_recurring_total()), |
|
122 | 122 | $period |
123 | 123 | ); |
124 | 124 | |
125 | 125 | $payable .= sprintf( |
126 | 126 | '<small class="text-muted form-text">%s</small>', |
127 | 127 | sprintf( |
128 | - __( 'First renewal on %s', 'invoicing' ), |
|
129 | - getpaid_format_date( date( 'Y-m-d H:i:s', strtotime( "+$_interval $_period", current_time( 'timestamp' ) ) ) ) |
|
128 | + __('First renewal on %s', 'invoicing'), |
|
129 | + getpaid_format_date(date('Y-m-d H:i:s', strtotime("+$_interval $_period", current_time('timestamp')))) |
|
130 | 130 | ) |
131 | 131 | ); |
132 | 132 | |
133 | 133 | } else { |
134 | 134 | $payable = sprintf( |
135 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
136 | - $submission->format_amount( $submission->get_total() ), |
|
137 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
135 | + __('%1$s (renews at %2$s / %3$s)', 'invoicing'), |
|
136 | + $submission->format_amount($submission->get_total()), |
|
137 | + $submission->format_amount($submission->get_recurring_total()), |
|
138 | 138 | $period |
139 | 139 | ); |
140 | 140 | } |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | '.getpaid-checkout-total-payable' => $payable, |
145 | 145 | ); |
146 | 146 | |
147 | - foreach ( $submission->get_items() as $item ) { |
|
147 | + foreach ($submission->get_items() as $item) { |
|
148 | 148 | $item_id = $item->has_variable_pricing() ? $item->get_price_id() : $item->get_id(); |
149 | 149 | |
150 | - $initial_price = $submission->format_amount( $item->get_sub_total() - $item->item_discount ); |
|
151 | - $recurring_price = $submission->format_amount( $item->get_recurring_sub_total() - $item->recurring_item_discount ); |
|
152 | - $texts[ ".item-$item_id .getpaid-form-item-price-desc" ] = getpaid_item_recurring_price_help_text( $item, $submission->get_currency(), $initial_price, $recurring_price ); |
|
153 | - $texts[ ".item-$item_id .getpaid-mobile-item-subtotal" ] = sprintf( __( 'Subtotal: %s', 'invoicing' ), $submission->format_amount( $item->get_sub_total() ) ); |
|
150 | + $initial_price = $submission->format_amount($item->get_sub_total() - $item->item_discount); |
|
151 | + $recurring_price = $submission->format_amount($item->get_recurring_sub_total() - $item->recurring_item_discount); |
|
152 | + $texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text($item, $submission->get_currency(), $initial_price, $recurring_price); |
|
153 | + $texts[".item-$item_id .getpaid-mobile-item-subtotal"] = sprintf(__('Subtotal: %s', 'invoicing'), $submission->format_amount($item->get_sub_total())); |
|
154 | 154 | |
155 | - if ( $item->get_quantity() == 1 ) { |
|
156 | - $texts[ ".item-$item_id .getpaid-mobile-item-subtotal" ] = ''; |
|
155 | + if ($item->get_quantity() == 1) { |
|
156 | + $texts[".item-$item_id .getpaid-mobile-item-subtotal"] = ''; |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
160 | + $this->response = array_merge($this->response, array('texts' => $texts)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -165,21 +165,21 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @param GetPaid_Payment_Form_Submission $submission |
167 | 167 | */ |
168 | - public function add_items( $submission ) { |
|
168 | + public function add_items($submission) { |
|
169 | 169 | |
170 | 170 | // Add items. |
171 | 171 | $items = array(); |
172 | 172 | $selected_items = array(); |
173 | 173 | |
174 | - foreach ( $submission->get_items() as $item ) { |
|
174 | + foreach ($submission->get_items() as $item) { |
|
175 | 175 | $item_id = $item->has_variable_pricing() ? $item->get_price_id() : $item->get_id(); |
176 | - $items[ "$item_id" ] = $submission->format_amount( $item->get_sub_total() ); |
|
176 | + $items["$item_id"] = $submission->format_amount($item->get_sub_total()); |
|
177 | 177 | |
178 | - $selected_items[ "$item_id" ] = array( |
|
178 | + $selected_items["$item_id"] = array( |
|
179 | 179 | 'quantity' => $item->get_quantity(), |
180 | 180 | 'price' => $item->get_price(), |
181 | 181 | 'price_id' => (int) $item_id, |
182 | - 'price_fmt' => $submission->format_amount( $item->get_price() ), |
|
182 | + 'price_fmt' => $submission->format_amount($item->get_price()), |
|
183 | 183 | ); |
184 | 184 | } |
185 | 185 | |
@@ -197,17 +197,17 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @param GetPaid_Payment_Form_Submission $submission |
199 | 199 | */ |
200 | - public function add_fees( $submission ) { |
|
200 | + public function add_fees($submission) { |
|
201 | 201 | |
202 | 202 | $fees = array(); |
203 | 203 | |
204 | - foreach ( $submission->get_fees() as $name => $data ) { |
|
205 | - $fees[ $name ] = $submission->format_amount( $data['initial_fee'] ); |
|
204 | + foreach ($submission->get_fees() as $name => $data) { |
|
205 | + $fees[$name] = $submission->format_amount($data['initial_fee']); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | $this->response = array_merge( |
209 | 209 | $this->response, |
210 | - array( 'fees' => $fees ) |
|
210 | + array('fees' => $fees) |
|
211 | 211 | ); |
212 | 212 | } |
213 | 213 | |
@@ -216,17 +216,17 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @param GetPaid_Payment_Form_Submission $submission |
218 | 218 | */ |
219 | - public function add_discounts( $submission ) { |
|
219 | + public function add_discounts($submission) { |
|
220 | 220 | |
221 | 221 | $discounts = array(); |
222 | 222 | |
223 | - foreach ( $submission->get_discounts() as $name => $data ) { |
|
224 | - $discounts[ $name ] = $submission->format_amount( $data['initial_discount'] ); |
|
223 | + foreach ($submission->get_discounts() as $name => $data) { |
|
224 | + $discounts[$name] = $submission->format_amount($data['initial_discount']); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | $this->response = array_merge( |
228 | 228 | $this->response, |
229 | - array( 'discounts' => $discounts ) |
|
229 | + array('discounts' => $discounts) |
|
230 | 230 | ); |
231 | 231 | } |
232 | 232 | |
@@ -235,20 +235,20 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @param GetPaid_Payment_Form_Submission $submission |
237 | 237 | */ |
238 | - public function add_taxes( $submission ) { |
|
238 | + public function add_taxes($submission) { |
|
239 | 239 | |
240 | 240 | $taxes = array(); |
241 | 241 | $markup = ''; |
242 | - foreach ( $submission->get_taxes() as $name => $data ) { |
|
243 | - $name = sanitize_text_field( $name ); |
|
244 | - $amount = $submission->format_amount( $data['initial_tax'] ); |
|
245 | - $taxes[ $name ] = $amount; |
|
242 | + foreach ($submission->get_taxes() as $name => $data) { |
|
243 | + $name = sanitize_text_field($name); |
|
244 | + $amount = $submission->format_amount($data['initial_tax']); |
|
245 | + $taxes[$name] = $amount; |
|
246 | 246 | $markup .= "<small class='form-text'>$name : $amount</small>"; |
247 | 247 | } |
248 | 248 | |
249 | 249 | $this->response = array_merge( |
250 | 250 | $this->response, |
251 | - array( 'taxes' => $taxes ) |
|
251 | + array('taxes' => $taxes) |
|
252 | 252 | ); |
253 | 253 | } |
254 | 254 | |
@@ -257,27 +257,27 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @param GetPaid_Payment_Form_Submission $submission |
259 | 259 | */ |
260 | - public function add_gateways( $submission ) { |
|
260 | + public function add_gateways($submission) { |
|
261 | 261 | |
262 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
262 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
263 | 263 | |
264 | - if ( $this->response['has_recurring'] ) { |
|
264 | + if ($this->response['has_recurring']) { |
|
265 | 265 | |
266 | - foreach ( $gateways as $i => $gateway ) { |
|
266 | + foreach ($gateways as $i => $gateway) { |
|
267 | 267 | |
268 | 268 | if ( |
269 | - ! getpaid_payment_gateway_supports( $gateway, 'subscription' ) |
|
270 | - || ( $this->response['has_subscription_group'] && ! getpaid_payment_gateway_supports( $gateway, 'single_subscription_group' ) ) |
|
271 | - || ( $this->response['has_multiple_subscription_groups'] && ! getpaid_payment_gateway_supports( $gateway, 'multiple_subscription_groups' ) ) ) { |
|
272 | - unset( $gateways[ $i ] ); |
|
269 | + !getpaid_payment_gateway_supports($gateway, 'subscription') |
|
270 | + || ($this->response['has_subscription_group'] && !getpaid_payment_gateway_supports($gateway, 'single_subscription_group')) |
|
271 | + || ($this->response['has_multiple_subscription_groups'] && !getpaid_payment_gateway_supports($gateway, 'multiple_subscription_groups')) ) { |
|
272 | + unset($gateways[$i]); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | } |
276 | 276 | |
277 | - $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
277 | + $gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission); |
|
278 | 278 | $this->response = array_merge( |
279 | 279 | $this->response, |
280 | - array( 'gateways' => $gateways ) |
|
280 | + array('gateways' => $gateways) |
|
281 | 281 | ); |
282 | 282 | } |
283 | 283 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @param GetPaid_Payment_Form_Submission $submission |
288 | 288 | */ |
289 | - public function add_data( $submission ) { |
|
289 | + public function add_data($submission) { |
|
290 | 290 | |
291 | 291 | $this->response = array_merge( |
292 | 292 | $this->response, |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -72,28 +72,28 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
74 | 74 | */ |
75 | - public function __construct( $form = 0 ) { |
|
76 | - parent::__construct( $form ); |
|
75 | + public function __construct($form = 0) { |
|
76 | + parent::__construct($form); |
|
77 | 77 | |
78 | - if ( is_numeric( $form ) && $form > 0 ) { |
|
79 | - $this->set_id( $form ); |
|
80 | - } elseif ( $form instanceof self ) { |
|
78 | + if (is_numeric($form) && $form > 0) { |
|
79 | + $this->set_id($form); |
|
80 | + } elseif ($form instanceof self) { |
|
81 | 81 | |
82 | - $this->set_id( $form->get_id() ); |
|
82 | + $this->set_id($form->get_id()); |
|
83 | 83 | $this->invoice = $form->invoice; |
84 | 84 | |
85 | - } elseif ( ! empty( $form->ID ) ) { |
|
86 | - $this->set_id( $form->ID ); |
|
85 | + } elseif (!empty($form->ID)) { |
|
86 | + $this->set_id($form->ID); |
|
87 | 87 | } else { |
88 | - $this->set_object_read( true ); |
|
88 | + $this->set_object_read(true); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Load the datastore. |
92 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
92 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
93 | 93 | |
94 | - if ( $this->get_id() > 0 ) { |
|
95 | - $this->post = get_post( $this->get_id() ); |
|
96 | - $this->data_store->read( $this ); |
|
94 | + if ($this->get_id() > 0) { |
|
95 | + $this->post = get_post($this->get_id()); |
|
96 | + $this->data_store->read($this); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @param string $context View or edit context. |
120 | 120 | * @return string |
121 | 121 | */ |
122 | - public function get_version( $context = 'view' ) { |
|
123 | - return $this->get_prop( 'version', $context ); |
|
122 | + public function get_version($context = 'view') { |
|
123 | + return $this->get_prop('version', $context); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | * @param string $context View or edit context. |
131 | 131 | * @return string |
132 | 132 | */ |
133 | - public function get_date_created( $context = 'view' ) { |
|
134 | - return $this->get_prop( 'date_created', $context ); |
|
133 | + public function get_date_created($context = 'view') { |
|
134 | + return $this->get_prop('date_created', $context); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | * @param string $context View or edit context. |
142 | 142 | * @return string |
143 | 143 | */ |
144 | - public function get_date_created_gmt( $context = 'view' ) { |
|
145 | - $date = $this->get_date_created( $context ); |
|
144 | + public function get_date_created_gmt($context = 'view') { |
|
145 | + $date = $this->get_date_created($context); |
|
146 | 146 | |
147 | - if ( $date ) { |
|
148 | - $date = get_gmt_from_date( $date ); |
|
147 | + if ($date) { |
|
148 | + $date = get_gmt_from_date($date); |
|
149 | 149 | } |
150 | 150 | return $date; |
151 | 151 | } |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @param string $context View or edit context. |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - public function get_date_modified( $context = 'view' ) { |
|
161 | - return $this->get_prop( 'date_modified', $context ); |
|
160 | + public function get_date_modified($context = 'view') { |
|
161 | + return $this->get_prop('date_modified', $context); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | * @param string $context View or edit context. |
169 | 169 | * @return string |
170 | 170 | */ |
171 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
172 | - $date = $this->get_date_modified( $context ); |
|
171 | + public function get_date_modified_gmt($context = 'view') { |
|
172 | + $date = $this->get_date_modified($context); |
|
173 | 173 | |
174 | - if ( $date ) { |
|
175 | - $date = get_gmt_from_date( $date ); |
|
174 | + if ($date) { |
|
175 | + $date = get_gmt_from_date($date); |
|
176 | 176 | } |
177 | 177 | return $date; |
178 | 178 | } |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @param string $context View or edit context. |
185 | 185 | * @return string |
186 | 186 | */ |
187 | - public function get_name( $context = 'view' ) { |
|
188 | - return $this->get_prop( 'name', $context ); |
|
187 | + public function get_name($context = 'view') { |
|
188 | + return $this->get_prop('name', $context); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | * @param string $context View or edit context. |
196 | 196 | * @return string |
197 | 197 | */ |
198 | - public function get_title( $context = 'view' ) { |
|
199 | - return $this->get_name( $context ); |
|
198 | + public function get_title($context = 'view') { |
|
199 | + return $this->get_name($context); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | * @param string $context View or edit context. |
207 | 207 | * @return int |
208 | 208 | */ |
209 | - public function get_author( $context = 'view' ) { |
|
210 | - return (int) $this->get_prop( 'author', $context ); |
|
209 | + public function get_author($context = 'view') { |
|
210 | + return (int) $this->get_prop('author', $context); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -217,21 +217,21 @@ discard block |
||
217 | 217 | * @param string $context View or edit context. |
218 | 218 | * @return array |
219 | 219 | */ |
220 | - public function get_elements( $context = 'view' ) { |
|
221 | - $elements = $this->get_prop( 'elements', $context ); |
|
220 | + public function get_elements($context = 'view') { |
|
221 | + $elements = $this->get_prop('elements', $context); |
|
222 | 222 | |
223 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
224 | - return wpinv_get_data( 'sample-payment-form' ); |
|
223 | + if (empty($elements) || !is_array($elements)) { |
|
224 | + return wpinv_get_data('sample-payment-form'); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // Ensure that all required elements exist. |
228 | 228 | $_elements = array(); |
229 | - foreach ( $elements as $element ) { |
|
229 | + foreach ($elements as $element) { |
|
230 | 230 | |
231 | - if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
231 | + if ($element['type'] == 'pay_button' && !$this->has_element_type('gateway_select')) { |
|
232 | 232 | |
233 | 233 | $_elements[] = array( |
234 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
234 | + 'text' => __('Select Payment Method', 'invoicing'), |
|
235 | 235 | 'id' => 'gtscicd', |
236 | 236 | 'name' => 'gtscicd', |
237 | 237 | 'type' => 'gateway_select', |
@@ -256,22 +256,22 @@ discard block |
||
256 | 256 | * @param string $return objects or arrays. |
257 | 257 | * @return GetPaid_Form_Item[] |
258 | 258 | */ |
259 | - public function get_items( $context = 'view', $return = 'objects' ) { |
|
260 | - $items = $this->get_prop( 'items', $context ); |
|
259 | + public function get_items($context = 'view', $return = 'objects') { |
|
260 | + $items = $this->get_prop('items', $context); |
|
261 | 261 | |
262 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
263 | - $items = wpinv_get_data( 'sample-payment-form-items' ); |
|
262 | + if (empty($items) || !is_array($items)) { |
|
263 | + $items = wpinv_get_data('sample-payment-form-items'); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | // Convert the items. |
267 | 267 | $prepared = array(); |
268 | 268 | |
269 | - foreach ( $items as $key => $value ) { |
|
269 | + foreach ($items as $key => $value) { |
|
270 | 270 | |
271 | 271 | // Form items. |
272 | - if ( $value instanceof GetPaid_Form_Item ) { |
|
272 | + if ($value instanceof GetPaid_Form_Item) { |
|
273 | 273 | |
274 | - if ( $value->can_purchase() ) { |
|
274 | + if ($value->can_purchase()) { |
|
275 | 275 | $prepared[] = $value; |
276 | 276 | } |
277 | 277 | |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | } |
281 | 281 | |
282 | 282 | // $item_id => $quantity (buy buttons) |
283 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
284 | - $item = new GetPaid_Form_Item( $key ); |
|
283 | + if (is_numeric($key) && is_numeric($value)) { |
|
284 | + $item = new GetPaid_Form_Item($key); |
|
285 | 285 | |
286 | - if ( $item->can_purchase() ) { |
|
286 | + if ($item->can_purchase()) { |
|
287 | 287 | |
288 | 288 | $value = (float) $value; |
289 | - $item->set_quantity( $value ); |
|
290 | - if ( 0 == $value ) { |
|
291 | - $item->set_quantity( 1 ); |
|
292 | - $item->set_allow_quantities( true ); |
|
289 | + $item->set_quantity($value); |
|
290 | + if (0 == $value) { |
|
291 | + $item->set_quantity(1); |
|
292 | + $item->set_allow_quantities(true); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | $prepared[] = $item; |
@@ -299,33 +299,33 @@ discard block |
||
299 | 299 | } |
300 | 300 | |
301 | 301 | // Items saved via payment forms editor. |
302 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
302 | + if (is_array($value) && isset($value['id'])) { |
|
303 | 303 | |
304 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
304 | + $item = new GetPaid_Form_Item($value['id']); |
|
305 | 305 | |
306 | - if ( ! $item->can_purchase() ) { |
|
306 | + if (!$item->can_purchase()) { |
|
307 | 307 | continue; |
308 | 308 | } |
309 | 309 | |
310 | 310 | // Sub-total (Cart items). |
311 | - if ( isset( $value['subtotal'] ) ) { |
|
312 | - $item->set_price( $value['subtotal'] ); |
|
311 | + if (isset($value['subtotal'])) { |
|
312 | + $item->set_price($value['subtotal']); |
|
313 | 313 | } |
314 | 314 | |
315 | - if ( isset( $value['quantity'] ) ) { |
|
316 | - $item->set_quantity( $value['quantity'] ); |
|
315 | + if (isset($value['quantity'])) { |
|
316 | + $item->set_quantity($value['quantity']); |
|
317 | 317 | } |
318 | 318 | |
319 | - if ( isset( $value['allow_quantities'] ) ) { |
|
320 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
319 | + if (isset($value['allow_quantities'])) { |
|
320 | + $item->set_allow_quantities($value['allow_quantities']); |
|
321 | 321 | } |
322 | 322 | |
323 | - if ( isset( $value['required'] ) ) { |
|
324 | - $item->set_is_required( $value['required'] ); |
|
323 | + if (isset($value['required'])) { |
|
324 | + $item->set_is_required($value['required']); |
|
325 | 325 | } |
326 | 326 | |
327 | - if ( isset( $value['description'] ) ) { |
|
328 | - $item->set_custom_description( $value['description'] ); |
|
327 | + if (isset($value['description'])) { |
|
328 | + $item->set_custom_description($value['description']); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | $prepared[] = $item; |
@@ -334,14 +334,14 @@ discard block |
||
334 | 334 | } |
335 | 335 | |
336 | 336 | // $item_id => array( 'price' => 10 ) (item variations) |
337 | - if ( is_numeric( $key ) && is_array( $value ) ) { |
|
338 | - $item = new GetPaid_Form_Item( $key ); |
|
337 | + if (is_numeric($key) && is_array($value)) { |
|
338 | + $item = new GetPaid_Form_Item($key); |
|
339 | 339 | |
340 | - if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) { |
|
341 | - $item->set_price( $value['price'] ); |
|
340 | + if (isset($value['price']) && $item->user_can_set_their_price()) { |
|
341 | + $item->set_price($value['price']); |
|
342 | 342 | } |
343 | 343 | |
344 | - if ( $item->can_purchase() ) { |
|
344 | + if ($item->can_purchase()) { |
|
345 | 345 | $prepared[] = $item; |
346 | 346 | } |
347 | 347 | |
@@ -349,12 +349,12 @@ discard block |
||
349 | 349 | } |
350 | 350 | } |
351 | 351 | |
352 | - if ( 'objects' == $return && 'view' == $context ) { |
|
352 | + if ('objects' == $return && 'view' == $context) { |
|
353 | 353 | return $prepared; |
354 | 354 | } |
355 | 355 | |
356 | 356 | $items = array(); |
357 | - foreach ( $prepared as $item ) { |
|
357 | + foreach ($prepared as $item) { |
|
358 | 358 | $items[] = $item->prepare_data_for_use(); |
359 | 359 | } |
360 | 360 | |
@@ -368,14 +368,14 @@ discard block |
||
368 | 368 | * @param int $item_id The item id to return. |
369 | 369 | * @return GetPaid_Form_Item|bool |
370 | 370 | */ |
371 | - public function get_item( $item_id ) { |
|
371 | + public function get_item($item_id) { |
|
372 | 372 | |
373 | - if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
373 | + if (empty($item_id) || !is_numeric($item_id)) { |
|
374 | 374 | return false; |
375 | 375 | } |
376 | 376 | |
377 | - foreach ( $this->get_items() as $item ) { |
|
378 | - if ( $item->get_id() == (int) $item_id ) { |
|
377 | + foreach ($this->get_items() as $item) { |
|
378 | + if ($item->get_id() == (int) $item_id) { |
|
379 | 379 | return $item; |
380 | 380 | } |
381 | 381 | } |
@@ -390,15 +390,15 @@ discard block |
||
390 | 390 | * @param string $element_type The element type to return. |
391 | 391 | * @return array|bool |
392 | 392 | */ |
393 | - public function get_element_type( $element_type ) { |
|
393 | + public function get_element_type($element_type) { |
|
394 | 394 | |
395 | - if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
395 | + if (empty($element_type) || !is_scalar($element_type)) { |
|
396 | 396 | return false; |
397 | 397 | } |
398 | 398 | |
399 | - foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
399 | + foreach ($this->get_prop('elements') as $element) { |
|
400 | 400 | |
401 | - if ( $element['type'] === $element_type ) { |
|
401 | + if ($element['type'] === $element_type) { |
|
402 | 402 | return $element; |
403 | 403 | } |
404 | 404 | } |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | * @param string $context View or edit context. |
414 | 414 | * @return float |
415 | 415 | */ |
416 | - public function get_earned( $context = 'view' ) { |
|
417 | - return $this->get_prop( 'earned', $context ); |
|
416 | + public function get_earned($context = 'view') { |
|
417 | + return $this->get_prop('earned', $context); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | * @param string $context View or edit context. |
425 | 425 | * @return float |
426 | 426 | */ |
427 | - public function get_refunded( $context = 'view' ) { |
|
428 | - return $this->get_prop( 'refunded', $context ); |
|
427 | + public function get_refunded($context = 'view') { |
|
428 | + return $this->get_prop('refunded', $context); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | * @param string $context View or edit context. |
436 | 436 | * @return float |
437 | 437 | */ |
438 | - public function get_cancelled( $context = 'view' ) { |
|
439 | - return $this->get_prop( 'cancelled', $context ); |
|
438 | + public function get_cancelled($context = 'view') { |
|
439 | + return $this->get_prop('cancelled', $context); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -446,8 +446,8 @@ discard block |
||
446 | 446 | * @param string $context View or edit context. |
447 | 447 | * @return float |
448 | 448 | */ |
449 | - public function get_failed( $context = 'view' ) { |
|
450 | - return $this->get_prop( 'failed', $context ); |
|
449 | + public function get_failed($context = 'view') { |
|
450 | + return $this->get_prop('failed', $context); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | /** |
@@ -458,8 +458,8 @@ discard block |
||
458 | 458 | * @return string |
459 | 459 | */ |
460 | 460 | public function get_currency() { |
461 | - $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
462 | - return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
461 | + $currency = empty($this->invoice) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
462 | + return apply_filters('getpaid-payment-form-currency', $currency, $this); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | /* |
@@ -477,8 +477,8 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @since 1.0.19 |
479 | 479 | */ |
480 | - public function set_version( $value ) { |
|
481 | - $this->set_prop( 'version', $value ); |
|
480 | + public function set_version($value) { |
|
481 | + $this->set_prop('version', $value); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | /** |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | * @param string $value Value to set. |
489 | 489 | * @return bool Whether or not the date was set. |
490 | 490 | */ |
491 | - public function set_date_created( $value ) { |
|
492 | - $date = strtotime( $value ); |
|
491 | + public function set_date_created($value) { |
|
492 | + $date = strtotime($value); |
|
493 | 493 | |
494 | - if ( $date ) { |
|
495 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
494 | + if ($date) { |
|
495 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
496 | 496 | return true; |
497 | 497 | } |
498 | 498 | |
@@ -506,11 +506,11 @@ discard block |
||
506 | 506 | * @param string $value Value to set. |
507 | 507 | * @return bool Whether or not the date was set. |
508 | 508 | */ |
509 | - public function set_date_modified( $value ) { |
|
510 | - $date = strtotime( $value ); |
|
509 | + public function set_date_modified($value) { |
|
510 | + $date = strtotime($value); |
|
511 | 511 | |
512 | - if ( $date ) { |
|
513 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
512 | + if ($date) { |
|
513 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
514 | 514 | return true; |
515 | 515 | } |
516 | 516 | |
@@ -523,8 +523,8 @@ discard block |
||
523 | 523 | * @since 1.0.19 |
524 | 524 | * @param string $value New name. |
525 | 525 | */ |
526 | - public function set_name( $value ) { |
|
527 | - $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
526 | + public function set_name($value) { |
|
527 | + $this->set_prop('name', sanitize_text_field($value)); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | /** |
@@ -533,8 +533,8 @@ discard block |
||
533 | 533 | * @since 1.0.19 |
534 | 534 | * @param string $value New name. |
535 | 535 | */ |
536 | - public function set_title( $value ) { |
|
537 | - $this->set_name( $value ); |
|
536 | + public function set_title($value) { |
|
537 | + $this->set_name($value); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | /** |
@@ -543,8 +543,8 @@ discard block |
||
543 | 543 | * @since 1.0.19 |
544 | 544 | * @param int $value New author. |
545 | 545 | */ |
546 | - public function set_author( $value ) { |
|
547 | - $this->set_prop( 'author', (int) $value ); |
|
546 | + public function set_author($value) { |
|
547 | + $this->set_prop('author', (int) $value); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
@@ -554,9 +554,9 @@ discard block |
||
554 | 554 | * @sinve 2.3.4 Array values sanitized. |
555 | 555 | * @param array $value Form elements. |
556 | 556 | */ |
557 | - public function set_elements( $value ) { |
|
558 | - if ( is_array( $value ) ) { |
|
559 | - $this->set_prop( 'elements', wp_kses_post_deep( $value ) ); |
|
557 | + public function set_elements($value) { |
|
558 | + if (is_array($value)) { |
|
559 | + $this->set_prop('elements', wp_kses_post_deep($value)); |
|
560 | 560 | } |
561 | 561 | } |
562 | 562 | |
@@ -567,36 +567,36 @@ discard block |
||
567 | 567 | * |
568 | 568 | * @return mixed |
569 | 569 | */ |
570 | - public function sanitize_array_values( $value ) { |
|
570 | + public function sanitize_array_values($value) { |
|
571 | 571 | |
572 | 572 | // sanitize |
573 | - if ( ! empty( $value ) ) { |
|
573 | + if (!empty($value)) { |
|
574 | 574 | |
575 | - foreach ( $value as $key => $val_arr ) { |
|
575 | + foreach ($value as $key => $val_arr) { |
|
576 | 576 | |
577 | - if ( is_array( $val_arr ) ) { |
|
577 | + if (is_array($val_arr)) { |
|
578 | 578 | // check if we have sub array items. |
579 | 579 | $sub_arr = array(); |
580 | - foreach ( $val_arr as $key2 => $val2 ) { |
|
581 | - if ( is_array( $val2 ) ) { |
|
582 | - $sub_arr[ $key2 ] = $this->sanitize_array_values( $val2 ); |
|
583 | - unset( $val_arr[ $key ][ $key2 ] ); |
|
580 | + foreach ($val_arr as $key2 => $val2) { |
|
581 | + if (is_array($val2)) { |
|
582 | + $sub_arr[$key2] = $this->sanitize_array_values($val2); |
|
583 | + unset($val_arr[$key][$key2]); |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | 587 | // we allow some html in description so we sanitize it separately. |
588 | - $help_text = ! empty( $val_arr['description'] ) ? wp_kses_post( $val_arr['description'] ) : ''; |
|
588 | + $help_text = !empty($val_arr['description']) ? wp_kses_post($val_arr['description']) : ''; |
|
589 | 589 | |
590 | 590 | // sanitize array elements |
591 | - $value[ $key ] = array_map( 'sanitize_text_field', $val_arr ); |
|
591 | + $value[$key] = array_map('sanitize_text_field', $val_arr); |
|
592 | 592 | |
593 | 593 | // add back the description if set |
594 | - if ( isset( $val_arr['description'] ) ) { |
|
595 | - $value[ $key ]['description'] = $help_text;} |
|
594 | + if (isset($val_arr['description'])) { |
|
595 | + $value[$key]['description'] = $help_text; } |
|
596 | 596 | |
597 | 597 | // add back sub array items after its been sanitized. |
598 | - if ( ! empty( $sub_arr ) ) { |
|
599 | - $value[ $key ] = array_merge( $value[ $key ], $sub_arr ); |
|
598 | + if (!empty($sub_arr)) { |
|
599 | + $value[$key] = array_merge($value[$key], $sub_arr); |
|
600 | 600 | } |
601 | 601 | } |
602 | 602 | } |
@@ -611,9 +611,9 @@ discard block |
||
611 | 611 | * @since 1.0.19 |
612 | 612 | * @param array $value Form elements. |
613 | 613 | */ |
614 | - public function set_items( $value ) { |
|
615 | - if ( is_array( $value ) ) { |
|
616 | - $this->set_prop( 'items', $value ); |
|
614 | + public function set_items($value) { |
|
615 | + if (is_array($value)) { |
|
616 | + $this->set_prop('items', $value); |
|
617 | 617 | } |
618 | 618 | } |
619 | 619 | |
@@ -623,9 +623,9 @@ discard block |
||
623 | 623 | * @since 1.0.19 |
624 | 624 | * @param float $value Amount earned. |
625 | 625 | */ |
626 | - public function set_earned( $value ) { |
|
627 | - $value = max( (float) $value, 0 ); |
|
628 | - $this->set_prop( 'earned', $value ); |
|
626 | + public function set_earned($value) { |
|
627 | + $value = max((float) $value, 0); |
|
628 | + $this->set_prop('earned', $value); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * @since 1.0.19 |
635 | 635 | * @param float $value Amount refunded. |
636 | 636 | */ |
637 | - public function set_refunded( $value ) { |
|
638 | - $value = max( (float) $value, 0 ); |
|
639 | - $this->set_prop( 'refunded', $value ); |
|
637 | + public function set_refunded($value) { |
|
638 | + $value = max((float) $value, 0); |
|
639 | + $this->set_prop('refunded', $value); |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | /** |
@@ -645,9 +645,9 @@ discard block |
||
645 | 645 | * @since 1.0.19 |
646 | 646 | * @param float $value Amount cancelled. |
647 | 647 | */ |
648 | - public function set_cancelled( $value ) { |
|
649 | - $value = max( (float) $value, 0 ); |
|
650 | - $this->set_prop( 'cancelled', $value ); |
|
648 | + public function set_cancelled($value) { |
|
649 | + $value = max((float) $value, 0); |
|
650 | + $this->set_prop('cancelled', $value); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | /** |
@@ -656,9 +656,9 @@ discard block |
||
656 | 656 | * @since 1.0.19 |
657 | 657 | * @param float $value Amount cancelled. |
658 | 658 | */ |
659 | - public function set_failed( $value ) { |
|
660 | - $value = max( (float) $value, 0 ); |
|
661 | - $this->set_prop( 'failed', $value ); |
|
659 | + public function set_failed($value) { |
|
660 | + $value = max((float) $value, 0); |
|
661 | + $this->set_prop('failed', $value); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | /** |
@@ -667,11 +667,11 @@ discard block |
||
667 | 667 | * @deprecated |
668 | 668 | * @return int item id |
669 | 669 | */ |
670 | - public function create( $data = array() ) { |
|
670 | + public function create($data = array()) { |
|
671 | 671 | |
672 | 672 | // Set the properties. |
673 | - if ( is_array( $data ) ) { |
|
674 | - $this->set_props( $data ); |
|
673 | + if (is_array($data)) { |
|
674 | + $this->set_props($data); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | // Save the item. |
@@ -684,8 +684,8 @@ discard block |
||
684 | 684 | * @deprecated |
685 | 685 | * @return int item id |
686 | 686 | */ |
687 | - public function update( $data = array() ) { |
|
688 | - return $this->create( $data ); |
|
687 | + public function update($data = array()) { |
|
688 | + return $this->create($data); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /* |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | */ |
706 | 706 | public function is_default() { |
707 | 707 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
708 | - return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this ); |
|
708 | + return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this); |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | /** |
@@ -717,11 +717,11 @@ discard block |
||
717 | 717 | public function is_active() { |
718 | 718 | $is_active = 0 !== (int) $this->get_id(); |
719 | 719 | |
720 | - if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) { |
|
720 | + if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') { |
|
721 | 721 | $is_active = false; |
722 | 722 | } |
723 | 723 | |
724 | - return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this ); |
|
724 | + return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this); |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | /** |
@@ -730,8 +730,8 @@ discard block |
||
730 | 730 | * @since 1.0.19 |
731 | 731 | * @return bool |
732 | 732 | */ |
733 | - public function has_item( $item_id ) { |
|
734 | - return false !== $this->get_item( $item_id ); |
|
733 | + public function has_item($item_id) { |
|
734 | + return false !== $this->get_item($item_id); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
@@ -740,8 +740,8 @@ discard block |
||
740 | 740 | * @since 1.0.19 |
741 | 741 | * @return bool |
742 | 742 | */ |
743 | - public function has_element_type( $element_type ) { |
|
744 | - return false !== $this->get_element_type( $element_type ); |
|
743 | + public function has_element_type($element_type) { |
|
744 | + return false !== $this->get_element_type($element_type); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | /** |
@@ -752,13 +752,13 @@ discard block |
||
752 | 752 | */ |
753 | 753 | public function is_recurring() { |
754 | 754 | |
755 | - if ( ! empty( $this->invoice ) ) { |
|
755 | + if (!empty($this->invoice)) { |
|
756 | 756 | return $this->invoice->is_recurring(); |
757 | 757 | } |
758 | 758 | |
759 | - foreach ( $this->get_items() as $item ) { |
|
759 | + foreach ($this->get_items() as $item) { |
|
760 | 760 | |
761 | - if ( $item->is_recurring() ) { |
|
761 | + if ($item->is_recurring()) { |
|
762 | 762 | return true; |
763 | 763 | } |
764 | 764 | } |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | * |
772 | 772 | * @since 1.0.19 |
773 | 773 | */ |
774 | - public function get_html( $extra_markup = '' ) { |
|
774 | + public function get_html($extra_markup = '') { |
|
775 | 775 | |
776 | 776 | // Return the HTML. |
777 | 777 | return wpinv_get_template_html( |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | * |
789 | 789 | * @since 1.0.19 |
790 | 790 | */ |
791 | - public function display( $extra_markup = '' ) { |
|
791 | + public function display($extra_markup = '') { |
|
792 | 792 | wpinv_get_template( |
793 | 793 | 'payment-forms/form.php', |
794 | 794 | array( |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves an item by it's ID. |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | * @param int the item ID to retrieve. |
15 | 15 | * @return WPInv_Item|false |
16 | 16 | */ |
17 | -function wpinv_get_item_by_id( $id ) { |
|
18 | - $item = wpinv_get_item( $id ); |
|
19 | - return empty( $item ) || $id != $item->get_id() ? false : $item; |
|
17 | +function wpinv_get_item_by_id($id) { |
|
18 | + $item = wpinv_get_item($id); |
|
19 | + return empty($item) || $id != $item->get_id() ? false : $item; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return WPInv_Item|false |
26 | 26 | */ |
27 | -function wpinv_get_item_by( $field = '', $value = '', $type = '' ) { |
|
27 | +function wpinv_get_item_by($field = '', $value = '', $type = '') { |
|
28 | 28 | |
29 | - if ( 'id' === strtolower( $field ) ) { |
|
30 | - return wpinv_get_item_by_id( $value ); |
|
29 | + if ('id' === strtolower($field)) { |
|
30 | + return wpinv_get_item_by_id($value); |
|
31 | 31 | } |
32 | 32 | |
33 | - $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type ); |
|
34 | - return empty( $id ) ? false : wpinv_get_item( $id ); |
|
33 | + $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type); |
|
34 | + return empty($id) ? false : wpinv_get_item($id); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -40,23 +40,23 @@ discard block |
||
40 | 40 | * @param int|WPInv_Item the item to retrieve. |
41 | 41 | * @return WPInv_Item|false |
42 | 42 | */ |
43 | -function wpinv_get_item( $item = 0 ) { |
|
43 | +function wpinv_get_item($item = 0) { |
|
44 | 44 | |
45 | - if ( empty( $item ) ) { |
|
45 | + if (empty($item)) { |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | - $item = new WPInv_Item( $item ); |
|
49 | + $item = new WPInv_Item($item); |
|
50 | 50 | return $item->exists() ? $item : false; |
51 | 51 | } |
52 | 52 | |
53 | -function wpinv_get_all_items( $args = array() ) { |
|
53 | +function wpinv_get_all_items($args = array()) { |
|
54 | 54 | |
55 | 55 | $args = wp_parse_args( |
56 | 56 | $args, |
57 | 57 | array( |
58 | - 'status' => array( 'publish' ), |
|
59 | - 'limit' => get_option( 'posts_per_page' ), |
|
58 | + 'status' => array('publish'), |
|
59 | + 'limit' => get_option('posts_per_page'), |
|
60 | 60 | 'page' => 1, |
61 | 61 | 'exclude' => array(), |
62 | 62 | 'orderby' => 'date', |
@@ -81,44 +81,44 @@ discard block |
||
81 | 81 | 'fields' => 'ids', |
82 | 82 | 'orderby' => $args['orderby'], |
83 | 83 | 'order' => $args['order'], |
84 | - 'paged' => absint( $args['page'] ), |
|
84 | + 'paged' => absint($args['page']), |
|
85 | 85 | ); |
86 | 86 | |
87 | - if ( ! empty( $args['exclude'] ) ) { |
|
88 | - $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] ); |
|
87 | + if (!empty($args['exclude'])) { |
|
88 | + $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']); |
|
89 | 89 | } |
90 | 90 | |
91 | - if ( ! $args['paginate'] ) { |
|
91 | + if (!$args['paginate']) { |
|
92 | 92 | $wp_query_args['no_found_rows'] = true; |
93 | 93 | } |
94 | 94 | |
95 | - if ( ! empty( $args['search'] ) ) { |
|
95 | + if (!empty($args['search'])) { |
|
96 | 96 | $wp_query_args['s'] = $args['search']; |
97 | 97 | } |
98 | 98 | |
99 | - if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) { |
|
100 | - $types = wpinv_parse_list( $args['type'] ); |
|
99 | + if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) { |
|
100 | + $types = wpinv_parse_list($args['type']); |
|
101 | 101 | $wp_query_args['meta_query'][] = array( |
102 | 102 | 'key' => '_wpinv_type', |
103 | - 'value' => implode( ',', $types ), |
|
103 | + 'value' => implode(',', $types), |
|
104 | 104 | 'compare' => 'IN', |
105 | 105 | ); |
106 | 106 | } |
107 | 107 | |
108 | - $wp_query_args = apply_filters( 'wpinv_get_items_args', $wp_query_args, $args ); |
|
108 | + $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args); |
|
109 | 109 | |
110 | 110 | // Get results. |
111 | - $items = new WP_Query( $wp_query_args ); |
|
111 | + $items = new WP_Query($wp_query_args); |
|
112 | 112 | |
113 | - if ( 'objects' === $args['return'] ) { |
|
114 | - $return = array_map( 'wpinv_get_item_by_id', $items->posts ); |
|
115 | - } elseif ( 'self' === $args['return'] ) { |
|
113 | + if ('objects' === $args['return']) { |
|
114 | + $return = array_map('wpinv_get_item_by_id', $items->posts); |
|
115 | + } elseif ('self' === $args['return']) { |
|
116 | 116 | return $items; |
117 | 117 | } else { |
118 | 118 | $return = $items->posts; |
119 | 119 | } |
120 | 120 | |
121 | - if ( $args['paginate'] ) { |
|
121 | + if ($args['paginate']) { |
|
122 | 122 | return (object) array( |
123 | 123 | 'items' => $return, |
124 | 124 | 'total' => $items->found_posts, |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | -function wpinv_is_free_item( $item_id = 0 ) { |
|
133 | - if ( empty( $item_id ) ) { |
|
132 | +function wpinv_is_free_item($item_id = 0) { |
|
133 | + if (empty($item_id)) { |
|
134 | 134 | return false; |
135 | 135 | } |
136 | 136 | |
137 | - $item = new WPInv_Item( $item_id ); |
|
137 | + $item = new WPInv_Item($item_id); |
|
138 | 138 | |
139 | 139 | return $item->is_free(); |
140 | 140 | } |
@@ -144,21 +144,21 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param WP_Post|WPInv_Item|Int $item The item to check for. |
146 | 146 | */ |
147 | -function wpinv_item_is_editable( $item = 0 ) { |
|
147 | +function wpinv_item_is_editable($item = 0) { |
|
148 | 148 | |
149 | 149 | // Fetch the item. |
150 | - $item = new WPInv_Item( $item ); |
|
150 | + $item = new WPInv_Item($item); |
|
151 | 151 | |
152 | 152 | // Check if it is editable. |
153 | 153 | return $item->is_editable(); |
154 | 154 | } |
155 | 155 | |
156 | -function wpinv_get_item_price( $item_id = 0 ) { |
|
157 | - if ( empty( $item_id ) ) { |
|
156 | +function wpinv_get_item_price($item_id = 0) { |
|
157 | + if (empty($item_id)) { |
|
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | |
161 | - $item = new WPInv_Item( $item_id ); |
|
161 | + $item = new WPInv_Item($item_id); |
|
162 | 162 | |
163 | 163 | return $item->get_price(); |
164 | 164 | } |
@@ -168,89 +168,89 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @param WPInv_Item|int $item |
170 | 170 | */ |
171 | -function wpinv_is_recurring_item( $item = 0 ) { |
|
172 | - $item = new WPInv_Item( $item ); |
|
171 | +function wpinv_is_recurring_item($item = 0) { |
|
172 | + $item = new WPInv_Item($item); |
|
173 | 173 | return $item->is_recurring(); |
174 | 174 | } |
175 | 175 | |
176 | -function wpinv_item_price( $item_id = 0 ) { |
|
177 | - if ( empty( $item_id ) ) { |
|
176 | +function wpinv_item_price($item_id = 0) { |
|
177 | + if (empty($item_id)) { |
|
178 | 178 | return false; |
179 | 179 | } |
180 | 180 | |
181 | - $price = wpinv_get_item_price( $item_id ); |
|
182 | - $price = wpinv_price( $price ); |
|
181 | + $price = wpinv_get_item_price($item_id); |
|
182 | + $price = wpinv_price($price); |
|
183 | 183 | |
184 | - return apply_filters( 'wpinv_item_price', $price, $item_id ); |
|
184 | + return apply_filters('wpinv_item_price', $price, $item_id); |
|
185 | 185 | } |
186 | 186 | |
187 | -function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) { |
|
188 | - if ( is_null( $amount_override ) ) { |
|
189 | - $original_price = get_post_meta( $item_id, '_wpinv_price', true ); |
|
187 | +function wpinv_get_item_final_price($item_id = 0, $amount_override = null) { |
|
188 | + if (is_null($amount_override)) { |
|
189 | + $original_price = get_post_meta($item_id, '_wpinv_price', true); |
|
190 | 190 | } else { |
191 | 191 | $original_price = $amount_override; |
192 | 192 | } |
193 | 193 | |
194 | 194 | $price = $original_price; |
195 | 195 | |
196 | - return apply_filters( 'wpinv_get_item_final_price', $price, $item_id ); |
|
196 | + return apply_filters('wpinv_get_item_final_price', $price, $item_id); |
|
197 | 197 | } |
198 | 198 | |
199 | -function wpinv_item_custom_singular_name( $item_id ) { |
|
200 | - if ( empty( $item_id ) ) { |
|
199 | +function wpinv_item_custom_singular_name($item_id) { |
|
200 | + if (empty($item_id)) { |
|
201 | 201 | return false; |
202 | 202 | } |
203 | 203 | |
204 | - $item = new WPInv_Item( $item_id ); |
|
204 | + $item = new WPInv_Item($item_id); |
|
205 | 205 | |
206 | 206 | return $item->get_custom_singular_name(); |
207 | 207 | } |
208 | 208 | |
209 | 209 | function wpinv_get_item_types() { |
210 | 210 | $item_types = array( |
211 | - 'custom' => __( 'Standard', 'invoicing' ), |
|
212 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
211 | + 'custom' => __('Standard', 'invoicing'), |
|
212 | + 'fee' => __('Fee', 'invoicing'), |
|
213 | 213 | ); |
214 | - return apply_filters( 'wpinv_get_item_types', $item_types ); |
|
214 | + return apply_filters('wpinv_get_item_types', $item_types); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | function wpinv_item_types() { |
218 | 218 | $item_types = wpinv_get_item_types(); |
219 | 219 | |
220 | - return ( ! empty( $item_types ) ? array_keys( $item_types ) : array() ); |
|
220 | + return (!empty($item_types) ? array_keys($item_types) : array()); |
|
221 | 221 | } |
222 | 222 | |
223 | -function wpinv_get_item_type( $item_id ) { |
|
224 | - if ( empty( $item_id ) ) { |
|
223 | +function wpinv_get_item_type($item_id) { |
|
224 | + if (empty($item_id)) { |
|
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
228 | - $item = new WPInv_Item( $item_id ); |
|
228 | + $item = new WPInv_Item($item_id); |
|
229 | 229 | |
230 | 230 | return $item->get_type(); |
231 | 231 | } |
232 | 232 | |
233 | -function wpinv_item_type( $item_id ) { |
|
233 | +function wpinv_item_type($item_id) { |
|
234 | 234 | $item_types = wpinv_get_item_types(); |
235 | 235 | |
236 | - $item_type = wpinv_get_item_type( $item_id ); |
|
236 | + $item_type = wpinv_get_item_type($item_id); |
|
237 | 237 | |
238 | - if ( empty( $item_type ) ) { |
|
238 | + if (empty($item_type)) { |
|
239 | 239 | $item_type = '-'; |
240 | 240 | } |
241 | 241 | |
242 | - $item_type = isset( $item_types[ $item_type ] ) ? $item_types[ $item_type ] : __( $item_type, 'invoicing' ); |
|
242 | + $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing'); |
|
243 | 243 | |
244 | - return apply_filters( 'wpinv_item_type', $item_type, $item_id ); |
|
244 | + return apply_filters('wpinv_item_type', $item_type, $item_id); |
|
245 | 245 | } |
246 | 246 | |
247 | -function wpinv_get_random_item( $post_ids = true ) { |
|
248 | - wpinv_get_random_items( 1, $post_ids ); |
|
247 | +function wpinv_get_random_item($post_ids = true) { |
|
248 | + wpinv_get_random_items(1, $post_ids); |
|
249 | 249 | } |
250 | 250 | |
251 | -function wpinv_get_random_items( $num = 3, $post_ids = true ) { |
|
251 | +function wpinv_get_random_items($num = 3, $post_ids = true) { |
|
252 | 252 | $args = array(); |
253 | - if ( $post_ids ) { |
|
253 | + if ($post_ids) { |
|
254 | 254 | $args = array( |
255 | 255 | 'fields' => 'ids', |
256 | 256 | ); |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | ) |
272 | 272 | ); |
273 | 273 | |
274 | - $args = apply_filters( 'wpinv_get_random_items', $args ); |
|
274 | + $args = apply_filters('wpinv_get_random_items', $args); |
|
275 | 275 | |
276 | - return get_posts( $args ); |
|
276 | + return get_posts($args); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -282,13 +282,13 @@ discard block |
||
282 | 282 | * @param WPInv_Item|int $item |
283 | 283 | * @param bool $html |
284 | 284 | */ |
285 | -function wpinv_get_item_suffix( $item, $html = true ) { |
|
285 | +function wpinv_get_item_suffix($item, $html = true) { |
|
286 | 286 | |
287 | - $item = new WPInv_Item( $item ); |
|
288 | - $suffix = $item->is_recurring() ? ' ' . __( '(r)', 'invoicing' ) : ''; |
|
289 | - $suffix = $html ? $suffix : wp_strip_all_tags( $suffix ); |
|
287 | + $item = new WPInv_Item($item); |
|
288 | + $suffix = $item->is_recurring() ? ' ' . __('(r)', 'invoicing') : ''; |
|
289 | + $suffix = $html ? $suffix : wp_strip_all_tags($suffix); |
|
290 | 290 | |
291 | - return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html ); |
|
291 | + return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | * @param WPInv_Item|int $item |
298 | 298 | * @param bool $force_delete |
299 | 299 | */ |
300 | -function wpinv_remove_item( $item = 0, $force_delete = false ) { |
|
301 | - $item = new WPInv_Item( $item ); |
|
302 | - $item->delete( $force_delete ); |
|
300 | +function wpinv_remove_item($item = 0, $force_delete = false) { |
|
301 | + $item = new WPInv_Item($item); |
|
302 | + $item->delete($force_delete); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -338,44 +338,44 @@ discard block |
||
338 | 338 | * @param bool $wp_error whether or not to return a WP_Error on failure. |
339 | 339 | * @return bool|WP_Error|WPInv_Item |
340 | 340 | */ |
341 | -function wpinv_create_item( $args = array(), $wp_error = false ) { |
|
341 | +function wpinv_create_item($args = array(), $wp_error = false) { |
|
342 | 342 | |
343 | 343 | // Prepare the item. |
344 | - if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) { |
|
345 | - $type = empty( $args['type'] ) ? 'custom' : $args['type']; |
|
346 | - $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type ); |
|
344 | + if (!empty($args['custom_id']) && empty($args['ID'])) { |
|
345 | + $type = empty($args['type']) ? 'custom' : $args['type']; |
|
346 | + $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type); |
|
347 | 347 | |
348 | - if ( ! empty( $item ) ) { |
|
348 | + if (!empty($item)) { |
|
349 | 349 | $args['ID'] = $item->get_id(); |
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
353 | 353 | // Do we have an item? |
354 | - if ( ! empty( $args['ID'] ) ) { |
|
355 | - $item = new WPInv_Item( $args['ID'] ); |
|
354 | + if (!empty($args['ID'])) { |
|
355 | + $item = new WPInv_Item($args['ID']); |
|
356 | 356 | } else { |
357 | 357 | $item = new WPInv_Item(); |
358 | 358 | } |
359 | 359 | |
360 | 360 | // Do we have an error? |
361 | - if ( ! empty( $item->last_error ) ) { |
|
362 | - return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false; |
|
361 | + if (!empty($item->last_error)) { |
|
362 | + return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false; |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | // Update item props. |
366 | - $item->set_props( $args ); |
|
366 | + $item->set_props($args); |
|
367 | 367 | |
368 | 368 | // Save the item. |
369 | 369 | $item->save(); |
370 | 370 | |
371 | 371 | // Do we have an error? |
372 | - if ( ! empty( $item->last_error ) ) { |
|
373 | - return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false; |
|
372 | + if (!empty($item->last_error)) { |
|
373 | + return $wp_error ? new WP_Error('not_saved', $item->last_error) : false; |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | // Was the item saved? |
377 | - if ( ! $item->get_id() ) { |
|
378 | - return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false; |
|
377 | + if (!$item->get_id()) { |
|
378 | + return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false; |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | return $item; |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | * |
387 | 387 | * @see wpinv_create_item() |
388 | 388 | */ |
389 | -function wpinv_update_item( $args = array(), $wp_error = false ) { |
|
390 | - return wpinv_create_item( $args, $wp_error ); |
|
389 | +function wpinv_update_item($args = array(), $wp_error = false) { |
|
390 | + return wpinv_create_item($args, $wp_error); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
394 | 394 | * Sanitizes a recurring period |
395 | 395 | */ |
396 | -function getpaid_sanitize_recurring_period( $period, $full = false ) { |
|
396 | +function getpaid_sanitize_recurring_period($period, $full = false) { |
|
397 | 397 | |
398 | 398 | $periods = array( |
399 | 399 | 'D' => 'day', |
@@ -402,15 +402,15 @@ discard block |
||
402 | 402 | 'Y' => 'year', |
403 | 403 | ); |
404 | 404 | |
405 | - if ( ! isset( $periods[ $period ] ) ) { |
|
405 | + if (!isset($periods[$period])) { |
|
406 | 406 | $period = 'D'; |
407 | 407 | } |
408 | 408 | |
409 | - return $full ? $periods[ $period ] : $period; |
|
409 | + return $full ? $periods[$period] : $period; |
|
410 | 410 | } |
411 | 411 | |
412 | -function wpinv_item_max_buyable_quantity( $item_id ) { |
|
413 | - return apply_filters( 'wpinv_item_max_buyable_quantity', 5, $item_id ); |
|
412 | +function wpinv_item_max_buyable_quantity($item_id) { |
|
413 | + return apply_filters('wpinv_item_max_buyable_quantity', 5, $item_id); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -418,47 +418,47 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @param WPInv_Item|GetPaid_Form_Item $item |
420 | 420 | */ |
421 | -function getpaid_item_recurring_price_help_text( $item, $currency = '', $_initial_price = false, $_recurring_price = false ) { |
|
421 | +function getpaid_item_recurring_price_help_text($item, $currency = '', $_initial_price = false, $_recurring_price = false) { |
|
422 | 422 | |
423 | 423 | // Abort if it is not recurring. |
424 | - if ( ! $item->is_recurring() ) { |
|
424 | + if (!$item->is_recurring()) { |
|
425 | 425 | return ''; |
426 | 426 | } |
427 | 427 | |
428 | - $initial_price = false === $_initial_price ? wpinv_price( $item->get_initial_price(), $currency ) : $_initial_price; |
|
429 | - $recurring_price = false === $_recurring_price ? wpinv_price( $item->get_recurring_price(), $currency ) : $_recurring_price; |
|
430 | - $period = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ); |
|
428 | + $initial_price = false === $_initial_price ? wpinv_price($item->get_initial_price(), $currency) : $_initial_price; |
|
429 | + $recurring_price = false === $_recurring_price ? wpinv_price($item->get_recurring_price(), $currency) : $_recurring_price; |
|
430 | + $period = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), ''); |
|
431 | 431 | $initial_class = 'getpaid-item-initial-price'; |
432 | 432 | $recurring_class = 'getpaid-item-recurring-price'; |
433 | 433 | $bill_times = $item->get_recurring_limit(); |
434 | 434 | $bill_times_less = $bill_times - 1; |
435 | 435 | |
436 | - if ( ! empty( $bill_times ) ) { |
|
436 | + if (!empty($bill_times)) { |
|
437 | 437 | $bill_times = $item->get_recurring_interval() * $bill_times; |
438 | - $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() ); |
|
439 | - $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
438 | + $bill_times_less = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times - $item->get_recurring_interval()); |
|
439 | + $bill_times = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times); |
|
440 | 440 | } |
441 | 441 | |
442 | - if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) { |
|
443 | - $initial_price = wpinv_price( $item->get_sub_total(), $currency ); |
|
444 | - $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency ); |
|
442 | + if ($item instanceof GetPaid_Form_Item && false === $_initial_price) { |
|
443 | + $initial_price = wpinv_price($item->get_sub_total(), $currency); |
|
444 | + $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency); |
|
445 | 445 | } |
446 | 446 | |
447 | - if ( wpinv_price( 0, $currency ) == $initial_price && wpinv_price( 0, $currency ) == $recurring_price ) { |
|
448 | - return __( 'Free forever', 'invoicing' ); |
|
447 | + if (wpinv_price(0, $currency) == $initial_price && wpinv_price(0, $currency) == $recurring_price) { |
|
448 | + return __('Free forever', 'invoicing'); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | // For free trial items. |
452 | - if ( $item->has_free_trial() ) { |
|
453 | - $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() ); |
|
452 | + if ($item->has_free_trial()) { |
|
453 | + $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval()); |
|
454 | 454 | |
455 | - if ( wpinv_price( 0, $currency ) == $initial_price ) { |
|
455 | + if (wpinv_price(0, $currency) == $initial_price) { |
|
456 | 456 | |
457 | - if ( empty( $bill_times ) ) { |
|
457 | + if (empty($bill_times)) { |
|
458 | 458 | |
459 | 459 | return sprintf( |
460 | 460 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period |
461 | - _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ), |
|
461 | + _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'), |
|
462 | 462 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
463 | 463 | "<span class='$recurring_class'>$recurring_price</span>", |
464 | 464 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | |
469 | 469 | return sprintf( |
470 | 470 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period, $4: is the bill times |
471 | - _x( 'Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing' ), |
|
471 | + _x('Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing'), |
|
472 | 472 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
473 | 473 | "<span class='$recurring_class'>$recurring_price</span>", |
474 | 474 | "<span class='getpaid-item-recurring-period'>$period</span>", |
@@ -477,11 +477,11 @@ discard block |
||
477 | 477 | |
478 | 478 | } |
479 | 479 | |
480 | - if ( empty( $bill_times ) ) { |
|
480 | + if (empty($bill_times)) { |
|
481 | 481 | |
482 | 482 | return sprintf( |
483 | 483 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period |
484 | - _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ), |
|
484 | + _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'), |
|
485 | 485 | "<span class='$initial_class'>$initial_price</span>", |
486 | 486 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
487 | 487 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | |
493 | 493 | return sprintf( |
494 | 494 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period, $4: is the susbcription bill times |
495 | - _x( '%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing' ), |
|
495 | + _x('%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing'), |
|
496 | 496 | "<span class='$initial_class'>$initial_price</span>", |
497 | 497 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
498 | 498 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -502,13 +502,13 @@ discard block |
||
502 | 502 | |
503 | 503 | } |
504 | 504 | |
505 | - if ( $initial_price == $recurring_price ) { |
|
505 | + if ($initial_price == $recurring_price) { |
|
506 | 506 | |
507 | - if ( empty( $bill_times ) ) { |
|
507 | + if (empty($bill_times)) { |
|
508 | 508 | |
509 | 509 | return sprintf( |
510 | 510 | // translators: $1: is the recurring price, $2: is the susbcription period |
511 | - _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
511 | + _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
512 | 512 | "<span class='$recurring_class'>$recurring_price</span>", |
513 | 513 | "<span class='getpaid-item-recurring-period'>$period</span>" |
514 | 514 | ); |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | |
518 | 518 | return sprintf( |
519 | 519 | // translators: $1: is the recurring price, $2: is the susbcription period, $3: is the susbcription bill times |
520 | - _x( '%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ), |
|
520 | + _x('%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'), |
|
521 | 521 | "<span class='$recurring_class'>$recurring_price</span>", |
522 | 522 | "<span class='getpaid-item-recurring-period'>$period</span>", |
523 | 523 | "<span class='getpaid-item-recurring-bill-times'>$bill_times</span>" |
@@ -525,13 +525,13 @@ discard block |
||
525 | 525 | |
526 | 526 | } |
527 | 527 | |
528 | - if ( $initial_price == wpinv_price( 0, $currency ) ) { |
|
528 | + if ($initial_price == wpinv_price(0, $currency)) { |
|
529 | 529 | |
530 | - if ( empty( $bill_times ) ) { |
|
530 | + if (empty($bill_times)) { |
|
531 | 531 | |
532 | 532 | return sprintf( |
533 | 533 | // translators: $1: is the recurring period, $2: is the recurring price |
534 | - _x( 'Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing' ), |
|
534 | + _x('Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing'), |
|
535 | 535 | "<span class='getpaid-item-recurring-period'>$period</span>", |
536 | 536 | "<span class='$recurring_class'>$recurring_price</span>" |
537 | 537 | ); |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | |
541 | 541 | return sprintf( |
542 | 542 | // translators: $1: is the recurring period, $2: is the recurring price, $3: is the bill times |
543 | - _x( 'Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing' ), |
|
543 | + _x('Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing'), |
|
544 | 544 | "<span class='getpaid-item-recurring-period'>$period</span>", |
545 | 545 | "<span class='$recurring_class'>$recurring_price</span>", |
546 | 546 | "<span class='getpaid-item-recurring-bill-times'>$bill_times_less</span>" |
@@ -548,11 +548,11 @@ discard block |
||
548 | 548 | |
549 | 549 | } |
550 | 550 | |
551 | - if ( empty( $bill_times ) ) { |
|
551 | + if (empty($bill_times)) { |
|
552 | 552 | |
553 | 553 | return sprintf( |
554 | 554 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period |
555 | - _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ), |
|
555 | + _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'), |
|
556 | 556 | "<span class='$initial_class'>$initial_price</span>", |
557 | 557 | "<span class='$recurring_class'>$recurring_price</span>", |
558 | 558 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | |
563 | 563 | return sprintf( |
564 | 564 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period, $4: is the susbcription bill times |
565 | - _x( 'Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing' ), |
|
565 | + _x('Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing'), |
|
566 | 566 | "<span class='$initial_class'>$initial_price</span>", |
567 | 567 | "<span class='$recurring_class'>$recurring_price</span>", |
568 | 568 | "<span class='getpaid-item-recurring-period'>$period</span>", |