Passed
Push — master ( 74b22c...c396d4 )
by Brian
09:42 queued 04:15
created
uninstall.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
4
-	exit;
4
+    exit;
5 5
 }
6 6
 
7 7
 global $wpdb;
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
3
+if (!defined('WP_UNINSTALL_PLUGIN')) {
4 4
 	exit;
5 5
 }
6 6
 
7 7
 global $wpdb;
8 8
 
9
-if ( get_option( 'wpinv_remove_data_on_invoice_unistall' ) ) {
9
+if (get_option('wpinv_remove_data_on_invoice_unistall')) {
10 10
 
11 11
     // Fetch settings.
12
-    $settings = get_option( 'wpinv_settings' );
12
+    $settings = get_option('wpinv_settings');
13 13
 
14 14
     // Delete pages.
15
-    $pages = array( 'checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page', 'invoice_subscription_page' );
16
-    foreach ( $pages as $page ) {
17
-        if ( is_array( $settings ) && ! empty( $settings[ $page ] ) ) {
18
-            wp_delete_post( $settings[ $page ], true );
15
+    $pages = array('checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page', 'invoice_subscription_page');
16
+    foreach ($pages as $page) {
17
+        if (is_array($settings) && !empty($settings[$page])) {
18
+            wp_delete_post($settings[$page], true);
19 19
         }
20 20
     }
21 21
 
22 22
     // Delete options.
23
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv\_%';" );
23
+    $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv\_%';");
24 24
 
25 25
     // Delete posts.
26 26
     $wpdb->query(
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
     );
50 50
 
51 51
     // Cleanup Cron Schedule
52
-    wp_clear_scheduled_hook( 'wp_session_garbage_collection' );
53
-    wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
54
-    wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
52
+    wp_clear_scheduled_hook('wp_session_garbage_collection');
53
+    wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily');
54
+    wp_clear_scheduled_hook('wpinv_register_schedule_event_daily');
55 55
 
56 56
     // Clear any cached data that has been removed
57 57
     wp_cache_flush();
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
         "{$wpdb->prefix}getpaid_invoice_items",
64 64
     );
65 65
 
66
-    foreach ( $tables as $table ) {
67
-        $wpdb->query( "DROP TABLE IF EXISTS {$table}" );
66
+    foreach ($tables as $table) {
67
+        $wpdb->query("DROP TABLE IF EXISTS {$table}");
68 68
     }
69 69
 
70 70
 }
Please login to merge, or discard this patch.
invoicing.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 
20 20
 // Define constants.
21 21
 if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
22
+    define( 'WPINV_PLUGIN_FILE', __FILE__ );
23 23
 }
24 24
 
25 25
 if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '1.0.19' );
26
+    define( 'WPINV_VERSION', '1.0.19' );
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30 30
 if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
31
+    require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
46
-	return $GLOBALS['invoicing'];
46
+    return $GLOBALS['invoicing'];
47 47
 }
48 48
 
49 49
 /**
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
  * @package GetPaid
16 16
  */
17 17
 
18
-defined( 'ABSPATH' ) || exit;
18
+defined('ABSPATH') || exit;
19 19
 
20 20
 // Define constants.
21
-if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
21
+if (!defined('WPINV_PLUGIN_FILE')) {
22
+	define('WPINV_PLUGIN_FILE', __FILE__);
23 23
 }
24 24
 
25
-if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '1.0.19' );
25
+if (!defined('WPINV_VERSION')) {
26
+	define('WPINV_VERSION', '1.0.19');
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30
-if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
30
+if (!class_exists('WPInv_Plugin', false)) {
31
+	require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function getpaid() {
41 41
 
42
-    if ( empty( $GLOBALS['invoicing'] ) ) {
42
+    if (empty($GLOBALS['invoicing'])) {
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
Please login to merge, or discard this patch.
includes/class-wpinv-legacy-invoice.php 1 patch
Spacing   +626 added lines, -626 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 final class WPInv_Legacy_Invoice {
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     /**
17 17
      * Invoice id.
18 18
      */
19
-    public $ID  = 0;
19
+    public $ID = 0;
20 20
 
21 21
     /**
22 22
      * The title of the invoice. Usually the invoice number.
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     /**
133 133
      * The invoice status.
134 134
      */
135
-    public $status      = 'wpi-pending';
135
+    public $status = 'wpi-pending';
136 136
 
137 137
     /**
138 138
      * Same as self::$status.
@@ -259,17 +259,17 @@  discard block
 block discarded – undo
259 259
      */
260 260
     public $parent_invoice = 0;
261 261
     
262
-    public function __construct( $invoice_id = false ) {
263
-        if( empty( $invoice_id ) ) {
262
+    public function __construct($invoice_id = false) {
263
+        if (empty($invoice_id)) {
264 264
             return false;
265 265
         }
266 266
 
267
-        $this->setup_invoice( $invoice_id );
267
+        $this->setup_invoice($invoice_id);
268 268
     }
269 269
 
270
-    public function get( $key ) {
271
-        if ( method_exists( $this, 'get_' . $key ) ) {
272
-            $value = call_user_func( array( $this, 'get_' . $key ) );
270
+    public function get($key) {
271
+        if (method_exists($this, 'get_' . $key)) {
272
+            $value = call_user_func(array($this, 'get_' . $key));
273 273
         } else {
274 274
             $value = $this->$key;
275 275
         }
@@ -277,51 +277,51 @@  discard block
 block discarded – undo
277 277
         return $value;
278 278
     }
279 279
 
280
-    public function set( $key, $value ) {
281
-        $ignore = array( 'items', 'cart_details', 'fees', '_ID' );
280
+    public function set($key, $value) {
281
+        $ignore = array('items', 'cart_details', 'fees', '_ID');
282 282
 
283
-        if ( $key === 'status' ) {
283
+        if ($key === 'status') {
284 284
             $this->old_status = $this->status;
285 285
         }
286 286
 
287
-        if ( ! in_array( $key, $ignore ) ) {
288
-            $this->pending[ $key ] = $value;
287
+        if (!in_array($key, $ignore)) {
288
+            $this->pending[$key] = $value;
289 289
         }
290 290
 
291
-        if( '_ID' !== $key ) {
291
+        if ('_ID' !== $key) {
292 292
             $this->$key = $value;
293 293
         }
294 294
     }
295 295
 
296
-    public function _isset( $name ) {
297
-        if ( property_exists( $this, $name) ) {
298
-            return false === empty( $this->$name );
296
+    public function _isset($name) {
297
+        if (property_exists($this, $name)) {
298
+            return false === empty($this->$name);
299 299
         } else {
300 300
             return null;
301 301
         }
302 302
     }
303 303
 
304
-    private function setup_invoice( $invoice_id ) {
304
+    private function setup_invoice($invoice_id) {
305 305
         $this->pending = array();
306 306
 
307
-        if ( empty( $invoice_id ) ) {
307
+        if (empty($invoice_id)) {
308 308
             return false;
309 309
         }
310 310
 
311
-        $invoice = get_post( $invoice_id );
311
+        $invoice = get_post($invoice_id);
312 312
 
313
-        if( !$invoice || is_wp_error( $invoice ) ) {
313
+        if (!$invoice || is_wp_error($invoice)) {
314 314
             return false;
315 315
         }
316 316
 
317
-        if( !('wpi_invoice' == $invoice->post_type OR 'wpi_quote' == $invoice->post_type) ) {
317
+        if (!('wpi_invoice' == $invoice->post_type OR 'wpi_quote' == $invoice->post_type)) {
318 318
             return false;
319 319
         }
320 320
 
321
-        do_action( 'wpinv_pre_setup_invoice', $this, $invoice_id );
321
+        do_action('wpinv_pre_setup_invoice', $this, $invoice_id);
322 322
 
323 323
         // Primary Identifier
324
-        $this->ID              = absint( $invoice_id );
324
+        $this->ID              = absint($invoice_id);
325 325
         $this->post_type       = $invoice->post_type;
326 326
 
327 327
         // We have a payment, get the generic payment_meta item to reduce calls to it
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
         $this->completed_date  = $this->setup_completed_date();
332 332
         $this->status          = $invoice->post_status;
333 333
 
334
-        if ( 'future' == $this->status ) {
334
+        if ('future' == $this->status) {
335 335
             $this->status = 'publish';
336 336
         }
337 337
 
338 338
         $this->post_status     = $this->status;
339 339
         $this->mode            = $this->setup_mode();
340 340
         $this->parent_invoice  = $invoice->post_parent;
341
-        $this->post_name       = $this->setup_post_name( $invoice );
341
+        $this->post_name       = $this->setup_post_name($invoice);
342 342
         $this->status_nicename = $this->setup_status_nicename($invoice->post_status);
343 343
 
344 344
         // Items
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
         
362 362
         // User based
363 363
         $this->ip              = $this->setup_ip();
364
-        $this->user_id         = !empty( $invoice->post_author ) ? $invoice->post_author : get_current_user_id();///$this->setup_user_id();
365
-        $this->email           = get_the_author_meta( 'email', $this->user_id );
364
+        $this->user_id         = !empty($invoice->post_author) ? $invoice->post_author : get_current_user_id(); ///$this->setup_user_id();
365
+        $this->email           = get_the_author_meta('email', $this->user_id);
366 366
 
367 367
         $this->user_info       = $this->setup_user_info();
368 368
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         $this->company         = $this->user_info['company'];
372 372
         $this->vat_number      = $this->user_info['vat_number'];
373 373
         $this->vat_rate        = $this->user_info['vat_rate'];
374
-        $this->adddress_confirmed  = $this->user_info['adddress_confirmed'];
374
+        $this->adddress_confirmed = $this->user_info['adddress_confirmed'];
375 375
         $this->address         = $this->user_info['address'];
376 376
         $this->city            = $this->user_info['city'];
377 377
         $this->country         = $this->user_info['country'];
@@ -386,39 +386,39 @@  discard block
 block discarded – undo
386 386
         // Other Identifiers
387 387
         $this->key             = $this->setup_invoice_key();
388 388
         $this->number          = $this->setup_invoice_number();
389
-        $this->title           = !empty( $invoice->post_title ) ? $invoice->post_title : $this->number;
389
+        $this->title           = !empty($invoice->post_title) ? $invoice->post_title : $this->number;
390 390
         
391
-        $this->full_name       = trim( $this->first_name . ' '. $this->last_name );
391
+        $this->full_name       = trim($this->first_name . ' ' . $this->last_name);
392 392
         
393 393
         // Allow extensions to add items to this object via hook
394
-        do_action( 'wpinv_setup_invoice', $this, $invoice_id );
394
+        do_action('wpinv_setup_invoice', $this, $invoice_id);
395 395
 
396 396
         return true;
397 397
     }
398 398
 
399
-    private function setup_status_nicename( $status ) {
400
-        $all_invoice_statuses  = wpinv_get_invoice_statuses( true, true, $this );
399
+    private function setup_status_nicename($status) {
400
+        $all_invoice_statuses = wpinv_get_invoice_statuses(true, true, $this);
401 401
 
402
-        if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
403
-            $all_invoice_statuses  = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
402
+        if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) {
403
+            $all_invoice_statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
404 404
         }
405
-        $status   = isset( $all_invoice_statuses[$status] ) ? $all_invoice_statuses[$status] : __( $status, 'invoicing' );
405
+        $status = isset($all_invoice_statuses[$status]) ? $all_invoice_statuses[$status] : __($status, 'invoicing');
406 406
 
407
-        return apply_filters( 'setup_status_nicename', $status );
407
+        return apply_filters('setup_status_nicename', $status);
408 408
     }
409 409
 
410
-    private function setup_post_name( $post = NULL ) {
410
+    private function setup_post_name($post = NULL) {
411 411
         global $wpdb;
412 412
         
413 413
         $post_name = '';
414 414
         
415
-        if ( !empty( $post ) ) {
416
-            if( !empty( $post->post_name ) ) {
415
+        if (!empty($post)) {
416
+            if (!empty($post->post_name)) {
417 417
                 $post_name = $post->post_name;
418
-            } else if ( !empty( $post->ID ) ) {
419
-                $post_name = wpinv_generate_post_name( $post->ID );
418
+            } else if (!empty($post->ID)) {
419
+                $post_name = wpinv_generate_post_name($post->ID);
420 420
 
421
-                $wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), array( 'ID' => $post->ID ) );
421
+                $wpdb->update($wpdb->posts, array('post_name' => $post_name), array('ID' => $post->ID));
422 422
             }
423 423
         }
424 424
 
@@ -426,12 +426,12 @@  discard block
 block discarded – undo
426 426
     }
427 427
     
428 428
     private function setup_due_date() {
429
-        $due_date = $this->get_meta( '_wpinv_due_date' );
429
+        $due_date = $this->get_meta('_wpinv_due_date');
430 430
         
431
-        if ( empty( $due_date ) ) {
432
-            $overdue_time = strtotime( $this->date ) + ( DAY_IN_SECONDS * absint( wpinv_get_option( 'overdue_days' ) ) );
433
-            $due_date = date_i18n( 'Y-m-d', $overdue_time );
434
-        } else if ( $due_date == 'none' ) {
431
+        if (empty($due_date)) {
432
+            $overdue_time = strtotime($this->date) + (DAY_IN_SECONDS * absint(wpinv_get_option('overdue_days')));
433
+            $due_date = date_i18n('Y-m-d', $overdue_time);
434
+        } else if ($due_date == 'none') {
435 435
             $due_date = '';
436 436
         }
437 437
         
@@ -439,67 +439,67 @@  discard block
 block discarded – undo
439 439
     }
440 440
     
441 441
     private function setup_completed_date() {
442
-        $invoice = get_post( $this->ID );
442
+        $invoice = get_post($this->ID);
443 443
 
444
-        if ( 'wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status ) {
444
+        if ('wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status) {
445 445
             return false; // This invoice was never paid
446 446
         }
447 447
 
448
-        $date = ( $date = $this->get_meta( '_wpinv_completed_date', true ) ) ? $date : $invoice->modified_date;
448
+        $date = ($date = $this->get_meta('_wpinv_completed_date', true)) ? $date : $invoice->modified_date;
449 449
 
450 450
         return $date;
451 451
     }
452 452
     
453 453
     private function setup_cart_details() {
454
-        $cart_details = isset( $this->payment_meta['cart_details'] ) ? maybe_unserialize( $this->payment_meta['cart_details'] ) : array();
454
+        $cart_details = isset($this->payment_meta['cart_details']) ? maybe_unserialize($this->payment_meta['cart_details']) : array();
455 455
         return $cart_details;
456 456
     }
457 457
     
458 458
     public function array_convert() {
459
-        return get_object_vars( $this );
459
+        return get_object_vars($this);
460 460
     }
461 461
     
462 462
     private function setup_items() {
463
-        $items = isset( $this->payment_meta['items'] ) ? maybe_unserialize( $this->payment_meta['items'] ) : array();
463
+        $items = isset($this->payment_meta['items']) ? maybe_unserialize($this->payment_meta['items']) : array();
464 464
         return $items;
465 465
     }
466 466
     
467 467
     private function setup_fees() {
468
-        $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
468
+        $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
469 469
         return $payment_fees;
470 470
     }
471 471
         
472 472
     private function setup_currency() {
473
-        $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'wpinv_currency_default', wpinv_get_currency(), $this );
473
+        $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('wpinv_currency_default', wpinv_get_currency(), $this);
474 474
         return $currency;
475 475
     }
476 476
     
477 477
     private function setup_discount() {
478 478
         //$discount = $this->get_meta( '_wpinv_discount', true );
479
-        $discount = (float)$this->subtotal - ( (float)$this->total - (float)$this->tax - (float)$this->fees_total );
480
-        if ( $discount < 0 ) {
479
+        $discount = (float) $this->subtotal - ((float) $this->total - (float) $this->tax - (float) $this->fees_total);
480
+        if ($discount < 0) {
481 481
             $discount = 0;
482 482
         }
483
-        $discount = wpinv_round_amount( $discount );
483
+        $discount = wpinv_round_amount($discount);
484 484
         
485 485
         return $discount;
486 486
     }
487 487
     
488 488
     private function setup_discount_code() {
489
-        $discount_code = !empty( $this->discounts ) ? $this->discounts : $this->get_meta( '_wpinv_discount_code', true );
489
+        $discount_code = !empty($this->discounts) ? $this->discounts : $this->get_meta('_wpinv_discount_code', true);
490 490
         return $discount_code;
491 491
     }
492 492
     
493 493
     private function setup_tax() {
494 494
 
495
-        $tax = $this->get_meta( '_wpinv_tax', true );
495
+        $tax = $this->get_meta('_wpinv_tax', true);
496 496
 
497 497
         // We don't have tax as it's own meta and no meta was passed
498
-        if ( '' === $tax ) {            
499
-            $tax = isset( $this->payment_meta['tax'] ) ? $this->payment_meta['tax'] : 0;
498
+        if ('' === $tax) {            
499
+            $tax = isset($this->payment_meta['tax']) ? $this->payment_meta['tax'] : 0;
500 500
         }
501 501
         
502
-        if ( $tax < 0 || ! $this->is_taxable() ) {
502
+        if ($tax < 0 || !$this->is_taxable()) {
503 503
             $tax = 0;
504 504
         }
505 505
 
@@ -510,16 +510,16 @@  discard block
 block discarded – undo
510 510
      * If taxes are enabled, allow users to enable/disable taxes per invoice.
511 511
      */
512 512
     private function setup_is_taxable() {
513
-        return (int) $this->get_meta( '_wpinv_disable_taxes', true );
513
+        return (int) $this->get_meta('_wpinv_disable_taxes', true);
514 514
     }
515 515
 
516 516
     private function setup_subtotal() {
517 517
         $subtotal     = 0;
518 518
         $cart_details = $this->cart_details;
519 519
 
520
-        if ( is_array( $cart_details ) ) {
521
-            foreach ( $cart_details as $item ) {
522
-                if ( isset( $item['subtotal'] ) ) {
520
+        if (is_array($cart_details)) {
521
+            foreach ($cart_details as $item) {
522
+                if (isset($item['subtotal'])) {
523 523
                     $subtotal += $item['subtotal'];
524 524
                 }
525 525
             }
@@ -533,23 +533,23 @@  discard block
 block discarded – undo
533 533
     }
534 534
 
535 535
     private function setup_discounts() {
536
-        $discounts = ! empty( $this->payment_meta['user_info']['discount'] ) ? $this->payment_meta['user_info']['discount'] : array();
536
+        $discounts = !empty($this->payment_meta['user_info']['discount']) ? $this->payment_meta['user_info']['discount'] : array();
537 537
         return $discounts;
538 538
     }
539 539
     
540 540
     private function setup_total() {
541
-        $amount = $this->get_meta( '_wpinv_total', true );
541
+        $amount = $this->get_meta('_wpinv_total', true);
542 542
 
543
-        if ( empty( $amount ) && '0.00' != $amount ) {
544
-            $meta   = $this->get_meta( '_wpinv_payment_meta', true );
545
-            $meta   = maybe_unserialize( $meta );
543
+        if (empty($amount) && '0.00' != $amount) {
544
+            $meta   = $this->get_meta('_wpinv_payment_meta', true);
545
+            $meta   = maybe_unserialize($meta);
546 546
 
547
-            if ( isset( $meta['amount'] ) ) {
547
+            if (isset($meta['amount'])) {
548 548
                 $amount = $meta['amount'];
549 549
             }
550 550
         }
551 551
 
552
-        if($amount < 0){
552
+        if ($amount < 0) {
553 553
             $amount = 0;
554 554
         }
555 555
 
@@ -557,13 +557,13 @@  discard block
 block discarded – undo
557 557
     }
558 558
     
559 559
     private function setup_mode() {
560
-        return $this->get_meta( '_wpinv_mode' );
560
+        return $this->get_meta('_wpinv_mode');
561 561
     }
562 562
 
563 563
     private function setup_gateway() {
564
-        $gateway = $this->get_meta( '_wpinv_gateway' );
564
+        $gateway = $this->get_meta('_wpinv_gateway');
565 565
         
566
-        if ( empty( $gateway ) && 'publish' === $this->status ) {
566
+        if (empty($gateway) && 'publish' === $this->status) {
567 567
             $gateway = 'manual';
568 568
         }
569 569
         
@@ -571,23 +571,23 @@  discard block
 block discarded – undo
571 571
     }
572 572
 
573 573
     private function setup_gateway_title() {
574
-        $gateway_title = wpinv_get_gateway_checkout_label( $this->gateway );
574
+        $gateway_title = wpinv_get_gateway_checkout_label($this->gateway);
575 575
         return $gateway_title;
576 576
     }
577 577
 
578 578
     private function setup_transaction_id() {
579
-        $transaction_id = $this->get_meta( '_wpinv_transaction_id' );
579
+        $transaction_id = $this->get_meta('_wpinv_transaction_id');
580 580
 
581
-        if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) {
581
+        if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) {
582 582
             $gateway        = $this->gateway;
583
-            $transaction_id = apply_filters( 'wpinv_get_invoice_transaction_id-' . $gateway, $this->ID );
583
+            $transaction_id = apply_filters('wpinv_get_invoice_transaction_id-' . $gateway, $this->ID);
584 584
         }
585 585
 
586 586
         return $transaction_id;
587 587
     }
588 588
 
589 589
     private function setup_ip() {
590
-        $ip = $this->get_meta( '_wpinv_user_ip' );
590
+        $ip = $this->get_meta('_wpinv_user_ip');
591 591
         return $ip;
592 592
     }
593 593
 
@@ -597,62 +597,62 @@  discard block
 block discarded – undo
597 597
     ///}
598 598
         
599 599
     private function setup_first_name() {
600
-        $first_name = $this->get_meta( '_wpinv_first_name' );
600
+        $first_name = $this->get_meta('_wpinv_first_name');
601 601
         return $first_name;
602 602
     }
603 603
     
604 604
     private function setup_last_name() {
605
-        $last_name = $this->get_meta( '_wpinv_last_name' );
605
+        $last_name = $this->get_meta('_wpinv_last_name');
606 606
         return $last_name;
607 607
     }
608 608
     
609 609
     private function setup_company() {
610
-        $company = $this->get_meta( '_wpinv_company' );
610
+        $company = $this->get_meta('_wpinv_company');
611 611
         return $company;
612 612
     }
613 613
     
614 614
     private function setup_vat_number() {
615
-        $vat_number = $this->get_meta( '_wpinv_vat_number' );
615
+        $vat_number = $this->get_meta('_wpinv_vat_number');
616 616
         return $vat_number;
617 617
     }
618 618
     
619 619
     private function setup_vat_rate() {
620
-        $vat_rate = $this->get_meta( '_wpinv_vat_rate' );
620
+        $vat_rate = $this->get_meta('_wpinv_vat_rate');
621 621
         return $vat_rate;
622 622
     }
623 623
     
624 624
     private function setup_adddress_confirmed() {
625
-        $adddress_confirmed = $this->get_meta( '_wpinv_adddress_confirmed' );
625
+        $adddress_confirmed = $this->get_meta('_wpinv_adddress_confirmed');
626 626
         return $adddress_confirmed;
627 627
     }
628 628
     
629 629
     private function setup_phone() {
630
-        $phone = $this->get_meta( '_wpinv_phone' );
630
+        $phone = $this->get_meta('_wpinv_phone');
631 631
         return $phone;
632 632
     }
633 633
     
634 634
     private function setup_address() {
635
-        $address = $this->get_meta( '_wpinv_address', true );
635
+        $address = $this->get_meta('_wpinv_address', true);
636 636
         return $address;
637 637
     }
638 638
     
639 639
     private function setup_city() {
640
-        $city = $this->get_meta( '_wpinv_city', true );
640
+        $city = $this->get_meta('_wpinv_city', true);
641 641
         return $city;
642 642
     }
643 643
     
644 644
     private function setup_country() {
645
-        $country = $this->get_meta( '_wpinv_country', true );
645
+        $country = $this->get_meta('_wpinv_country', true);
646 646
         return $country;
647 647
     }
648 648
     
649 649
     private function setup_state() {
650
-        $state = $this->get_meta( '_wpinv_state', true );
650
+        $state = $this->get_meta('_wpinv_state', true);
651 651
         return $state;
652 652
     }
653 653
     
654 654
     private function setup_zip() {
655
-        $zip = $this->get_meta( '_wpinv_zip', true );
655
+        $zip = $this->get_meta('_wpinv_zip', true);
656 656
         return $zip;
657 657
     }
658 658
 
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
             'user_id'        => $this->user_id,
662 662
             'first_name'     => $this->first_name,
663 663
             'last_name'      => $this->last_name,
664
-            'email'          => get_the_author_meta( 'email', $this->user_id ),
664
+            'email'          => get_the_author_meta('email', $this->user_id),
665 665
             'phone'          => $this->phone,
666 666
             'address'        => $this->address,
667 667
             'city'           => $this->city,
@@ -676,12 +676,12 @@  discard block
 block discarded – undo
676 676
         );
677 677
         
678 678
         $user_info = array();
679
-        if ( isset( $this->payment_meta['user_info'] ) ) {
680
-            $user_info = maybe_unserialize( $this->payment_meta['user_info'] );
679
+        if (isset($this->payment_meta['user_info'])) {
680
+            $user_info = maybe_unserialize($this->payment_meta['user_info']);
681 681
             
682
-            if ( !empty( $user_info ) && isset( $user_info['user_id'] ) && $post = get_post( $this->ID ) ) {
682
+            if (!empty($user_info) && isset($user_info['user_id']) && $post = get_post($this->ID)) {
683 683
                 $this->user_id = $post->post_author;
684
-                $this->email = get_the_author_meta( 'email', $this->user_id );
684
+                $this->email = get_the_author_meta('email', $this->user_id);
685 685
                 
686 686
                 $user_info['user_id'] = $this->user_id;
687 687
                 $user_info['email'] = $this->email;
@@ -690,13 +690,13 @@  discard block
 block discarded – undo
690 690
             }
691 691
         }
692 692
         
693
-        $user_info    = wp_parse_args( $user_info, $defaults );
693
+        $user_info = wp_parse_args($user_info, $defaults);
694 694
         
695 695
         // Get the user, but only if it's been created
696
-        $user = get_userdata( $this->user_id );
696
+        $user = get_userdata($this->user_id);
697 697
         
698
-        if ( !empty( $user ) && $user->ID > 0 ) {
699
-            if ( empty( $user_info ) ) {
698
+        if (!empty($user) && $user->ID > 0) {
699
+            if (empty($user_info)) {
700 700
                 $user_info = array(
701 701
                     'user_id'    => $user->ID,
702 702
                     'first_name' => $user->first_name,
@@ -705,23 +705,23 @@  discard block
 block discarded – undo
705 705
                     'discount'   => '',
706 706
                 );
707 707
             } else {
708
-                foreach ( $user_info as $key => $value ) {
709
-                    if ( ! empty( $value ) ) {
708
+                foreach ($user_info as $key => $value) {
709
+                    if (!empty($value)) {
710 710
                         continue;
711 711
                     }
712 712
 
713
-                    switch( $key ) {
713
+                    switch ($key) {
714 714
                         case 'user_id':
715
-                            $user_info[ $key ] = $user->ID;
715
+                            $user_info[$key] = $user->ID;
716 716
                             break;
717 717
                         case 'first_name':
718
-                            $user_info[ $key ] = $user->first_name;
718
+                            $user_info[$key] = $user->first_name;
719 719
                             break;
720 720
                         case 'last_name':
721
-                            $user_info[ $key ] = $user->last_name;
721
+                            $user_info[$key] = $user->last_name;
722 722
                             break;
723 723
                         case 'email':
724
-                            $user_info[ $key ] = $user->user_email;
724
+                            $user_info[$key] = $user->user_email;
725 725
                             break;
726 726
                     }
727 727
                 }
@@ -732,25 +732,25 @@  discard block
 block discarded – undo
732 732
     }
733 733
 
734 734
     private function setup_invoice_key() {
735
-        $key = $this->get_meta( '_wpinv_key', true );
735
+        $key = $this->get_meta('_wpinv_key', true);
736 736
         
737 737
         return $key;
738 738
     }
739 739
 
740 740
     private function setup_invoice_number() {
741
-        $number = $this->get_meta( '_wpinv_number', true );
741
+        $number = $this->get_meta('_wpinv_number', true);
742 742
 
743
-        if ( !$number ) {
743
+        if (!$number) {
744 744
             $number = $this->ID;
745 745
 
746
-            if ( $this->status == 'auto-draft' ) {
747
-                if ( wpinv_sequential_number_active( $this->post_type ) ) {
748
-                    $next_number = wpinv_get_next_invoice_number( $this->post_type );
746
+            if ($this->status == 'auto-draft') {
747
+                if (wpinv_sequential_number_active($this->post_type)) {
748
+                    $next_number = wpinv_get_next_invoice_number($this->post_type);
749 749
                     $number      = $next_number;
750 750
                 }
751 751
             }
752 752
             
753
-            $number = wpinv_format_invoice_number( $number, $this->post_type );
753
+            $number = wpinv_format_invoice_number($number, $this->post_type);
754 754
         }
755 755
 
756 756
         return $number;
@@ -759,10 +759,10 @@  discard block
 block discarded – undo
759 759
     private function insert_invoice() {
760 760
         global $wpdb;
761 761
 
762
-        if ( empty( $this->post_type ) ) {
763
-            if ( !empty( $this->ID ) && $post_type = get_post_type( $this->ID ) ) {
762
+        if (empty($this->post_type)) {
763
+            if (!empty($this->ID) && $post_type = get_post_type($this->ID)) {
764 764
                 $this->post_type = $post_type;
765
-            } else if ( !empty( $this->parent_invoice ) && $post_type = get_post_type( $this->parent_invoice ) ) {
765
+            } else if (!empty($this->parent_invoice) && $post_type = get_post_type($this->parent_invoice)) {
766 766
                 $this->post_type = $post_type;
767 767
             } else {
768 768
                 $this->post_type = 'wpi_invoice';
@@ -770,16 +770,16 @@  discard block
 block discarded – undo
770 770
         }
771 771
 
772 772
         $invoice_number = $this->ID;
773
-        if ( $number = $this->get_meta( '_wpinv_number', true ) ) {
773
+        if ($number = $this->get_meta('_wpinv_number', true)) {
774 774
             $invoice_number = $number;
775 775
         }
776 776
 
777
-        if ( empty( $this->key ) ) {
777
+        if (empty($this->key)) {
778 778
             $this->key = self::generate_key();
779 779
             $this->pending['key'] = $this->key;
780 780
         }
781 781
 
782
-        if ( empty( $this->ip ) ) {
782
+        if (empty($this->ip)) {
783 783
             $this->ip = wpinv_get_ip();
784 784
             $this->pending['ip'] = $this->ip;
785 785
         }
@@ -816,60 +816,60 @@  discard block
 block discarded – undo
816 816
                         'post_status'   => $this->status,
817 817
                         'post_author'   => $this->user_id,
818 818
                         'post_type'     => $this->post_type,
819
-                        'post_date'     => ! empty( $this->date ) && $this->date != '0000-00-00 00:00:00' ? $this->date : current_time( 'mysql' ),
820
-                        'post_date_gmt' => ! empty( $this->date ) && $this->date != '0000-00-00 00:00:00' ? get_gmt_from_date( $this->date ) : current_time( 'mysql', 1 ),
819
+                        'post_date'     => !empty($this->date) && $this->date != '0000-00-00 00:00:00' ? $this->date : current_time('mysql'),
820
+                        'post_date_gmt' => !empty($this->date) && $this->date != '0000-00-00 00:00:00' ? get_gmt_from_date($this->date) : current_time('mysql', 1),
821 821
                         'post_parent'   => $this->parent_invoice,
822 822
                     );
823
-        $args = apply_filters( 'wpinv_insert_invoice_args', $post_data, $this );
823
+        $args = apply_filters('wpinv_insert_invoice_args', $post_data, $this);
824 824
 
825 825
         // Create a blank invoice
826
-        if ( !empty( $this->ID ) ) {
827
-            $args['ID']         = $this->ID;
826
+        if (!empty($this->ID)) {
827
+            $args['ID'] = $this->ID;
828 828
 
829
-            $invoice_id = wp_update_post( $args, true );
829
+            $invoice_id = wp_update_post($args, true);
830 830
         } else {
831
-            $invoice_id = wp_insert_post( $args, true );
831
+            $invoice_id = wp_insert_post($args, true);
832 832
         }
833 833
 
834
-        if ( is_wp_error( $invoice_id ) ) {
834
+        if (is_wp_error($invoice_id)) {
835 835
             return false;
836 836
         }
837 837
 
838
-        if ( !empty( $invoice_id ) ) {
838
+        if (!empty($invoice_id)) {
839 839
             $this->ID  = $invoice_id;
840 840
             $this->_ID = $invoice_id;
841 841
 
842
-            $this->payment_meta = apply_filters( 'wpinv_payment_meta', $this->payment_meta, $payment_data );
843
-            if ( ! empty( $this->payment_meta['fees'] ) ) {
844
-                $this->fees = array_merge( $this->fees, $this->payment_meta['fees'] );
845
-                foreach( $this->fees as $fee ) {
846
-                    $this->increase_fees( $fee['amount'] );
842
+            $this->payment_meta = apply_filters('wpinv_payment_meta', $this->payment_meta, $payment_data);
843
+            if (!empty($this->payment_meta['fees'])) {
844
+                $this->fees = array_merge($this->fees, $this->payment_meta['fees']);
845
+                foreach ($this->fees as $fee) {
846
+                    $this->increase_fees($fee['amount']);
847 847
                 }
848 848
             }
849 849
 
850
-            $this->update_meta( '_wpinv_payment_meta', $this->payment_meta );    
850
+            $this->update_meta('_wpinv_payment_meta', $this->payment_meta);    
851 851
             $this->new = true;
852 852
         }
853 853
 
854 854
         return $this->ID;
855 855
     }
856 856
 
857
-    public function save( $setup = false ) {
857
+    public function save($setup = false) {
858 858
         
859 859
         $saved = false;
860
-        if ( empty( $this->items ) ) {
860
+        if (empty($this->items)) {
861 861
             return $saved; // Don't save empty invoice.
862 862
         }
863 863
         
864
-        if ( empty( $this->key ) ) {
864
+        if (empty($this->key)) {
865 865
             $this->key = self::generate_key();
866 866
             $this->pending['key'] = $this->key;
867 867
         }
868 868
         
869
-        if ( empty( $this->ID ) ) {
869
+        if (empty($this->ID)) {
870 870
             $invoice_id = $this->insert_invoice();
871 871
 
872
-            if ( false === $invoice_id ) {
872
+            if (false === $invoice_id) {
873 873
                 $saved = false;
874 874
             } else {
875 875
                 $this->ID = $invoice_id;
@@ -877,27 +877,27 @@  discard block
 block discarded – undo
877 877
         }
878 878
 
879 879
         // If we have something pending, let's save it
880
-        if ( !empty( $this->pending ) ) {
880
+        if (!empty($this->pending)) {
881 881
             $total_increase = 0;
882 882
             $total_decrease = 0;
883 883
 
884
-            foreach ( $this->pending as $key => $value ) {
885
-                switch( $key ) {
884
+            foreach ($this->pending as $key => $value) {
885
+                switch ($key) {
886 886
                     case 'items':
887 887
                         // Update totals for pending items
888
-                        foreach ( $this->pending[ $key ] as $item ) {
889
-                            switch( $item['action'] ) {
888
+                        foreach ($this->pending[$key] as $item) {
889
+                            switch ($item['action']) {
890 890
                                 case 'add':
891 891
                                     $price = $item['price'];
892 892
                                     $taxes = $item['tax'];
893 893
 
894
-                                    if ( 'publish' === $this->status ) {
894
+                                    if ('publish' === $this->status) {
895 895
                                         $total_increase += $price;
896 896
                                     }
897 897
                                     break;
898 898
 
899 899
                                 case 'remove':
900
-                                    if ( 'publish' === $this->status ) {
900
+                                    if ('publish' === $this->status) {
901 901
                                         $total_decrease += $item['price'];
902 902
                                     }
903 903
                                     break;
@@ -905,16 +905,16 @@  discard block
 block discarded – undo
905 905
                         }
906 906
                         break;
907 907
                     case 'fees':
908
-                        if ( 'publish' !== $this->status ) {
908
+                        if ('publish' !== $this->status) {
909 909
                             break;
910 910
                         }
911 911
 
912
-                        if ( empty( $this->pending[ $key ] ) ) {
912
+                        if (empty($this->pending[$key])) {
913 913
                             break;
914 914
                         }
915 915
 
916
-                        foreach ( $this->pending[ $key ] as $fee ) {
917
-                            switch( $fee['action'] ) {
916
+                        foreach ($this->pending[$key] as $fee) {
917
+                            switch ($fee['action']) {
918 918
                                 case 'add':
919 919
                                     $total_increase += $fee['amount'];
920 920
                                     break;
@@ -926,86 +926,86 @@  discard block
 block discarded – undo
926 926
                         }
927 927
                         break;
928 928
                     case 'status':
929
-                        $this->update_status( $this->status );
929
+                        $this->update_status($this->status);
930 930
                         break;
931 931
                     case 'gateway':
932
-                        $this->update_meta( '_wpinv_gateway', $this->gateway );
932
+                        $this->update_meta('_wpinv_gateway', $this->gateway);
933 933
                         break;
934 934
                     case 'mode':
935
-                        $this->update_meta( '_wpinv_mode', $this->mode );
935
+                        $this->update_meta('_wpinv_mode', $this->mode);
936 936
                         break;
937 937
                     case 'transaction_id':
938
-                        $this->update_meta( '_wpinv_transaction_id', $this->transaction_id );
938
+                        $this->update_meta('_wpinv_transaction_id', $this->transaction_id);
939 939
                         break;
940 940
                     case 'ip':
941
-                        $this->update_meta( '_wpinv_user_ip', $this->ip );
941
+                        $this->update_meta('_wpinv_user_ip', $this->ip);
942 942
                         break;
943 943
                     ///case 'user_id':
944 944
                         ///$this->update_meta( '_wpinv_user_id', $this->user_id );
945 945
                         ///$this->user_info['user_id'] = $this->user_id;
946 946
                         ///break;
947 947
                     case 'first_name':
948
-                        $this->update_meta( '_wpinv_first_name', $this->first_name );
948
+                        $this->update_meta('_wpinv_first_name', $this->first_name);
949 949
                         $this->user_info['first_name'] = $this->first_name;
950 950
                         break;
951 951
                     case 'last_name':
952
-                        $this->update_meta( '_wpinv_last_name', $this->last_name );
952
+                        $this->update_meta('_wpinv_last_name', $this->last_name);
953 953
                         $this->user_info['last_name'] = $this->last_name;
954 954
                         break;
955 955
                     case 'phone':
956
-                        $this->update_meta( '_wpinv_phone', $this->phone );
956
+                        $this->update_meta('_wpinv_phone', $this->phone);
957 957
                         $this->user_info['phone'] = $this->phone;
958 958
                         break;
959 959
                     case 'address':
960
-                        $this->update_meta( '_wpinv_address', $this->address );
960
+                        $this->update_meta('_wpinv_address', $this->address);
961 961
                         $this->user_info['address'] = $this->address;
962 962
                         break;
963 963
                     case 'city':
964
-                        $this->update_meta( '_wpinv_city', $this->city );
964
+                        $this->update_meta('_wpinv_city', $this->city);
965 965
                         $this->user_info['city'] = $this->city;
966 966
                         break;
967 967
                     case 'country':
968
-                        $this->update_meta( '_wpinv_country', $this->country );
968
+                        $this->update_meta('_wpinv_country', $this->country);
969 969
                         $this->user_info['country'] = $this->country;
970 970
                         break;
971 971
                     case 'state':
972
-                        $this->update_meta( '_wpinv_state', $this->state );
972
+                        $this->update_meta('_wpinv_state', $this->state);
973 973
                         $this->user_info['state'] = $this->state;
974 974
                         break;
975 975
                     case 'zip':
976
-                        $this->update_meta( '_wpinv_zip', $this->zip );
976
+                        $this->update_meta('_wpinv_zip', $this->zip);
977 977
                         $this->user_info['zip'] = $this->zip;
978 978
                         break;
979 979
                     case 'company':
980
-                        $this->update_meta( '_wpinv_company', $this->company );
980
+                        $this->update_meta('_wpinv_company', $this->company);
981 981
                         $this->user_info['company'] = $this->company;
982 982
                         break;
983 983
                     case 'vat_number':
984
-                        $this->update_meta( '_wpinv_vat_number', $this->vat_number );
984
+                        $this->update_meta('_wpinv_vat_number', $this->vat_number);
985 985
                         $this->user_info['vat_number'] = $this->vat_number;
986 986
                         
987
-                        $vat_info = getpaid_session()->get( 'user_vat_data' );
988
-                        if ( $this->vat_number && !empty( $vat_info ) && isset( $vat_info['number'] ) && isset( $vat_info['valid'] ) && $vat_info['number'] == $this->vat_number ) {
989
-                            $adddress_confirmed = isset( $vat_info['adddress_confirmed'] ) ? $vat_info['adddress_confirmed'] : false;
990
-                            $this->update_meta( '_wpinv_adddress_confirmed', (bool)$adddress_confirmed );
991
-                            $this->user_info['adddress_confirmed'] = (bool)$adddress_confirmed;
987
+                        $vat_info = getpaid_session()->get('user_vat_data');
988
+                        if ($this->vat_number && !empty($vat_info) && isset($vat_info['number']) && isset($vat_info['valid']) && $vat_info['number'] == $this->vat_number) {
989
+                            $adddress_confirmed = isset($vat_info['adddress_confirmed']) ? $vat_info['adddress_confirmed'] : false;
990
+                            $this->update_meta('_wpinv_adddress_confirmed', (bool) $adddress_confirmed);
991
+                            $this->user_info['adddress_confirmed'] = (bool) $adddress_confirmed;
992 992
                         }
993 993
     
994 994
                         break;
995 995
                     case 'vat_rate':
996
-                        $this->update_meta( '_wpinv_vat_rate', $this->vat_rate );
996
+                        $this->update_meta('_wpinv_vat_rate', $this->vat_rate);
997 997
                         $this->user_info['vat_rate'] = $this->vat_rate;
998 998
                         break;
999 999
                     case 'adddress_confirmed':
1000
-                        $this->update_meta( '_wpinv_adddress_confirmed', $this->adddress_confirmed );
1000
+                        $this->update_meta('_wpinv_adddress_confirmed', $this->adddress_confirmed);
1001 1001
                         $this->user_info['adddress_confirmed'] = $this->adddress_confirmed;
1002 1002
                         break;
1003 1003
                     
1004 1004
                     case 'key':
1005
-                        $this->update_meta( '_wpinv_key', $this->key );
1005
+                        $this->update_meta('_wpinv_key', $this->key);
1006 1006
                         break;
1007 1007
                     case 'disable_taxes':
1008
-                        $this->update_meta( '_wpinv_disable_taxes', $this->disable_taxes );
1008
+                        $this->update_meta('_wpinv_disable_taxes', $this->disable_taxes);
1009 1009
                         break;
1010 1010
                     case 'date':
1011 1011
                         $args = array(
@@ -1014,49 +1014,49 @@  discard block
 block discarded – undo
1014 1014
                             'edit_date' => true,
1015 1015
                         );
1016 1016
 
1017
-                        wp_update_post( $args );
1017
+                        wp_update_post($args);
1018 1018
                         break;
1019 1019
                     case 'due_date':
1020
-                        if ( empty( $this->due_date ) ) {
1020
+                        if (empty($this->due_date)) {
1021 1021
                             $this->due_date = 'none';
1022 1022
                         }
1023 1023
                         
1024
-                        $this->update_meta( '_wpinv_due_date', $this->due_date );
1024
+                        $this->update_meta('_wpinv_due_date', $this->due_date);
1025 1025
                         break;
1026 1026
                     case 'completed_date':
1027
-                        $this->update_meta( '_wpinv_completed_date', $this->completed_date );
1027
+                        $this->update_meta('_wpinv_completed_date', $this->completed_date);
1028 1028
                         break;
1029 1029
                     case 'discounts':
1030
-                        if ( ! is_array( $this->discounts ) ) {
1031
-                            $this->discounts = explode( ',', $this->discounts );
1030
+                        if (!is_array($this->discounts)) {
1031
+                            $this->discounts = explode(',', $this->discounts);
1032 1032
                         }
1033 1033
 
1034
-                        $this->user_info['discount'] = implode( ',', $this->discounts );
1034
+                        $this->user_info['discount'] = implode(',', $this->discounts);
1035 1035
                         break;
1036 1036
                     case 'discount':
1037
-                        $this->update_meta( '_wpinv_discount', wpinv_round_amount( $this->discount ) );
1037
+                        $this->update_meta('_wpinv_discount', wpinv_round_amount($this->discount));
1038 1038
                         break;
1039 1039
                     case 'discount_code':
1040
-                        $this->update_meta( '_wpinv_discount_code', $this->discount_code );
1040
+                        $this->update_meta('_wpinv_discount_code', $this->discount_code);
1041 1041
                         break;
1042 1042
                     case 'parent_invoice':
1043 1043
                         $args = array(
1044 1044
                             'ID'          => $this->ID,
1045 1045
                             'post_parent' => $this->parent_invoice,
1046 1046
                         );
1047
-                        wp_update_post( $args );
1047
+                        wp_update_post($args);
1048 1048
                         break;
1049 1049
                     default:
1050
-                        do_action( 'wpinv_save', $this, $key );
1050
+                        do_action('wpinv_save', $this, $key);
1051 1051
                         break;
1052 1052
                 }
1053 1053
             }
1054 1054
 
1055
-            $this->update_meta( '_wpinv_subtotal', wpinv_round_amount( $this->subtotal ) );
1056
-            $this->update_meta( '_wpinv_total', wpinv_round_amount( $this->total ) );
1057
-            $this->update_meta( '_wpinv_tax', wpinv_round_amount( $this->tax ) );
1055
+            $this->update_meta('_wpinv_subtotal', wpinv_round_amount($this->subtotal));
1056
+            $this->update_meta('_wpinv_total', wpinv_round_amount($this->total));
1057
+            $this->update_meta('_wpinv_tax', wpinv_round_amount($this->tax));
1058 1058
             
1059
-            $this->items    = array_values( $this->items );
1059
+            $this->items = array_values($this->items);
1060 1060
             
1061 1061
             $new_meta = array(
1062 1062
                 'items'         => $this->items,
@@ -1067,12 +1067,12 @@  discard block
 block discarded – undo
1067 1067
             );
1068 1068
             
1069 1069
             $meta        = $this->get_meta();
1070
-            $merged_meta = array_merge( $meta, $new_meta );
1070
+            $merged_meta = array_merge($meta, $new_meta);
1071 1071
 
1072 1072
             // Only save the payment meta if it's changed
1073
-            if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta) ) ) {
1074
-                $updated     = $this->update_meta( '_wpinv_payment_meta', $merged_meta );
1075
-                if ( false !== $updated ) {
1073
+            if (md5(serialize($meta)) !== md5(serialize($merged_meta))) {
1074
+                $updated = $this->update_meta('_wpinv_payment_meta', $merged_meta);
1075
+                if (false !== $updated) {
1076 1076
                     $saved = true;
1077 1077
                 }
1078 1078
             }
@@ -1080,15 +1080,15 @@  discard block
 block discarded – undo
1080 1080
             $this->pending = array();
1081 1081
             $saved         = true;
1082 1082
         } else {
1083
-            $this->update_meta( '_wpinv_subtotal', wpinv_round_amount( $this->subtotal ) );
1084
-            $this->update_meta( '_wpinv_total', wpinv_round_amount( $this->total ) );
1085
-            $this->update_meta( '_wpinv_tax', wpinv_round_amount( $this->tax ) );
1083
+            $this->update_meta('_wpinv_subtotal', wpinv_round_amount($this->subtotal));
1084
+            $this->update_meta('_wpinv_total', wpinv_round_amount($this->total));
1085
+            $this->update_meta('_wpinv_tax', wpinv_round_amount($this->tax));
1086 1086
         }
1087 1087
         
1088
-        do_action( 'wpinv_invoice_save', $this, $saved );
1088
+        do_action('wpinv_invoice_save', $this, $saved);
1089 1089
 
1090
-        if ( true === $saved || $setup ) {
1091
-            $this->setup_invoice( $this->ID );
1090
+        if (true === $saved || $setup) {
1091
+            $this->setup_invoice($this->ID);
1092 1092
         }
1093 1093
         
1094 1094
         $this->refresh_item_ids();
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
         return $saved;
1097 1097
     }
1098 1098
     
1099
-    public function add_fee( $args, $global = true ) {
1099
+    public function add_fee($args, $global = true) {
1100 1100
         $default_args = array(
1101 1101
             'label'       => '',
1102 1102
             'amount'      => 0,
@@ -1106,75 +1106,75 @@  discard block
 block discarded – undo
1106 1106
             'item_id'     => 0,
1107 1107
         );
1108 1108
 
1109
-        $fee = wp_parse_args( $args, $default_args );
1109
+        $fee = wp_parse_args($args, $default_args);
1110 1110
         
1111
-        if ( empty( $fee['label'] ) ) {
1111
+        if (empty($fee['label'])) {
1112 1112
             return false;
1113 1113
         }
1114 1114
         
1115
-        $fee['id']  = sanitize_title( $fee['label'] );
1115
+        $fee['id'] = sanitize_title($fee['label']);
1116 1116
         
1117
-        $this->fees[]               = $fee;
1117
+        $this->fees[] = $fee;
1118 1118
         
1119 1119
         $added_fee               = $fee;
1120 1120
         $added_fee['action']     = 'add';
1121 1121
         $this->pending['fees'][] = $added_fee;
1122
-        reset( $this->fees );
1122
+        reset($this->fees);
1123 1123
 
1124
-        $this->increase_fees( $fee['amount'] );
1124
+        $this->increase_fees($fee['amount']);
1125 1125
         return true;
1126 1126
     }
1127 1127
 
1128
-    public function remove_fee( $key ) {
1128
+    public function remove_fee($key) {
1129 1129
         $removed = false;
1130 1130
 
1131
-        if ( is_numeric( $key ) ) {
1132
-            $removed = $this->remove_fee_by( 'index', $key );
1131
+        if (is_numeric($key)) {
1132
+            $removed = $this->remove_fee_by('index', $key);
1133 1133
         }
1134 1134
 
1135 1135
         return $removed;
1136 1136
     }
1137 1137
 
1138
-    public function remove_fee_by( $key, $value, $global = false ) {
1139
-        $allowed_fee_keys = apply_filters( 'wpinv_fee_keys', array(
1138
+    public function remove_fee_by($key, $value, $global = false) {
1139
+        $allowed_fee_keys = apply_filters('wpinv_fee_keys', array(
1140 1140
             'index', 'label', 'amount', 'type',
1141
-        ) );
1141
+        ));
1142 1142
 
1143
-        if ( ! in_array( $key, $allowed_fee_keys ) ) {
1143
+        if (!in_array($key, $allowed_fee_keys)) {
1144 1144
             return false;
1145 1145
         }
1146 1146
 
1147 1147
         $removed = false;
1148
-        if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) {
1149
-            $removed_fee             = $this->fees[ $value ];
1148
+        if ('index' === $key && array_key_exists($value, $this->fees)) {
1149
+            $removed_fee             = $this->fees[$value];
1150 1150
             $removed_fee['action']   = 'remove';
1151 1151
             $this->pending['fees'][] = $removed_fee;
1152 1152
 
1153
-            $this->decrease_fees( $removed_fee['amount'] );
1153
+            $this->decrease_fees($removed_fee['amount']);
1154 1154
 
1155
-            unset( $this->fees[ $value ] );
1155
+            unset($this->fees[$value]);
1156 1156
             $removed = true;
1157
-        } else if ( 'index' !== $key ) {
1158
-            foreach ( $this->fees as $index => $fee ) {
1159
-                if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) {
1157
+        } else if ('index' !== $key) {
1158
+            foreach ($this->fees as $index => $fee) {
1159
+                if (isset($fee[$key]) && $fee[$key] == $value) {
1160 1160
                     $removed_fee             = $fee;
1161 1161
                     $removed_fee['action']   = 'remove';
1162 1162
                     $this->pending['fees'][] = $removed_fee;
1163 1163
 
1164
-                    $this->decrease_fees( $removed_fee['amount'] );
1164
+                    $this->decrease_fees($removed_fee['amount']);
1165 1165
 
1166
-                    unset( $this->fees[ $index ] );
1166
+                    unset($this->fees[$index]);
1167 1167
                     $removed = true;
1168 1168
 
1169
-                    if ( false === $global ) {
1169
+                    if (false === $global) {
1170 1170
                         break;
1171 1171
                     }
1172 1172
                 }
1173 1173
             }
1174 1174
         }
1175 1175
 
1176
-        if ( true === $removed ) {
1177
-            $this->fees = array_values( $this->fees );
1176
+        if (true === $removed) {
1177
+            $this->fees = array_values($this->fees);
1178 1178
         }
1179 1179
 
1180 1180
         return $removed;
@@ -1182,35 +1182,35 @@  discard block
 block discarded – undo
1182 1182
 
1183 1183
     
1184 1184
 
1185
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
1185
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
1186 1186
         // Bail if no note specified
1187
-        if( !$note ) {
1187
+        if (!$note) {
1188 1188
             return false;
1189 1189
         }
1190 1190
 
1191
-        if ( empty( $this->ID ) )
1191
+        if (empty($this->ID))
1192 1192
             return false;
1193 1193
         
1194
-        if ( ( ( is_user_logged_in() && wpinv_current_user_can_manage_invoicing() ) || $added_by_user ) && !$system ) {
1195
-            $user                 = get_user_by( 'id', get_current_user_id() );
1194
+        if (((is_user_logged_in() && wpinv_current_user_can_manage_invoicing()) || $added_by_user) && !$system) {
1195
+            $user                 = get_user_by('id', get_current_user_id());
1196 1196
             $comment_author       = $user->display_name;
1197 1197
             $comment_author_email = $user->user_email;
1198 1198
         } else {
1199 1199
             $comment_author       = 'System';
1200 1200
             $comment_author_email = 'system@';
1201
-            $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) : 'noreply.com';
1202
-            $comment_author_email = sanitize_email( $comment_author_email );
1201
+            $comment_author_email .= isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : 'noreply.com';
1202
+            $comment_author_email = sanitize_email($comment_author_email);
1203 1203
         }
1204 1204
 
1205
-        do_action( 'wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type );
1205
+        do_action('wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type);
1206 1206
 
1207
-        $note_id = wp_insert_comment( wp_filter_comment( array(
1207
+        $note_id = wp_insert_comment(wp_filter_comment(array(
1208 1208
             'comment_post_ID'      => $this->ID,
1209 1209
             'comment_content'      => $note,
1210 1210
             'comment_agent'        => 'WPInvoicing',
1211 1211
             'user_id'              => is_admin() ? get_current_user_id() : 0,
1212
-            'comment_date'         => current_time( 'mysql' ),
1213
-            'comment_date_gmt'     => current_time( 'mysql', 1 ),
1212
+            'comment_date'         => current_time('mysql'),
1213
+            'comment_date_gmt'     => current_time('mysql', 1),
1214 1214
             'comment_approved'     => 1,
1215 1215
             'comment_parent'       => 0,
1216 1216
             'comment_author'       => $comment_author,
@@ -1218,53 +1218,53 @@  discard block
 block discarded – undo
1218 1218
             'comment_author_url'   => '',
1219 1219
             'comment_author_email' => $comment_author_email,
1220 1220
             'comment_type'         => 'wpinv_note'
1221
-        ) ) );
1221
+        )));
1222 1222
 
1223
-        do_action( 'wpinv_insert_payment_note', $note_id, $this->ID, $note );
1223
+        do_action('wpinv_insert_payment_note', $note_id, $this->ID, $note);
1224 1224
         
1225
-        if ( $customer_type ) {
1226
-            add_comment_meta( $note_id, '_wpi_customer_note', 1 );
1225
+        if ($customer_type) {
1226
+            add_comment_meta($note_id, '_wpi_customer_note', 1);
1227 1227
 
1228
-            do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $this->ID, 'user_note' => $note ) );
1228
+            do_action('wpinv_new_customer_note', array('invoice_id' => $this->ID, 'user_note' => $note));
1229 1229
         }
1230 1230
 
1231 1231
         return $note_id;
1232 1232
     }
1233 1233
 
1234
-    private function increase_subtotal( $amount = 0.00 ) {
1234
+    private function increase_subtotal($amount = 0.00) {
1235 1235
         $amount          = (float) $amount;
1236 1236
         $this->subtotal += $amount;
1237
-        $this->subtotal  = wpinv_round_amount( $this->subtotal );
1237
+        $this->subtotal  = wpinv_round_amount($this->subtotal);
1238 1238
 
1239 1239
         $this->recalculate_total();
1240 1240
     }
1241 1241
 
1242
-    private function decrease_subtotal( $amount = 0.00 ) {
1242
+    private function decrease_subtotal($amount = 0.00) {
1243 1243
         $amount          = (float) $amount;
1244 1244
         $this->subtotal -= $amount;
1245
-        $this->subtotal  = wpinv_round_amount( $this->subtotal );
1245
+        $this->subtotal  = wpinv_round_amount($this->subtotal);
1246 1246
 
1247
-        if ( $this->subtotal < 0 ) {
1247
+        if ($this->subtotal < 0) {
1248 1248
             $this->subtotal = 0;
1249 1249
         }
1250 1250
 
1251 1251
         $this->recalculate_total();
1252 1252
     }
1253 1253
 
1254
-    private function increase_fees( $amount = 0.00 ) {
1255
-        $amount            = (float)$amount;
1254
+    private function increase_fees($amount = 0.00) {
1255
+        $amount            = (float) $amount;
1256 1256
         $this->fees_total += $amount;
1257
-        $this->fees_total  = wpinv_round_amount( $this->fees_total );
1257
+        $this->fees_total  = wpinv_round_amount($this->fees_total);
1258 1258
 
1259 1259
         $this->recalculate_total();
1260 1260
     }
1261 1261
 
1262
-    private function decrease_fees( $amount = 0.00 ) {
1262
+    private function decrease_fees($amount = 0.00) {
1263 1263
         $amount            = (float) $amount;
1264 1264
         $this->fees_total -= $amount;
1265
-        $this->fees_total  = wpinv_round_amount( $this->fees_total );
1265
+        $this->fees_total  = wpinv_round_amount($this->fees_total);
1266 1266
 
1267
-        if ( $this->fees_total < 0 ) {
1267
+        if ($this->fees_total < 0) {
1268 1268
             $this->fees_total = 0;
1269 1269
         }
1270 1270
 
@@ -1275,54 +1275,54 @@  discard block
 block discarded – undo
1275 1275
         global $wpi_nosave;
1276 1276
         
1277 1277
         $this->total = $this->subtotal + $this->tax + $this->fees_total;
1278
-        $this->total = wpinv_round_amount( $this->total );
1278
+        $this->total = wpinv_round_amount($this->total);
1279 1279
         
1280
-        do_action( 'wpinv_invoice_recalculate_total', $this, $wpi_nosave );
1280
+        do_action('wpinv_invoice_recalculate_total', $this, $wpi_nosave);
1281 1281
     }
1282 1282
     
1283
-    public function increase_tax( $amount = 0.00 ) {
1283
+    public function increase_tax($amount = 0.00) {
1284 1284
         $amount       = (float) $amount;
1285 1285
         $this->tax   += $amount;
1286 1286
 
1287 1287
         $this->recalculate_total();
1288 1288
     }
1289 1289
 
1290
-    public function decrease_tax( $amount = 0.00 ) {
1290
+    public function decrease_tax($amount = 0.00) {
1291 1291
         $amount     = (float) $amount;
1292 1292
         $this->tax -= $amount;
1293 1293
 
1294
-        if ( $this->tax < 0 ) {
1294
+        if ($this->tax < 0) {
1295 1295
             $this->tax = 0;
1296 1296
         }
1297 1297
 
1298 1298
         $this->recalculate_total();
1299 1299
     }
1300 1300
 
1301
-    public function update_status( $new_status = false, $note = '', $manual = false ) {
1302
-        $old_status = ! empty( $this->old_status ) ? $this->old_status : get_post_status( $this->ID );
1301
+    public function update_status($new_status = false, $note = '', $manual = false) {
1302
+        $old_status = !empty($this->old_status) ? $this->old_status : get_post_status($this->ID);
1303 1303
 
1304
-        if ( $old_status === $new_status && in_array( $new_status, array_keys( wpinv_get_invoice_statuses( true ) ) ) ) {
1304
+        if ($old_status === $new_status && in_array($new_status, array_keys(wpinv_get_invoice_statuses(true)))) {
1305 1305
             return false; // Don't permit status changes that aren't changes
1306 1306
         }
1307 1307
 
1308
-        $do_change = apply_filters( 'wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status );
1308
+        $do_change = apply_filters('wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status);
1309 1309
         $updated = false;
1310 1310
 
1311
-        if ( $do_change ) {
1312
-            do_action( 'wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status );
1311
+        if ($do_change) {
1312
+            do_action('wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status);
1313 1313
 
1314 1314
             $update_post_data                   = array();
1315 1315
             $update_post_data['ID']             = $this->ID;
1316 1316
             $update_post_data['post_status']    = $new_status;
1317
-            $update_post_data['edit_date']      = current_time( 'mysql', 0 );
1318
-            $update_post_data['edit_date_gmt']  = current_time( 'mysql', 1 );
1317
+            $update_post_data['edit_date']      = current_time('mysql', 0);
1318
+            $update_post_data['edit_date_gmt']  = current_time('mysql', 1);
1319 1319
             
1320
-            $update_post_data = apply_filters( 'wpinv_update_invoice_status_fields', $update_post_data, $this->ID );
1320
+            $update_post_data = apply_filters('wpinv_update_invoice_status_fields', $update_post_data, $this->ID);
1321 1321
 
1322
-            $updated = wp_update_post( $update_post_data );     
1322
+            $updated = wp_update_post($update_post_data);     
1323 1323
            
1324 1324
             // Process any specific status functions
1325
-            switch( $new_status ) {
1325
+            switch ($new_status) {
1326 1326
                 case 'wpi-refunded':
1327 1327
                     $this->process_refund();
1328 1328
                     break;
@@ -1335,9 +1335,9 @@  discard block
 block discarded – undo
1335 1335
             }
1336 1336
             
1337 1337
             // Status was changed.
1338
-            do_action( 'wpinv_status_' . $new_status, $this->ID, $old_status );
1339
-            do_action( 'wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status );
1340
-            do_action( 'wpinv_update_status', $this->ID, $new_status, $old_status );
1338
+            do_action('wpinv_status_' . $new_status, $this->ID, $old_status);
1339
+            do_action('wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status);
1340
+            do_action('wpinv_update_status', $this->ID, $new_status, $old_status);
1341 1341
         }
1342 1342
 
1343 1343
         return $updated;
@@ -1351,20 +1351,20 @@  discard block
 block discarded – undo
1351 1351
         $this->save();
1352 1352
     }
1353 1353
 
1354
-    public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1355
-        if ( empty( $meta_key ) ) {
1354
+    public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1355
+        if (empty($meta_key)) {
1356 1356
             return false;
1357 1357
         }
1358 1358
 
1359
-        if ( $meta_key == 'key' || $meta_key == 'date' ) {
1359
+        if ($meta_key == 'key' || $meta_key == 'date') {
1360 1360
             $current_meta = $this->get_meta();
1361
-            $current_meta[ $meta_key ] = $meta_value;
1361
+            $current_meta[$meta_key] = $meta_value;
1362 1362
 
1363 1363
             $meta_key     = '_wpinv_payment_meta';
1364 1364
             $meta_value   = $current_meta;
1365 1365
         }
1366 1366
 
1367
-        $meta_value = apply_filters( 'wpinv_update_payment_meta_' . $meta_key, $meta_value, $this->ID );
1367
+        $meta_value = apply_filters('wpinv_update_payment_meta_' . $meta_key, $meta_value, $this->ID);
1368 1368
         
1369 1369
         // Do not update created date on invoice marked as paid.
1370 1370
         /*if ( $meta_key == '_wpinv_completed_date' && !empty( $meta_value ) ) {
@@ -1379,45 +1379,45 @@  discard block
 block discarded – undo
1379 1379
             wp_update_post( $args );
1380 1380
         }*/
1381 1381
         
1382
-        return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1382
+        return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value);
1383 1383
     }
1384 1384
 
1385 1385
     private function process_refund() {
1386 1386
         $process_refund = true;
1387 1387
 
1388 1388
         // If the payment was not in publish, don't decrement stats as they were never incremented
1389
-        if ( 'publish' != $this->old_status || 'wpi-refunded' != $this->status ) {
1389
+        if ('publish' != $this->old_status || 'wpi-refunded' != $this->status) {
1390 1390
             $process_refund = false;
1391 1391
         }
1392 1392
 
1393 1393
         // Allow extensions to filter for their own payment types, Example: Recurring Payments
1394
-        $process_refund = apply_filters( 'wpinv_should_process_refund', $process_refund, $this );
1394
+        $process_refund = apply_filters('wpinv_should_process_refund', $process_refund, $this);
1395 1395
 
1396
-        if ( false === $process_refund ) {
1396
+        if (false === $process_refund) {
1397 1397
             return;
1398 1398
         }
1399 1399
 
1400
-        do_action( 'wpinv_pre_refund_invoice', $this );
1400
+        do_action('wpinv_pre_refund_invoice', $this);
1401 1401
         
1402
-        $decrease_store_earnings = apply_filters( 'wpinv_decrease_store_earnings_on_refund', true, $this );
1403
-        $decrease_customer_value = apply_filters( 'wpinv_decrease_customer_value_on_refund', true, $this );
1404
-        $decrease_purchase_count = apply_filters( 'wpinv_decrease_customer_purchase_count_on_refund', true, $this );
1402
+        $decrease_store_earnings = apply_filters('wpinv_decrease_store_earnings_on_refund', true, $this);
1403
+        $decrease_customer_value = apply_filters('wpinv_decrease_customer_value_on_refund', true, $this);
1404
+        $decrease_purchase_count = apply_filters('wpinv_decrease_customer_purchase_count_on_refund', true, $this);
1405 1405
         
1406
-        do_action( 'wpinv_post_refund_invoice', $this );
1406
+        do_action('wpinv_post_refund_invoice', $this);
1407 1407
     }
1408 1408
 
1409 1409
     private function process_failure() {
1410 1410
         $discounts = $this->discounts;
1411
-        if ( empty( $discounts ) ) {
1411
+        if (empty($discounts)) {
1412 1412
             return;
1413 1413
         }
1414 1414
 
1415
-        if ( ! is_array( $discounts ) ) {
1416
-            $discounts = array_map( 'trim', explode( ',', $discounts ) );
1415
+        if (!is_array($discounts)) {
1416
+            $discounts = array_map('trim', explode(',', $discounts));
1417 1417
         }
1418 1418
 
1419
-        foreach ( $discounts as $discount ) {
1420
-            wpinv_decrease_discount_usage( $discount );
1419
+        foreach ($discounts as $discount) {
1420
+            wpinv_decrease_discount_usage($discount);
1421 1421
         }
1422 1422
     }
1423 1423
     
@@ -1425,92 +1425,92 @@  discard block
 block discarded – undo
1425 1425
         $process_pending = true;
1426 1426
 
1427 1427
         // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1428
-        if ( ( 'publish' != $this->old_status && 'revoked' != $this->old_status ) || 'wpi-pending' != $this->status ) {
1428
+        if (('publish' != $this->old_status && 'revoked' != $this->old_status) || 'wpi-pending' != $this->status) {
1429 1429
             $process_pending = false;
1430 1430
         }
1431 1431
 
1432 1432
         // Allow extensions to filter for their own payment types, Example: Recurring Payments
1433
-        $process_pending = apply_filters( 'wpinv_should_process_pending', $process_pending, $this );
1433
+        $process_pending = apply_filters('wpinv_should_process_pending', $process_pending, $this);
1434 1434
 
1435
-        if ( false === $process_pending ) {
1435
+        if (false === $process_pending) {
1436 1436
             return;
1437 1437
         }
1438 1438
 
1439
-        $decrease_store_earnings = apply_filters( 'wpinv_decrease_store_earnings_on_pending', true, $this );
1440
-        $decrease_customer_value = apply_filters( 'wpinv_decrease_customer_value_on_pending', true, $this );
1441
-        $decrease_purchase_count = apply_filters( 'wpinv_decrease_customer_purchase_count_on_pending', true, $this );
1439
+        $decrease_store_earnings = apply_filters('wpinv_decrease_store_earnings_on_pending', true, $this);
1440
+        $decrease_customer_value = apply_filters('wpinv_decrease_customer_value_on_pending', true, $this);
1441
+        $decrease_purchase_count = apply_filters('wpinv_decrease_customer_purchase_count_on_pending', true, $this);
1442 1442
 
1443 1443
         $this->completed_date = '';
1444
-        $this->update_meta( '_wpinv_completed_date', '' );
1444
+        $this->update_meta('_wpinv_completed_date', '');
1445 1445
     }
1446 1446
     
1447 1447
     // get data
1448
-    public function get_meta( $meta_key = '_wpinv_payment_meta', $single = true ) {
1449
-        $meta = get_post_meta( $this->ID, $meta_key, $single );
1448
+    public function get_meta($meta_key = '_wpinv_payment_meta', $single = true) {
1449
+        $meta = get_post_meta($this->ID, $meta_key, $single);
1450 1450
 
1451
-        if ( $meta_key === '_wpinv_payment_meta' ) {
1451
+        if ($meta_key === '_wpinv_payment_meta') {
1452 1452
 
1453
-            if(!is_array($meta)){$meta = array();} // we need this to be an array so make sure it is.
1453
+            if (!is_array($meta)) {$meta = array(); } // we need this to be an array so make sure it is.
1454 1454
 
1455
-            if ( empty( $meta['key'] ) ) {
1455
+            if (empty($meta['key'])) {
1456 1456
                 $meta['key'] = $this->setup_invoice_key();
1457 1457
             }
1458 1458
 
1459
-            if ( empty( $meta['date'] ) ) {
1460
-                $meta['date'] = get_post_field( 'post_date', $this->ID );
1459
+            if (empty($meta['date'])) {
1460
+                $meta['date'] = get_post_field('post_date', $this->ID);
1461 1461
             }
1462 1462
         }
1463 1463
 
1464
-        $meta = apply_filters( 'wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID );
1464
+        $meta = apply_filters('wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID);
1465 1465
 
1466
-        return apply_filters( 'wpinv_get_invoice_meta', $meta, $this->ID, $meta_key );
1466
+        return apply_filters('wpinv_get_invoice_meta', $meta, $this->ID, $meta_key);
1467 1467
     }
1468 1468
     
1469 1469
     public function get_description() {
1470
-        $post = get_post( $this->ID );
1470
+        $post = get_post($this->ID);
1471 1471
         
1472
-        $description = !empty( $post ) ? $post->post_content : '';
1473
-        return apply_filters( 'wpinv_get_description', $description, $this->ID, $this );
1472
+        $description = !empty($post) ? $post->post_content : '';
1473
+        return apply_filters('wpinv_get_description', $description, $this->ID, $this);
1474 1474
     }
1475 1475
     
1476
-    public function get_status( $nicename = false ) {
1477
-        if ( !$nicename ) {
1476
+    public function get_status($nicename = false) {
1477
+        if (!$nicename) {
1478 1478
             $status = $this->status;
1479 1479
         } else {
1480 1480
             $status = $this->status_nicename;
1481 1481
         }
1482 1482
         
1483
-        return apply_filters( 'wpinv_get_status', $status, $nicename, $this->ID, $this );
1483
+        return apply_filters('wpinv_get_status', $status, $nicename, $this->ID, $this);
1484 1484
     }
1485 1485
     
1486 1486
     public function get_cart_details() {
1487
-        return apply_filters( 'wpinv_cart_details', $this->cart_details, $this->ID, $this );
1487
+        return apply_filters('wpinv_cart_details', $this->cart_details, $this->ID, $this);
1488 1488
     }
1489 1489
     
1490
-    public function get_subtotal( $currency = false ) {
1491
-        $subtotal = wpinv_round_amount( $this->subtotal );
1490
+    public function get_subtotal($currency = false) {
1491
+        $subtotal = wpinv_round_amount($this->subtotal);
1492 1492
         
1493
-        if ( $currency ) {
1494
-            $subtotal = wpinv_price( wpinv_format_amount( $subtotal, NULL, !$currency ), $this->get_currency() );
1493
+        if ($currency) {
1494
+            $subtotal = wpinv_price(wpinv_format_amount($subtotal, NULL, !$currency), $this->get_currency());
1495 1495
         }
1496 1496
         
1497
-        return apply_filters( 'wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency );
1497
+        return apply_filters('wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency);
1498 1498
     }
1499 1499
     
1500
-    public function get_total( $currency = false ) {        
1501
-        if ( $this->is_free_trial() ) {
1502
-            $total = wpinv_round_amount( 0 );
1500
+    public function get_total($currency = false) {        
1501
+        if ($this->is_free_trial()) {
1502
+            $total = wpinv_round_amount(0);
1503 1503
         } else {
1504
-            $total = wpinv_round_amount( $this->total );
1504
+            $total = wpinv_round_amount($this->total);
1505 1505
         }
1506
-        if ( $currency ) {
1507
-            $total = wpinv_price( wpinv_format_amount( $total, NULL, !$currency ), $this->get_currency() );
1506
+        if ($currency) {
1507
+            $total = wpinv_price(wpinv_format_amount($total, NULL, !$currency), $this->get_currency());
1508 1508
         }
1509 1509
         
1510
-        return apply_filters( 'wpinv_get_invoice_total', $total, $this->ID, $this, $currency );
1510
+        return apply_filters('wpinv_get_invoice_total', $total, $this->ID, $this, $currency);
1511 1511
     }
1512 1512
     
1513
-    public function get_recurring_details( $field = '', $currency = false ) {        
1513
+    public function get_recurring_details($field = '', $currency = false) {        
1514 1514
         $data                 = array();
1515 1515
         $data['cart_details'] = $this->cart_details;
1516 1516
         $data['subtotal']     = $this->get_subtotal();
@@ -1518,119 +1518,119 @@  discard block
 block discarded – undo
1518 1518
         $data['tax']          = $this->get_tax();
1519 1519
         $data['total']        = $this->get_total();
1520 1520
     
1521
-        if ( !empty( $this->cart_details ) && ( $this->is_parent() || $this->is_renewal() ) ) {
1521
+        if (!empty($this->cart_details) && ($this->is_parent() || $this->is_renewal())) {
1522 1522
             $is_free_trial = $this->is_free_trial();
1523
-            $discounts = $this->get_discounts( true );
1523
+            $discounts = $this->get_discounts(true);
1524 1524
             
1525
-            if ( $is_free_trial || !empty( $discounts ) ) {
1525
+            if ($is_free_trial || !empty($discounts)) {
1526 1526
                 $first_use_only = false;
1527 1527
                 
1528
-                if ( !empty( $discounts ) ) {
1529
-                    foreach ( $discounts as $key => $code ) {
1530
-                        if ( wpinv_discount_is_recurring( $code, true ) && !$this->is_renewal() ) {
1528
+                if (!empty($discounts)) {
1529
+                    foreach ($discounts as $key => $code) {
1530
+                        if (wpinv_discount_is_recurring($code, true) && !$this->is_renewal()) {
1531 1531
                             $first_use_only = true;
1532 1532
                             break;
1533 1533
                         }
1534 1534
                     }
1535 1535
                 }
1536 1536
                     
1537
-                if ( !$first_use_only ) {
1538
-                    $data['subtotal'] = wpinv_round_amount( $this->subtotal );
1539
-                    $data['discount'] = wpinv_round_amount( $this->discount );
1540
-                    $data['tax']      = wpinv_round_amount( $this->tax );
1541
-                    $data['total']    = wpinv_round_amount( $this->total );
1537
+                if (!$first_use_only) {
1538
+                    $data['subtotal'] = wpinv_round_amount($this->subtotal);
1539
+                    $data['discount'] = wpinv_round_amount($this->discount);
1540
+                    $data['tax']      = wpinv_round_amount($this->tax);
1541
+                    $data['total']    = wpinv_round_amount($this->total);
1542 1542
                 } else {
1543 1543
                     $cart_subtotal   = 0;
1544 1544
                     $cart_discount   = $this->discount;
1545 1545
                     $cart_tax        = 0;
1546 1546
 
1547
-                    foreach ( $this->cart_details as $key => $item ) {
1548
-                        $item_quantity  = $item['quantity'] > 0 ? absint( $item['quantity'] ) : 1;
1549
-                        $item_subtotal  = !empty( $item['subtotal'] ) ? $item['subtotal'] : $item['item_price'] * $item_quantity;
1547
+                    foreach ($this->cart_details as $key => $item) {
1548
+                        $item_quantity  = $item['quantity'] > 0 ? absint($item['quantity']) : 1;
1549
+                        $item_subtotal  = !empty($item['subtotal']) ? $item['subtotal'] : $item['item_price'] * $item_quantity;
1550 1550
                         $item_discount  = 0;
1551
-                        $item_tax       = $item_subtotal > 0 && !empty( $item['vat_rate'] ) ? ( $item_subtotal * 0.01 * (float)$item['vat_rate'] ) : 0;
1551
+                        $item_tax       = $item_subtotal > 0 && !empty($item['vat_rate']) ? ($item_subtotal * 0.01 * (float) $item['vat_rate']) : 0;
1552 1552
                         
1553
-                        if ( wpinv_prices_include_tax() ) {
1554
-                            $item_subtotal -= wpinv_round_amount( $item_tax );
1553
+                        if (wpinv_prices_include_tax()) {
1554
+                            $item_subtotal -= wpinv_round_amount($item_tax);
1555 1555
                         }
1556 1556
                         
1557 1557
                         $item_total     = $item_subtotal - $item_discount + $item_tax;
1558 1558
                         // Do not allow totals to go negative
1559
-                        if ( $item_total < 0 ) {
1559
+                        if ($item_total < 0) {
1560 1560
                             $item_total = 0;
1561 1561
                         }
1562 1562
                         
1563
-                        $cart_subtotal  += (float)($item_subtotal);
1564
-                        $cart_discount  += (float)($item_discount);
1565
-                        $cart_tax       += (float)($item_tax);
1563
+                        $cart_subtotal  += (float) ($item_subtotal);
1564
+                        $cart_discount  += (float) ($item_discount);
1565
+                        $cart_tax       += (float) ($item_tax);
1566 1566
                         
1567
-                        $data['cart_details'][$key]['discount']   = wpinv_round_amount( $item_discount );
1568
-                        $data['cart_details'][$key]['tax']        = wpinv_round_amount( $item_tax );
1569
-                        $data['cart_details'][$key]['price']      = wpinv_round_amount( $item_total );
1567
+                        $data['cart_details'][$key]['discount']   = wpinv_round_amount($item_discount);
1568
+                        $data['cart_details'][$key]['tax']        = wpinv_round_amount($item_tax);
1569
+                        $data['cart_details'][$key]['price']      = wpinv_round_amount($item_total);
1570 1570
                     }
1571 1571
 
1572 1572
 	                $total = $data['subtotal'] - $data['discount'] + $data['tax'];
1573
-	                if ( $total < 0 ) {
1573
+	                if ($total < 0) {
1574 1574
 		                $total = 0;
1575 1575
 	                }
1576 1576
 
1577
-                    $data['subtotal'] = wpinv_round_amount( $cart_subtotal );
1578
-                    $data['discount'] = wpinv_round_amount( $cart_discount );
1579
-                    $data['tax']      = wpinv_round_amount( $cart_tax );
1580
-                    $data['total']    = wpinv_round_amount( $total );
1577
+                    $data['subtotal'] = wpinv_round_amount($cart_subtotal);
1578
+                    $data['discount'] = wpinv_round_amount($cart_discount);
1579
+                    $data['tax']      = wpinv_round_amount($cart_tax);
1580
+                    $data['total']    = wpinv_round_amount($total);
1581 1581
                 }
1582 1582
             }
1583 1583
         }
1584 1584
         
1585
-        $data = apply_filters( 'wpinv_get_invoice_recurring_details', $data, $this, $field, $currency );
1585
+        $data = apply_filters('wpinv_get_invoice_recurring_details', $data, $this, $field, $currency);
1586 1586
 
1587
-        if ( isset( $data[$field] ) ) {
1588
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1587
+        if (isset($data[$field])) {
1588
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1589 1589
         }
1590 1590
         
1591 1591
         return $data;
1592 1592
     }
1593 1593
     
1594
-    public function get_final_tax( $currency = false ) {        
1595
-        $final_total = wpinv_round_amount( $this->tax );
1596
-        if ( $currency ) {
1597
-            $final_total = wpinv_price( wpinv_format_amount( $final_total, NULL, !$currency ), $this->get_currency() );
1594
+    public function get_final_tax($currency = false) {        
1595
+        $final_total = wpinv_round_amount($this->tax);
1596
+        if ($currency) {
1597
+            $final_total = wpinv_price(wpinv_format_amount($final_total, NULL, !$currency), $this->get_currency());
1598 1598
         }
1599 1599
         
1600
-        return apply_filters( 'wpinv_get_invoice_final_total', $final_total, $this, $currency );
1600
+        return apply_filters('wpinv_get_invoice_final_total', $final_total, $this, $currency);
1601 1601
     }
1602 1602
     
1603
-    public function get_discounts( $array = false ) {
1603
+    public function get_discounts($array = false) {
1604 1604
         $discounts = $this->discounts;
1605
-        if ( $array && $discounts ) {
1606
-            $discounts = explode( ',', $discounts );
1605
+        if ($array && $discounts) {
1606
+            $discounts = explode(',', $discounts);
1607 1607
         }
1608
-        return apply_filters( 'wpinv_payment_discounts', $discounts, $this->ID, $this, $array );
1608
+        return apply_filters('wpinv_payment_discounts', $discounts, $this->ID, $this, $array);
1609 1609
     }
1610 1610
     
1611
-    public function get_discount( $currency = false, $dash = false ) {
1612
-        if ( !empty( $this->discounts ) ) {
1611
+    public function get_discount($currency = false, $dash = false) {
1612
+        if (!empty($this->discounts)) {
1613 1613
             global $ajax_cart_details;
1614 1614
             $ajax_cart_details = $this->get_cart_details();
1615 1615
             
1616
-            if ( !empty( $ajax_cart_details ) && count( $ajax_cart_details ) == count( $this->items ) ) {
1616
+            if (!empty($ajax_cart_details) && count($ajax_cart_details) == count($this->items)) {
1617 1617
                 $cart_items = $ajax_cart_details;
1618 1618
             } else {
1619 1619
                 $cart_items = $this->items;
1620 1620
             }
1621 1621
 
1622
-            $this->discount = wpinv_get_cart_items_discount_amount( $cart_items , $this->discounts );
1622
+            $this->discount = wpinv_get_cart_items_discount_amount($cart_items, $this->discounts);
1623 1623
         }
1624
-        $discount   = wpinv_round_amount( $this->discount );
1624
+        $discount   = wpinv_round_amount($this->discount);
1625 1625
         $dash       = $dash && $discount > 0 ? '&ndash;' : '';
1626 1626
         
1627
-        if ( $currency ) {
1628
-            $discount = wpinv_price( wpinv_format_amount( $discount, NULL, !$currency ), $this->get_currency() );
1627
+        if ($currency) {
1628
+            $discount = wpinv_price(wpinv_format_amount($discount, NULL, !$currency), $this->get_currency());
1629 1629
         }
1630 1630
         
1631
-        $discount   = $dash . $discount;
1631
+        $discount = $dash . $discount;
1632 1632
         
1633
-        return apply_filters( 'wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash );
1633
+        return apply_filters('wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash);
1634 1634
     }
1635 1635
     
1636 1636
     public function get_discount_code() {
@@ -1642,49 +1642,49 @@  discard block
 block discarded – undo
1642 1642
         return (int) $this->disable_taxes === 0;
1643 1643
     }
1644 1644
 
1645
-    public function get_tax( $currency = false ) {
1646
-        $tax = wpinv_round_amount( $this->tax );
1645
+    public function get_tax($currency = false) {
1646
+        $tax = wpinv_round_amount($this->tax);
1647 1647
 
1648
-        if ( $currency ) {
1649
-            $tax = wpinv_price( wpinv_format_amount( $tax, NULL, !$currency ), $this->get_currency() );
1648
+        if ($currency) {
1649
+            $tax = wpinv_price(wpinv_format_amount($tax, NULL, !$currency), $this->get_currency());
1650 1650
         }
1651 1651
 
1652
-        if ( ! $this->is_taxable() ) {
1653
-            $tax = wpinv_round_amount( 0.00 );
1652
+        if (!$this->is_taxable()) {
1653
+            $tax = wpinv_round_amount(0.00);
1654 1654
         }
1655 1655
 
1656
-        return apply_filters( 'wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency );
1656
+        return apply_filters('wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency);
1657 1657
     }
1658 1658
     
1659
-    public function get_fees( $type = 'all' ) {
1660
-        $fees    = array();
1659
+    public function get_fees($type = 'all') {
1660
+        $fees = array();
1661 1661
 
1662
-        if ( ! empty( $this->fees ) && is_array( $this->fees ) ) {
1663
-            foreach ( $this->fees as $fee ) {
1664
-                if( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1662
+        if (!empty($this->fees) && is_array($this->fees)) {
1663
+            foreach ($this->fees as $fee) {
1664
+                if ('all' != $type && !empty($fee['type']) && $type != $fee['type']) {
1665 1665
                     continue;
1666 1666
                 }
1667 1667
 
1668
-                $fee['label'] = stripslashes( $fee['label'] );
1669
-                $fee['amount_display'] = wpinv_price( $fee['amount'], $this->get_currency() );
1670
-                $fees[]    = $fee;
1668
+                $fee['label'] = stripslashes($fee['label']);
1669
+                $fee['amount_display'] = wpinv_price($fee['amount'], $this->get_currency());
1670
+                $fees[] = $fee;
1671 1671
             }
1672 1672
         }
1673 1673
 
1674
-        return apply_filters( 'wpinv_get_invoice_fees', $fees, $this->ID, $this );
1674
+        return apply_filters('wpinv_get_invoice_fees', $fees, $this->ID, $this);
1675 1675
     }
1676 1676
     
1677
-    public function get_fees_total( $type = 'all' ) {
1677
+    public function get_fees_total($type = 'all') {
1678 1678
         $fees_total = (float) 0.00;
1679 1679
 
1680
-        $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1681
-        if ( ! empty( $payment_fees ) ) {
1682
-            foreach ( $payment_fees as $fee ) {
1680
+        $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1681
+        if (!empty($payment_fees)) {
1682
+            foreach ($payment_fees as $fee) {
1683 1683
                 $fees_total += (float) $fee['amount'];
1684 1684
             }
1685 1685
         }
1686 1686
 
1687
-        return apply_filters( 'wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this );
1687
+        return apply_filters('wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this);
1688 1688
         /*
1689 1689
         $fees = $this->get_fees( $type );
1690 1690
 
@@ -1704,116 +1704,116 @@  discard block
 block discarded – undo
1704 1704
     }
1705 1705
 
1706 1706
     public function get_user_id() {
1707
-        return apply_filters( 'wpinv_user_id', $this->user_id, $this->ID, $this );
1707
+        return apply_filters('wpinv_user_id', $this->user_id, $this->ID, $this);
1708 1708
     }
1709 1709
     
1710 1710
     public function get_first_name() {
1711
-        return apply_filters( 'wpinv_first_name', $this->first_name, $this->ID, $this );
1711
+        return apply_filters('wpinv_first_name', $this->first_name, $this->ID, $this);
1712 1712
     }
1713 1713
     
1714 1714
     public function get_last_name() {
1715
-        return apply_filters( 'wpinv_last_name', $this->last_name, $this->ID, $this );
1715
+        return apply_filters('wpinv_last_name', $this->last_name, $this->ID, $this);
1716 1716
     }
1717 1717
     
1718 1718
     public function get_user_full_name() {
1719
-        return apply_filters( 'wpinv_user_full_name', $this->full_name, $this->ID, $this );
1719
+        return apply_filters('wpinv_user_full_name', $this->full_name, $this->ID, $this);
1720 1720
     }
1721 1721
     
1722 1722
     public function get_user_info() {
1723
-        return apply_filters( 'wpinv_user_info', $this->user_info, $this->ID, $this );
1723
+        return apply_filters('wpinv_user_info', $this->user_info, $this->ID, $this);
1724 1724
     }
1725 1725
     
1726 1726
     public function get_email() {
1727
-        return apply_filters( 'wpinv_user_email', $this->email, $this->ID, $this );
1727
+        return apply_filters('wpinv_user_email', $this->email, $this->ID, $this);
1728 1728
     }
1729 1729
     
1730 1730
     public function get_address() {
1731
-        return apply_filters( 'wpinv_address', $this->address, $this->ID, $this );
1731
+        return apply_filters('wpinv_address', $this->address, $this->ID, $this);
1732 1732
     }
1733 1733
     
1734 1734
     public function get_phone() {
1735
-        return apply_filters( 'wpinv_phone', $this->phone, $this->ID, $this );
1735
+        return apply_filters('wpinv_phone', $this->phone, $this->ID, $this);
1736 1736
     }
1737 1737
     
1738 1738
     public function get_number() {
1739
-        return apply_filters( 'wpinv_number', $this->number, $this->ID, $this );
1739
+        return apply_filters('wpinv_number', $this->number, $this->ID, $this);
1740 1740
     }
1741 1741
     
1742 1742
     public function get_items() {
1743
-        return apply_filters( 'wpinv_payment_meta_items', $this->items, $this->ID, $this );
1743
+        return apply_filters('wpinv_payment_meta_items', $this->items, $this->ID, $this);
1744 1744
     }
1745 1745
     
1746 1746
     public function get_key() {
1747
-        return apply_filters( 'wpinv_key', $this->key, $this->ID, $this );
1747
+        return apply_filters('wpinv_key', $this->key, $this->ID, $this);
1748 1748
     }
1749 1749
     
1750 1750
     public function get_transaction_id() {
1751
-        return apply_filters( 'wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this );
1751
+        return apply_filters('wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this);
1752 1752
     }
1753 1753
     
1754 1754
     public function get_gateway() {
1755
-        return apply_filters( 'wpinv_gateway', $this->gateway, $this->ID, $this );
1755
+        return apply_filters('wpinv_gateway', $this->gateway, $this->ID, $this);
1756 1756
     }
1757 1757
     
1758 1758
     public function get_gateway_title() {
1759
-        $this->gateway_title = !empty( $this->gateway_title ) ? $this->gateway_title : wpinv_get_gateway_checkout_label( $this->gateway );
1759
+        $this->gateway_title = !empty($this->gateway_title) ? $this->gateway_title : wpinv_get_gateway_checkout_label($this->gateway);
1760 1760
         
1761
-        return apply_filters( 'wpinv_gateway_title', $this->gateway_title, $this->ID, $this );
1761
+        return apply_filters('wpinv_gateway_title', $this->gateway_title, $this->ID, $this);
1762 1762
     }
1763 1763
     
1764 1764
     public function get_currency() {
1765
-        return apply_filters( 'wpinv_currency_code', $this->currency, $this->ID, $this );
1765
+        return apply_filters('wpinv_currency_code', $this->currency, $this->ID, $this);
1766 1766
     }
1767 1767
     
1768 1768
     public function get_created_date() {
1769
-        return apply_filters( 'wpinv_created_date', $this->date, $this->ID, $this );
1769
+        return apply_filters('wpinv_created_date', $this->date, $this->ID, $this);
1770 1770
     }
1771 1771
     
1772
-    public function get_due_date( $display = false ) {
1773
-        $due_date = apply_filters( 'wpinv_due_date', $this->due_date, $this->ID, $this );
1772
+    public function get_due_date($display = false) {
1773
+        $due_date = apply_filters('wpinv_due_date', $this->due_date, $this->ID, $this);
1774 1774
         
1775
-        if ( !$display || empty( $due_date ) ) {
1775
+        if (!$display || empty($due_date)) {
1776 1776
             return $due_date;
1777 1777
         }
1778 1778
         
1779
-        return date_i18n( get_option( 'date_format' ), strtotime( $due_date ) );
1779
+        return date_i18n(get_option('date_format'), strtotime($due_date));
1780 1780
     }
1781 1781
     
1782 1782
     public function get_completed_date() {
1783
-        return apply_filters( 'wpinv_completed_date', $this->completed_date, $this->ID, $this );
1783
+        return apply_filters('wpinv_completed_date', $this->completed_date, $this->ID, $this);
1784 1784
     }
1785 1785
     
1786
-    public function get_invoice_date( $formatted = true ) {
1786
+    public function get_invoice_date($formatted = true) {
1787 1787
         $date_completed = $this->completed_date;
1788 1788
         $invoice_date   = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
1789 1789
         
1790
-        if ( $invoice_date == '' ) {
1790
+        if ($invoice_date == '') {
1791 1791
             $date_created   = $this->date;
1792 1792
             $invoice_date   = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? $date_created : '';
1793 1793
         }
1794 1794
         
1795
-        if ( $formatted && $invoice_date ) {
1796
-            $invoice_date   = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) );
1795
+        if ($formatted && $invoice_date) {
1796
+            $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date));
1797 1797
         }
1798 1798
 
1799
-        return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this );
1799
+        return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this);
1800 1800
     }
1801 1801
     
1802 1802
     public function get_ip() {
1803
-        return apply_filters( 'wpinv_user_ip', $this->ip, $this->ID, $this );
1803
+        return apply_filters('wpinv_user_ip', $this->ip, $this->ID, $this);
1804 1804
     }
1805 1805
         
1806
-    public function has_status( $status ) {
1807
-        return apply_filters( 'wpinv_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status ) ) || $this->get_status() === $status ? true : false, $this, $status );
1806
+    public function has_status($status) {
1807
+        return apply_filters('wpinv_has_status', (is_array($status) && in_array($this->get_status(), $status)) || $this->get_status() === $status ? true : false, $this, $status);
1808 1808
     }
1809 1809
     
1810
-    public function add_item( $item_id = 0, $args = array() ) {
1810
+    public function add_item($item_id = 0, $args = array()) {
1811 1811
         global $wpi_current_id, $wpi_item_id;
1812 1812
         
1813
-        $item = new WPInv_Item( $item_id );
1813
+        $item = new WPInv_Item($item_id);
1814 1814
 
1815 1815
         // Bail if this post isn't a item
1816
-        if( !$item || $item->post_type !== 'wpi_item' ) {
1816
+        if (!$item || $item->post_type !== 'wpi_item') {
1817 1817
             return false;
1818 1818
         }
1819 1819
         
@@ -1832,8 +1832,8 @@  discard block
 block discarded – undo
1832 1832
             'fees'          => array()
1833 1833
         );
1834 1834
 
1835
-        $args = wp_parse_args( apply_filters( 'wpinv_add_item_args', $args, $item->ID ), $defaults );
1836
-        $args['quantity']   = $has_quantities && $args['quantity'] > 0 ? absint( $args['quantity'] ) : 1;
1835
+        $args = wp_parse_args(apply_filters('wpinv_add_item_args', $args, $item->ID), $defaults);
1836
+        $args['quantity'] = $has_quantities && $args['quantity'] > 0 ? absint($args['quantity']) : 1;
1837 1837
 
1838 1838
         $wpi_current_id         = $this->ID;
1839 1839
         $wpi_item_id            = $item->ID;
@@ -1845,19 +1845,19 @@  discard block
 block discarded – undo
1845 1845
         $found_cart_key         = false;
1846 1846
         
1847 1847
         if ($has_quantities) {
1848
-            $this->cart_details = !empty( $this->cart_details ) ? array_values( $this->cart_details ) : $this->cart_details;
1848
+            $this->cart_details = !empty($this->cart_details) ? array_values($this->cart_details) : $this->cart_details;
1849 1849
             
1850
-            foreach ( $this->items as $key => $cart_item ) {
1851
-                if ( (int)$item_id !== (int)$cart_item['id'] ) {
1850
+            foreach ($this->items as $key => $cart_item) {
1851
+                if ((int) $item_id !== (int) $cart_item['id']) {
1852 1852
                     continue;
1853 1853
                 }
1854 1854
 
1855
-                $this->items[ $key ]['quantity'] += $args['quantity'];
1855
+                $this->items[$key]['quantity'] += $args['quantity'];
1856 1856
                 break;
1857 1857
             }
1858 1858
             
1859
-            foreach ( $this->cart_details as $cart_key => $cart_item ) {
1860
-                if ( $item_id != $cart_item['id'] ) {
1859
+            foreach ($this->cart_details as $cart_key => $cart_item) {
1860
+                if ($item_id != $cart_item['id']) {
1861 1861
                     continue;
1862 1862
                 }
1863 1863
 
@@ -1869,29 +1869,29 @@  discard block
 block discarded – undo
1869 1869
         if ($has_quantities && $found_cart_key !== false) {
1870 1870
             $cart_item          = $this->cart_details[$found_cart_key];
1871 1871
             $item_price         = $cart_item['item_price'];
1872
-            $quantity           = !empty( $cart_item['quantity'] ) ? $cart_item['quantity'] : 1;
1873
-            $tax_rate           = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : 0;
1872
+            $quantity           = !empty($cart_item['quantity']) ? $cart_item['quantity'] : 1;
1873
+            $tax_rate           = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : 0;
1874 1874
             
1875 1875
             $new_quantity       = $quantity + $args['quantity'];
1876 1876
             $subtotal           = $item_price * $new_quantity;
1877 1877
             
1878 1878
             $args['quantity']   = $new_quantity;
1879
-            $discount           = !empty( $args['discount'] ) ? $args['discount'] : 0;
1880
-            $tax                = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
1879
+            $discount           = !empty($args['discount']) ? $args['discount'] : 0;
1880
+            $tax                = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
1881 1881
             
1882
-            $discount_increased = $discount > 0 && $subtotal > 0 && $discount > (float)$cart_item['discount'] ? $discount - (float)$cart_item['discount'] : 0;
1883
-            $tax_increased      = $tax > 0 && $subtotal > 0 && $tax > (float)$cart_item['tax'] ? $tax - (float)$cart_item['tax'] : 0;
1882
+            $discount_increased = $discount > 0 && $subtotal > 0 && $discount > (float) $cart_item['discount'] ? $discount - (float) $cart_item['discount'] : 0;
1883
+            $tax_increased      = $tax > 0 && $subtotal > 0 && $tax > (float) $cart_item['tax'] ? $tax - (float) $cart_item['tax'] : 0;
1884 1884
             // The total increase equals the number removed * the item_price
1885
-            $total_increased    = wpinv_round_amount( $item_price );
1885
+            $total_increased    = wpinv_round_amount($item_price);
1886 1886
             
1887
-            if ( wpinv_prices_include_tax() ) {
1888
-                $subtotal -= wpinv_round_amount( $tax );
1887
+            if (wpinv_prices_include_tax()) {
1888
+                $subtotal -= wpinv_round_amount($tax);
1889 1889
             }
1890 1890
 
1891
-            $total              = $subtotal - $discount + $tax;
1891
+            $total = $subtotal - $discount + $tax;
1892 1892
 
1893 1893
             // Do not allow totals to go negative
1894
-            if( $total < 0 ) {
1894
+            if ($total < 0) {
1895 1895
                 $total = 0;
1896 1896
             }
1897 1897
             
@@ -1907,25 +1907,25 @@  discard block
 block discarded – undo
1907 1907
             $this->cart_details[$found_cart_key] = $cart_item;
1908 1908
         } else {
1909 1909
             // Set custom price.
1910
-            if ( $args['custom_price'] !== '' ) {
1910
+            if ($args['custom_price'] !== '') {
1911 1911
                 $item_price = $args['custom_price'];
1912 1912
             } else {
1913 1913
                 // Allow overriding the price
1914
-                if ( false !== $args['item_price'] ) {
1914
+                if (false !== $args['item_price']) {
1915 1915
                     $item_price = $args['item_price'];
1916 1916
                 } else {
1917
-                    $item_price = wpinv_get_item_price( $item->ID );
1917
+                    $item_price = wpinv_get_item_price($item->ID);
1918 1918
                 }
1919 1919
             }
1920 1920
 
1921 1921
             // Sanitizing the price here so we don't have a dozen calls later
1922
-            $item_price = wpinv_sanitize_amount( $item_price );
1923
-            $subtotal   = wpinv_round_amount( $item_price * $args['quantity'] );
1922
+            $item_price = wpinv_sanitize_amount($item_price);
1923
+            $subtotal   = wpinv_round_amount($item_price * $args['quantity']);
1924 1924
         
1925
-            $discount   = !empty( $args['discount'] ) ? $args['discount'] : 0;
1926
-            $tax_class  = !empty( $args['vat_class'] ) ? $args['vat_class'] : '';
1927
-            $tax_rate   = !empty( $args['vat_rate'] ) ? $args['vat_rate'] : 0;
1928
-            $tax        = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
1925
+            $discount   = !empty($args['discount']) ? $args['discount'] : 0;
1926
+            $tax_class  = !empty($args['vat_class']) ? $args['vat_class'] : '';
1927
+            $tax_rate   = !empty($args['vat_rate']) ? $args['vat_rate'] : 0;
1928
+            $tax        = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
1929 1929
 
1930 1930
             // Setup the items meta item
1931 1931
             $new_item = array(
@@ -1933,29 +1933,29 @@  discard block
 block discarded – undo
1933 1933
                 'quantity' => $args['quantity'],
1934 1934
             );
1935 1935
 
1936
-            $this->items[]  = $new_item;
1936
+            $this->items[] = $new_item;
1937 1937
 
1938
-            if ( wpinv_prices_include_tax() ) {
1939
-                $subtotal -= wpinv_round_amount( $tax );
1938
+            if (wpinv_prices_include_tax()) {
1939
+                $subtotal -= wpinv_round_amount($tax);
1940 1940
             }
1941 1941
 
1942
-            $total      = $subtotal - $discount + $tax;
1942
+            $total = $subtotal - $discount + $tax;
1943 1943
 
1944 1944
             // Do not allow totals to go negative
1945
-            if( $total < 0 ) {
1945
+            if ($total < 0) {
1946 1946
                 $total = 0;
1947 1947
             }
1948 1948
         
1949 1949
             $this->cart_details[] = array(
1950 1950
                 'name'          => !empty($args['name']) ? $args['name'] : $item->get_name(),
1951 1951
                 'id'            => $item->ID,
1952
-                'item_price'    => wpinv_round_amount( $item_price ),
1953
-                'custom_price'  => ( $args['custom_price'] !== '' ? wpinv_round_amount( $args['custom_price'] ) : '' ),
1952
+                'item_price'    => wpinv_round_amount($item_price),
1953
+                'custom_price'  => ($args['custom_price'] !== '' ? wpinv_round_amount($args['custom_price']) : ''),
1954 1954
                 'quantity'      => $args['quantity'],
1955 1955
                 'discount'      => $discount,
1956
-                'subtotal'      => wpinv_round_amount( $subtotal ),
1957
-                'tax'           => wpinv_round_amount( $tax ),
1958
-                'price'         => wpinv_round_amount( $total ),
1956
+                'subtotal'      => wpinv_round_amount($subtotal),
1957
+                'tax'           => wpinv_round_amount($tax),
1958
+                'price'         => wpinv_round_amount($total),
1959 1959
                 'vat_rate'      => $tax_rate,
1960 1960
                 'vat_class'     => $tax_class,
1961 1961
                 'meta'          => $args['meta'],
@@ -1965,18 +1965,18 @@  discard block
 block discarded – undo
1965 1965
             $subtotal = $subtotal - $discount;
1966 1966
         }
1967 1967
         
1968
-        $added_item = end( $this->cart_details );
1969
-        $added_item['action']  = 'add';
1968
+        $added_item = end($this->cart_details);
1969
+        $added_item['action'] = 'add';
1970 1970
         
1971 1971
         $this->pending['items'][] = $added_item;
1972 1972
         
1973
-        $this->increase_subtotal( $subtotal );
1974
-        $this->increase_tax( $tax );
1973
+        $this->increase_subtotal($subtotal);
1974
+        $this->increase_tax($tax);
1975 1975
 
1976 1976
         return true;
1977 1977
     }
1978 1978
     
1979
-    public function remove_item( $item_id, $args = array() ) {
1979
+    public function remove_item($item_id, $args = array()) {
1980 1980
         // Set some defaults
1981 1981
         $defaults = array(
1982 1982
             'quantity'      => 1,
@@ -1984,51 +1984,51 @@  discard block
 block discarded – undo
1984 1984
             'custom_price'  => '',
1985 1985
             'cart_index'    => false,
1986 1986
         );
1987
-        $args = wp_parse_args( $args, $defaults );
1987
+        $args = wp_parse_args($args, $defaults);
1988 1988
 
1989 1989
         // Bail if this post isn't a item
1990
-        if ( get_post_type( $item_id ) !== 'wpi_item' ) {
1990
+        if (get_post_type($item_id) !== 'wpi_item') {
1991 1991
             return false;
1992 1992
         }
1993 1993
         
1994
-        $this->cart_details = !empty( $this->cart_details ) ? array_values( $this->cart_details ) : $this->cart_details;
1994
+        $this->cart_details = !empty($this->cart_details) ? array_values($this->cart_details) : $this->cart_details;
1995 1995
 
1996
-        foreach ( $this->items as $key => $item ) {
1997
-            if ( !empty($item['id']) && (int)$item_id !== (int)$item['id'] ) {
1996
+        foreach ($this->items as $key => $item) {
1997
+            if (!empty($item['id']) && (int) $item_id !== (int) $item['id']) {
1998 1998
                 continue;
1999 1999
             }
2000 2000
 
2001
-            if ( false !== $args['cart_index'] ) {
2002
-                $cart_index = absint( $args['cart_index'] );
2003
-                $cart_item  = ! empty( $this->cart_details[ $cart_index ] ) ? $this->cart_details[ $cart_index ] : false;
2001
+            if (false !== $args['cart_index']) {
2002
+                $cart_index = absint($args['cart_index']);
2003
+                $cart_item  = !empty($this->cart_details[$cart_index]) ? $this->cart_details[$cart_index] : false;
2004 2004
 
2005
-                if ( ! empty( $cart_item ) ) {
2005
+                if (!empty($cart_item)) {
2006 2006
                     // If the cart index item isn't the same item ID, don't remove it
2007
-                    if ( !empty($cart_item['id']) && $cart_item['id'] != $item['id'] ) {
2007
+                    if (!empty($cart_item['id']) && $cart_item['id'] != $item['id']) {
2008 2008
                         continue;
2009 2009
                     }
2010 2010
                 }
2011 2011
             }
2012 2012
 
2013
-            $item_quantity = $this->items[ $key ]['quantity'];
2014
-            if ( $item_quantity > $args['quantity'] ) {
2015
-                $this->items[ $key ]['quantity'] -= $args['quantity'];
2013
+            $item_quantity = $this->items[$key]['quantity'];
2014
+            if ($item_quantity > $args['quantity']) {
2015
+                $this->items[$key]['quantity'] -= $args['quantity'];
2016 2016
                 break;
2017 2017
             } else {
2018
-                unset( $this->items[ $key ] );
2018
+                unset($this->items[$key]);
2019 2019
                 break;
2020 2020
             }
2021 2021
         }
2022 2022
 
2023 2023
         $found_cart_key = false;
2024
-        if ( false === $args['cart_index'] ) {
2025
-            foreach ( $this->cart_details as $cart_key => $item ) {
2026
-                if ( $item_id != $item['id'] ) {
2024
+        if (false === $args['cart_index']) {
2025
+            foreach ($this->cart_details as $cart_key => $item) {
2026
+                if ($item_id != $item['id']) {
2027 2027
                     continue;
2028 2028
                 }
2029 2029
 
2030
-                if ( false !== $args['item_price'] ) {
2031
-                    if ( isset( $item['item_price'] ) && (float) $args['item_price'] != (float) $item['item_price'] ) {
2030
+                if (false !== $args['item_price']) {
2031
+                    if (isset($item['item_price']) && (float) $args['item_price'] != (float) $item['item_price']) {
2032 2032
                         continue;
2033 2033
                     }
2034 2034
                 }
@@ -2037,13 +2037,13 @@  discard block
 block discarded – undo
2037 2037
                 break;
2038 2038
             }
2039 2039
         } else {
2040
-            $cart_index = absint( $args['cart_index'] );
2040
+            $cart_index = absint($args['cart_index']);
2041 2041
 
2042
-            if ( ! array_key_exists( $cart_index, $this->cart_details ) ) {
2042
+            if (!array_key_exists($cart_index, $this->cart_details)) {
2043 2043
                 return false; // Invalid cart index passed.
2044 2044
             }
2045 2045
 
2046
-            if ( (int) $this->cart_details[ $cart_index ]['id'] > 0 && (int) $this->cart_details[ $cart_index ]['id'] !== (int) $item_id ) {
2046
+            if ((int) $this->cart_details[$cart_index]['id'] > 0 && (int) $this->cart_details[$cart_index]['id'] !== (int) $item_id) {
2047 2047
                 return false; // We still need the proper Item ID to be sure.
2048 2048
             }
2049 2049
 
@@ -2051,41 +2051,41 @@  discard block
 block discarded – undo
2051 2051
         }
2052 2052
         
2053 2053
         $cart_item  = $this->cart_details[$found_cart_key];
2054
-        $quantity   = !empty( $cart_item['quantity'] ) ? $cart_item['quantity'] : 1;
2054
+        $quantity   = !empty($cart_item['quantity']) ? $cart_item['quantity'] : 1;
2055 2055
         
2056
-        if ( count( $this->cart_details ) == 1 && ( $quantity - $args['quantity'] ) < 1 ) {
2056
+        if (count($this->cart_details) == 1 && ($quantity - $args['quantity']) < 1) {
2057 2057
             //return false; // Invoice must contain at least one item.
2058 2058
         }
2059 2059
         
2060
-        $discounts  = $this->get_discounts();
2060
+        $discounts = $this->get_discounts();
2061 2061
         
2062
-        if ( $quantity > $args['quantity'] ) {
2062
+        if ($quantity > $args['quantity']) {
2063 2063
             $item_price         = $cart_item['item_price'];
2064
-            $tax_rate           = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : 0;
2064
+            $tax_rate           = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : 0;
2065 2065
             
2066
-            $new_quantity       = max( $quantity - $args['quantity'], 1);
2066
+            $new_quantity       = max($quantity - $args['quantity'], 1);
2067 2067
             $subtotal           = $item_price * $new_quantity;
2068 2068
             
2069 2069
             $args['quantity']   = $new_quantity;
2070
-            $discount           = !empty( $cart_item['discount'] ) ? $cart_item['discount'] : 0;
2071
-            $tax                = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
2070
+            $discount           = !empty($cart_item['discount']) ? $cart_item['discount'] : 0;
2071
+            $tax                = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
2072 2072
             
2073
-            $discount_decrease  = (float)$cart_item['discount'] > 0 && $quantity > 0 ? wpinv_round_amount( ( (float)$cart_item['discount'] / $quantity ) ) : 0;
2074
-            $discount_decrease  = $discount > 0 && $subtotal > 0 && (float)$cart_item['discount'] > $discount ? (float)$cart_item['discount'] - $discount : $discount_decrease; 
2075
-            $tax_decrease       = (float)$cart_item['tax'] > 0 && $quantity > 0 ? wpinv_round_amount( ( (float)$cart_item['tax'] / $quantity ) ) : 0;
2076
-            $tax_decrease       = $tax > 0 && $subtotal > 0 && (float)$cart_item['tax'] > $tax ? (float)$cart_item['tax'] - $tax : $tax_decrease;
2073
+            $discount_decrease  = (float) $cart_item['discount'] > 0 && $quantity > 0 ? wpinv_round_amount(((float) $cart_item['discount'] / $quantity)) : 0;
2074
+            $discount_decrease  = $discount > 0 && $subtotal > 0 && (float) $cart_item['discount'] > $discount ? (float) $cart_item['discount'] - $discount : $discount_decrease; 
2075
+            $tax_decrease       = (float) $cart_item['tax'] > 0 && $quantity > 0 ? wpinv_round_amount(((float) $cart_item['tax'] / $quantity)) : 0;
2076
+            $tax_decrease       = $tax > 0 && $subtotal > 0 && (float) $cart_item['tax'] > $tax ? (float) $cart_item['tax'] - $tax : $tax_decrease;
2077 2077
             
2078 2078
             // The total increase equals the number removed * the item_price
2079
-            $total_decrease     = wpinv_round_amount( $item_price );
2079
+            $total_decrease     = wpinv_round_amount($item_price);
2080 2080
             
2081
-            if ( wpinv_prices_include_tax() ) {
2082
-                $subtotal -= wpinv_round_amount( $tax );
2081
+            if (wpinv_prices_include_tax()) {
2082
+                $subtotal -= wpinv_round_amount($tax);
2083 2083
             }
2084 2084
 
2085
-            $total              = $subtotal - $discount + $tax;
2085
+            $total = $subtotal - $discount + $tax;
2086 2086
 
2087 2087
             // Do not allow totals to go negative
2088
-            if( $total < 0 ) {
2088
+            if ($total < 0) {
2089 2089
                 $total = 0;
2090 2090
             }
2091 2091
             
@@ -2104,16 +2104,16 @@  discard block
 block discarded – undo
2104 2104
             
2105 2105
             $this->cart_details[$found_cart_key] = $cart_item;
2106 2106
             
2107
-            $remove_item = end( $this->cart_details );
2107
+            $remove_item = end($this->cart_details);
2108 2108
         } else {
2109 2109
             $item_price     = $cart_item['item_price'];
2110
-            $discount       = !empty( $cart_item['discount'] ) ? $cart_item['discount'] : 0;
2111
-            $tax            = !empty( $cart_item['tax'] ) ? $cart_item['tax'] : 0;
2110
+            $discount       = !empty($cart_item['discount']) ? $cart_item['discount'] : 0;
2111
+            $tax            = !empty($cart_item['tax']) ? $cart_item['tax'] : 0;
2112 2112
         
2113
-            $subtotal_decrease  = ( $item_price * $quantity ) - $discount;
2113
+            $subtotal_decrease  = ($item_price * $quantity) - $discount;
2114 2114
             $tax_decrease       = $tax;
2115 2115
 
2116
-            unset( $this->cart_details[$found_cart_key] );
2116
+            unset($this->cart_details[$found_cart_key]);
2117 2117
             
2118 2118
             $remove_item             = $args;
2119 2119
             $remove_item['id']       = $item_id;
@@ -2124,8 +2124,8 @@  discard block
 block discarded – undo
2124 2124
         $remove_item['action']      = 'remove';
2125 2125
         $this->pending['items'][]   = $remove_item;
2126 2126
                
2127
-        $this->decrease_subtotal( $subtotal_decrease );
2128
-        $this->decrease_tax( $tax_decrease );
2127
+        $this->decrease_subtotal($subtotal_decrease);
2128
+        $this->decrease_tax($tax_decrease);
2129 2129
         
2130 2130
         return true;
2131 2131
     }
@@ -2133,7 +2133,7 @@  discard block
 block discarded – undo
2133 2133
     public function update_items($temp = false) {
2134 2134
         global $wpinv_euvat, $wpi_current_id, $wpi_item_id, $wpi_nosave;
2135 2135
         
2136
-        if ( !empty( $this->cart_details ) ) {
2136
+        if (!empty($this->cart_details)) {
2137 2137
             $wpi_nosave             = $temp;
2138 2138
             $cart_subtotal          = 0;
2139 2139
             $cart_discount          = 0;
@@ -2143,65 +2143,65 @@  discard block
 block discarded – undo
2143 2143
             $_POST['wpinv_country'] = $this->country;
2144 2144
             $_POST['wpinv_state']   = $this->state;
2145 2145
 
2146
-            foreach ( $this->cart_details as $key => $item ) {
2146
+            foreach ($this->cart_details as $key => $item) {
2147 2147
                 $item_price = $item['item_price'];
2148
-                $quantity   = wpinv_item_quantities_enabled() && $item['quantity'] > 0 ? absint( $item['quantity'] ) : 1;
2149
-                $amount     = wpinv_round_amount( $item_price * $quantity );
2148
+                $quantity   = wpinv_item_quantities_enabled() && $item['quantity'] > 0 ? absint($item['quantity']) : 1;
2149
+                $amount     = wpinv_round_amount($item_price * $quantity);
2150 2150
                 $subtotal   = $item_price * $quantity;
2151 2151
                 
2152 2152
                 $wpi_current_id         = $this->ID;
2153 2153
                 $wpi_item_id            = $item['id'];
2154 2154
                 
2155
-                $discount   = wpinv_get_cart_item_discount_amount( $item, $this->get_discounts() );
2155
+                $discount   = wpinv_get_cart_item_discount_amount($item, $this->get_discounts());
2156 2156
                 
2157
-                $tax_rate   = wpinv_get_tax_rate( $this->country, $this->state, $wpi_item_id );
2158
-                $tax_class  = $wpinv_euvat->get_item_class( $wpi_item_id );
2159
-                $tax        = $item_price > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
2157
+                $tax_rate   = wpinv_get_tax_rate($this->country, $this->state, $wpi_item_id);
2158
+                $tax_class  = $wpinv_euvat->get_item_class($wpi_item_id);
2159
+                $tax        = $item_price > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
2160 2160
 
2161
-                if ( ! $this->is_taxable() ) {
2161
+                if (!$this->is_taxable()) {
2162 2162
                     $tax = 0;
2163 2163
                 }
2164 2164
 
2165
-                if ( wpinv_prices_include_tax() ) {
2166
-                    $subtotal -= wpinv_round_amount( $tax );
2165
+                if (wpinv_prices_include_tax()) {
2166
+                    $subtotal -= wpinv_round_amount($tax);
2167 2167
                 }
2168 2168
 
2169
-                $total      = $subtotal - $discount + $tax;
2169
+                $total = $subtotal - $discount + $tax;
2170 2170
 
2171 2171
                 // Do not allow totals to go negative
2172
-                if( $total < 0 ) {
2172
+                if ($total < 0) {
2173 2173
                     $total = 0;
2174 2174
                 }
2175 2175
 
2176 2176
                 $cart_details[] = array(
2177 2177
                     'id'          => $item['id'],
2178 2178
                     'name'        => $item['name'],
2179
-                    'item_price'  => wpinv_round_amount( $item_price ),
2180
-                    'custom_price'=> ( isset( $item['custom_price'] ) ? $item['custom_price'] : '' ),
2179
+                    'item_price'  => wpinv_round_amount($item_price),
2180
+                    'custom_price'=> (isset($item['custom_price']) ? $item['custom_price'] : ''),
2181 2181
                     'quantity'    => $quantity,
2182 2182
                     'discount'    => $discount,
2183
-                    'subtotal'    => wpinv_round_amount( $subtotal ),
2184
-                    'tax'         => wpinv_round_amount( $tax ),
2185
-                    'price'       => wpinv_round_amount( $total ),
2183
+                    'subtotal'    => wpinv_round_amount($subtotal),
2184
+                    'tax'         => wpinv_round_amount($tax),
2185
+                    'price'       => wpinv_round_amount($total),
2186 2186
                     'vat_rate'    => $tax_rate,
2187 2187
                     'vat_class'   => $tax_class,
2188 2188
                     'meta'        => isset($item['meta']) ? $item['meta'] : array(),
2189 2189
                     'fees'        => isset($item['fees']) ? $item['fees'] : array(),
2190 2190
                 );
2191 2191
 
2192
-                $cart_subtotal  += (float)($subtotal - $discount); // TODO
2193
-                $cart_discount  += (float)($discount);
2194
-                $cart_tax       += (float)($tax);
2192
+                $cart_subtotal  += (float) ($subtotal - $discount); // TODO
2193
+                $cart_discount  += (float) ($discount);
2194
+                $cart_tax       += (float) ($tax);
2195 2195
             }
2196
-            if ( $cart_subtotal < 0 ) {
2196
+            if ($cart_subtotal < 0) {
2197 2197
                 $cart_subtotal = 0;
2198 2198
             }
2199
-            if ( $cart_tax < 0 ) {
2199
+            if ($cart_tax < 0) {
2200 2200
                 $cart_tax = 0;
2201 2201
             }
2202
-            $this->subtotal = wpinv_round_amount( $cart_subtotal );
2203
-            $this->tax      = wpinv_round_amount( $cart_tax );
2204
-            $this->discount = wpinv_round_amount( $cart_discount );
2202
+            $this->subtotal = wpinv_round_amount($cart_subtotal);
2203
+            $this->tax      = wpinv_round_amount($cart_tax);
2204
+            $this->discount = wpinv_round_amount($cart_discount);
2205 2205
             
2206 2206
             $this->recalculate_total();
2207 2207
             
@@ -2213,177 +2213,177 @@  discard block
 block discarded – undo
2213 2213
     
2214 2214
     public function recalculate_totals($temp = false) {        
2215 2215
         $this->update_items($temp);
2216
-        $this->save( true );
2216
+        $this->save(true);
2217 2217
         
2218 2218
         return $this;
2219 2219
     }
2220 2220
     
2221 2221
     public function needs_payment() {
2222
-        $valid_invoice_statuses = apply_filters( 'wpinv_valid_invoice_statuses_for_payment', array( 'wpi-pending' ), $this );
2222
+        $valid_invoice_statuses = apply_filters('wpinv_valid_invoice_statuses_for_payment', array('wpi-pending'), $this);
2223 2223
 
2224
-        if ( $this->has_status( $valid_invoice_statuses ) && ( $this->get_total() > 0 || $this->is_free_trial() || $this->is_free() || $this->is_initial_free() ) ) {
2224
+        if ($this->has_status($valid_invoice_statuses) && ($this->get_total() > 0 || $this->is_free_trial() || $this->is_free() || $this->is_initial_free())) {
2225 2225
             $needs_payment = true;
2226 2226
         } else {
2227 2227
             $needs_payment = false;
2228 2228
         }
2229 2229
 
2230
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this, $valid_invoice_statuses );
2230
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this, $valid_invoice_statuses);
2231 2231
     }
2232 2232
     
2233
-    public function get_checkout_payment_url( $with_key = false, $secret = false ) {
2233
+    public function get_checkout_payment_url($with_key = false, $secret = false) {
2234 2234
         $pay_url = wpinv_get_checkout_uri();
2235 2235
 
2236
-        if ( is_ssl() ) {
2237
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
2236
+        if (is_ssl()) {
2237
+            $pay_url = str_replace('http:', 'https:', $pay_url);
2238 2238
         }
2239 2239
         
2240 2240
         $key = $this->get_key();
2241 2241
 
2242
-        if ( $with_key ) {
2243
-            $pay_url = add_query_arg( 'invoice_key', $key, $pay_url );
2242
+        if ($with_key) {
2243
+            $pay_url = add_query_arg('invoice_key', $key, $pay_url);
2244 2244
         } else {
2245
-            $pay_url = add_query_arg( array( 'wpi_action' => 'pay_for_invoice', 'invoice_key' => $key ), $pay_url );
2245
+            $pay_url = add_query_arg(array('wpi_action' => 'pay_for_invoice', 'invoice_key' => $key), $pay_url);
2246 2246
         }
2247 2247
         
2248
-        if ( $secret ) {
2249
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $key ) ), $pay_url );
2248
+        if ($secret) {
2249
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $key)), $pay_url);
2250 2250
         }
2251 2251
 
2252
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $with_key, $secret );
2252
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $with_key, $secret);
2253 2253
     }
2254 2254
     
2255
-    public function get_view_url( $with_key = false ) {
2256
-        $invoice_url = get_permalink( $this->ID );
2255
+    public function get_view_url($with_key = false) {
2256
+        $invoice_url = get_permalink($this->ID);
2257 2257
 
2258
-        if ( $with_key ) {
2259
-            $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
2258
+        if ($with_key) {
2259
+            $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
2260 2260
         }
2261 2261
 
2262
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this, $with_key );
2262
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this, $with_key);
2263 2263
     }
2264 2264
     
2265
-    public function generate_key( $string = '' ) {
2266
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
2267
-        return strtolower( md5( $string . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) );  // Unique key
2265
+    public function generate_key($string = '') {
2266
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
2267
+        return strtolower(md5($string . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))); // Unique key
2268 2268
     }
2269 2269
     
2270 2270
     public function is_recurring() {
2271
-        if ( empty( $this->cart_details ) ) {
2271
+        if (empty($this->cart_details)) {
2272 2272
             return false;
2273 2273
         }
2274 2274
         
2275 2275
         $has_subscription = false;
2276
-        foreach( $this->cart_details as $cart_item ) {
2277
-            if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] )  ) {
2276
+        foreach ($this->cart_details as $cart_item) {
2277
+            if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) {
2278 2278
                 $has_subscription = true;
2279 2279
                 break;
2280 2280
             }
2281 2281
         }
2282 2282
         
2283
-        if ( count( $this->cart_details ) > 1 ) {
2283
+        if (count($this->cart_details) > 1) {
2284 2284
             $has_subscription = false;
2285 2285
         }
2286 2286
 
2287
-        return apply_filters( 'wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details );
2287
+        return apply_filters('wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details);
2288 2288
     }
2289 2289
 
2290 2290
     public function is_free_trial() {
2291 2291
         $is_free_trial = false;
2292 2292
         
2293
-        if ( $this->is_parent() && $item = $this->get_recurring( true ) ) {
2294
-            if ( !empty( $item ) && $item->has_free_trial() ) {
2293
+        if ($this->is_parent() && $item = $this->get_recurring(true)) {
2294
+            if (!empty($item) && $item->has_free_trial()) {
2295 2295
                 $is_free_trial = true;
2296 2296
             }
2297 2297
         }
2298 2298
 
2299
-        return apply_filters( 'wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this );
2299
+        return apply_filters('wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this);
2300 2300
     }
2301 2301
 
2302 2302
     public function is_initial_free() {
2303 2303
         $is_initial_free = false;
2304 2304
         
2305
-        if ( ! ( (float)wpinv_round_amount( $this->get_total() ) > 0 ) && $this->is_parent() && $this->is_recurring() && ! $this->is_free_trial() && ! $this->is_free() ) {
2305
+        if (!((float) wpinv_round_amount($this->get_total()) > 0) && $this->is_parent() && $this->is_recurring() && !$this->is_free_trial() && !$this->is_free()) {
2306 2306
             $is_initial_free = true;
2307 2307
         }
2308 2308
 
2309
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->cart_details );
2309
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->cart_details);
2310 2310
     }
2311 2311
     
2312
-    public function get_recurring( $object = false ) {
2312
+    public function get_recurring($object = false) {
2313 2313
         $item = NULL;
2314 2314
         
2315
-        if ( empty( $this->cart_details ) ) {
2315
+        if (empty($this->cart_details)) {
2316 2316
             return $item;
2317 2317
         }
2318 2318
         
2319
-        foreach( $this->cart_details as $cart_item ) {
2320
-            if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] )  ) {
2319
+        foreach ($this->cart_details as $cart_item) {
2320
+            if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) {
2321 2321
                 $item = $cart_item['id'];
2322 2322
                 break;
2323 2323
             }
2324 2324
         }
2325 2325
         
2326
-        if ( $object ) {
2327
-            $item = $item ? new WPInv_Item( $item ) : NULL;
2326
+        if ($object) {
2327
+            $item = $item ? new WPInv_Item($item) : NULL;
2328 2328
             
2329
-            apply_filters( 'wpinv_invoice_get_recurring_item', $item, $this );
2329
+            apply_filters('wpinv_invoice_get_recurring_item', $item, $this);
2330 2330
         }
2331 2331
 
2332
-        return apply_filters( 'wpinv_invoice_get_recurring_item_id', $item, $this );
2332
+        return apply_filters('wpinv_invoice_get_recurring_item_id', $item, $this);
2333 2333
     }
2334 2334
 
2335 2335
     public function get_subscription_name() {
2336
-        $item = $this->get_recurring( true );
2336
+        $item = $this->get_recurring(true);
2337 2337
 
2338
-        if ( empty( $item ) ) {
2338
+        if (empty($item)) {
2339 2339
             return NULL;
2340 2340
         }
2341 2341
 
2342
-        if ( !($name = $item->get_name()) ) {
2342
+        if (!($name = $item->get_name())) {
2343 2343
             $name = $item->post_name;
2344 2344
         }
2345 2345
 
2346
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $name, $this );
2346
+        return apply_filters('wpinv_invoice_get_subscription_name', $name, $this);
2347 2347
     }
2348 2348
 
2349 2349
     public function get_subscription_id() {
2350
-        $subscription_id = $this->get_meta( '_wpinv_subscr_profile_id', true );
2350
+        $subscription_id = $this->get_meta('_wpinv_subscr_profile_id', true);
2351 2351
 
2352
-        if ( empty( $subscription_id ) && !empty( $this->parent_invoice ) ) {
2353
-            $parent_invoice = wpinv_get_invoice( $this->parent_invoice );
2352
+        if (empty($subscription_id) && !empty($this->parent_invoice)) {
2353
+            $parent_invoice = wpinv_get_invoice($this->parent_invoice);
2354 2354
 
2355
-            $subscription_id = $parent_invoice->get_meta( '_wpinv_subscr_profile_id', true );
2355
+            $subscription_id = $parent_invoice->get_meta('_wpinv_subscr_profile_id', true);
2356 2356
         }
2357 2357
         
2358 2358
         return $subscription_id;
2359 2359
     }
2360 2360
     
2361 2361
     public function is_parent() {
2362
-        $is_parent = empty( $this->parent_invoice ) ? true : false;
2362
+        $is_parent = empty($this->parent_invoice) ? true : false;
2363 2363
 
2364
-        return apply_filters( 'wpinv_invoice_is_parent', $is_parent, $this );
2364
+        return apply_filters('wpinv_invoice_is_parent', $is_parent, $this);
2365 2365
     }
2366 2366
     
2367 2367
     public function is_renewal() {
2368 2368
         $is_renewal = $this->parent_invoice && $this->parent_invoice != $this->ID ? true : false;
2369 2369
 
2370
-        return apply_filters( 'wpinv_invoice_is_renewal', $is_renewal, $this );
2370
+        return apply_filters('wpinv_invoice_is_renewal', $is_renewal, $this);
2371 2371
     }
2372 2372
     
2373 2373
     public function get_parent_payment() {
2374 2374
         $parent_payment = NULL;
2375 2375
         
2376
-        if ( $this->is_renewal() ) {
2377
-            $parent_payment = wpinv_get_invoice( $this->parent_invoice );
2376
+        if ($this->is_renewal()) {
2377
+            $parent_payment = wpinv_get_invoice($this->parent_invoice);
2378 2378
         }
2379 2379
         
2380 2380
         return $parent_payment;
2381 2381
     }
2382 2382
     
2383 2383
     public function is_paid() {
2384
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2384
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2385 2385
 
2386
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2386
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2387 2387
     }
2388 2388
 
2389 2389
     /**
@@ -2396,23 +2396,23 @@  discard block
 block discarded – undo
2396 2396
     }
2397 2397
     
2398 2398
     public function is_refunded() {
2399
-        $is_refunded = $this->has_status( array( 'wpi-refunded' ) );
2399
+        $is_refunded = $this->has_status(array('wpi-refunded'));
2400 2400
 
2401
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2401
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
2402 2402
     }
2403 2403
     
2404 2404
     public function is_free() {
2405 2405
         $is_free = false;
2406 2406
         
2407
-        if ( !( (float)wpinv_round_amount( $this->get_total() ) > 0 ) ) {
2408
-            if ( $this->is_parent() && $this->is_recurring() ) {
2409
-                $is_free = (float)wpinv_round_amount( $this->get_recurring_details( 'total' ) ) > 0 ? false : true;
2407
+        if (!((float) wpinv_round_amount($this->get_total()) > 0)) {
2408
+            if ($this->is_parent() && $this->is_recurring()) {
2409
+                $is_free = (float) wpinv_round_amount($this->get_recurring_details('total')) > 0 ? false : true;
2410 2410
             } else {
2411 2411
                 $is_free = true;
2412 2412
             }
2413 2413
         }
2414 2414
         
2415
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2415
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2416 2416
     }
2417 2417
     
2418 2418
     public function has_vat() {
@@ -2420,41 +2420,41 @@  discard block
 block discarded – undo
2420 2420
         
2421 2421
         $requires_vat = false;
2422 2422
         
2423
-        if ( $this->country ) {
2423
+        if ($this->country) {
2424 2424
             $wpi_country        = $this->country;
2425 2425
             
2426
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2426
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2427 2427
         }
2428 2428
         
2429
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2429
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2430 2430
     }
2431 2431
     
2432 2432
     public function refresh_item_ids() {
2433 2433
         $item_ids = array();
2434 2434
         
2435
-        if ( !empty( $this->cart_details ) ) {
2436
-            foreach ( $this->cart_details as $key => $item ) {
2437
-                if ( !empty( $item['id'] ) ) {
2435
+        if (!empty($this->cart_details)) {
2436
+            foreach ($this->cart_details as $key => $item) {
2437
+                if (!empty($item['id'])) {
2438 2438
                     $item_ids[] = $item['id'];
2439 2439
                 }
2440 2440
             }
2441 2441
         }
2442 2442
         
2443
-        $item_ids = !empty( $item_ids ) ? implode( ',', array_unique( $item_ids ) ) : '';
2443
+        $item_ids = !empty($item_ids) ? implode(',', array_unique($item_ids)) : '';
2444 2444
         
2445
-        update_post_meta( $this->ID, '_wpinv_item_ids', $item_ids );
2445
+        update_post_meta($this->ID, '_wpinv_item_ids', $item_ids);
2446 2446
     }
2447 2447
     
2448
-    public function get_invoice_quote_type( $post_id ) {
2449
-        if ( empty( $post_id ) ) {
2448
+    public function get_invoice_quote_type($post_id) {
2449
+        if (empty($post_id)) {
2450 2450
             return '';
2451 2451
         }
2452 2452
 
2453
-        $type = get_post_type( $post_id );
2453
+        $type = get_post_type($post_id);
2454 2454
 
2455
-        if ( 'wpi_invoice' === $type ) {
2455
+        if ('wpi_invoice' === $type) {
2456 2456
             $post_type = __('Invoice', 'invoicing');
2457
-        } else{
2457
+        } else {
2458 2458
             $post_type = __('Quote', 'invoicing');
2459 2459
         }
2460 2460
 
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2235 added lines, -2235 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'            => 0,
38
-		'status'               => 'wpi-pending',
39
-		'version'              => '',
40
-		'date_created'         => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'            => 0,
38
+        'status'               => 'wpi-pending',
39
+        'version'              => '',
40
+        'date_created'         => null,
41 41
         'date_modified'        => null,
42 42
         'due_date'             => null,
43 43
         'completed_date'       => null,
@@ -79,20 +79,20 @@  discard block
 block discarded – undo
79 79
         'transaction_id'       => '',
80 80
         'currency'             => '',
81 81
         'disable_taxes'        => false,
82
-		'subscription_id'      => null,
83
-		'is_viewed'            => false,
84
-		'email_cc'             => '',
85
-		'template'             => 'quantity', // hours, amount only
82
+        'subscription_id'      => null,
83
+        'is_viewed'            => false,
84
+        'email_cc'             => '',
85
+        'template'             => 'quantity', // hours, amount only
86 86
     );
87 87
 
88 88
     /**
89
-	 * Stores meta in cache for future reads.
90
-	 *
91
-	 * A group must be set to to enable caching.
92
-	 *
93
-	 * @var string
94
-	 */
95
-	protected $cache_group = 'getpaid_invoices';
89
+     * Stores meta in cache for future reads.
90
+     *
91
+     * A group must be set to to enable caching.
92
+     *
93
+     * @var string
94
+     */
95
+    protected $cache_group = 'getpaid_invoices';
96 96
 
97 97
     /**
98 98
      * Stores a reference to the original WP_Post object
@@ -106,104 +106,104 @@  discard block
 block discarded – undo
106 106
      *
107 107
      * @var int
108 108
      */
109
-	protected $recurring_item = null;
109
+    protected $recurring_item = null;
110 110
 
111
-	/**
111
+    /**
112 112
      * Stores an array of item totals.
113
-	 *
114
-	 * e.g $totals['discount'] = array(
115
-	 * 		'initial'   => 10,
116
-	 * 		'recurring' => 10,
117
-	 * )
113
+     *
114
+     * e.g $totals['discount'] = array(
115
+     * 		'initial'   => 10,
116
+     * 		'recurring' => 10,
117
+     * )
118 118
      *
119 119
      * @var array
120 120
      */
121
-	protected $totals = array();
121
+    protected $totals = array();
122 122
 
123
-	/**
124
-	 * Stores the status transition information.
125
-	 *
126
-	 * @since 1.0.19
127
-	 * @var bool
128
-	 */
129
-	protected $status_transition = false;
123
+    /**
124
+     * Stores the status transition information.
125
+     *
126
+     * @since 1.0.19
127
+     * @var bool
128
+     */
129
+    protected $status_transition = false;
130 130
 
131 131
     /**
132
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
133
-	 *
134
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
135
-	 */
132
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
133
+     *
134
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
135
+     */
136 136
     public function __construct( $invoice = false ) {
137 137
 
138 138
         parent::__construct( $invoice );
139 139
 
140
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
141
-			$this->set_id( $invoice );
142
-		} elseif ( $invoice instanceof self ) {
143
-			$this->set_id( $invoice->get_id() );
144
-		} elseif ( ! empty( $invoice->ID ) ) {
145
-			$this->set_id( $invoice->ID );
146
-		} elseif ( is_array( $invoice ) ) {
147
-			$this->set_props( $invoice );
148
-
149
-			if ( isset( $invoice['ID'] ) ) {
150
-				$this->set_id( $invoice['ID'] );
151
-			}
152
-
153
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
154
-			$this->set_id( $invoice_id );
155
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
156
-			$this->set_id( $invoice_id );
157
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
158
-			$this->set_id( $invoice_id );
159
-		}else {
160
-			$this->set_object_read( true );
161
-		}
140
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
141
+            $this->set_id( $invoice );
142
+        } elseif ( $invoice instanceof self ) {
143
+            $this->set_id( $invoice->get_id() );
144
+        } elseif ( ! empty( $invoice->ID ) ) {
145
+            $this->set_id( $invoice->ID );
146
+        } elseif ( is_array( $invoice ) ) {
147
+            $this->set_props( $invoice );
148
+
149
+            if ( isset( $invoice['ID'] ) ) {
150
+                $this->set_id( $invoice['ID'] );
151
+            }
152
+
153
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
154
+            $this->set_id( $invoice_id );
155
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
156
+            $this->set_id( $invoice_id );
157
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
158
+            $this->set_id( $invoice_id );
159
+        }else {
160
+            $this->set_object_read( true );
161
+        }
162 162
 
163 163
         // Load the datastore.
164
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
164
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
165 165
 
166
-		if ( $this->get_id() > 0 ) {
166
+        if ( $this->get_id() > 0 ) {
167 167
             $this->post = get_post( $this->get_id() );
168 168
             $this->ID   = $this->get_id();
169
-			$this->data_store->read( $this );
169
+            $this->data_store->read( $this );
170 170
         }
171 171
 
172 172
     }
173 173
 
174 174
     /**
175
-	 * Given an invoice key/number, it returns its id.
176
-	 *
177
-	 *
178
-	 * @static
179
-	 * @param string $value The invoice key or number
180
-	 * @param string $field Either key, transaction_id or number.
181
-	 * @since 1.0.15
182
-	 * @return int
183
-	 */
184
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
175
+     * Given an invoice key/number, it returns its id.
176
+     *
177
+     *
178
+     * @static
179
+     * @param string $value The invoice key or number
180
+     * @param string $field Either key, transaction_id or number.
181
+     * @since 1.0.15
182
+     * @return int
183
+     */
184
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
185 185
         global $wpdb;
186 186
 
187
-		// Trim the value.
188
-		$value = trim( $value );
187
+        // Trim the value.
188
+        $value = trim( $value );
189 189
 
190
-		if ( empty( $value ) ) {
191
-			return 0;
192
-		}
190
+        if ( empty( $value ) ) {
191
+            return 0;
192
+        }
193 193
 
194 194
         // Valid fields.
195 195
         $fields = array( 'key', 'number', 'transaction_id' );
196 196
 
197
-		// Ensure a field has been passed.
198
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
199
-			return 0;
200
-		}
197
+        // Ensure a field has been passed.
198
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
199
+            return 0;
200
+        }
201 201
 
202
-		// Maybe retrieve from the cache.
203
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
204
-		if ( ! empty( $invoice_id ) ) {
205
-			return $invoice_id;
206
-		}
202
+        // Maybe retrieve from the cache.
203
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
204
+        if ( ! empty( $invoice_id ) ) {
205
+            return $invoice_id;
206
+        }
207 207
 
208 208
         // Fetch from the db.
209 209
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
212 212
         );
213 213
 
214
-		if ( empty( $invoice_id ) ) {
215
-			return 0;
216
-		}
214
+        if ( empty( $invoice_id ) ) {
215
+            return 0;
216
+        }
217 217
 
218
-		// Update the cache with our data
219
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
218
+        // Update the cache with our data
219
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
220 220
 
221
-		return $invoice_id;
221
+        return $invoice_id;
222 222
     }
223 223
 
224 224
     /**
@@ -244,73 +244,73 @@  discard block
 block discarded – undo
244 244
     */
245 245
 
246 246
     /**
247
-	 * Get parent invoice ID.
248
-	 *
249
-	 * @since 1.0.19
250
-	 * @param  string $context View or edit context.
251
-	 * @return int
252
-	 */
253
-	public function get_parent_id( $context = 'view' ) {
254
-		return (int) $this->get_prop( 'parent_id', $context );
247
+     * Get parent invoice ID.
248
+     *
249
+     * @since 1.0.19
250
+     * @param  string $context View or edit context.
251
+     * @return int
252
+     */
253
+    public function get_parent_id( $context = 'view' ) {
254
+        return (int) $this->get_prop( 'parent_id', $context );
255 255
     }
256 256
 
257 257
     /**
258
-	 * Get parent invoice.
259
-	 *
260
-	 * @since 1.0.19
261
-	 * @return WPInv_Invoice
262
-	 */
258
+     * Get parent invoice.
259
+     *
260
+     * @since 1.0.19
261
+     * @return WPInv_Invoice
262
+     */
263 263
     public function get_parent_payment() {
264 264
         return new WPInv_Invoice( $this->get_parent_id() );
265 265
     }
266 266
 
267 267
     /**
268
-	 * Alias for self::get_parent_payment().
269
-	 *
270
-	 * @since 1.0.19
271
-	 * @return WPInv_Invoice
272
-	 */
268
+     * Alias for self::get_parent_payment().
269
+     *
270
+     * @since 1.0.19
271
+     * @return WPInv_Invoice
272
+     */
273 273
     public function get_parent() {
274 274
         return $this->get_parent_payment();
275 275
     }
276 276
 
277 277
     /**
278
-	 * Get invoice status.
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @param  string $context View or edit context.
282
-	 * @return string
283
-	 */
284
-	public function get_status( $context = 'view' ) {
285
-		return $this->get_prop( 'status', $context );
286
-	}
278
+     * Get invoice status.
279
+     *
280
+     * @since 1.0.19
281
+     * @param  string $context View or edit context.
282
+     * @return string
283
+     */
284
+    public function get_status( $context = 'view' ) {
285
+        return $this->get_prop( 'status', $context );
286
+    }
287 287
 	
288
-	/**
289
-	 * Retrieves an array of possible invoice statuses.
290
-	 *
291
-	 * @since 1.0.19
292
-	 * @return array
293
-	 */
294
-	public function get_all_statuses() {
295
-
296
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
297
-
298
-		// For backwards compatibility.
299
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
288
+    /**
289
+     * Retrieves an array of possible invoice statuses.
290
+     *
291
+     * @since 1.0.19
292
+     * @return array
293
+     */
294
+    public function get_all_statuses() {
295
+
296
+        $statuses = wpinv_get_invoice_statuses( true, true, $this );
297
+
298
+        // For backwards compatibility.
299
+        if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
300 300
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
301
-		}
301
+        }
302 302
 
303
-		return $statuses;
303
+        return $statuses;
304 304
     }
305 305
 
306 306
     /**
307
-	 * Get invoice status nice name.
308
-	 *
309
-	 * @since 1.0.19
310
-	 * @return string
311
-	 */
307
+     * Get invoice status nice name.
308
+     *
309
+     * @since 1.0.19
310
+     * @return string
311
+     */
312 312
     public function get_status_nicename() {
313
-		$statuses = $this->get_all_statuses();
313
+        $statuses = $this->get_all_statuses();
314 314
 
315 315
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
316 316
 
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
     }
319 319
 
320 320
     /**
321
-	 * Get plugin version when the invoice was created.
322
-	 *
323
-	 * @since 1.0.19
324
-	 * @param  string $context View or edit context.
325
-	 * @return string
326
-	 */
327
-	public function get_version( $context = 'view' ) {
328
-		return $this->get_prop( 'version', $context );
329
-	}
321
+     * Get plugin version when the invoice was created.
322
+     *
323
+     * @since 1.0.19
324
+     * @param  string $context View or edit context.
325
+     * @return string
326
+     */
327
+    public function get_version( $context = 'view' ) {
328
+        return $this->get_prop( 'version', $context );
329
+    }
330 330
 
331
-	/**
332
-	 * @deprecated
333
-	 */
334
-	public function get_invoice_date( $formatted = true ) {
331
+    /**
332
+     * @deprecated
333
+     */
334
+    public function get_invoice_date( $formatted = true ) {
335 335
         $date_completed = $this->get_date_completed();
336 336
         $invoice_date   = $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
337 337
 
@@ -348,187 +348,187 @@  discard block
 block discarded – undo
348 348
     }
349 349
 
350 350
     /**
351
-	 * Get date when the invoice was created.
352
-	 *
353
-	 * @since 1.0.19
354
-	 * @param  string $context View or edit context.
355
-	 * @return string
356
-	 */
357
-	public function get_date_created( $context = 'view' ) {
358
-		return $this->get_prop( 'date_created', $context );
359
-	}
351
+     * Get date when the invoice was created.
352
+     *
353
+     * @since 1.0.19
354
+     * @param  string $context View or edit context.
355
+     * @return string
356
+     */
357
+    public function get_date_created( $context = 'view' ) {
358
+        return $this->get_prop( 'date_created', $context );
359
+    }
360 360
 	
361
-	/**
362
-	 * Alias for self::get_date_created().
363
-	 *
364
-	 * @since 1.0.19
365
-	 * @param  string $context View or edit context.
366
-	 * @return string
367
-	 */
368
-	public function get_created_date( $context = 'view' ) {
369
-		return $this->get_date_created( $context );
370
-    }
371
-
372
-    /**
373
-	 * Get GMT date when the invoice was created.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_date_created_gmt( $context = 'view' ) {
361
+    /**
362
+     * Alias for self::get_date_created().
363
+     *
364
+     * @since 1.0.19
365
+     * @param  string $context View or edit context.
366
+     * @return string
367
+     */
368
+    public function get_created_date( $context = 'view' ) {
369
+        return $this->get_date_created( $context );
370
+    }
371
+
372
+    /**
373
+     * Get GMT date when the invoice was created.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_date_created_gmt( $context = 'view' ) {
380 380
         $date = $this->get_date_created( $context );
381 381
 
382 382
         if ( $date ) {
383 383
             $date = get_gmt_from_date( $date );
384 384
         }
385
-		return $date;
385
+        return $date;
386 386
     }
387 387
 
388 388
     /**
389
-	 * Get date when the invoice was last modified.
390
-	 *
391
-	 * @since 1.0.19
392
-	 * @param  string $context View or edit context.
393
-	 * @return string
394
-	 */
395
-	public function get_date_modified( $context = 'view' ) {
396
-		return $this->get_prop( 'date_modified', $context );
397
-	}
389
+     * Get date when the invoice was last modified.
390
+     *
391
+     * @since 1.0.19
392
+     * @param  string $context View or edit context.
393
+     * @return string
394
+     */
395
+    public function get_date_modified( $context = 'view' ) {
396
+        return $this->get_prop( 'date_modified', $context );
397
+    }
398 398
 
399
-	/**
400
-	 * Alias for self::get_date_modified().
401
-	 *
402
-	 * @since 1.0.19
403
-	 * @param  string $context View or edit context.
404
-	 * @return string
405
-	 */
406
-	public function get_modified_date( $context = 'view' ) {
407
-		return $this->get_date_modified( $context );
399
+    /**
400
+     * Alias for self::get_date_modified().
401
+     *
402
+     * @since 1.0.19
403
+     * @param  string $context View or edit context.
404
+     * @return string
405
+     */
406
+    public function get_modified_date( $context = 'view' ) {
407
+        return $this->get_date_modified( $context );
408 408
     }
409 409
 
410 410
     /**
411
-	 * Get GMT date when the invoice was last modified.
412
-	 *
413
-	 * @since 1.0.19
414
-	 * @param  string $context View or edit context.
415
-	 * @return string
416
-	 */
417
-	public function get_date_modified_gmt( $context = 'view' ) {
411
+     * Get GMT date when the invoice was last modified.
412
+     *
413
+     * @since 1.0.19
414
+     * @param  string $context View or edit context.
415
+     * @return string
416
+     */
417
+    public function get_date_modified_gmt( $context = 'view' ) {
418 418
         $date = $this->get_date_modified( $context );
419 419
 
420 420
         if ( $date ) {
421 421
             $date = get_gmt_from_date( $date );
422 422
         }
423
-		return $date;
423
+        return $date;
424 424
     }
425 425
 
426 426
     /**
427
-	 * Get the invoice due date.
428
-	 *
429
-	 * @since 1.0.19
430
-	 * @param  string $context View or edit context.
431
-	 * @return string
432
-	 */
433
-	public function get_due_date( $context = 'view' ) {
434
-		return $this->get_prop( 'due_date', $context );
427
+     * Get the invoice due date.
428
+     *
429
+     * @since 1.0.19
430
+     * @param  string $context View or edit context.
431
+     * @return string
432
+     */
433
+    public function get_due_date( $context = 'view' ) {
434
+        return $this->get_prop( 'due_date', $context );
435 435
     }
436 436
 
437 437
     /**
438
-	 * Alias for self::get_due_date().
439
-	 *
440
-	 * @since 1.0.19
441
-	 * @param  string $context View or edit context.
442
-	 * @return string
443
-	 */
444
-	public function get_date_due( $context = 'view' ) {
445
-		return $this->get_due_date( $context );
438
+     * Alias for self::get_due_date().
439
+     *
440
+     * @since 1.0.19
441
+     * @param  string $context View or edit context.
442
+     * @return string
443
+     */
444
+    public function get_date_due( $context = 'view' ) {
445
+        return $this->get_due_date( $context );
446 446
     }
447 447
 
448 448
     /**
449
-	 * Get the invoice GMT due date.
450
-	 *
451
-	 * @since 1.0.19
452
-	 * @param  string $context View or edit context.
453
-	 * @return string
454
-	 */
455
-	public function get_due_date_gmt( $context = 'view' ) {
449
+     * Get the invoice GMT due date.
450
+     *
451
+     * @since 1.0.19
452
+     * @param  string $context View or edit context.
453
+     * @return string
454
+     */
455
+    public function get_due_date_gmt( $context = 'view' ) {
456 456
         $date = $this->get_due_date( $context );
457 457
 
458 458
         if ( $date ) {
459 459
             $date = get_gmt_from_date( $date );
460 460
         }
461
-		return $date;
461
+        return $date;
462 462
     }
463 463
 
464 464
     /**
465
-	 * Alias for self::get_due_date_gmt().
466
-	 *
467
-	 * @since 1.0.19
468
-	 * @param  string $context View or edit context.
469
-	 * @return string
470
-	 */
471
-	public function get_gmt_date_due( $context = 'view' ) {
472
-		return $this->get_due_date_gmt( $context );
465
+     * Alias for self::get_due_date_gmt().
466
+     *
467
+     * @since 1.0.19
468
+     * @param  string $context View or edit context.
469
+     * @return string
470
+     */
471
+    public function get_gmt_date_due( $context = 'view' ) {
472
+        return $this->get_due_date_gmt( $context );
473 473
     }
474 474
 
475 475
     /**
476
-	 * Get date when the invoice was completed.
477
-	 *
478
-	 * @since 1.0.19
479
-	 * @param  string $context View or edit context.
480
-	 * @return string
481
-	 */
482
-	public function get_completed_date( $context = 'view' ) {
483
-		return $this->get_prop( 'completed_date', $context );
476
+     * Get date when the invoice was completed.
477
+     *
478
+     * @since 1.0.19
479
+     * @param  string $context View or edit context.
480
+     * @return string
481
+     */
482
+    public function get_completed_date( $context = 'view' ) {
483
+        return $this->get_prop( 'completed_date', $context );
484 484
     }
485 485
 
486 486
     /**
487
-	 * Alias for self::get_completed_date().
488
-	 *
489
-	 * @since 1.0.19
490
-	 * @param  string $context View or edit context.
491
-	 * @return string
492
-	 */
493
-	public function get_date_completed( $context = 'view' ) {
494
-		return $this->get_completed_date( $context );
487
+     * Alias for self::get_completed_date().
488
+     *
489
+     * @since 1.0.19
490
+     * @param  string $context View or edit context.
491
+     * @return string
492
+     */
493
+    public function get_date_completed( $context = 'view' ) {
494
+        return $this->get_completed_date( $context );
495 495
     }
496 496
 
497 497
     /**
498
-	 * Get GMT date when the invoice was was completed.
499
-	 *
500
-	 * @since 1.0.19
501
-	 * @param  string $context View or edit context.
502
-	 * @return string
503
-	 */
504
-	public function get_completed_date_gmt( $context = 'view' ) {
498
+     * Get GMT date when the invoice was was completed.
499
+     *
500
+     * @since 1.0.19
501
+     * @param  string $context View or edit context.
502
+     * @return string
503
+     */
504
+    public function get_completed_date_gmt( $context = 'view' ) {
505 505
         $date = $this->get_completed_date( $context );
506 506
 
507 507
         if ( $date ) {
508 508
             $date = get_gmt_from_date( $date );
509 509
         }
510
-		return $date;
510
+        return $date;
511 511
     }
512 512
 
513 513
     /**
514
-	 * Alias for self::get_completed_date_gmt().
515
-	 *
516
-	 * @since 1.0.19
517
-	 * @param  string $context View or edit context.
518
-	 * @return string
519
-	 */
520
-	public function get_gmt_completed_date( $context = 'view' ) {
521
-		return $this->get_completed_date_gmt( $context );
514
+     * Alias for self::get_completed_date_gmt().
515
+     *
516
+     * @since 1.0.19
517
+     * @param  string $context View or edit context.
518
+     * @return string
519
+     */
520
+    public function get_gmt_completed_date( $context = 'view' ) {
521
+        return $this->get_completed_date_gmt( $context );
522 522
     }
523 523
 
524 524
     /**
525
-	 * Get the invoice number.
526
-	 *
527
-	 * @since 1.0.19
528
-	 * @param  string $context View or edit context.
529
-	 * @return string
530
-	 */
531
-	public function get_number( $context = 'view' ) {
525
+     * Get the invoice number.
526
+     *
527
+     * @since 1.0.19
528
+     * @param  string $context View or edit context.
529
+     * @return string
530
+     */
531
+    public function get_number( $context = 'view' ) {
532 532
         $number = $this->get_prop( 'number', $context );
533 533
 
534 534
         if ( empty( $number ) ) {
@@ -536,17 +536,17 @@  discard block
 block discarded – undo
536 536
             $this->set_number( $number );
537 537
         }
538 538
 
539
-		return $number;
539
+        return $number;
540 540
     }
541 541
 
542 542
     /**
543
-	 * Get the invoice key.
544
-	 *
545
-	 * @since 1.0.19
546
-	 * @param  string $context View or edit context.
547
-	 * @return string
548
-	 */
549
-	public function get_key( $context = 'view' ) {
543
+     * Get the invoice key.
544
+     *
545
+     * @since 1.0.19
546
+     * @param  string $context View or edit context.
547
+     * @return string
548
+     */
549
+    public function get_key( $context = 'view' ) {
550 550
         $key = $this->get_prop( 'key', $context );
551 551
 
552 552
         if ( empty( $key ) ) {
@@ -554,24 +554,24 @@  discard block
 block discarded – undo
554 554
             $this->set_key( $key );
555 555
         }
556 556
 
557
-		return $key;
557
+        return $key;
558 558
     }
559 559
 
560 560
     /**
561
-	 * Get the invoice type.
562
-	 *
563
-	 * @since 1.0.19
564
-	 * @param  string $context View or edit context.
565
-	 * @return string
566
-	 */
567
-	public function get_type( $context = 'view' ) {
561
+     * Get the invoice type.
562
+     *
563
+     * @since 1.0.19
564
+     * @param  string $context View or edit context.
565
+     * @return string
566
+     */
567
+    public function get_type( $context = 'view' ) {
568 568
         return $this->get_prop( 'type', $context );
569
-	}
569
+    }
570 570
 
571
-	/**
572
-	 * @deprecated
573
-	 */
574
-	public function get_invoice_quote_type( $post_id ) {
571
+    /**
572
+     * @deprecated
573
+     */
574
+    public function get_invoice_quote_type( $post_id ) {
575 575
         if ( empty( $post_id ) ) {
576 576
             return '';
577 577
         }
@@ -588,35 +588,35 @@  discard block
 block discarded – undo
588 588
     }
589 589
 
590 590
     /**
591
-	 * Get the invoice post type.
592
-	 *
593
-	 * @since 1.0.19
594
-	 * @param  string $context View or edit context.
595
-	 * @return string
596
-	 */
597
-	public function get_post_type( $context = 'view' ) {
591
+     * Get the invoice post type.
592
+     *
593
+     * @since 1.0.19
594
+     * @param  string $context View or edit context.
595
+     * @return string
596
+     */
597
+    public function get_post_type( $context = 'view' ) {
598 598
         return $this->get_prop( 'post_type', $context );
599 599
     }
600 600
 
601 601
     /**
602
-	 * Get the invoice mode.
603
-	 *
604
-	 * @since 1.0.19
605
-	 * @param  string $context View or edit context.
606
-	 * @return string
607
-	 */
608
-	public function get_mode( $context = 'view' ) {
602
+     * Get the invoice mode.
603
+     *
604
+     * @since 1.0.19
605
+     * @param  string $context View or edit context.
606
+     * @return string
607
+     */
608
+    public function get_mode( $context = 'view' ) {
609 609
         return $this->get_prop( 'mode', $context );
610 610
     }
611 611
 
612 612
     /**
613
-	 * Get the invoice path.
614
-	 *
615
-	 * @since 1.0.19
616
-	 * @param  string $context View or edit context.
617
-	 * @return string
618
-	 */
619
-	public function get_path( $context = 'view' ) {
613
+     * Get the invoice path.
614
+     *
615
+     * @since 1.0.19
616
+     * @param  string $context View or edit context.
617
+     * @return string
618
+     */
619
+    public function get_path( $context = 'view' ) {
620 620
         $path = $this->get_prop( 'path', $context );
621 621
 
622 622
         if ( empty( $path ) ) {
@@ -624,73 +624,73 @@  discard block
 block discarded – undo
624 624
             $path   = sanitize_title( $prefix . $this->get_id() );
625 625
         }
626 626
 
627
-		return $path;
627
+        return $path;
628 628
     }
629 629
 
630 630
     /**
631
-	 * Get the invoice name/title.
632
-	 *
633
-	 * @since 1.0.19
634
-	 * @param  string $context View or edit context.
635
-	 * @return string
636
-	 */
637
-	public function get_name( $context = 'view' ) {
631
+     * Get the invoice name/title.
632
+     *
633
+     * @since 1.0.19
634
+     * @param  string $context View or edit context.
635
+     * @return string
636
+     */
637
+    public function get_name( $context = 'view' ) {
638 638
         $name = $this->get_prop( 'title', $context );
639 639
 
640
-		return empty( $name ) ? $this->get_number( $context ) : $name;
640
+        return empty( $name ) ? $this->get_number( $context ) : $name;
641 641
     }
642 642
 
643 643
     /**
644
-	 * Alias of self::get_name().
645
-	 *
646
-	 * @since 1.0.19
647
-	 * @param  string $context View or edit context.
648
-	 * @return string
649
-	 */
650
-	public function get_title( $context = 'view' ) {
651
-		return $this->get_name( $context );
644
+     * Alias of self::get_name().
645
+     *
646
+     * @since 1.0.19
647
+     * @param  string $context View or edit context.
648
+     * @return string
649
+     */
650
+    public function get_title( $context = 'view' ) {
651
+        return $this->get_name( $context );
652 652
     }
653 653
 
654 654
     /**
655
-	 * Get the invoice description.
656
-	 *
657
-	 * @since 1.0.19
658
-	 * @param  string $context View or edit context.
659
-	 * @return string
660
-	 */
661
-	public function get_description( $context = 'view' ) {
662
-		return $this->get_prop( 'description', $context );
655
+     * Get the invoice description.
656
+     *
657
+     * @since 1.0.19
658
+     * @param  string $context View or edit context.
659
+     * @return string
660
+     */
661
+    public function get_description( $context = 'view' ) {
662
+        return $this->get_prop( 'description', $context );
663 663
     }
664 664
 
665 665
     /**
666
-	 * Alias of self::get_description().
667
-	 *
668
-	 * @since 1.0.19
669
-	 * @param  string $context View or edit context.
670
-	 * @return string
671
-	 */
672
-	public function get_excerpt( $context = 'view' ) {
673
-		return $this->get_description( $context );
666
+     * Alias of self::get_description().
667
+     *
668
+     * @since 1.0.19
669
+     * @param  string $context View or edit context.
670
+     * @return string
671
+     */
672
+    public function get_excerpt( $context = 'view' ) {
673
+        return $this->get_description( $context );
674 674
     }
675 675
 
676 676
     /**
677
-	 * Alias of self::get_description().
678
-	 *
679
-	 * @since 1.0.19
680
-	 * @param  string $context View or edit context.
681
-	 * @return string
682
-	 */
683
-	public function get_summary( $context = 'view' ) {
684
-		return $this->get_description( $context );
677
+     * Alias of self::get_description().
678
+     *
679
+     * @since 1.0.19
680
+     * @param  string $context View or edit context.
681
+     * @return string
682
+     */
683
+    public function get_summary( $context = 'view' ) {
684
+        return $this->get_description( $context );
685 685
     }
686 686
 
687 687
     /**
688
-	 * Returns the user info.
689
-	 *
690
-	 * @since 1.0.19
688
+     * Returns the user info.
689
+     *
690
+     * @since 1.0.19
691 691
      * @param  string $context View or edit context.
692
-	 * @return array
693
-	 */
692
+     * @return array
693
+     */
694 694
     public function get_user_info( $context = 'view' ) {
695 695
 
696 696
         $user_info = array(
@@ -707,605 +707,605 @@  discard block
 block discarded – undo
707 707
             'company'    => $this->get_company( $context ),
708 708
             'vat_number' => $this->get_vat_number( $context ),
709 709
             'discount'   => $this->get_discount_code( $context ),
710
-		);
710
+        );
711 711
 
712
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
712
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
713 713
 
714 714
     }
715 715
 
716 716
     /**
717
-	 * Get the customer id.
718
-	 *
719
-	 * @since 1.0.19
720
-	 * @param  string $context View or edit context.
721
-	 * @return int
722
-	 */
723
-	public function get_author( $context = 'view' ) {
724
-		return (int) $this->get_prop( 'author', $context );
717
+     * Get the customer id.
718
+     *
719
+     * @since 1.0.19
720
+     * @param  string $context View or edit context.
721
+     * @return int
722
+     */
723
+    public function get_author( $context = 'view' ) {
724
+        return (int) $this->get_prop( 'author', $context );
725 725
     }
726 726
 
727 727
     /**
728
-	 * Alias of self::get_author().
729
-	 *
730
-	 * @since 1.0.19
731
-	 * @param  string $context View or edit context.
732
-	 * @return int
733
-	 */
734
-	public function get_user_id( $context = 'view' ) {
735
-		return $this->get_author( $context );
728
+     * Alias of self::get_author().
729
+     *
730
+     * @since 1.0.19
731
+     * @param  string $context View or edit context.
732
+     * @return int
733
+     */
734
+    public function get_user_id( $context = 'view' ) {
735
+        return $this->get_author( $context );
736 736
     }
737 737
 
738
-     /**
739
-	 * Alias of self::get_author().
740
-	 *
741
-	 * @since 1.0.19
742
-	 * @param  string $context View or edit context.
743
-	 * @return int
744
-	 */
745
-	public function get_customer_id( $context = 'view' ) {
746
-		return $this->get_author( $context );
738
+        /**
739
+         * Alias of self::get_author().
740
+         *
741
+         * @since 1.0.19
742
+         * @param  string $context View or edit context.
743
+         * @return int
744
+         */
745
+    public function get_customer_id( $context = 'view' ) {
746
+        return $this->get_author( $context );
747 747
     }
748 748
 
749 749
     /**
750
-	 * Get the customer's ip.
751
-	 *
752
-	 * @since 1.0.19
753
-	 * @param  string $context View or edit context.
754
-	 * @return string
755
-	 */
756
-	public function get_ip( $context = 'view' ) {
757
-		return $this->get_prop( 'user_ip', $context );
750
+     * Get the customer's ip.
751
+     *
752
+     * @since 1.0.19
753
+     * @param  string $context View or edit context.
754
+     * @return string
755
+     */
756
+    public function get_ip( $context = 'view' ) {
757
+        return $this->get_prop( 'user_ip', $context );
758 758
     }
759 759
 
760 760
     /**
761
-	 * Alias of self::get_ip().
762
-	 *
763
-	 * @since 1.0.19
764
-	 * @param  string $context View or edit context.
765
-	 * @return string
766
-	 */
767
-	public function get_user_ip( $context = 'view' ) {
768
-		return $this->get_ip( $context );
761
+     * Alias of self::get_ip().
762
+     *
763
+     * @since 1.0.19
764
+     * @param  string $context View or edit context.
765
+     * @return string
766
+     */
767
+    public function get_user_ip( $context = 'view' ) {
768
+        return $this->get_ip( $context );
769 769
     }
770 770
 
771
-     /**
772
-	 * Alias of self::get_ip().
773
-	 *
774
-	 * @since 1.0.19
775
-	 * @param  string $context View or edit context.
776
-	 * @return string
777
-	 */
778
-	public function get_customer_ip( $context = 'view' ) {
779
-		return $this->get_ip( $context );
771
+        /**
772
+         * Alias of self::get_ip().
773
+         *
774
+         * @since 1.0.19
775
+         * @param  string $context View or edit context.
776
+         * @return string
777
+         */
778
+    public function get_customer_ip( $context = 'view' ) {
779
+        return $this->get_ip( $context );
780 780
     }
781 781
 
782 782
     /**
783
-	 * Get the customer's first name.
784
-	 *
785
-	 * @since 1.0.19
786
-	 * @param  string $context View or edit context.
787
-	 * @return string
788
-	 */
789
-	public function get_first_name( $context = 'view' ) {
790
-		return $this->get_prop( 'first_name', $context );
783
+     * Get the customer's first name.
784
+     *
785
+     * @since 1.0.19
786
+     * @param  string $context View or edit context.
787
+     * @return string
788
+     */
789
+    public function get_first_name( $context = 'view' ) {
790
+        return $this->get_prop( 'first_name', $context );
791 791
     }
792 792
 
793 793
     /**
794
-	 * Alias of self::get_first_name().
795
-	 *
796
-	 * @since 1.0.19
797
-	 * @param  string $context View or edit context.
798
-	 * @return int
799
-	 */
800
-	public function get_user_first_name( $context = 'view' ) {
801
-		return $this->get_first_name( $context );
794
+     * Alias of self::get_first_name().
795
+     *
796
+     * @since 1.0.19
797
+     * @param  string $context View or edit context.
798
+     * @return int
799
+     */
800
+    public function get_user_first_name( $context = 'view' ) {
801
+        return $this->get_first_name( $context );
802 802
     }
803 803
 
804
-     /**
805
-	 * Alias of self::get_first_name().
806
-	 *
807
-	 * @since 1.0.19
808
-	 * @param  string $context View or edit context.
809
-	 * @return int
810
-	 */
811
-	public function get_customer_first_name( $context = 'view' ) {
812
-		return $this->get_first_name( $context );
804
+        /**
805
+         * Alias of self::get_first_name().
806
+         *
807
+         * @since 1.0.19
808
+         * @param  string $context View or edit context.
809
+         * @return int
810
+         */
811
+    public function get_customer_first_name( $context = 'view' ) {
812
+        return $this->get_first_name( $context );
813 813
     }
814 814
 
815 815
     /**
816
-	 * Get the customer's last name.
817
-	 *
818
-	 * @since 1.0.19
819
-	 * @param  string $context View or edit context.
820
-	 * @return string
821
-	 */
822
-	public function get_last_name( $context = 'view' ) {
823
-		return $this->get_prop( 'last_name', $context );
816
+     * Get the customer's last name.
817
+     *
818
+     * @since 1.0.19
819
+     * @param  string $context View or edit context.
820
+     * @return string
821
+     */
822
+    public function get_last_name( $context = 'view' ) {
823
+        return $this->get_prop( 'last_name', $context );
824 824
     }
825 825
 
826 826
     /**
827
-	 * Alias of self::get_last_name().
828
-	 *
829
-	 * @since 1.0.19
830
-	 * @param  string $context View or edit context.
831
-	 * @return int
832
-	 */
833
-	public function get_user_last_name( $context = 'view' ) {
834
-		return $this->get_last_name( $context );
827
+     * Alias of self::get_last_name().
828
+     *
829
+     * @since 1.0.19
830
+     * @param  string $context View or edit context.
831
+     * @return int
832
+     */
833
+    public function get_user_last_name( $context = 'view' ) {
834
+        return $this->get_last_name( $context );
835 835
     }
836 836
 
837 837
     /**
838
-	 * Alias of self::get_last_name().
839
-	 *
840
-	 * @since 1.0.19
841
-	 * @param  string $context View or edit context.
842
-	 * @return int
843
-	 */
844
-	public function get_customer_last_name( $context = 'view' ) {
845
-		return $this->get_last_name( $context );
838
+     * Alias of self::get_last_name().
839
+     *
840
+     * @since 1.0.19
841
+     * @param  string $context View or edit context.
842
+     * @return int
843
+     */
844
+    public function get_customer_last_name( $context = 'view' ) {
845
+        return $this->get_last_name( $context );
846 846
     }
847 847
 
848 848
     /**
849
-	 * Get the customer's full name.
850
-	 *
851
-	 * @since 1.0.19
852
-	 * @param  string $context View or edit context.
853
-	 * @return string
854
-	 */
855
-	public function get_full_name( $context = 'view' ) {
856
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
849
+     * Get the customer's full name.
850
+     *
851
+     * @since 1.0.19
852
+     * @param  string $context View or edit context.
853
+     * @return string
854
+     */
855
+    public function get_full_name( $context = 'view' ) {
856
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
857 857
     }
858 858
 
859 859
     /**
860
-	 * Alias of self::get_full_name().
861
-	 *
862
-	 * @since 1.0.19
863
-	 * @param  string $context View or edit context.
864
-	 * @return int
865
-	 */
866
-	public function get_user_full_name( $context = 'view' ) {
867
-		return $this->get_full_name( $context );
860
+     * Alias of self::get_full_name().
861
+     *
862
+     * @since 1.0.19
863
+     * @param  string $context View or edit context.
864
+     * @return int
865
+     */
866
+    public function get_user_full_name( $context = 'view' ) {
867
+        return $this->get_full_name( $context );
868 868
     }
869 869
 
870 870
     /**
871
-	 * Alias of self::get_full_name().
872
-	 *
873
-	 * @since 1.0.19
874
-	 * @param  string $context View or edit context.
875
-	 * @return int
876
-	 */
877
-	public function get_customer_full_name( $context = 'view' ) {
878
-		return $this->get_full_name( $context );
871
+     * Alias of self::get_full_name().
872
+     *
873
+     * @since 1.0.19
874
+     * @param  string $context View or edit context.
875
+     * @return int
876
+     */
877
+    public function get_customer_full_name( $context = 'view' ) {
878
+        return $this->get_full_name( $context );
879 879
     }
880 880
 
881 881
     /**
882
-	 * Get the customer's phone number.
883
-	 *
884
-	 * @since 1.0.19
885
-	 * @param  string $context View or edit context.
886
-	 * @return string
887
-	 */
888
-	public function get_phone( $context = 'view' ) {
889
-		return $this->get_prop( 'phone', $context );
882
+     * Get the customer's phone number.
883
+     *
884
+     * @since 1.0.19
885
+     * @param  string $context View or edit context.
886
+     * @return string
887
+     */
888
+    public function get_phone( $context = 'view' ) {
889
+        return $this->get_prop( 'phone', $context );
890 890
     }
891 891
 
892 892
     /**
893
-	 * Alias of self::get_phone().
894
-	 *
895
-	 * @since 1.0.19
896
-	 * @param  string $context View or edit context.
897
-	 * @return int
898
-	 */
899
-	public function get_phone_number( $context = 'view' ) {
900
-		return $this->get_phone( $context );
893
+     * Alias of self::get_phone().
894
+     *
895
+     * @since 1.0.19
896
+     * @param  string $context View or edit context.
897
+     * @return int
898
+     */
899
+    public function get_phone_number( $context = 'view' ) {
900
+        return $this->get_phone( $context );
901 901
     }
902 902
 
903 903
     /**
904
-	 * Alias of self::get_phone().
905
-	 *
906
-	 * @since 1.0.19
907
-	 * @param  string $context View or edit context.
908
-	 * @return int
909
-	 */
910
-	public function get_user_phone( $context = 'view' ) {
911
-		return $this->get_phone( $context );
904
+     * Alias of self::get_phone().
905
+     *
906
+     * @since 1.0.19
907
+     * @param  string $context View or edit context.
908
+     * @return int
909
+     */
910
+    public function get_user_phone( $context = 'view' ) {
911
+        return $this->get_phone( $context );
912 912
     }
913 913
 
914 914
     /**
915
-	 * Alias of self::get_phone().
916
-	 *
917
-	 * @since 1.0.19
918
-	 * @param  string $context View or edit context.
919
-	 * @return int
920
-	 */
921
-	public function get_customer_phone( $context = 'view' ) {
922
-		return $this->get_phone( $context );
915
+     * Alias of self::get_phone().
916
+     *
917
+     * @since 1.0.19
918
+     * @param  string $context View or edit context.
919
+     * @return int
920
+     */
921
+    public function get_customer_phone( $context = 'view' ) {
922
+        return $this->get_phone( $context );
923 923
     }
924 924
 
925 925
     /**
926
-	 * Get the customer's email address.
927
-	 *
928
-	 * @since 1.0.19
929
-	 * @param  string $context View or edit context.
930
-	 * @return string
931
-	 */
932
-	public function get_email( $context = 'view' ) {
933
-		return $this->get_prop( 'email', $context );
926
+     * Get the customer's email address.
927
+     *
928
+     * @since 1.0.19
929
+     * @param  string $context View or edit context.
930
+     * @return string
931
+     */
932
+    public function get_email( $context = 'view' ) {
933
+        return $this->get_prop( 'email', $context );
934 934
     }
935 935
 
936 936
     /**
937
-	 * Alias of self::get_email().
938
-	 *
939
-	 * @since 1.0.19
940
-	 * @param  string $context View or edit context.
941
-	 * @return string
942
-	 */
943
-	public function get_email_address( $context = 'view' ) {
944
-		return $this->get_email( $context );
937
+     * Alias of self::get_email().
938
+     *
939
+     * @since 1.0.19
940
+     * @param  string $context View or edit context.
941
+     * @return string
942
+     */
943
+    public function get_email_address( $context = 'view' ) {
944
+        return $this->get_email( $context );
945 945
     }
946 946
 
947 947
     /**
948
-	 * Alias of self::get_email().
949
-	 *
950
-	 * @since 1.0.19
951
-	 * @param  string $context View or edit context.
952
-	 * @return int
953
-	 */
954
-	public function get_user_email( $context = 'view' ) {
955
-		return $this->get_email( $context );
948
+     * Alias of self::get_email().
949
+     *
950
+     * @since 1.0.19
951
+     * @param  string $context View or edit context.
952
+     * @return int
953
+     */
954
+    public function get_user_email( $context = 'view' ) {
955
+        return $this->get_email( $context );
956 956
     }
957 957
 
958 958
     /**
959
-	 * Alias of self::get_email().
960
-	 *
961
-	 * @since 1.0.19
962
-	 * @param  string $context View or edit context.
963
-	 * @return int
964
-	 */
965
-	public function get_customer_email( $context = 'view' ) {
966
-		return $this->get_email( $context );
959
+     * Alias of self::get_email().
960
+     *
961
+     * @since 1.0.19
962
+     * @param  string $context View or edit context.
963
+     * @return int
964
+     */
965
+    public function get_customer_email( $context = 'view' ) {
966
+        return $this->get_email( $context );
967 967
     }
968 968
 
969 969
     /**
970
-	 * Get the customer's country.
971
-	 *
972
-	 * @since 1.0.19
973
-	 * @param  string $context View or edit context.
974
-	 * @return string
975
-	 */
976
-	public function get_country( $context = 'view' ) {
977
-		$country = $this->get_prop( 'country', $context );
978
-		return empty( $country ) ? wpinv_get_default_country() : $country;
970
+     * Get the customer's country.
971
+     *
972
+     * @since 1.0.19
973
+     * @param  string $context View or edit context.
974
+     * @return string
975
+     */
976
+    public function get_country( $context = 'view' ) {
977
+        $country = $this->get_prop( 'country', $context );
978
+        return empty( $country ) ? wpinv_get_default_country() : $country;
979 979
     }
980 980
 
981 981
     /**
982
-	 * Alias of self::get_country().
983
-	 *
984
-	 * @since 1.0.19
985
-	 * @param  string $context View or edit context.
986
-	 * @return int
987
-	 */
988
-	public function get_user_country( $context = 'view' ) {
989
-		return $this->get_country( $context );
982
+     * Alias of self::get_country().
983
+     *
984
+     * @since 1.0.19
985
+     * @param  string $context View or edit context.
986
+     * @return int
987
+     */
988
+    public function get_user_country( $context = 'view' ) {
989
+        return $this->get_country( $context );
990 990
     }
991 991
 
992 992
     /**
993
-	 * Alias of self::get_country().
994
-	 *
995
-	 * @since 1.0.19
996
-	 * @param  string $context View or edit context.
997
-	 * @return int
998
-	 */
999
-	public function get_customer_country( $context = 'view' ) {
1000
-		return $this->get_country( $context );
993
+     * Alias of self::get_country().
994
+     *
995
+     * @since 1.0.19
996
+     * @param  string $context View or edit context.
997
+     * @return int
998
+     */
999
+    public function get_customer_country( $context = 'view' ) {
1000
+        return $this->get_country( $context );
1001 1001
     }
1002 1002
 
1003 1003
     /**
1004
-	 * Get the customer's state.
1005
-	 *
1006
-	 * @since 1.0.19
1007
-	 * @param  string $context View or edit context.
1008
-	 * @return string
1009
-	 */
1010
-	public function get_state( $context = 'view' ) {
1011
-		$state = $this->get_prop( 'state', $context );
1012
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1004
+     * Get the customer's state.
1005
+     *
1006
+     * @since 1.0.19
1007
+     * @param  string $context View or edit context.
1008
+     * @return string
1009
+     */
1010
+    public function get_state( $context = 'view' ) {
1011
+        $state = $this->get_prop( 'state', $context );
1012
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1013 1013
     }
1014 1014
 
1015 1015
     /**
1016
-	 * Alias of self::get_state().
1017
-	 *
1018
-	 * @since 1.0.19
1019
-	 * @param  string $context View or edit context.
1020
-	 * @return int
1021
-	 */
1022
-	public function get_user_state( $context = 'view' ) {
1023
-		return $this->get_state( $context );
1016
+     * Alias of self::get_state().
1017
+     *
1018
+     * @since 1.0.19
1019
+     * @param  string $context View or edit context.
1020
+     * @return int
1021
+     */
1022
+    public function get_user_state( $context = 'view' ) {
1023
+        return $this->get_state( $context );
1024 1024
     }
1025 1025
 
1026 1026
     /**
1027
-	 * Alias of self::get_state().
1028
-	 *
1029
-	 * @since 1.0.19
1030
-	 * @param  string $context View or edit context.
1031
-	 * @return int
1032
-	 */
1033
-	public function get_customer_state( $context = 'view' ) {
1034
-		return $this->get_state( $context );
1027
+     * Alias of self::get_state().
1028
+     *
1029
+     * @since 1.0.19
1030
+     * @param  string $context View or edit context.
1031
+     * @return int
1032
+     */
1033
+    public function get_customer_state( $context = 'view' ) {
1034
+        return $this->get_state( $context );
1035 1035
     }
1036 1036
 
1037 1037
     /**
1038
-	 * Get the customer's city.
1039
-	 *
1040
-	 * @since 1.0.19
1041
-	 * @param  string $context View or edit context.
1042
-	 * @return string
1043
-	 */
1044
-	public function get_city( $context = 'view' ) {
1045
-		return $this->get_prop( 'city', $context );
1038
+     * Get the customer's city.
1039
+     *
1040
+     * @since 1.0.19
1041
+     * @param  string $context View or edit context.
1042
+     * @return string
1043
+     */
1044
+    public function get_city( $context = 'view' ) {
1045
+        return $this->get_prop( 'city', $context );
1046 1046
     }
1047 1047
 
1048 1048
     /**
1049
-	 * Alias of self::get_city().
1050
-	 *
1051
-	 * @since 1.0.19
1052
-	 * @param  string $context View or edit context.
1053
-	 * @return string
1054
-	 */
1055
-	public function get_user_city( $context = 'view' ) {
1056
-		return $this->get_city( $context );
1049
+     * Alias of self::get_city().
1050
+     *
1051
+     * @since 1.0.19
1052
+     * @param  string $context View or edit context.
1053
+     * @return string
1054
+     */
1055
+    public function get_user_city( $context = 'view' ) {
1056
+        return $this->get_city( $context );
1057 1057
     }
1058 1058
 
1059 1059
     /**
1060
-	 * Alias of self::get_city().
1061
-	 *
1062
-	 * @since 1.0.19
1063
-	 * @param  string $context View or edit context.
1064
-	 * @return string
1065
-	 */
1066
-	public function get_customer_city( $context = 'view' ) {
1067
-		return $this->get_city( $context );
1060
+     * Alias of self::get_city().
1061
+     *
1062
+     * @since 1.0.19
1063
+     * @param  string $context View or edit context.
1064
+     * @return string
1065
+     */
1066
+    public function get_customer_city( $context = 'view' ) {
1067
+        return $this->get_city( $context );
1068 1068
     }
1069 1069
 
1070 1070
     /**
1071
-	 * Get the customer's zip.
1072
-	 *
1073
-	 * @since 1.0.19
1074
-	 * @param  string $context View or edit context.
1075
-	 * @return string
1076
-	 */
1077
-	public function get_zip( $context = 'view' ) {
1078
-		return $this->get_prop( 'zip', $context );
1071
+     * Get the customer's zip.
1072
+     *
1073
+     * @since 1.0.19
1074
+     * @param  string $context View or edit context.
1075
+     * @return string
1076
+     */
1077
+    public function get_zip( $context = 'view' ) {
1078
+        return $this->get_prop( 'zip', $context );
1079 1079
     }
1080 1080
 
1081 1081
     /**
1082
-	 * Alias of self::get_zip().
1083
-	 *
1084
-	 * @since 1.0.19
1085
-	 * @param  string $context View or edit context.
1086
-	 * @return string
1087
-	 */
1088
-	public function get_user_zip( $context = 'view' ) {
1089
-		return $this->get_zip( $context );
1082
+     * Alias of self::get_zip().
1083
+     *
1084
+     * @since 1.0.19
1085
+     * @param  string $context View or edit context.
1086
+     * @return string
1087
+     */
1088
+    public function get_user_zip( $context = 'view' ) {
1089
+        return $this->get_zip( $context );
1090 1090
     }
1091 1091
 
1092 1092
     /**
1093
-	 * Alias of self::get_zip().
1094
-	 *
1095
-	 * @since 1.0.19
1096
-	 * @param  string $context View or edit context.
1097
-	 * @return string
1098
-	 */
1099
-	public function get_customer_zip( $context = 'view' ) {
1100
-		return $this->get_zip( $context );
1093
+     * Alias of self::get_zip().
1094
+     *
1095
+     * @since 1.0.19
1096
+     * @param  string $context View or edit context.
1097
+     * @return string
1098
+     */
1099
+    public function get_customer_zip( $context = 'view' ) {
1100
+        return $this->get_zip( $context );
1101 1101
     }
1102 1102
 
1103 1103
     /**
1104
-	 * Get the customer's company.
1105
-	 *
1106
-	 * @since 1.0.19
1107
-	 * @param  string $context View or edit context.
1108
-	 * @return string
1109
-	 */
1110
-	public function get_company( $context = 'view' ) {
1111
-		return $this->get_prop( 'company', $context );
1104
+     * Get the customer's company.
1105
+     *
1106
+     * @since 1.0.19
1107
+     * @param  string $context View or edit context.
1108
+     * @return string
1109
+     */
1110
+    public function get_company( $context = 'view' ) {
1111
+        return $this->get_prop( 'company', $context );
1112 1112
     }
1113 1113
 
1114 1114
     /**
1115
-	 * Alias of self::get_company().
1116
-	 *
1117
-	 * @since 1.0.19
1118
-	 * @param  string $context View or edit context.
1119
-	 * @return string
1120
-	 */
1121
-	public function get_user_company( $context = 'view' ) {
1122
-		return $this->get_company( $context );
1115
+     * Alias of self::get_company().
1116
+     *
1117
+     * @since 1.0.19
1118
+     * @param  string $context View or edit context.
1119
+     * @return string
1120
+     */
1121
+    public function get_user_company( $context = 'view' ) {
1122
+        return $this->get_company( $context );
1123 1123
     }
1124 1124
 
1125 1125
     /**
1126
-	 * Alias of self::get_company().
1127
-	 *
1128
-	 * @since 1.0.19
1129
-	 * @param  string $context View or edit context.
1130
-	 * @return string
1131
-	 */
1132
-	public function get_customer_company( $context = 'view' ) {
1133
-		return $this->get_company( $context );
1126
+     * Alias of self::get_company().
1127
+     *
1128
+     * @since 1.0.19
1129
+     * @param  string $context View or edit context.
1130
+     * @return string
1131
+     */
1132
+    public function get_customer_company( $context = 'view' ) {
1133
+        return $this->get_company( $context );
1134 1134
     }
1135 1135
 
1136 1136
     /**
1137
-	 * Get the customer's vat number.
1138
-	 *
1139
-	 * @since 1.0.19
1140
-	 * @param  string $context View or edit context.
1141
-	 * @return string
1142
-	 */
1143
-	public function get_vat_number( $context = 'view' ) {
1144
-		return $this->get_prop( 'vat_number', $context );
1137
+     * Get the customer's vat number.
1138
+     *
1139
+     * @since 1.0.19
1140
+     * @param  string $context View or edit context.
1141
+     * @return string
1142
+     */
1143
+    public function get_vat_number( $context = 'view' ) {
1144
+        return $this->get_prop( 'vat_number', $context );
1145 1145
     }
1146 1146
 
1147 1147
     /**
1148
-	 * Alias of self::get_vat_number().
1149
-	 *
1150
-	 * @since 1.0.19
1151
-	 * @param  string $context View or edit context.
1152
-	 * @return string
1153
-	 */
1154
-	public function get_user_vat_number( $context = 'view' ) {
1155
-		return $this->get_vat_number( $context );
1148
+     * Alias of self::get_vat_number().
1149
+     *
1150
+     * @since 1.0.19
1151
+     * @param  string $context View or edit context.
1152
+     * @return string
1153
+     */
1154
+    public function get_user_vat_number( $context = 'view' ) {
1155
+        return $this->get_vat_number( $context );
1156 1156
     }
1157 1157
 
1158 1158
     /**
1159
-	 * Alias of self::get_vat_number().
1160
-	 *
1161
-	 * @since 1.0.19
1162
-	 * @param  string $context View or edit context.
1163
-	 * @return string
1164
-	 */
1165
-	public function get_customer_vat_number( $context = 'view' ) {
1166
-		return $this->get_vat_number( $context );
1167
-    }
1168
-
1159
+     * Alias of self::get_vat_number().
1160
+     *
1161
+     * @since 1.0.19
1162
+     * @param  string $context View or edit context.
1163
+     * @return string
1164
+     */
1165
+    public function get_customer_vat_number( $context = 'view' ) {
1166
+        return $this->get_vat_number( $context );
1167
+    }
1168
+
1169
+    /**
1170
+     * Get the customer's vat rate.
1171
+     *
1172
+     * @since 1.0.19
1173
+     * @param  string $context View or edit context.
1174
+     * @return string
1175
+     */
1176
+    public function get_vat_rate( $context = 'view' ) {
1177
+        return $this->get_prop( 'vat_rate', $context );
1178
+    }
1179
+
1180
+    /**
1181
+     * Alias of self::get_vat_rate().
1182
+     *
1183
+     * @since 1.0.19
1184
+     * @param  string $context View or edit context.
1185
+     * @return string
1186
+     */
1187
+    public function get_user_vat_rate( $context = 'view' ) {
1188
+        return $this->get_vat_rate( $context );
1189
+    }
1190
+
1191
+    /**
1192
+     * Alias of self::get_vat_rate().
1193
+     *
1194
+     * @since 1.0.19
1195
+     * @param  string $context View or edit context.
1196
+     * @return string
1197
+     */
1198
+    public function get_customer_vat_rate( $context = 'view' ) {
1199
+        return $this->get_vat_rate( $context );
1200
+    }
1201
+
1169 1202
     /**
1170
-	 * Get the customer's vat rate.
1171
-	 *
1172
-	 * @since 1.0.19
1173
-	 * @param  string $context View or edit context.
1174
-	 * @return string
1175
-	 */
1176
-	public function get_vat_rate( $context = 'view' ) {
1177
-		return $this->get_prop( 'vat_rate', $context );
1203
+     * Get the customer's address.
1204
+     *
1205
+     * @since 1.0.19
1206
+     * @param  string $context View or edit context.
1207
+     * @return string
1208
+     */
1209
+    public function get_address( $context = 'view' ) {
1210
+        return $this->get_prop( 'address', $context );
1178 1211
     }
1179 1212
 
1180 1213
     /**
1181
-	 * Alias of self::get_vat_rate().
1182
-	 *
1183
-	 * @since 1.0.19
1184
-	 * @param  string $context View or edit context.
1185
-	 * @return string
1186
-	 */
1187
-	public function get_user_vat_rate( $context = 'view' ) {
1188
-		return $this->get_vat_rate( $context );
1214
+     * Alias of self::get_address().
1215
+     *
1216
+     * @since 1.0.19
1217
+     * @param  string $context View or edit context.
1218
+     * @return string
1219
+     */
1220
+    public function get_user_address( $context = 'view' ) {
1221
+        return $this->get_address( $context );
1189 1222
     }
1190 1223
 
1191 1224
     /**
1192
-	 * Alias of self::get_vat_rate().
1193
-	 *
1194
-	 * @since 1.0.19
1195
-	 * @param  string $context View or edit context.
1196
-	 * @return string
1197
-	 */
1198
-	public function get_customer_vat_rate( $context = 'view' ) {
1199
-		return $this->get_vat_rate( $context );
1225
+     * Alias of self::get_address().
1226
+     *
1227
+     * @since 1.0.19
1228
+     * @param  string $context View or edit context.
1229
+     * @return string
1230
+     */
1231
+    public function get_customer_address( $context = 'view' ) {
1232
+        return $this->get_address( $context );
1233
+    }
1234
+
1235
+    /**
1236
+     * Get whether the customer has viewed the invoice or not.
1237
+     *
1238
+     * @since 1.0.19
1239
+     * @param  string $context View or edit context.
1240
+     * @return bool
1241
+     */
1242
+    public function get_is_viewed( $context = 'view' ) {
1243
+        return (bool) $this->get_prop( 'is_viewed', $context );
1200 1244
     }
1201 1245
 
1202 1246
     /**
1203
-	 * Get the customer's address.
1204
-	 *
1205
-	 * @since 1.0.19
1206
-	 * @param  string $context View or edit context.
1207
-	 * @return string
1208
-	 */
1209
-	public function get_address( $context = 'view' ) {
1210
-		return $this->get_prop( 'address', $context );
1211
-    }
1212
-
1213
-    /**
1214
-	 * Alias of self::get_address().
1215
-	 *
1216
-	 * @since 1.0.19
1217
-	 * @param  string $context View or edit context.
1218
-	 * @return string
1219
-	 */
1220
-	public function get_user_address( $context = 'view' ) {
1221
-		return $this->get_address( $context );
1222
-    }
1223
-
1224
-    /**
1225
-	 * Alias of self::get_address().
1226
-	 *
1227
-	 * @since 1.0.19
1228
-	 * @param  string $context View or edit context.
1229
-	 * @return string
1230
-	 */
1231
-	public function get_customer_address( $context = 'view' ) {
1232
-		return $this->get_address( $context );
1233
-    }
1234
-
1235
-    /**
1236
-	 * Get whether the customer has viewed the invoice or not.
1237
-	 *
1238
-	 * @since 1.0.19
1239
-	 * @param  string $context View or edit context.
1240
-	 * @return bool
1241
-	 */
1242
-	public function get_is_viewed( $context = 'view' ) {
1243
-		return (bool) $this->get_prop( 'is_viewed', $context );
1244
-	}
1245
-
1246
-	/**
1247
-	 * Get other recipients for invoice communications.
1248
-	 *
1249
-	 * @since 1.0.19
1250
-	 * @param  string $context View or edit context.
1251
-	 * @return bool
1252
-	 */
1253
-	public function get_email_cc( $context = 'view' ) {
1254
-		return $this->get_prop( 'email_cc', $context );
1255
-	}
1256
-
1257
-	/**
1258
-	 * Get invoice template.
1259
-	 *
1260
-	 * @since 1.0.19
1261
-	 * @param  string $context View or edit context.
1262
-	 * @return bool
1263
-	 */
1264
-	public function get_template( $context = 'view' ) {
1265
-		return $this->get_prop( 'template', $context );
1266
-	}
1267
-
1268
-	/**
1269
-	 * Get whether the customer has confirmed their address.
1270
-	 *
1271
-	 * @since 1.0.19
1272
-	 * @param  string $context View or edit context.
1273
-	 * @return bool
1274
-	 */
1275
-	public function get_address_confirmed( $context = 'view' ) {
1276
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1277
-    }
1278
-
1279
-    /**
1280
-	 * Alias of self::get_address_confirmed().
1281
-	 *
1282
-	 * @since 1.0.19
1283
-	 * @param  string $context View or edit context.
1284
-	 * @return bool
1285
-	 */
1286
-	public function get_user_address_confirmed( $context = 'view' ) {
1287
-		return $this->get_address_confirmed( $context );
1288
-    }
1289
-
1290
-    /**
1291
-	 * Alias of self::get_address().
1292
-	 *
1293
-	 * @since 1.0.19
1294
-	 * @param  string $context View or edit context.
1295
-	 * @return bool
1296
-	 */
1297
-	public function get_customer_address_confirmed( $context = 'view' ) {
1298
-		return $this->get_address_confirmed( $context );
1299
-    }
1300
-
1301
-    /**
1302
-	 * Get the invoice subtotal.
1303
-	 *
1304
-	 * @since 1.0.19
1305
-	 * @param  string $context View or edit context.
1306
-	 * @return float
1307
-	 */
1308
-	public function get_subtotal( $context = 'view' ) {
1247
+     * Get other recipients for invoice communications.
1248
+     *
1249
+     * @since 1.0.19
1250
+     * @param  string $context View or edit context.
1251
+     * @return bool
1252
+     */
1253
+    public function get_email_cc( $context = 'view' ) {
1254
+        return $this->get_prop( 'email_cc', $context );
1255
+    }
1256
+
1257
+    /**
1258
+     * Get invoice template.
1259
+     *
1260
+     * @since 1.0.19
1261
+     * @param  string $context View or edit context.
1262
+     * @return bool
1263
+     */
1264
+    public function get_template( $context = 'view' ) {
1265
+        return $this->get_prop( 'template', $context );
1266
+    }
1267
+
1268
+    /**
1269
+     * Get whether the customer has confirmed their address.
1270
+     *
1271
+     * @since 1.0.19
1272
+     * @param  string $context View or edit context.
1273
+     * @return bool
1274
+     */
1275
+    public function get_address_confirmed( $context = 'view' ) {
1276
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1277
+    }
1278
+
1279
+    /**
1280
+     * Alias of self::get_address_confirmed().
1281
+     *
1282
+     * @since 1.0.19
1283
+     * @param  string $context View or edit context.
1284
+     * @return bool
1285
+     */
1286
+    public function get_user_address_confirmed( $context = 'view' ) {
1287
+        return $this->get_address_confirmed( $context );
1288
+    }
1289
+
1290
+    /**
1291
+     * Alias of self::get_address().
1292
+     *
1293
+     * @since 1.0.19
1294
+     * @param  string $context View or edit context.
1295
+     * @return bool
1296
+     */
1297
+    public function get_customer_address_confirmed( $context = 'view' ) {
1298
+        return $this->get_address_confirmed( $context );
1299
+    }
1300
+
1301
+    /**
1302
+     * Get the invoice subtotal.
1303
+     *
1304
+     * @since 1.0.19
1305
+     * @param  string $context View or edit context.
1306
+     * @return float
1307
+     */
1308
+    public function get_subtotal( $context = 'view' ) {
1309 1309
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1310 1310
 
1311 1311
         // Backwards compatibility.
@@ -1317,165 +1317,165 @@  discard block
 block discarded – undo
1317 1317
     }
1318 1318
 
1319 1319
     /**
1320
-	 * Get the invoice discount total.
1321
-	 *
1322
-	 * @since 1.0.19
1323
-	 * @param  string $context View or edit context.
1324
-	 * @return float
1325
-	 */
1326
-	public function get_total_discount( $context = 'view' ) {
1327
-		return (float) $this->get_prop( 'total_discount', $context );
1320
+     * Get the invoice discount total.
1321
+     *
1322
+     * @since 1.0.19
1323
+     * @param  string $context View or edit context.
1324
+     * @return float
1325
+     */
1326
+    public function get_total_discount( $context = 'view' ) {
1327
+        return (float) $this->get_prop( 'total_discount', $context );
1328 1328
     }
1329 1329
 
1330 1330
     /**
1331
-	 * Get the invoice tax total.
1332
-	 *
1333
-	 * @since 1.0.19
1334
-	 * @param  string $context View or edit context.
1335
-	 * @return float
1336
-	 */
1337
-	public function get_total_tax( $context = 'view' ) {
1338
-		return (float) $this->get_prop( 'total_tax', $context );
1339
-	}
1331
+     * Get the invoice tax total.
1332
+     *
1333
+     * @since 1.0.19
1334
+     * @param  string $context View or edit context.
1335
+     * @return float
1336
+     */
1337
+    public function get_total_tax( $context = 'view' ) {
1338
+        return (float) $this->get_prop( 'total_tax', $context );
1339
+    }
1340 1340
 
1341
-	/**
1342
-	 * @deprecated
1343
-	 */
1344
-	public function get_final_tax( $currency = false ) {
1345
-		$tax = $this->get_total_tax();
1341
+    /**
1342
+     * @deprecated
1343
+     */
1344
+    public function get_final_tax( $currency = false ) {
1345
+        $tax = $this->get_total_tax();
1346 1346
 
1347 1347
         if ( $currency ) {
1348
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1348
+            return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1349 1349
         }
1350 1350
 
1351 1351
         return $tax;
1352 1352
     }
1353 1353
 
1354 1354
     /**
1355
-	 * Get the invoice fees total.
1356
-	 *
1357
-	 * @since 1.0.19
1358
-	 * @param  string $context View or edit context.
1359
-	 * @return float
1360
-	 */
1361
-	public function get_total_fees( $context = 'view' ) {
1362
-		return (float) $this->get_prop( 'total_fees', $context );
1355
+     * Get the invoice fees total.
1356
+     *
1357
+     * @since 1.0.19
1358
+     * @param  string $context View or edit context.
1359
+     * @return float
1360
+     */
1361
+    public function get_total_fees( $context = 'view' ) {
1362
+        return (float) $this->get_prop( 'total_fees', $context );
1363 1363
     }
1364 1364
 
1365 1365
     /**
1366
-	 * Alias for self::get_total_fees().
1367
-	 *
1368
-	 * @since 1.0.19
1369
-	 * @param  string $context View or edit context.
1370
-	 * @return float
1371
-	 */
1372
-	public function get_fees_total( $context = 'view' ) {
1373
-		return $this->get_total_fees( $context );
1366
+     * Alias for self::get_total_fees().
1367
+     *
1368
+     * @since 1.0.19
1369
+     * @param  string $context View or edit context.
1370
+     * @return float
1371
+     */
1372
+    public function get_fees_total( $context = 'view' ) {
1373
+        return $this->get_total_fees( $context );
1374 1374
     }
1375 1375
 
1376 1376
     /**
1377
-	 * Get the invoice total.
1378
-	 *
1379
-	 * @since 1.0.19
1377
+     * Get the invoice total.
1378
+     *
1379
+     * @since 1.0.19
1380 1380
      * @return float
1381
-	 */
1382
-	public function get_total() {
1383
-		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1384
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1385
-	}
1381
+     */
1382
+    public function get_total() {
1383
+        $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1384
+        return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1385
+    }
1386 1386
 	
1387
-	/**
1388
-	 * Get the invoice totals.
1389
-	 *
1390
-	 * @since 1.0.19
1387
+    /**
1388
+     * Get the invoice totals.
1389
+     *
1390
+     * @since 1.0.19
1391 1391
      * @return float
1392
-	 */
1393
-	public function get_totals() {
1394
-		return $this->totals;
1392
+     */
1393
+    public function get_totals() {
1394
+        return $this->totals;
1395 1395
     }
1396 1396
 
1397 1397
     /**
1398
-	 * Get the initial invoice total.
1399
-	 *
1400
-	 * @since 1.0.19
1398
+     * Get the initial invoice total.
1399
+     *
1400
+     * @since 1.0.19
1401 1401
      * @param  string $context View or edit context.
1402 1402
      * @return float
1403
-	 */
1403
+     */
1404 1404
     public function get_initial_total() {
1405 1405
 
1406
-		if ( empty( $this->totals ) ) {
1407
-			$this->recalculate_total();
1408
-		}
1406
+        if ( empty( $this->totals ) ) {
1407
+            $this->recalculate_total();
1408
+        }
1409 1409
 
1410
-		$tax      = $this->totals['tax']['initial'];
1411
-		$fee      = $this->totals['fee']['initial'];
1412
-		$discount = $this->totals['discount']['initial'];
1413
-		$subtotal = $this->totals['subtotal']['initial'];
1414
-		$total    = $tax + $fee - $discount + $subtotal;
1410
+        $tax      = $this->totals['tax']['initial'];
1411
+        $fee      = $this->totals['fee']['initial'];
1412
+        $discount = $this->totals['discount']['initial'];
1413
+        $subtotal = $this->totals['subtotal']['initial'];
1414
+        $total    = $tax + $fee - $discount + $subtotal;
1415 1415
 
1416
-		if ( 0 > $total ) {
1417
-			$total = 0;
1418
-		}
1416
+        if ( 0 > $total ) {
1417
+            $total = 0;
1418
+        }
1419 1419
 
1420 1420
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1421
-	}
1421
+    }
1422 1422
 
1423
-	/**
1424
-	 * Get the recurring invoice total.
1425
-	 *
1426
-	 * @since 1.0.19
1423
+    /**
1424
+     * Get the recurring invoice total.
1425
+     *
1426
+     * @since 1.0.19
1427 1427
      * @param  string $context View or edit context.
1428 1428
      * @return float
1429
-	 */
1429
+     */
1430 1430
     public function get_recurring_total() {
1431 1431
 
1432
-		if ( empty( $this->totals ) ) {
1433
-			$this->recalculate_total();
1434
-		}
1432
+        if ( empty( $this->totals ) ) {
1433
+            $this->recalculate_total();
1434
+        }
1435 1435
 
1436
-		$tax      = $this->totals['tax']['recurring'];
1437
-		$fee      = $this->totals['fee']['recurring'];
1438
-		$discount = $this->totals['discount']['recurring'];
1439
-		$subtotal = $this->totals['subtotal']['recurring'];
1440
-		$total    = $tax + $fee - $discount + $subtotal;
1436
+        $tax      = $this->totals['tax']['recurring'];
1437
+        $fee      = $this->totals['fee']['recurring'];
1438
+        $discount = $this->totals['discount']['recurring'];
1439
+        $subtotal = $this->totals['subtotal']['recurring'];
1440
+        $total    = $tax + $fee - $discount + $subtotal;
1441 1441
 
1442
-		if ( 0 > $total ) {
1443
-			$total = 0;
1444
-		}
1442
+        if ( 0 > $total ) {
1443
+            $total = 0;
1444
+        }
1445 1445
 
1446 1446
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1447
-	}
1447
+    }
1448 1448
 
1449
-	/**
1450
-	 * Returns recurring payment details.
1451
-	 *
1452
-	 * @since 1.0.19
1449
+    /**
1450
+     * Returns recurring payment details.
1451
+     *
1452
+     * @since 1.0.19
1453 1453
      * @param  string $field Optionally provide a field to return.
1454
-	 * @param string $currency Whether to include the currency.
1454
+     * @param string $currency Whether to include the currency.
1455 1455
      * @return float
1456
-	 */
1456
+     */
1457 1457
     public function get_recurring_details( $field = '', $currency = false ) {
1458 1458
 
1459
-		// Maybe recalculate totals.
1460
-		if ( empty( $this->totals ) ) {
1461
-			$this->recalculate_total();
1462
-		}
1459
+        // Maybe recalculate totals.
1460
+        if ( empty( $this->totals ) ) {
1461
+            $this->recalculate_total();
1462
+        }
1463 1463
 
1464
-		// Prepare recurring totals.
1464
+        // Prepare recurring totals.
1465 1465
         $data = apply_filters(
1466
-			'wpinv_get_invoice_recurring_details',
1467
-			array(
1468
-				'cart_details' => $this->get_cart_details(),
1469
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1470
-				'discount'     => $this->totals['discount']['recurring'],
1471
-				'tax'          => $this->totals['tax']['recurring'],
1472
-				'fee'          => $this->totals['fee']['recurring'],
1473
-				'total'        => $this->get_recurring_total(),
1474
-			),
1475
-			$this,
1476
-			$field,
1477
-			$currency
1478
-		);
1466
+            'wpinv_get_invoice_recurring_details',
1467
+            array(
1468
+                'cart_details' => $this->get_cart_details(),
1469
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1470
+                'discount'     => $this->totals['discount']['recurring'],
1471
+                'tax'          => $this->totals['tax']['recurring'],
1472
+                'fee'          => $this->totals['fee']['recurring'],
1473
+                'total'        => $this->get_recurring_total(),
1474
+            ),
1475
+            $this,
1476
+            $field,
1477
+            $currency
1478
+        );
1479 1479
 
1480 1480
         if ( isset( $data[$field] ) ) {
1481 1481
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1485,145 +1485,145 @@  discard block
 block discarded – undo
1485 1485
     }
1486 1486
 
1487 1487
     /**
1488
-	 * Get the invoice fees.
1489
-	 *
1490
-	 * @since 1.0.19
1491
-	 * @param  string $context View or edit context.
1492
-	 * @return array
1493
-	 */
1494
-	public function get_fees( $context = 'view' ) {
1495
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1488
+     * Get the invoice fees.
1489
+     *
1490
+     * @since 1.0.19
1491
+     * @param  string $context View or edit context.
1492
+     * @return array
1493
+     */
1494
+    public function get_fees( $context = 'view' ) {
1495
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1496 1496
     }
1497 1497
 
1498 1498
     /**
1499
-	 * Get the invoice discounts.
1500
-	 *
1501
-	 * @since 1.0.19
1502
-	 * @param  string $context View or edit context.
1503
-	 * @return array
1504
-	 */
1505
-	public function get_discounts( $context = 'view' ) {
1506
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1499
+     * Get the invoice discounts.
1500
+     *
1501
+     * @since 1.0.19
1502
+     * @param  string $context View or edit context.
1503
+     * @return array
1504
+     */
1505
+    public function get_discounts( $context = 'view' ) {
1506
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1507 1507
     }
1508 1508
 
1509 1509
     /**
1510
-	 * Get the invoice taxes.
1511
-	 *
1512
-	 * @since 1.0.19
1513
-	 * @param  string $context View or edit context.
1514
-	 * @return array
1515
-	 */
1516
-	public function get_taxes( $context = 'view' ) {
1517
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1510
+     * Get the invoice taxes.
1511
+     *
1512
+     * @since 1.0.19
1513
+     * @param  string $context View or edit context.
1514
+     * @return array
1515
+     */
1516
+    public function get_taxes( $context = 'view' ) {
1517
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1518 1518
     }
1519 1519
 
1520 1520
     /**
1521
-	 * Get the invoice items.
1522
-	 *
1523
-	 * @since 1.0.19
1524
-	 * @param  string $context View or edit context.
1525
-	 * @return GetPaid_Form_Item[]
1526
-	 */
1527
-	public function get_items( $context = 'view' ) {
1521
+     * Get the invoice items.
1522
+     *
1523
+     * @since 1.0.19
1524
+     * @param  string $context View or edit context.
1525
+     * @return GetPaid_Form_Item[]
1526
+     */
1527
+    public function get_items( $context = 'view' ) {
1528 1528
         return $this->get_prop( 'items', $context );
1529 1529
     }
1530 1530
 
1531 1531
     /**
1532
-	 * Get the invoice's payment form.
1533
-	 *
1534
-	 * @since 1.0.19
1535
-	 * @param  string $context View or edit context.
1536
-	 * @return int
1537
-	 */
1538
-	public function get_payment_form( $context = 'view' ) {
1539
-		return intval( $this->get_prop( 'payment_form', $context ) );
1532
+     * Get the invoice's payment form.
1533
+     *
1534
+     * @since 1.0.19
1535
+     * @param  string $context View or edit context.
1536
+     * @return int
1537
+     */
1538
+    public function get_payment_form( $context = 'view' ) {
1539
+        return intval( $this->get_prop( 'payment_form', $context ) );
1540 1540
     }
1541 1541
 
1542 1542
     /**
1543
-	 * Get the invoice's submission id.
1544
-	 *
1545
-	 * @since 1.0.19
1546
-	 * @param  string $context View or edit context.
1547
-	 * @return string
1548
-	 */
1549
-	public function get_submission_id( $context = 'view' ) {
1550
-		return $this->get_prop( 'submission_id', $context );
1543
+     * Get the invoice's submission id.
1544
+     *
1545
+     * @since 1.0.19
1546
+     * @param  string $context View or edit context.
1547
+     * @return string
1548
+     */
1549
+    public function get_submission_id( $context = 'view' ) {
1550
+        return $this->get_prop( 'submission_id', $context );
1551 1551
     }
1552 1552
 
1553 1553
     /**
1554
-	 * Get the invoice's discount code.
1555
-	 *
1556
-	 * @since 1.0.19
1557
-	 * @param  string $context View or edit context.
1558
-	 * @return string
1559
-	 */
1560
-	public function get_discount_code( $context = 'view' ) {
1561
-		return $this->get_prop( 'discount_code', $context );
1554
+     * Get the invoice's discount code.
1555
+     *
1556
+     * @since 1.0.19
1557
+     * @param  string $context View or edit context.
1558
+     * @return string
1559
+     */
1560
+    public function get_discount_code( $context = 'view' ) {
1561
+        return $this->get_prop( 'discount_code', $context );
1562 1562
     }
1563 1563
 
1564 1564
     /**
1565
-	 * Get the invoice's gateway.
1566
-	 *
1567
-	 * @since 1.0.19
1568
-	 * @param  string $context View or edit context.
1569
-	 * @return string
1570
-	 */
1571
-	public function get_gateway( $context = 'view' ) {
1572
-		return $this->get_prop( 'gateway', $context );
1565
+     * Get the invoice's gateway.
1566
+     *
1567
+     * @since 1.0.19
1568
+     * @param  string $context View or edit context.
1569
+     * @return string
1570
+     */
1571
+    public function get_gateway( $context = 'view' ) {
1572
+        return $this->get_prop( 'gateway', $context );
1573 1573
     }
1574 1574
 
1575 1575
     /**
1576
-	 * Get the invoice's gateway display title.
1577
-	 *
1578
-	 * @since 1.0.19
1579
-	 * @return string
1580
-	 */
1576
+     * Get the invoice's gateway display title.
1577
+     *
1578
+     * @since 1.0.19
1579
+     * @return string
1580
+     */
1581 1581
     public function get_gateway_title() {
1582 1582
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1583 1583
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1584 1584
     }
1585 1585
 
1586 1586
     /**
1587
-	 * Get the invoice's transaction id.
1588
-	 *
1589
-	 * @since 1.0.19
1590
-	 * @param  string $context View or edit context.
1591
-	 * @return string
1592
-	 */
1593
-	public function get_transaction_id( $context = 'view' ) {
1594
-		return $this->get_prop( 'transaction_id', $context );
1587
+     * Get the invoice's transaction id.
1588
+     *
1589
+     * @since 1.0.19
1590
+     * @param  string $context View or edit context.
1591
+     * @return string
1592
+     */
1593
+    public function get_transaction_id( $context = 'view' ) {
1594
+        return $this->get_prop( 'transaction_id', $context );
1595 1595
     }
1596 1596
 
1597 1597
     /**
1598
-	 * Get the invoice's currency.
1599
-	 *
1600
-	 * @since 1.0.19
1601
-	 * @param  string $context View or edit context.
1602
-	 * @return string
1603
-	 */
1604
-	public function get_currency( $context = 'view' ) {
1598
+     * Get the invoice's currency.
1599
+     *
1600
+     * @since 1.0.19
1601
+     * @param  string $context View or edit context.
1602
+     * @return string
1603
+     */
1604
+    public function get_currency( $context = 'view' ) {
1605 1605
         $currency = $this->get_prop( 'currency', $context );
1606 1606
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1607 1607
     }
1608 1608
 
1609 1609
     /**
1610
-	 * Checks if we are charging taxes for this invoice.
1611
-	 *
1612
-	 * @since 1.0.19
1613
-	 * @param  string $context View or edit context.
1614
-	 * @return bool
1615
-	 */
1616
-	public function get_disable_taxes( $context = 'view' ) {
1610
+     * Checks if we are charging taxes for this invoice.
1611
+     *
1612
+     * @since 1.0.19
1613
+     * @param  string $context View or edit context.
1614
+     * @return bool
1615
+     */
1616
+    public function get_disable_taxes( $context = 'view' ) {
1617 1617
         return (bool) $this->get_prop( 'disable_taxes', $context );
1618 1618
     }
1619 1619
 
1620 1620
     /**
1621
-	 * Retrieves the remote subscription id for an invoice.
1622
-	 *
1623
-	 * @since 1.0.19
1624
-	 * @param  string $context View or edit context.
1625
-	 * @return int
1626
-	 */
1621
+     * Retrieves the remote subscription id for an invoice.
1622
+     *
1623
+     * @since 1.0.19
1624
+     * @param  string $context View or edit context.
1625
+     * @return int
1626
+     */
1627 1627
     public function get_subscription_id( $context = 'view' ) {
1628 1628
         $subscription_id = $this->get_prop( 'subscription_id', $context );
1629 1629
 
@@ -1636,12 +1636,12 @@  discard block
 block discarded – undo
1636 1636
     }
1637 1637
 
1638 1638
     /**
1639
-	 * Retrieves the payment meta for an invoice.
1640
-	 *
1641
-	 * @since 1.0.19
1642
-	 * @param  string $context View or edit context.
1643
-	 * @return array
1644
-	 */
1639
+     * Retrieves the payment meta for an invoice.
1640
+     *
1641
+     * @since 1.0.19
1642
+     * @param  string $context View or edit context.
1643
+     * @return array
1644
+     */
1645 1645
     public function get_payment_meta( $context = 'view' ) {
1646 1646
 
1647 1647
         return array(
@@ -1661,11 +1661,11 @@  discard block
 block discarded – undo
1661 1661
     }
1662 1662
 
1663 1663
     /**
1664
-	 * Retrieves the cart details for an invoice.
1665
-	 *
1666
-	 * @since 1.0.19
1667
-	 * @return array
1668
-	 */
1664
+     * Retrieves the cart details for an invoice.
1665
+     *
1666
+     * @since 1.0.19
1667
+     * @return array
1668
+     */
1669 1669
     public function get_cart_details() {
1670 1670
         $items        = $this->get_items();
1671 1671
         $cart_details = array();
@@ -1675,16 +1675,16 @@  discard block
 block discarded – undo
1675 1675
         }
1676 1676
 
1677 1677
         return $cart_details;
1678
-	}
1678
+    }
1679 1679
 
1680
-	/**
1681
-	 * Retrieves the recurring item.
1682
-	 *
1683
-	 * @return null|GetPaid_Form_Item|int
1684
-	 */
1685
-	public function get_recurring( $object = false ) {
1680
+    /**
1681
+     * Retrieves the recurring item.
1682
+     *
1683
+     * @return null|GetPaid_Form_Item|int
1684
+     */
1685
+    public function get_recurring( $object = false ) {
1686 1686
 
1687
-		// Are we returning an object?
1687
+        // Are we returning an object?
1688 1688
         if ( $object ) {
1689 1689
             return $this->get_item( $this->recurring_item );
1690 1690
         }
@@ -1692,100 +1692,100 @@  discard block
 block discarded – undo
1692 1692
         return $this->recurring_item;
1693 1693
     }
1694 1694
 
1695
-	/**
1696
-	 * Retrieves the subscription name.
1697
-	 *
1698
-	 * @since 1.0.19
1699
-	 * @return string
1700
-	 */
1701
-	public function get_subscription_name() {
1695
+    /**
1696
+     * Retrieves the subscription name.
1697
+     *
1698
+     * @since 1.0.19
1699
+     * @return string
1700
+     */
1701
+    public function get_subscription_name() {
1702 1702
 
1703
-		// Retrieve the recurring name
1703
+        // Retrieve the recurring name
1704 1704
         $item = $this->get_recurring( true );
1705 1705
 
1706
-		// Abort if it does not exist.
1706
+        // Abort if it does not exist.
1707 1707
         if ( empty( $item ) ) {
1708 1708
             return '';
1709 1709
         }
1710 1710
 
1711
-		// Return the item name.
1711
+        // Return the item name.
1712 1712
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1713
-	}
1714
-
1715
-	/**
1716
-	 * Retrieves the view url.
1717
-	 *
1718
-	 * @since 1.0.19
1719
-	 * @return string
1720
-	 */
1721
-	public function get_view_url() {
1713
+    }
1714
+
1715
+    /**
1716
+     * Retrieves the view url.
1717
+     *
1718
+     * @since 1.0.19
1719
+     * @return string
1720
+     */
1721
+    public function get_view_url() {
1722 1722
         $invoice_url = get_permalink( $this->get_id() );
1723
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1723
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1724 1724
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1725
-	}
1725
+    }
1726 1726
 
1727
-	/**
1728
-	 * Retrieves the payment url.
1729
-	 *
1730
-	 * @since 1.0.19
1731
-	 * @return string
1732
-	 */
1733
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1727
+    /**
1728
+     * Retrieves the payment url.
1729
+     *
1730
+     * @since 1.0.19
1731
+     * @return string
1732
+     */
1733
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1734 1734
 
1735
-		// Retrieve the checkout url.
1735
+        // Retrieve the checkout url.
1736 1736
         $pay_url = wpinv_get_checkout_uri();
1737 1737
 
1738
-		// Maybe force ssl.
1738
+        // Maybe force ssl.
1739 1739
         if ( is_ssl() ) {
1740 1740
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1741 1741
         }
1742 1742
 
1743
-		// Add the invoice key.
1744
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1743
+        // Add the invoice key.
1744
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1745 1745
 
1746
-		// (Maybe?) add a secret
1746
+        // (Maybe?) add a secret
1747 1747
         if ( $secret ) {
1748 1748
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1749 1749
         }
1750 1750
 
1751 1751
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1752
-	}
1752
+    }
1753 1753
 	
1754
-	/**
1755
-	 * Retrieves the receipt url.
1756
-	 *
1757
-	 * @since 1.0.19
1758
-	 * @return string
1759
-	 */
1760
-	public function get_receipt_url() {
1761
-
1762
-		// Retrieve the checkout url.
1754
+    /**
1755
+     * Retrieves the receipt url.
1756
+     *
1757
+     * @since 1.0.19
1758
+     * @return string
1759
+     */
1760
+    public function get_receipt_url() {
1761
+
1762
+        // Retrieve the checkout url.
1763 1763
         $receipt_url = wpinv_get_success_page_uri();
1764 1764
 
1765
-		// Maybe force ssl.
1765
+        // Maybe force ssl.
1766 1766
         if ( is_ssl() ) {
1767 1767
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1768 1768
         }
1769 1769
 
1770
-		// Add the invoice key.
1771
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1770
+        // Add the invoice key.
1771
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1772 1772
 
1773 1773
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1774 1774
     }
1775 1775
 
1776 1776
     /**
1777
-	 * Magic method for accessing invoice properties.
1778
-	 *
1779
-	 * @since 1.0.15
1780
-	 * @access public
1781
-	 *
1782
-	 * @param string $key Discount data to retrieve
1783
-	 * @param  string $context View or edit context.
1784
-	 * @return mixed Value of the given invoice property (if set).
1785
-	 */
1786
-	public function get( $key, $context = 'view' ) {
1777
+     * Magic method for accessing invoice properties.
1778
+     *
1779
+     * @since 1.0.15
1780
+     * @access public
1781
+     *
1782
+     * @param string $key Discount data to retrieve
1783
+     * @param  string $context View or edit context.
1784
+     * @return mixed Value of the given invoice property (if set).
1785
+     */
1786
+    public function get( $key, $context = 'view' ) {
1787 1787
         return $this->get_prop( $key, $context );
1788
-	}
1788
+    }
1789 1789
 
1790 1790
     /*
1791 1791
 	|--------------------------------------------------------------------------
@@ -1798,131 +1798,131 @@  discard block
 block discarded – undo
1798 1798
     */
1799 1799
 
1800 1800
     /**
1801
-	 * Magic method for setting invoice properties.
1802
-	 *
1803
-	 * @since 1.0.19
1804
-	 * @access public
1805
-	 *
1806
-	 * @param string $key Discount data to retrieve
1807
-	 * @param  mixed $value new value.
1808
-	 * @return mixed Value of the given invoice property (if set).
1809
-	 */
1810
-	public function set( $key, $value ) {
1801
+     * Magic method for setting invoice properties.
1802
+     *
1803
+     * @since 1.0.19
1804
+     * @access public
1805
+     *
1806
+     * @param string $key Discount data to retrieve
1807
+     * @param  mixed $value new value.
1808
+     * @return mixed Value of the given invoice property (if set).
1809
+     */
1810
+    public function set( $key, $value ) {
1811 1811
 
1812 1812
         $setter = "set_$key";
1813 1813
         if ( is_callable( array( $this, $setter ) ) ) {
1814 1814
             $this->{$setter}( $value );
1815 1815
         }
1816 1816
 
1817
-	}
1817
+    }
1818 1818
 
1819
-	/**
1820
-	 * Sets item status.
1821
-	 *
1822
-	 * @since 1.0.19
1823
-	 * @param string $new_status    New status.
1824
-	 * @param string $note          Optional note to add.
1825
-	 * @param bool   $manual_update Is this a manual status change?.
1826
-	 * @return array details of change.
1827
-	 */
1828
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1829
-		$old_status = $this->get_status();
1819
+    /**
1820
+     * Sets item status.
1821
+     *
1822
+     * @since 1.0.19
1823
+     * @param string $new_status    New status.
1824
+     * @param string $note          Optional note to add.
1825
+     * @param bool   $manual_update Is this a manual status change?.
1826
+     * @return array details of change.
1827
+     */
1828
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1829
+        $old_status = $this->get_status();
1830 1830
 
1831
-		$statuses = $this->get_all_statuses();
1831
+        $statuses = $this->get_all_statuses();
1832 1832
 
1833
-		if ( isset( $statuses[ 'draft' ] ) ) {
1834
-			unset( $statuses[ 'draft' ] );
1835
-		}
1833
+        if ( isset( $statuses[ 'draft' ] ) ) {
1834
+            unset( $statuses[ 'draft' ] );
1835
+        }
1836 1836
 
1837 1837
 
1838
-		$this->set_prop( 'status', $new_status );
1838
+        $this->set_prop( 'status', $new_status );
1839 1839
 
1840
-		// If setting the status, ensure it's set to a valid status.
1841
-		if ( true === $this->object_read ) {
1840
+        // If setting the status, ensure it's set to a valid status.
1841
+        if ( true === $this->object_read ) {
1842 1842
 
1843
-			// Only allow valid new status.
1844
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1845
-				$new_status = 'wpi-pending';
1846
-			}
1843
+            // Only allow valid new status.
1844
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1845
+                $new_status = 'wpi-pending';
1846
+            }
1847 1847
 
1848
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1849
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1850
-				$old_status = 'wpi-pending';
1851
-			}
1848
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1849
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1850
+                $old_status = 'wpi-pending';
1851
+            }
1852 1852
 
1853
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1854
-			if ( $new_status == 'wpi-renewal' && $old_status == 'publish' ) {
1855
-				$old_status = 'wpi-pending';
1856
-			}
1853
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1854
+            if ( $new_status == 'wpi-renewal' && $old_status == 'publish' ) {
1855
+                $old_status = 'wpi-pending';
1856
+            }
1857 1857
 
1858
-		}
1858
+        }
1859 1859
 
1860
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1861
-			$this->status_transition = array(
1862
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1863
-				'to'     => $new_status,
1864
-				'note'   => $note,
1865
-				'manual' => (bool) $manual_update,
1866
-			);
1860
+        if ( true === $this->object_read && $old_status !== $new_status ) {
1861
+            $this->status_transition = array(
1862
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1863
+                'to'     => $new_status,
1864
+                'note'   => $note,
1865
+                'manual' => (bool) $manual_update,
1866
+            );
1867 1867
 
1868
-			if ( $manual_update ) {
1869
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1870
-			}
1868
+            if ( $manual_update ) {
1869
+                do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1870
+            }
1871 1871
 
1872
-			$this->maybe_set_date_paid();
1872
+            $this->maybe_set_date_paid();
1873 1873
 
1874
-		}
1874
+        }
1875 1875
 
1876
-		return array(
1877
-			'from' => $old_status,
1878
-			'to'   => $new_status,
1879
-		);
1880
-	}
1876
+        return array(
1877
+            'from' => $old_status,
1878
+            'to'   => $new_status,
1879
+        );
1880
+    }
1881 1881
 
1882
-	/**
1883
-	 * Maybe set date paid.
1884
-	 *
1885
-	 * Sets the date paid variable when transitioning to the payment complete
1886
-	 * order status.
1887
-	 *
1888
-	 * @since 1.0.19
1889
-	 */
1890
-	public function maybe_set_date_paid() {
1882
+    /**
1883
+     * Maybe set date paid.
1884
+     *
1885
+     * Sets the date paid variable when transitioning to the payment complete
1886
+     * order status.
1887
+     *
1888
+     * @since 1.0.19
1889
+     */
1890
+    public function maybe_set_date_paid() {
1891 1891
 
1892
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1893
-			$this->set_date_completed( current_time( 'mysql' ) );
1894
-		}
1895
-	}
1892
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1893
+            $this->set_date_completed( current_time( 'mysql' ) );
1894
+        }
1895
+    }
1896 1896
 
1897 1897
     /**
1898
-	 * Set parent invoice ID.
1899
-	 *
1900
-	 * @since 1.0.19
1901
-	 */
1902
-	public function set_parent_id( $value ) {
1903
-		if ( $value && ( $value === $this->get_id() ) ) {
1904
-			return;
1905
-		}
1906
-		$this->set_prop( 'parent_id', absint( $value ) );
1898
+     * Set parent invoice ID.
1899
+     *
1900
+     * @since 1.0.19
1901
+     */
1902
+    public function set_parent_id( $value ) {
1903
+        if ( $value && ( $value === $this->get_id() ) ) {
1904
+            return;
1905
+        }
1906
+        $this->set_prop( 'parent_id', absint( $value ) );
1907 1907
     }
1908 1908
 
1909 1909
     /**
1910
-	 * Set plugin version when the invoice was created.
1911
-	 *
1912
-	 * @since 1.0.19
1913
-	 */
1914
-	public function set_version( $value ) {
1915
-		$this->set_prop( 'version', $value );
1910
+     * Set plugin version when the invoice was created.
1911
+     *
1912
+     * @since 1.0.19
1913
+     */
1914
+    public function set_version( $value ) {
1915
+        $this->set_prop( 'version', $value );
1916 1916
     }
1917
-
1918
-    /**
1919
-	 * Set date when the invoice was created.
1920
-	 *
1921
-	 * @since 1.0.19
1922
-	 * @param string $value Value to set.
1917
+
1918
+    /**
1919
+     * Set date when the invoice was created.
1920
+     *
1921
+     * @since 1.0.19
1922
+     * @param string $value Value to set.
1923 1923
      * @return bool Whether or not the date was set.
1924
-	 */
1925
-	public function set_date_created( $value ) {
1924
+     */
1925
+    public function set_date_created( $value ) {
1926 1926
         $date = strtotime( $value );
1927 1927
 
1928 1928
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1935,13 +1935,13 @@  discard block
 block discarded – undo
1935 1935
     }
1936 1936
 
1937 1937
     /**
1938
-	 * Set date invoice due date.
1939
-	 *
1940
-	 * @since 1.0.19
1941
-	 * @param string $value Value to set.
1938
+     * Set date invoice due date.
1939
+     *
1940
+     * @since 1.0.19
1941
+     * @param string $value Value to set.
1942 1942
      * @return bool Whether or not the date was set.
1943
-	 */
1944
-	public function set_due_date( $value ) {
1943
+     */
1944
+    public function set_due_date( $value ) {
1945 1945
         $date = strtotime( $value );
1946 1946
 
1947 1947
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1949,29 +1949,29 @@  discard block
 block discarded – undo
1949 1949
             return true;
1950 1950
         }
1951 1951
 
1952
-		$this->set_prop( 'due_date', '' );
1952
+        $this->set_prop( 'due_date', '' );
1953 1953
         return false;
1954 1954
 
1955 1955
     }
1956 1956
 
1957 1957
     /**
1958
-	 * Alias of self::set_due_date().
1959
-	 *
1960
-	 * @since 1.0.19
1961
-	 * @param  string $value New name.
1962
-	 */
1963
-	public function set_date_due( $value ) {
1964
-		$this->set_due_date( $value );
1958
+     * Alias of self::set_due_date().
1959
+     *
1960
+     * @since 1.0.19
1961
+     * @param  string $value New name.
1962
+     */
1963
+    public function set_date_due( $value ) {
1964
+        $this->set_due_date( $value );
1965 1965
     }
1966 1966
 
1967 1967
     /**
1968
-	 * Set date invoice was completed.
1969
-	 *
1970
-	 * @since 1.0.19
1971
-	 * @param string $value Value to set.
1968
+     * Set date invoice was completed.
1969
+     *
1970
+     * @since 1.0.19
1971
+     * @param string $value Value to set.
1972 1972
      * @return bool Whether or not the date was set.
1973
-	 */
1974
-	public function set_completed_date( $value ) {
1973
+     */
1974
+    public function set_completed_date( $value ) {
1975 1975
         $date = strtotime( $value );
1976 1976
 
1977 1977
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -1979,29 +1979,29 @@  discard block
 block discarded – undo
1979 1979
             return true;
1980 1980
         }
1981 1981
 
1982
-		$this->set_prop( 'completed_date', '' );
1982
+        $this->set_prop( 'completed_date', '' );
1983 1983
         return false;
1984 1984
 
1985 1985
     }
1986 1986
 
1987 1987
     /**
1988
-	 * Alias of self::set_completed_date().
1989
-	 *
1990
-	 * @since 1.0.19
1991
-	 * @param  string $value New name.
1992
-	 */
1993
-	public function set_date_completed( $value ) {
1994
-		$this->set_completed_date( $value );
1988
+     * Alias of self::set_completed_date().
1989
+     *
1990
+     * @since 1.0.19
1991
+     * @param  string $value New name.
1992
+     */
1993
+    public function set_date_completed( $value ) {
1994
+        $this->set_completed_date( $value );
1995 1995
     }
1996 1996
 
1997 1997
     /**
1998
-	 * Set date when the invoice was last modified.
1999
-	 *
2000
-	 * @since 1.0.19
2001
-	 * @param string $value Value to set.
1998
+     * Set date when the invoice was last modified.
1999
+     *
2000
+     * @since 1.0.19
2001
+     * @param string $value Value to set.
2002 2002
      * @return bool Whether or not the date was set.
2003
-	 */
2004
-	public function set_date_modified( $value ) {
2003
+     */
2004
+    public function set_date_modified( $value ) {
2005 2005
         $date = strtotime( $value );
2006 2006
 
2007 2007
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2009,706 +2009,706 @@  discard block
 block discarded – undo
2009 2009
             return true;
2010 2010
         }
2011 2011
 
2012
-		$this->set_prop( 'date_modified', '' );
2012
+        $this->set_prop( 'date_modified', '' );
2013 2013
         return false;
2014 2014
 
2015 2015
     }
2016 2016
 
2017 2017
     /**
2018
-	 * Set the invoice number.
2019
-	 *
2020
-	 * @since 1.0.19
2021
-	 * @param  string $value New number.
2022
-	 */
2023
-	public function set_number( $value ) {
2018
+     * Set the invoice number.
2019
+     *
2020
+     * @since 1.0.19
2021
+     * @param  string $value New number.
2022
+     */
2023
+    public function set_number( $value ) {
2024 2024
         $number = sanitize_text_field( $value );
2025
-		$this->set_prop( 'number', $number );
2025
+        $this->set_prop( 'number', $number );
2026 2026
     }
2027 2027
 
2028 2028
     /**
2029
-	 * Set the invoice type.
2030
-	 *
2031
-	 * @since 1.0.19
2032
-	 * @param  string $value Type.
2033
-	 */
2034
-	public function set_type( $value ) {
2029
+     * Set the invoice type.
2030
+     *
2031
+     * @since 1.0.19
2032
+     * @param  string $value Type.
2033
+     */
2034
+    public function set_type( $value ) {
2035 2035
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2036
-		$this->set_prop( 'type', $type );
2037
-	}
2036
+        $this->set_prop( 'type', $type );
2037
+    }
2038 2038
 
2039 2039
     /**
2040
-	 * Set the invoice post type.
2041
-	 *
2042
-	 * @since 1.0.19
2043
-	 * @param  string $value Post type.
2044
-	 */
2045
-	public function set_post_type( $value ) {
2040
+     * Set the invoice post type.
2041
+     *
2042
+     * @since 1.0.19
2043
+     * @param  string $value Post type.
2044
+     */
2045
+    public function set_post_type( $value ) {
2046 2046
         if ( getpaid_is_invoice_post_type( $value ) ) {
2047
-			$this->set_type( $value );
2047
+            $this->set_type( $value );
2048 2048
             $this->set_prop( 'post_type', $value );
2049 2049
         }
2050 2050
     }
2051 2051
 
2052 2052
     /**
2053
-	 * Set the invoice key.
2054
-	 *
2055
-	 * @since 1.0.19
2056
-	 * @param  string $value New key.
2057
-	 */
2058
-	public function set_key( $value ) {
2053
+     * Set the invoice key.
2054
+     *
2055
+     * @since 1.0.19
2056
+     * @param  string $value New key.
2057
+     */
2058
+    public function set_key( $value ) {
2059 2059
         $key = sanitize_text_field( $value );
2060
-		$this->set_prop( 'key', $key );
2060
+        $this->set_prop( 'key', $key );
2061 2061
     }
2062 2062
 
2063 2063
     /**
2064
-	 * Set the invoice mode.
2065
-	 *
2066
-	 * @since 1.0.19
2067
-	 * @param  string $value mode.
2068
-	 */
2069
-	public function set_mode( $value ) {
2064
+     * Set the invoice mode.
2065
+     *
2066
+     * @since 1.0.19
2067
+     * @param  string $value mode.
2068
+     */
2069
+    public function set_mode( $value ) {
2070 2070
         if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2071 2071
             $this->set_prop( 'value', $value );
2072 2072
         }
2073 2073
     }
2074 2074
 
2075 2075
     /**
2076
-	 * Set the invoice path.
2077
-	 *
2078
-	 * @since 1.0.19
2079
-	 * @param  string $value path.
2080
-	 */
2081
-	public function set_path( $value ) {
2076
+     * Set the invoice path.
2077
+     *
2078
+     * @since 1.0.19
2079
+     * @param  string $value path.
2080
+     */
2081
+    public function set_path( $value ) {
2082 2082
         $this->set_prop( 'path', $value );
2083 2083
     }
2084 2084
 
2085 2085
     /**
2086
-	 * Set the invoice name.
2087
-	 *
2088
-	 * @since 1.0.19
2089
-	 * @param  string $value New name.
2090
-	 */
2091
-	public function set_name( $value ) {
2086
+     * Set the invoice name.
2087
+     *
2088
+     * @since 1.0.19
2089
+     * @param  string $value New name.
2090
+     */
2091
+    public function set_name( $value ) {
2092 2092
         $name = sanitize_text_field( $value );
2093
-		$this->set_prop( 'name', $name );
2093
+        $this->set_prop( 'name', $name );
2094 2094
     }
2095 2095
 
2096 2096
     /**
2097
-	 * Alias of self::set_name().
2098
-	 *
2099
-	 * @since 1.0.19
2100
-	 * @param  string $value New name.
2101
-	 */
2102
-	public function set_title( $value ) {
2103
-		$this->set_name( $value );
2097
+     * Alias of self::set_name().
2098
+     *
2099
+     * @since 1.0.19
2100
+     * @param  string $value New name.
2101
+     */
2102
+    public function set_title( $value ) {
2103
+        $this->set_name( $value );
2104 2104
     }
2105 2105
 
2106 2106
     /**
2107
-	 * Set the invoice description.
2108
-	 *
2109
-	 * @since 1.0.19
2110
-	 * @param  string $value New description.
2111
-	 */
2112
-	public function set_description( $value ) {
2107
+     * Set the invoice description.
2108
+     *
2109
+     * @since 1.0.19
2110
+     * @param  string $value New description.
2111
+     */
2112
+    public function set_description( $value ) {
2113 2113
         $description = wp_kses_post( $value );
2114
-		return $this->set_prop( 'description', $description );
2114
+        return $this->set_prop( 'description', $description );
2115 2115
     }
2116 2116
 
2117 2117
     /**
2118
-	 * Alias of self::set_description().
2119
-	 *
2120
-	 * @since 1.0.19
2121
-	 * @param  string $value New description.
2122
-	 */
2123
-	public function set_excerpt( $value ) {
2124
-		$this->set_description( $value );
2118
+     * Alias of self::set_description().
2119
+     *
2120
+     * @since 1.0.19
2121
+     * @param  string $value New description.
2122
+     */
2123
+    public function set_excerpt( $value ) {
2124
+        $this->set_description( $value );
2125 2125
     }
2126 2126
 
2127 2127
     /**
2128
-	 * Alias of self::set_description().
2129
-	 *
2130
-	 * @since 1.0.19
2131
-	 * @param  string $value New description.
2132
-	 */
2133
-	public function set_summary( $value ) {
2134
-		$this->set_description( $value );
2128
+     * Alias of self::set_description().
2129
+     *
2130
+     * @since 1.0.19
2131
+     * @param  string $value New description.
2132
+     */
2133
+    public function set_summary( $value ) {
2134
+        $this->set_description( $value );
2135 2135
     }
2136 2136
 
2137 2137
     /**
2138
-	 * Set the receiver of the invoice.
2139
-	 *
2140
-	 * @since 1.0.19
2141
-	 * @param  int $value New author.
2142
-	 */
2143
-	public function set_author( $value ) {
2144
-		$user = get_user_by( 'id', (int) $value );
2138
+     * Set the receiver of the invoice.
2139
+     *
2140
+     * @since 1.0.19
2141
+     * @param  int $value New author.
2142
+     */
2143
+    public function set_author( $value ) {
2144
+        $user = get_user_by( 'id', (int) $value );
2145 2145
 
2146
-		if ( $user && $user->ID ) {
2147
-			$this->set_prop( 'author', $user->ID );
2148
-			$this->set_prop( 'email', $user->user_email );
2149
-		}
2146
+        if ( $user && $user->ID ) {
2147
+            $this->set_prop( 'author', $user->ID );
2148
+            $this->set_prop( 'email', $user->user_email );
2149
+        }
2150 2150
 		
2151 2151
     }
2152 2152
 
2153 2153
     /**
2154
-	 * Alias of self::set_author().
2155
-	 *
2156
-	 * @since 1.0.19
2157
-	 * @param  int $value New user id.
2158
-	 */
2159
-	public function set_user_id( $value ) {
2160
-		$this->set_author( $value );
2154
+     * Alias of self::set_author().
2155
+     *
2156
+     * @since 1.0.19
2157
+     * @param  int $value New user id.
2158
+     */
2159
+    public function set_user_id( $value ) {
2160
+        $this->set_author( $value );
2161
+    }
2162
+
2163
+    /**
2164
+     * Alias of self::set_author().
2165
+     *
2166
+     * @since 1.0.19
2167
+     * @param  int $value New user id.
2168
+     */
2169
+    public function set_customer_id( $value ) {
2170
+        $this->set_author( $value );
2171
+    }
2172
+
2173
+    /**
2174
+     * Set the customer's ip.
2175
+     *
2176
+     * @since 1.0.19
2177
+     * @param  string $value ip address.
2178
+     */
2179
+    public function set_ip( $value ) {
2180
+        $this->set_prop( 'ip', $value );
2161 2181
     }
2162 2182
 
2163 2183
     /**
2164
-	 * Alias of self::set_author().
2165
-	 *
2166
-	 * @since 1.0.19
2167
-	 * @param  int $value New user id.
2168
-	 */
2169
-	public function set_customer_id( $value ) {
2170
-		$this->set_author( $value );
2184
+     * Alias of self::set_ip().
2185
+     *
2186
+     * @since 1.0.19
2187
+     * @param  string $value ip address.
2188
+     */
2189
+    public function set_user_ip( $value ) {
2190
+        $this->set_ip( $value );
2171 2191
     }
2172 2192
 
2173 2193
     /**
2174
-	 * Set the customer's ip.
2175
-	 *
2176
-	 * @since 1.0.19
2177
-	 * @param  string $value ip address.
2178
-	 */
2179
-	public function set_ip( $value ) {
2180
-		$this->set_prop( 'ip', $value );
2194
+     * Set the customer's first name.
2195
+     *
2196
+     * @since 1.0.19
2197
+     * @param  string $value first name.
2198
+     */
2199
+    public function set_first_name( $value ) {
2200
+        $this->set_prop( 'first_name', $value );
2181 2201
     }
2182 2202
 
2183 2203
     /**
2184
-	 * Alias of self::set_ip().
2185
-	 *
2186
-	 * @since 1.0.19
2187
-	 * @param  string $value ip address.
2188
-	 */
2189
-	public function set_user_ip( $value ) {
2190
-		$this->set_ip( $value );
2204
+     * Alias of self::set_first_name().
2205
+     *
2206
+     * @since 1.0.19
2207
+     * @param  string $value first name.
2208
+     */
2209
+    public function set_user_first_name( $value ) {
2210
+        $this->set_first_name( $value );
2191 2211
     }
2192 2212
 
2193 2213
     /**
2194
-	 * Set the customer's first name.
2195
-	 *
2196
-	 * @since 1.0.19
2197
-	 * @param  string $value first name.
2198
-	 */
2199
-	public function set_first_name( $value ) {
2200
-		$this->set_prop( 'first_name', $value );
2214
+     * Alias of self::set_first_name().
2215
+     *
2216
+     * @since 1.0.19
2217
+     * @param  string $value first name.
2218
+     */
2219
+    public function set_customer_first_name( $value ) {
2220
+        $this->set_first_name( $value );
2201 2221
     }
2202 2222
 
2203 2223
     /**
2204
-	 * Alias of self::set_first_name().
2205
-	 *
2206
-	 * @since 1.0.19
2207
-	 * @param  string $value first name.
2208
-	 */
2209
-	public function set_user_first_name( $value ) {
2210
-		$this->set_first_name( $value );
2224
+     * Set the customer's last name.
2225
+     *
2226
+     * @since 1.0.19
2227
+     * @param  string $value last name.
2228
+     */
2229
+    public function set_last_name( $value ) {
2230
+        $this->set_prop( 'last_name', $value );
2211 2231
     }
2212 2232
 
2213 2233
     /**
2214
-	 * Alias of self::set_first_name().
2215
-	 *
2216
-	 * @since 1.0.19
2217
-	 * @param  string $value first name.
2218
-	 */
2219
-	public function set_customer_first_name( $value ) {
2220
-		$this->set_first_name( $value );
2234
+     * Alias of self::set_last_name().
2235
+     *
2236
+     * @since 1.0.19
2237
+     * @param  string $value last name.
2238
+     */
2239
+    public function set_user_last_name( $value ) {
2240
+        $this->set_last_name( $value );
2221 2241
     }
2222 2242
 
2223 2243
     /**
2224
-	 * Set the customer's last name.
2225
-	 *
2226
-	 * @since 1.0.19
2227
-	 * @param  string $value last name.
2228
-	 */
2229
-	public function set_last_name( $value ) {
2230
-		$this->set_prop( 'last_name', $value );
2244
+     * Alias of self::set_last_name().
2245
+     *
2246
+     * @since 1.0.19
2247
+     * @param  string $value last name.
2248
+     */
2249
+    public function set_customer_last_name( $value ) {
2250
+        $this->set_last_name( $value );
2231 2251
     }
2232 2252
 
2233 2253
     /**
2234
-	 * Alias of self::set_last_name().
2235
-	 *
2236
-	 * @since 1.0.19
2237
-	 * @param  string $value last name.
2238
-	 */
2239
-	public function set_user_last_name( $value ) {
2240
-		$this->set_last_name( $value );
2254
+     * Set the customer's phone number.
2255
+     *
2256
+     * @since 1.0.19
2257
+     * @param  string $value phone.
2258
+     */
2259
+    public function set_phone( $value ) {
2260
+        $this->set_prop( 'phone', $value );
2241 2261
     }
2242 2262
 
2243 2263
     /**
2244
-	 * Alias of self::set_last_name().
2245
-	 *
2246
-	 * @since 1.0.19
2247
-	 * @param  string $value last name.
2248
-	 */
2249
-	public function set_customer_last_name( $value ) {
2250
-		$this->set_last_name( $value );
2264
+     * Alias of self::set_phone().
2265
+     *
2266
+     * @since 1.0.19
2267
+     * @param  string $value phone.
2268
+     */
2269
+    public function set_user_phone( $value ) {
2270
+        $this->set_phone( $value );
2271
+    }
2272
+
2273
+    /**
2274
+     * Alias of self::set_phone().
2275
+     *
2276
+     * @since 1.0.19
2277
+     * @param  string $value phone.
2278
+     */
2279
+    public function set_customer_phone( $value ) {
2280
+        $this->set_phone( $value );
2251 2281
     }
2252 2282
 
2253 2283
     /**
2254
-	 * Set the customer's phone number.
2255
-	 *
2256
-	 * @since 1.0.19
2257
-	 * @param  string $value phone.
2258
-	 */
2259
-	public function set_phone( $value ) {
2260
-		$this->set_prop( 'phone', $value );
2284
+     * Alias of self::set_phone().
2285
+     *
2286
+     * @since 1.0.19
2287
+     * @param  string $value phone.
2288
+     */
2289
+    public function set_phone_number( $value ) {
2290
+        $this->set_phone( $value );
2261 2291
     }
2262 2292
 
2263 2293
     /**
2264
-	 * Alias of self::set_phone().
2265
-	 *
2266
-	 * @since 1.0.19
2267
-	 * @param  string $value phone.
2268
-	 */
2269
-	public function set_user_phone( $value ) {
2270
-		$this->set_phone( $value );
2294
+     * Set the customer's email address.
2295
+     *
2296
+     * @since 1.0.19
2297
+     * @param  string $value email address.
2298
+     */
2299
+    public function set_email( $value ) {
2300
+        $this->set_prop( 'email', $value );
2271 2301
     }
2272 2302
 
2273 2303
     /**
2274
-	 * Alias of self::set_phone().
2275
-	 *
2276
-	 * @since 1.0.19
2277
-	 * @param  string $value phone.
2278
-	 */
2279
-	public function set_customer_phone( $value ) {
2280
-		$this->set_phone( $value );
2304
+     * Alias of self::set_email().
2305
+     *
2306
+     * @since 1.0.19
2307
+     * @param  string $value email address.
2308
+     */
2309
+    public function set_user_email( $value ) {
2310
+        $this->set_email( $value );
2281 2311
     }
2282 2312
 
2283 2313
     /**
2284
-	 * Alias of self::set_phone().
2285
-	 *
2286
-	 * @since 1.0.19
2287
-	 * @param  string $value phone.
2288
-	 */
2289
-	public function set_phone_number( $value ) {
2290
-		$this->set_phone( $value );
2314
+     * Alias of self::set_email().
2315
+     *
2316
+     * @since 1.0.19
2317
+     * @param  string $value email address.
2318
+     */
2319
+    public function set_email_address( $value ) {
2320
+        $this->set_email( $value );
2291 2321
     }
2292 2322
 
2293 2323
     /**
2294
-	 * Set the customer's email address.
2295
-	 *
2296
-	 * @since 1.0.19
2297
-	 * @param  string $value email address.
2298
-	 */
2299
-	public function set_email( $value ) {
2300
-		$this->set_prop( 'email', $value );
2324
+     * Alias of self::set_email().
2325
+     *
2326
+     * @since 1.0.19
2327
+     * @param  string $value email address.
2328
+     */
2329
+    public function set_customer_email( $value ) {
2330
+        $this->set_email( $value );
2301 2331
     }
2302 2332
 
2303 2333
     /**
2304
-	 * Alias of self::set_email().
2305
-	 *
2306
-	 * @since 1.0.19
2307
-	 * @param  string $value email address.
2308
-	 */
2309
-	public function set_user_email( $value ) {
2310
-		$this->set_email( $value );
2334
+     * Set the customer's country.
2335
+     *
2336
+     * @since 1.0.19
2337
+     * @param  string $value country.
2338
+     */
2339
+    public function set_country( $value ) {
2340
+        $this->set_prop( 'country', $value );
2311 2341
     }
2312 2342
 
2313 2343
     /**
2314
-	 * Alias of self::set_email().
2315
-	 *
2316
-	 * @since 1.0.19
2317
-	 * @param  string $value email address.
2318
-	 */
2319
-	public function set_email_address( $value ) {
2320
-		$this->set_email( $value );
2344
+     * Alias of self::set_country().
2345
+     *
2346
+     * @since 1.0.19
2347
+     * @param  string $value country.
2348
+     */
2349
+    public function set_user_country( $value ) {
2350
+        $this->set_country( $value );
2321 2351
     }
2322 2352
 
2323 2353
     /**
2324
-	 * Alias of self::set_email().
2325
-	 *
2326
-	 * @since 1.0.19
2327
-	 * @param  string $value email address.
2328
-	 */
2329
-	public function set_customer_email( $value ) {
2330
-		$this->set_email( $value );
2354
+     * Alias of self::set_country().
2355
+     *
2356
+     * @since 1.0.19
2357
+     * @param  string $value country.
2358
+     */
2359
+    public function set_customer_country( $value ) {
2360
+        $this->set_country( $value );
2331 2361
     }
2332 2362
 
2333 2363
     /**
2334
-	 * Set the customer's country.
2335
-	 *
2336
-	 * @since 1.0.19
2337
-	 * @param  string $value country.
2338
-	 */
2339
-	public function set_country( $value ) {
2340
-		$this->set_prop( 'country', $value );
2364
+     * Set the customer's state.
2365
+     *
2366
+     * @since 1.0.19
2367
+     * @param  string $value state.
2368
+     */
2369
+    public function set_state( $value ) {
2370
+        $this->set_prop( 'state', $value );
2341 2371
     }
2342 2372
 
2343 2373
     /**
2344
-	 * Alias of self::set_country().
2345
-	 *
2346
-	 * @since 1.0.19
2347
-	 * @param  string $value country.
2348
-	 */
2349
-	public function set_user_country( $value ) {
2350
-		$this->set_country( $value );
2374
+     * Alias of self::set_state().
2375
+     *
2376
+     * @since 1.0.19
2377
+     * @param  string $value state.
2378
+     */
2379
+    public function set_user_state( $value ) {
2380
+        $this->set_state( $value );
2351 2381
     }
2352 2382
 
2353 2383
     /**
2354
-	 * Alias of self::set_country().
2355
-	 *
2356
-	 * @since 1.0.19
2357
-	 * @param  string $value country.
2358
-	 */
2359
-	public function set_customer_country( $value ) {
2360
-		$this->set_country( $value );
2384
+     * Alias of self::set_state().
2385
+     *
2386
+     * @since 1.0.19
2387
+     * @param  string $value state.
2388
+     */
2389
+    public function set_customer_state( $value ) {
2390
+        $this->set_state( $value );
2361 2391
     }
2362 2392
 
2363 2393
     /**
2364
-	 * Set the customer's state.
2365
-	 *
2366
-	 * @since 1.0.19
2367
-	 * @param  string $value state.
2368
-	 */
2369
-	public function set_state( $value ) {
2370
-		$this->set_prop( 'state', $value );
2394
+     * Set the customer's city.
2395
+     *
2396
+     * @since 1.0.19
2397
+     * @param  string $value city.
2398
+     */
2399
+    public function set_city( $value ) {
2400
+        $this->set_prop( 'city', $value );
2371 2401
     }
2372 2402
 
2373 2403
     /**
2374
-	 * Alias of self::set_state().
2375
-	 *
2376
-	 * @since 1.0.19
2377
-	 * @param  string $value state.
2378
-	 */
2379
-	public function set_user_state( $value ) {
2380
-		$this->set_state( $value );
2404
+     * Alias of self::set_city().
2405
+     *
2406
+     * @since 1.0.19
2407
+     * @param  string $value city.
2408
+     */
2409
+    public function set_user_city( $value ) {
2410
+        $this->set_city( $value );
2381 2411
     }
2382 2412
 
2383 2413
     /**
2384
-	 * Alias of self::set_state().
2385
-	 *
2386
-	 * @since 1.0.19
2387
-	 * @param  string $value state.
2388
-	 */
2389
-	public function set_customer_state( $value ) {
2390
-		$this->set_state( $value );
2414
+     * Alias of self::set_city().
2415
+     *
2416
+     * @since 1.0.19
2417
+     * @param  string $value city.
2418
+     */
2419
+    public function set_customer_city( $value ) {
2420
+        $this->set_city( $value );
2391 2421
     }
2392 2422
 
2393 2423
     /**
2394
-	 * Set the customer's city.
2395
-	 *
2396
-	 * @since 1.0.19
2397
-	 * @param  string $value city.
2398
-	 */
2399
-	public function set_city( $value ) {
2400
-		$this->set_prop( 'city', $value );
2424
+     * Set the customer's zip code.
2425
+     *
2426
+     * @since 1.0.19
2427
+     * @param  string $value zip.
2428
+     */
2429
+    public function set_zip( $value ) {
2430
+        $this->set_prop( 'zip', $value );
2401 2431
     }
2402 2432
 
2403 2433
     /**
2404
-	 * Alias of self::set_city().
2405
-	 *
2406
-	 * @since 1.0.19
2407
-	 * @param  string $value city.
2408
-	 */
2409
-	public function set_user_city( $value ) {
2410
-		$this->set_city( $value );
2434
+     * Alias of self::set_zip().
2435
+     *
2436
+     * @since 1.0.19
2437
+     * @param  string $value zip.
2438
+     */
2439
+    public function set_user_zip( $value ) {
2440
+        $this->set_zip( $value );
2411 2441
     }
2412 2442
 
2413 2443
     /**
2414
-	 * Alias of self::set_city().
2415
-	 *
2416
-	 * @since 1.0.19
2417
-	 * @param  string $value city.
2418
-	 */
2419
-	public function set_customer_city( $value ) {
2420
-		$this->set_city( $value );
2444
+     * Alias of self::set_zip().
2445
+     *
2446
+     * @since 1.0.19
2447
+     * @param  string $value zip.
2448
+     */
2449
+    public function set_customer_zip( $value ) {
2450
+        $this->set_zip( $value );
2421 2451
     }
2422 2452
 
2423 2453
     /**
2424
-	 * Set the customer's zip code.
2425
-	 *
2426
-	 * @since 1.0.19
2427
-	 * @param  string $value zip.
2428
-	 */
2429
-	public function set_zip( $value ) {
2430
-		$this->set_prop( 'zip', $value );
2454
+     * Set the customer's company.
2455
+     *
2456
+     * @since 1.0.19
2457
+     * @param  string $value company.
2458
+     */
2459
+    public function set_company( $value ) {
2460
+        $this->set_prop( 'company', $value );
2431 2461
     }
2432 2462
 
2433 2463
     /**
2434
-	 * Alias of self::set_zip().
2435
-	 *
2436
-	 * @since 1.0.19
2437
-	 * @param  string $value zip.
2438
-	 */
2439
-	public function set_user_zip( $value ) {
2440
-		$this->set_zip( $value );
2464
+     * Alias of self::set_company().
2465
+     *
2466
+     * @since 1.0.19
2467
+     * @param  string $value company.
2468
+     */
2469
+    public function set_user_company( $value ) {
2470
+        $this->set_company( $value );
2441 2471
     }
2442 2472
 
2443 2473
     /**
2444
-	 * Alias of self::set_zip().
2445
-	 *
2446
-	 * @since 1.0.19
2447
-	 * @param  string $value zip.
2448
-	 */
2449
-	public function set_customer_zip( $value ) {
2450
-		$this->set_zip( $value );
2474
+     * Alias of self::set_company().
2475
+     *
2476
+     * @since 1.0.19
2477
+     * @param  string $value company.
2478
+     */
2479
+    public function set_customer_company( $value ) {
2480
+        $this->set_company( $value );
2451 2481
     }
2452 2482
 
2453 2483
     /**
2454
-	 * Set the customer's company.
2455
-	 *
2456
-	 * @since 1.0.19
2457
-	 * @param  string $value company.
2458
-	 */
2459
-	public function set_company( $value ) {
2460
-		$this->set_prop( 'company', $value );
2484
+     * Set the customer's var number.
2485
+     *
2486
+     * @since 1.0.19
2487
+     * @param  string $value var number.
2488
+     */
2489
+    public function set_vat_number( $value ) {
2490
+        $this->set_prop( 'vat_number', $value );
2461 2491
     }
2462 2492
 
2463 2493
     /**
2464
-	 * Alias of self::set_company().
2465
-	 *
2466
-	 * @since 1.0.19
2467
-	 * @param  string $value company.
2468
-	 */
2469
-	public function set_user_company( $value ) {
2470
-		$this->set_company( $value );
2494
+     * Alias of self::set_vat_number().
2495
+     *
2496
+     * @since 1.0.19
2497
+     * @param  string $value var number.
2498
+     */
2499
+    public function set_user_vat_number( $value ) {
2500
+        $this->set_vat_number( $value );
2471 2501
     }
2472 2502
 
2473 2503
     /**
2474
-	 * Alias of self::set_company().
2475
-	 *
2476
-	 * @since 1.0.19
2477
-	 * @param  string $value company.
2478
-	 */
2479
-	public function set_customer_company( $value ) {
2480
-		$this->set_company( $value );
2504
+     * Alias of self::set_vat_number().
2505
+     *
2506
+     * @since 1.0.19
2507
+     * @param  string $value var number.
2508
+     */
2509
+    public function set_customer_vat_number( $value ) {
2510
+        $this->set_vat_number( $value );
2481 2511
     }
2482 2512
 
2483 2513
     /**
2484
-	 * Set the customer's var number.
2485
-	 *
2486
-	 * @since 1.0.19
2487
-	 * @param  string $value var number.
2488
-	 */
2489
-	public function set_vat_number( $value ) {
2490
-		$this->set_prop( 'vat_number', $value );
2514
+     * Set the customer's vat rate.
2515
+     *
2516
+     * @since 1.0.19
2517
+     * @param  string $value var rate.
2518
+     */
2519
+    public function set_vat_rate( $value ) {
2520
+        $this->set_prop( 'vat_rate', $value );
2491 2521
     }
2492 2522
 
2493 2523
     /**
2494
-	 * Alias of self::set_vat_number().
2495
-	 *
2496
-	 * @since 1.0.19
2497
-	 * @param  string $value var number.
2498
-	 */
2499
-	public function set_user_vat_number( $value ) {
2500
-		$this->set_vat_number( $value );
2524
+     * Alias of self::set_vat_rate().
2525
+     *
2526
+     * @since 1.0.19
2527
+     * @param  string $value var number.
2528
+     */
2529
+    public function set_user_vat_rate( $value ) {
2530
+        $this->set_vat_rate( $value );
2501 2531
     }
2502 2532
 
2503 2533
     /**
2504
-	 * Alias of self::set_vat_number().
2505
-	 *
2506
-	 * @since 1.0.19
2507
-	 * @param  string $value var number.
2508
-	 */
2509
-	public function set_customer_vat_number( $value ) {
2510
-		$this->set_vat_number( $value );
2534
+     * Alias of self::set_vat_rate().
2535
+     *
2536
+     * @since 1.0.19
2537
+     * @param  string $value var number.
2538
+     */
2539
+    public function set_customer_vat_rate( $value ) {
2540
+        $this->set_vat_rate( $value );
2511 2541
     }
2512 2542
 
2513 2543
     /**
2514
-	 * Set the customer's vat rate.
2515
-	 *
2516
-	 * @since 1.0.19
2517
-	 * @param  string $value var rate.
2518
-	 */
2519
-	public function set_vat_rate( $value ) {
2520
-		$this->set_prop( 'vat_rate', $value );
2544
+     * Set the customer's address.
2545
+     *
2546
+     * @since 1.0.19
2547
+     * @param  string $value address.
2548
+     */
2549
+    public function set_address( $value ) {
2550
+        $this->set_prop( 'address', $value );
2521 2551
     }
2522 2552
 
2523 2553
     /**
2524
-	 * Alias of self::set_vat_rate().
2525
-	 *
2526
-	 * @since 1.0.19
2527
-	 * @param  string $value var number.
2528
-	 */
2529
-	public function set_user_vat_rate( $value ) {
2530
-		$this->set_vat_rate( $value );
2554
+     * Alias of self::set_address().
2555
+     *
2556
+     * @since 1.0.19
2557
+     * @param  string $value address.
2558
+     */
2559
+    public function set_user_address( $value ) {
2560
+        $this->set_address( $value );
2531 2561
     }
2532 2562
 
2533 2563
     /**
2534
-	 * Alias of self::set_vat_rate().
2535
-	 *
2536
-	 * @since 1.0.19
2537
-	 * @param  string $value var number.
2538
-	 */
2539
-	public function set_customer_vat_rate( $value ) {
2540
-		$this->set_vat_rate( $value );
2564
+     * Alias of self::set_address().
2565
+     *
2566
+     * @since 1.0.19
2567
+     * @param  string $value address.
2568
+     */
2569
+    public function set_customer_address( $value ) {
2570
+        $this->set_address( $value );
2541 2571
     }
2542 2572
 
2543 2573
     /**
2544
-	 * Set the customer's address.
2545
-	 *
2546
-	 * @since 1.0.19
2547
-	 * @param  string $value address.
2548
-	 */
2549
-	public function set_address( $value ) {
2550
-		$this->set_prop( 'address', $value );
2574
+     * Set whether the customer has viewed the invoice or not.
2575
+     *
2576
+     * @since 1.0.19
2577
+     * @param  int|bool $value confirmed.
2578
+     */
2579
+    public function set_is_viewed( $value ) {
2580
+        $this->set_prop( 'is_viewed', $value );
2551 2581
     }
2552 2582
 
2553 2583
     /**
2554
-	 * Alias of self::set_address().
2555
-	 *
2556
-	 * @since 1.0.19
2557
-	 * @param  string $value address.
2558
-	 */
2559
-	public function set_user_address( $value ) {
2560
-		$this->set_address( $value );
2584
+     * Set extra email recipients.
2585
+     *
2586
+     * @since 1.0.19
2587
+     * @param  string $value email recipients.
2588
+     */
2589
+    public function set_email_cc( $value ) {
2590
+        $this->set_prop( 'email_cc', $value );
2561 2591
     }
2562 2592
 
2563 2593
     /**
2564
-	 * Alias of self::set_address().
2565
-	 *
2566
-	 * @since 1.0.19
2567
-	 * @param  string $value address.
2568
-	 */
2569
-	public function set_customer_address( $value ) {
2570
-		$this->set_address( $value );
2594
+     * Set the invoice template.
2595
+     *
2596
+     * @since 1.0.19
2597
+     * @param  string $value email recipients.
2598
+     */
2599
+    public function set_template( $value ) {
2600
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2601
+            $this->set_prop( 'template', $value );
2602
+        }
2571 2603
     }
2572 2604
 
2573 2605
     /**
2574
-	 * Set whether the customer has viewed the invoice or not.
2575
-	 *
2576
-	 * @since 1.0.19
2577
-	 * @param  int|bool $value confirmed.
2578
-	 */
2579
-	public function set_is_viewed( $value ) {
2580
-		$this->set_prop( 'is_viewed', $value );
2581
-	}
2582
-
2583
-	/**
2584
-	 * Set extra email recipients.
2585
-	 *
2586
-	 * @since 1.0.19
2587
-	 * @param  string $value email recipients.
2588
-	 */
2589
-	public function set_email_cc( $value ) {
2590
-		$this->set_prop( 'email_cc', $value );
2591
-	}
2592
-
2593
-	/**
2594
-	 * Set the invoice template.
2595
-	 *
2596
-	 * @since 1.0.19
2597
-	 * @param  string $value email recipients.
2598
-	 */
2599
-	public function set_template( $value ) {
2600
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2601
-			$this->set_prop( 'template', $value );
2602
-		}
2603
-	}
2604
-
2605
-	/**
2606
-	 * Set the customer's address confirmed status.
2607
-	 *
2608
-	 * @since 1.0.19
2609
-	 * @param  int|bool $value confirmed.
2610
-	 */
2611
-	public function set_address_confirmed( $value ) {
2612
-		$this->set_prop( 'address_confirmed', $value );
2606
+     * Set the customer's address confirmed status.
2607
+     *
2608
+     * @since 1.0.19
2609
+     * @param  int|bool $value confirmed.
2610
+     */
2611
+    public function set_address_confirmed( $value ) {
2612
+        $this->set_prop( 'address_confirmed', $value );
2613 2613
     }
2614 2614
 
2615 2615
     /**
2616
-	 * Alias of self::set_address_confirmed().
2617
-	 *
2618
-	 * @since 1.0.19
2619
-	 * @param  int|bool $value confirmed.
2620
-	 */
2621
-	public function set_user_address_confirmed( $value ) {
2622
-		$this->set_address_confirmed( $value );
2616
+     * Alias of self::set_address_confirmed().
2617
+     *
2618
+     * @since 1.0.19
2619
+     * @param  int|bool $value confirmed.
2620
+     */
2621
+    public function set_user_address_confirmed( $value ) {
2622
+        $this->set_address_confirmed( $value );
2623 2623
     }
2624 2624
 
2625 2625
     /**
2626
-	 * Alias of self::set_address_confirmed().
2627
-	 *
2628
-	 * @since 1.0.19
2629
-	 * @param  int|bool $value confirmed.
2630
-	 */
2631
-	public function set_customer_address_confirmed( $value ) {
2632
-		$this->set_address_confirmed( $value );
2626
+     * Alias of self::set_address_confirmed().
2627
+     *
2628
+     * @since 1.0.19
2629
+     * @param  int|bool $value confirmed.
2630
+     */
2631
+    public function set_customer_address_confirmed( $value ) {
2632
+        $this->set_address_confirmed( $value );
2633 2633
     }
2634 2634
 
2635 2635
     /**
2636
-	 * Set the invoice sub total.
2637
-	 *
2638
-	 * @since 1.0.19
2639
-	 * @param  float $value sub total.
2640
-	 */
2641
-	public function set_subtotal( $value ) {
2642
-		$this->set_prop( 'subtotal', $value );
2636
+     * Set the invoice sub total.
2637
+     *
2638
+     * @since 1.0.19
2639
+     * @param  float $value sub total.
2640
+     */
2641
+    public function set_subtotal( $value ) {
2642
+        $this->set_prop( 'subtotal', $value );
2643 2643
     }
2644 2644
 
2645 2645
     /**
2646
-	 * Set the invoice discount amount.
2647
-	 *
2648
-	 * @since 1.0.19
2649
-	 * @param  float $value discount total.
2650
-	 */
2651
-	public function set_total_discount( $value ) {
2652
-		$this->set_prop( 'total_discount', $value );
2646
+     * Set the invoice discount amount.
2647
+     *
2648
+     * @since 1.0.19
2649
+     * @param  float $value discount total.
2650
+     */
2651
+    public function set_total_discount( $value ) {
2652
+        $this->set_prop( 'total_discount', $value );
2653 2653
     }
2654 2654
 
2655 2655
     /**
2656
-	 * Alias of self::set_total_discount().
2657
-	 *
2658
-	 * @since 1.0.19
2659
-	 * @param  float $value discount total.
2660
-	 */
2661
-	public function set_discount( $value ) {
2662
-		$this->set_total_discount( $value );
2656
+     * Alias of self::set_total_discount().
2657
+     *
2658
+     * @since 1.0.19
2659
+     * @param  float $value discount total.
2660
+     */
2661
+    public function set_discount( $value ) {
2662
+        $this->set_total_discount( $value );
2663 2663
     }
2664 2664
 
2665 2665
     /**
2666
-	 * Set the invoice tax amount.
2667
-	 *
2668
-	 * @since 1.0.19
2669
-	 * @param  float $value tax total.
2670
-	 */
2671
-	public function set_total_tax( $value ) {
2672
-		$this->set_prop( 'total_tax', $value );
2666
+     * Set the invoice tax amount.
2667
+     *
2668
+     * @since 1.0.19
2669
+     * @param  float $value tax total.
2670
+     */
2671
+    public function set_total_tax( $value ) {
2672
+        $this->set_prop( 'total_tax', $value );
2673 2673
     }
2674 2674
 
2675 2675
     /**
2676
-	 * Alias of self::set_total_tax().
2677
-	 *
2678
-	 * @since 1.0.19
2679
-	 * @param  float $value tax total.
2680
-	 */
2681
-	public function set_tax_total( $value ) {
2682
-		$this->set_total_tax( $value );
2676
+     * Alias of self::set_total_tax().
2677
+     *
2678
+     * @since 1.0.19
2679
+     * @param  float $value tax total.
2680
+     */
2681
+    public function set_tax_total( $value ) {
2682
+        $this->set_total_tax( $value );
2683 2683
     }
2684 2684
 
2685 2685
     /**
2686
-	 * Set the invoice fees amount.
2687
-	 *
2688
-	 * @since 1.0.19
2689
-	 * @param  float $value fees total.
2690
-	 */
2691
-	public function set_total_fees( $value ) {
2692
-		$this->set_prop( 'total_fees', $value );
2686
+     * Set the invoice fees amount.
2687
+     *
2688
+     * @since 1.0.19
2689
+     * @param  float $value fees total.
2690
+     */
2691
+    public function set_total_fees( $value ) {
2692
+        $this->set_prop( 'total_fees', $value );
2693 2693
     }
2694 2694
 
2695 2695
     /**
2696
-	 * Alias of self::set_total_fees().
2697
-	 *
2698
-	 * @since 1.0.19
2699
-	 * @param  float $value fees total.
2700
-	 */
2701
-	public function set_fees_total( $value ) {
2702
-		$this->set_total_fees( $value );
2696
+     * Alias of self::set_total_fees().
2697
+     *
2698
+     * @since 1.0.19
2699
+     * @param  float $value fees total.
2700
+     */
2701
+    public function set_fees_total( $value ) {
2702
+        $this->set_total_fees( $value );
2703 2703
     }
2704 2704
 
2705 2705
     /**
2706
-	 * Set the invoice fees.
2707
-	 *
2708
-	 * @since 1.0.19
2709
-	 * @param  array $value fees.
2710
-	 */
2711
-	public function set_fees( $value ) {
2706
+     * Set the invoice fees.
2707
+     *
2708
+     * @since 1.0.19
2709
+     * @param  array $value fees.
2710
+     */
2711
+    public function set_fees( $value ) {
2712 2712
 
2713 2713
         $this->set_prop( 'fees', array() );
2714 2714
 
@@ -2726,23 +2726,23 @@  discard block
 block discarded – undo
2726 2726
     }
2727 2727
 
2728 2728
     /**
2729
-	 * Set the invoice taxes.
2730
-	 *
2731
-	 * @since 1.0.19
2732
-	 * @param  array $value taxes.
2733
-	 */
2734
-	public function set_taxes( $value ) {
2735
-		$this->set_prop( 'taxes', $value );
2729
+     * Set the invoice taxes.
2730
+     *
2731
+     * @since 1.0.19
2732
+     * @param  array $value taxes.
2733
+     */
2734
+    public function set_taxes( $value ) {
2735
+        $this->set_prop( 'taxes', $value );
2736 2736
     }
2737 2737
 
2738 2738
     /**
2739
-	 * Set the invoice discounts.
2740
-	 *
2741
-	 * @since 1.0.19
2742
-	 * @param  array $value discounts.
2743
-	 */
2744
-	public function set_discounts( $value ) {
2745
-		$this->set_prop( 'discounts', array() );
2739
+     * Set the invoice discounts.
2740
+     *
2741
+     * @since 1.0.19
2742
+     * @param  array $value discounts.
2743
+     */
2744
+    public function set_discounts( $value ) {
2745
+        $this->set_prop( 'discounts', array() );
2746 2746
 
2747 2747
         // Ensure that we have an array.
2748 2748
         if ( ! is_array( $value ) ) {
@@ -2757,12 +2757,12 @@  discard block
 block discarded – undo
2757 2757
     }
2758 2758
 
2759 2759
     /**
2760
-	 * Set the invoice items.
2761
-	 *
2762
-	 * @since 1.0.19
2763
-	 * @param  GetPaid_Form_Item[] $value items.
2764
-	 */
2765
-	public function set_items( $value ) {
2760
+     * Set the invoice items.
2761
+     *
2762
+     * @since 1.0.19
2763
+     * @param  GetPaid_Form_Item[] $value items.
2764
+     */
2765
+    public function set_items( $value ) {
2766 2766
 
2767 2767
         // Remove existing items.
2768 2768
         $this->set_prop( 'items', array() );
@@ -2779,85 +2779,85 @@  discard block
 block discarded – undo
2779 2779
     }
2780 2780
 
2781 2781
     /**
2782
-	 * Set the payment form.
2783
-	 *
2784
-	 * @since 1.0.19
2785
-	 * @param  int $value payment form.
2786
-	 */
2787
-	public function set_payment_form( $value ) {
2788
-		$this->set_prop( 'payment_form', $value );
2782
+     * Set the payment form.
2783
+     *
2784
+     * @since 1.0.19
2785
+     * @param  int $value payment form.
2786
+     */
2787
+    public function set_payment_form( $value ) {
2788
+        $this->set_prop( 'payment_form', $value );
2789 2789
     }
2790 2790
 
2791 2791
     /**
2792
-	 * Set the submission id.
2793
-	 *
2794
-	 * @since 1.0.19
2795
-	 * @param  string $value submission id.
2796
-	 */
2797
-	public function set_submission_id( $value ) {
2798
-		$this->set_prop( 'submission_id', $value );
2792
+     * Set the submission id.
2793
+     *
2794
+     * @since 1.0.19
2795
+     * @param  string $value submission id.
2796
+     */
2797
+    public function set_submission_id( $value ) {
2798
+        $this->set_prop( 'submission_id', $value );
2799 2799
     }
2800 2800
 
2801 2801
     /**
2802
-	 * Set the discount code.
2803
-	 *
2804
-	 * @since 1.0.19
2805
-	 * @param  string $value discount code.
2806
-	 */
2807
-	public function set_discount_code( $value ) {
2808
-		$this->set_prop( 'discount_code', $value );
2802
+     * Set the discount code.
2803
+     *
2804
+     * @since 1.0.19
2805
+     * @param  string $value discount code.
2806
+     */
2807
+    public function set_discount_code( $value ) {
2808
+        $this->set_prop( 'discount_code', $value );
2809 2809
     }
2810 2810
 
2811 2811
     /**
2812
-	 * Set the gateway.
2813
-	 *
2814
-	 * @since 1.0.19
2815
-	 * @param  string $value gateway.
2816
-	 */
2817
-	public function set_gateway( $value ) {
2818
-		$this->set_prop( 'gateway', $value );
2812
+     * Set the gateway.
2813
+     *
2814
+     * @since 1.0.19
2815
+     * @param  string $value gateway.
2816
+     */
2817
+    public function set_gateway( $value ) {
2818
+        $this->set_prop( 'gateway', $value );
2819 2819
     }
2820 2820
 
2821 2821
     /**
2822
-	 * Set the transaction id.
2823
-	 *
2824
-	 * @since 1.0.19
2825
-	 * @param  string $value transaction id.
2826
-	 */
2827
-	public function set_transaction_id( $value ) {
2828
-		if ( ! empty( $value ) ) {
2829
-			$this->set_prop( 'transaction_id', $value );
2830
-		}
2822
+     * Set the transaction id.
2823
+     *
2824
+     * @since 1.0.19
2825
+     * @param  string $value transaction id.
2826
+     */
2827
+    public function set_transaction_id( $value ) {
2828
+        if ( ! empty( $value ) ) {
2829
+            $this->set_prop( 'transaction_id', $value );
2830
+        }
2831 2831
     }
2832 2832
 
2833 2833
     /**
2834
-	 * Set the currency id.
2835
-	 *
2836
-	 * @since 1.0.19
2837
-	 * @param  string $value currency id.
2838
-	 */
2839
-	public function set_currency( $value ) {
2840
-		$this->set_prop( 'currency', $value );
2834
+     * Set the currency id.
2835
+     *
2836
+     * @since 1.0.19
2837
+     * @param  string $value currency id.
2838
+     */
2839
+    public function set_currency( $value ) {
2840
+        $this->set_prop( 'currency', $value );
2841 2841
     }
2842 2842
 
2843
-	/**
2844
-	 * Set whether to disable taxes.
2845
-	 *
2846
-	 * @since 1.0.19
2847
-	 * @param  bool $value value.
2848
-	 */
2849
-	public function set_disable_taxes( $value ) {
2850
-		$this->set_prop( 'disable_taxes', (bool) $value );
2851
-	}
2843
+    /**
2844
+     * Set whether to disable taxes.
2845
+     *
2846
+     * @since 1.0.19
2847
+     * @param  bool $value value.
2848
+     */
2849
+    public function set_disable_taxes( $value ) {
2850
+        $this->set_prop( 'disable_taxes', (bool) $value );
2851
+    }
2852 2852
 
2853 2853
     /**
2854
-	 * Set the subscription id.
2855
-	 *
2856
-	 * @since 1.0.19
2857
-	 * @param  string $value subscription id.
2858
-	 */
2859
-	public function set_subscription_id( $value ) {
2860
-		$this->set_prop( 'subscription_id', $value );
2854
+     * Set the subscription id.
2855
+     *
2856
+     * @since 1.0.19
2857
+     * @param  string $value subscription id.
2858
+     */
2859
+    public function set_subscription_id( $value ) {
2860
+        $this->set_prop( 'subscription_id', $value );
2861 2861
     }
2862 2862
 
2863 2863
     /*
@@ -2896,12 +2896,12 @@  discard block
 block discarded – undo
2896 2896
      */
2897 2897
     public function is_taxable() {
2898 2898
         return ! $this->get_disable_taxes();
2899
-	}
2899
+    }
2900 2900
 
2901
-	/**
2902
-	 * @deprecated
2903
-	 */
2904
-	public function has_vat() {
2901
+    /**
2902
+     * @deprecated
2903
+     */
2904
+    public function has_vat() {
2905 2905
         global $wpinv_euvat, $wpi_country;
2906 2906
 
2907 2907
         $requires_vat = false;
@@ -2912,17 +2912,17 @@  discard block
 block discarded – undo
2912 2912
         }
2913 2913
 
2914 2914
         return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2915
-	}
2915
+    }
2916 2916
 
2917
-	/**
2918
-	 * Checks to see if the invoice requires payment.
2919
-	 */
2920
-	public function is_free() {
2917
+    /**
2918
+     * Checks to see if the invoice requires payment.
2919
+     */
2920
+    public function is_free() {
2921 2921
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2922 2922
 
2923
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2924
-			$is_free = false;
2925
-		}
2923
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2924
+            $is_free = false;
2925
+        }
2926 2926
 
2927 2927
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2928 2928
     }
@@ -2933,46 +2933,46 @@  discard block
 block discarded – undo
2933 2933
     public function is_paid() {
2934 2934
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2935 2935
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2936
-	}
2936
+    }
2937 2937
 
2938
-	/**
2938
+    /**
2939 2939
      * Checks if the invoice needs payment.
2940 2940
      */
2941
-	public function needs_payment() {
2942
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2941
+    public function needs_payment() {
2942
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2943 2943
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2944 2944
     }
2945 2945
 
2946
-	/**
2946
+    /**
2947 2947
      * Checks if the invoice is refunded.
2948 2948
      */
2949
-	public function is_refunded() {
2949
+    public function is_refunded() {
2950 2950
         $is_refunded = $this->has_status( 'wpi-refunded' );
2951 2951
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2952
-	}
2952
+    }
2953 2953
 
2954
-	/**
2954
+    /**
2955 2955
      * Checks if the invoice is held.
2956 2956
      */
2957
-	public function is_held() {
2957
+    public function is_held() {
2958 2958
         $is_held = $this->has_status( 'wpi-onhold' );
2959 2959
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2960
-	}
2960
+    }
2961 2961
 
2962
-	/**
2962
+    /**
2963 2963
      * Checks if the invoice is due.
2964 2964
      */
2965
-	public function is_due() {
2966
-		$due_date = $this->get_due_date();
2967
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2968
-	}
2965
+    public function is_due() {
2966
+        $due_date = $this->get_due_date();
2967
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2968
+    }
2969 2969
 
2970
-	/**
2970
+    /**
2971 2971
      * Checks if the invoice is draft.
2972 2972
      */
2973
-	public function is_draft() {
2973
+    public function is_draft() {
2974 2974
         return $this->has_status( 'draft, auto-draft' );
2975
-	}
2975
+    }
2976 2976
 
2977 2977
     /**
2978 2978
      * Checks if the invoice has a given status.
@@ -2980,9 +2980,9 @@  discard block
 block discarded – undo
2980 2980
     public function has_status( $status ) {
2981 2981
         $status = wpinv_parse_list( $status );
2982 2982
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
2983
-	}
2983
+    }
2984 2984
 
2985
-	/**
2985
+    /**
2986 2986
      * Checks if the invoice is of a given type.
2987 2987
      */
2988 2988
     public function is_type( $type ) {
@@ -3005,25 +3005,25 @@  discard block
 block discarded – undo
3005 3005
      */
3006 3006
     public function has_free_trial() {
3007 3007
         return $this->is_recurring() && 0 == $this->get_initial_total();
3008
-	}
3008
+    }
3009 3009
 
3010
-	/**
3010
+    /**
3011 3011
      * @deprecated
3012 3012
      */
3013 3013
     public function is_free_trial() {
3014 3014
         $this->has_free_trial();
3015 3015
     }
3016 3016
 
3017
-	/**
3017
+    /**
3018 3018
      * Check if the initial payment if 0.
3019 3019
      *
3020 3020
      */
3021
-	public function is_initial_free() {
3021
+    public function is_initial_free() {
3022 3022
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3023 3023
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3024 3024
     }
3025 3025
 	
3026
-	/**
3026
+    /**
3027 3027
      * Check if the recurring item has a free trial.
3028 3028
      *
3029 3029
      */
@@ -3036,21 +3036,21 @@  discard block
 block discarded – undo
3036 3036
 
3037 3037
         $item = $this->get_recurring( true );
3038 3038
         return $item->has_free_trial();
3039
-	}
3039
+    }
3040 3040
 
3041
-	/**
3041
+    /**
3042 3042
      * Check if the free trial is a result of a discount.
3043 3043
      */
3044 3044
     public function is_free_trial_from_discount() {
3045
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3046
-	}
3045
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3046
+    }
3047 3047
 	
3048
-	/**
3048
+    /**
3049 3049
      * @deprecated
3050 3050
      */
3051 3051
     public function discount_first_payment_only() {
3052 3052
 
3053
-		$discount_code = $this->get_discount_code();
3053
+        $discount_code = $this->get_discount_code();
3054 3054
         if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3055 3055
             return true;
3056 3056
         }
@@ -3081,28 +3081,28 @@  discard block
 block discarded – undo
3081 3081
      */
3082 3082
     public function add_item( $item ) {
3083 3083
 
3084
-		if ( is_array( $item ) ) {
3085
-			$item = $this->process_array_item( $item );
3086
-		}
3084
+        if ( is_array( $item ) ) {
3085
+            $item = $this->process_array_item( $item );
3086
+        }
3087 3087
 
3088
-		if ( is_numeric( $item ) ) {
3089
-			$item = new GetPaid_Form_Item( $item );
3090
-		}
3088
+        if ( is_numeric( $item ) ) {
3089
+            $item = new GetPaid_Form_Item( $item );
3090
+        }
3091 3091
 
3092 3092
         // Make sure that it is available for purchase.
3093
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3094
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3093
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3094
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3095 3095
         }
3096 3096
 
3097 3097
         // Do we have a recurring item?
3098
-		if ( $item->is_recurring() ) {
3098
+        if ( $item->is_recurring() ) {
3099 3099
 
3100
-			// An invoice can only contain one recurring item.
3101
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3102
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3103
-			}
3100
+            // An invoice can only contain one recurring item.
3101
+            if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3102
+                return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3103
+            }
3104 3104
 
3105
-			$this->recurring_item = $item->get_id();
3105
+            $this->recurring_item = $item->get_id();
3106 3106
         }
3107 3107
 
3108 3108
         // Invoice id.
@@ -3113,60 +3113,60 @@  discard block
 block discarded – undo
3113 3113
         $items[ (int) $item->get_id() ] = $item;
3114 3114
 
3115 3115
         $this->set_prop( 'items', $items );
3116
-		return true;
3117
-	}
3116
+        return true;
3117
+    }
3118 3118
 	
3119
-	/**
3120
-	 * Converts an array to an item.
3121
-	 *
3122
-	 * @since 1.0.19
3123
-	 * @return GetPaid_Form_Item
3124
-	 */
3125
-	protected function process_array_item( $array ) {
3126
-
3127
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3128
-		$item    = new GetPaid_Form_Item( $item_id );
3129
-
3130
-		// Set item data.
3131
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3132
-			if ( isset( $array[ "item_$key" ] ) ) {
3133
-				$method = "set_$key";
3134
-				$item->$method( $array[ "item_$key" ] );
3135
-			}
3136
-		}
3137
-
3138
-		if ( isset( $array['quantity'] ) ) {
3139
-			$item->set_quantity( $array['quantity'] );
3140
-		}
3141
-
3142
-		// Set item meta.
3143
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3144
-			$item->set_item_meta( $array['meta'] );
3145
-		}
3146
-
3147
-		return $item;
3148
-
3149
-	}
3150
-
3151
-    /**
3152
-	 * Retrieves a specific item.
3153
-	 *
3154
-	 * @since 1.0.19
3155
-	 */
3156
-	public function get_item( $item_id ) {
3157
-		$items   = $this->get_items();
3158
-		$item_id = (int) $item_id;
3159
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3160
-    }
3161
-
3162
-    /**
3163
-	 * Removes a specific item.
3164
-	 *
3165
-	 * @since 1.0.19
3166
-	 */
3167
-	public function remove_item( $item_id ) {
3168
-		$items   = $this->get_items();
3169
-		$item_id = (int) $item_id;
3119
+    /**
3120
+     * Converts an array to an item.
3121
+     *
3122
+     * @since 1.0.19
3123
+     * @return GetPaid_Form_Item
3124
+     */
3125
+    protected function process_array_item( $array ) {
3126
+
3127
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3128
+        $item    = new GetPaid_Form_Item( $item_id );
3129
+
3130
+        // Set item data.
3131
+        foreach( array( 'name', 'price', 'description' ) as $key ) {
3132
+            if ( isset( $array[ "item_$key" ] ) ) {
3133
+                $method = "set_$key";
3134
+                $item->$method( $array[ "item_$key" ] );
3135
+            }
3136
+        }
3137
+
3138
+        if ( isset( $array['quantity'] ) ) {
3139
+            $item->set_quantity( $array['quantity'] );
3140
+        }
3141
+
3142
+        // Set item meta.
3143
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3144
+            $item->set_item_meta( $array['meta'] );
3145
+        }
3146
+
3147
+        return $item;
3148
+
3149
+    }
3150
+
3151
+    /**
3152
+     * Retrieves a specific item.
3153
+     *
3154
+     * @since 1.0.19
3155
+     */
3156
+    public function get_item( $item_id ) {
3157
+        $items   = $this->get_items();
3158
+        $item_id = (int) $item_id;
3159
+        return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3160
+    }
3161
+
3162
+    /**
3163
+     * Removes a specific item.
3164
+     *
3165
+     * @since 1.0.19
3166
+     */
3167
+    public function remove_item( $item_id ) {
3168
+        $items   = $this->get_items();
3169
+        $item_id = (int) $item_id;
3170 3170
 
3171 3171
         if ( $item_id == $this->recurring_item ) {
3172 3172
             $this->recurring_item = null;
@@ -3193,38 +3193,38 @@  discard block
 block discarded – undo
3193 3193
         if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3194 3194
 
3195 3195
             $amount = $fees[ $fee ]['amount'] += $amount;
3196
-			$fees[ $fee ] = array(
3197
-				'amount'    => $amount,
3196
+            $fees[ $fee ] = array(
3197
+                'amount'    => $amount,
3198 3198
                 'recurring' => (bool) $recurring,
3199 3199
             );
3200 3200
 
3201
-		} else {
3202
-			$fees[ $fee ] = array(
3201
+        } else {
3202
+            $fees[ $fee ] = array(
3203 3203
                 'amount'    => $amount,
3204 3204
                 'recurring' => (bool) $recurring,
3205 3205
             );
3206
-		}
3206
+        }
3207 3207
 
3208 3208
         $this->set_prop( 'fees', $fee );
3209 3209
 
3210 3210
     }
3211 3211
 
3212 3212
     /**
3213
-	 * Retrieves a specific fee.
3214
-	 *
3215
-	 * @since 1.0.19
3216
-	 */
3217
-	public function get_fee( $fee ) {
3213
+     * Retrieves a specific fee.
3214
+     *
3215
+     * @since 1.0.19
3216
+     */
3217
+    public function get_fee( $fee ) {
3218 3218
         $fees = $this->get_fees();
3219
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3219
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3220 3220
     }
3221 3221
 
3222 3222
     /**
3223
-	 * Removes a specific fee.
3224
-	 *
3225
-	 * @since 1.0.19
3226
-	 */
3227
-	public function remove_fee( $fee ) {
3223
+     * Removes a specific fee.
3224
+     *
3225
+     * @since 1.0.19
3226
+     */
3227
+    public function remove_fee( $fee ) {
3228 3228
         $fees = $this->get_fees();
3229 3229
         if ( isset( $fees[ $fee ] ) ) {
3230 3230
             unset( $fees[ $fee ] );
@@ -3247,44 +3247,44 @@  discard block
 block discarded – undo
3247 3247
         if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3248 3248
 
3249 3249
             $amount = $discounts[ $discount ]['amount'] += $amount;
3250
-			$discounts[ $discount ] = array(
3250
+            $discounts[ $discount ] = array(
3251 3251
                 'amount'    => $amount,
3252 3252
                 'recurring' => (bool) $recurring,
3253 3253
             );
3254 3254
 
3255
-		} else {
3256
-			$discounts[ $discount ] = array(
3255
+        } else {
3256
+            $discounts[ $discount ] = array(
3257 3257
                 'amount'    => $amount,
3258 3258
                 'recurring' => (bool) $recurring,
3259 3259
             );
3260
-		}
3260
+        }
3261 3261
 
3262 3262
         $this->set_prop( 'discounts', $discount );
3263 3263
 
3264 3264
     }
3265 3265
 
3266 3266
     /**
3267
-	 * Retrieves a specific discount.
3268
-	 *
3269
-	 * @since 1.0.19
3270
-	 */
3271
-	public function get_discount( $discount = false ) {
3267
+     * Retrieves a specific discount.
3268
+     *
3269
+     * @since 1.0.19
3270
+     */
3271
+    public function get_discount( $discount = false ) {
3272 3272
 
3273
-		// Backwards compatibilty.
3274
-		if ( empty( $discount ) ) {
3275
-			return $this->get_total_discount();
3276
-		}
3273
+        // Backwards compatibilty.
3274
+        if ( empty( $discount ) ) {
3275
+            return $this->get_total_discount();
3276
+        }
3277 3277
 
3278 3278
         $discounts = $this->get_discounts();
3279
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3279
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3280 3280
     }
3281 3281
 
3282 3282
     /**
3283
-	 * Removes a specific discount.
3284
-	 *
3285
-	 * @since 1.0.19
3286
-	 */
3287
-	public function remove_discount( $discount ) {
3283
+     * Removes a specific discount.
3284
+     *
3285
+     * @since 1.0.19
3286
+     */
3287
+    public function remove_discount( $discount ) {
3288 3288
         $discounts = $this->get_discounts();
3289 3289
         if ( isset( $discounts[ $discount ] ) ) {
3290 3290
             unset( $discounts[ $discount ] );
@@ -3310,44 +3310,44 @@  discard block
 block discarded – undo
3310 3310
         if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3311 3311
 
3312 3312
             $amount = $taxes[ $tax ]['amount'] += $amount;
3313
-			$taxes[ $tax ] = array(
3313
+            $taxes[ $tax ] = array(
3314 3314
                 'amount'    => $amount,
3315 3315
                 'recurring' => (bool) $recurring,
3316 3316
             );
3317 3317
 
3318
-		} else {
3319
-			$taxes[ $tax ] = array(
3318
+        } else {
3319
+            $taxes[ $tax ] = array(
3320 3320
                 'amount'    => $amount,
3321 3321
                 'recurring' => (bool) $recurring,
3322 3322
             );
3323
-		}
3323
+        }
3324 3324
 
3325 3325
         $this->set_prop( 'taxes', $tax );
3326 3326
 
3327 3327
     }
3328 3328
 
3329 3329
     /**
3330
-	 * Retrieves a specific tax.
3331
-	 *
3332
-	 * @since 1.0.19
3333
-	 */
3334
-	public function get_tax( $tax = null ) {
3330
+     * Retrieves a specific tax.
3331
+     *
3332
+     * @since 1.0.19
3333
+     */
3334
+    public function get_tax( $tax = null ) {
3335 3335
 
3336
-		// Backwards compatility.
3337
-		if ( empty( $tax ) ) {
3338
-			return $this->get_total_tax();
3339
-		}
3336
+        // Backwards compatility.
3337
+        if ( empty( $tax ) ) {
3338
+            return $this->get_total_tax();
3339
+        }
3340 3340
 
3341 3341
         $taxes = $this->get_taxes();
3342
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3342
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3343 3343
     }
3344 3344
 
3345 3345
     /**
3346
-	 * Removes a specific tax.
3347
-	 *
3348
-	 * @since 1.0.19
3349
-	 */
3350
-	public function remove_tax( $tax ) {
3346
+     * Removes a specific tax.
3347
+     *
3348
+     * @since 1.0.19
3349
+     */
3350
+    public function remove_tax( $tax ) {
3351 3351
         $taxes = $this->get_discounts();
3352 3352
         if ( isset( $taxes[ $tax ] ) ) {
3353 3353
             unset( $taxes[ $tax ] );
@@ -3356,160 +3356,160 @@  discard block
 block discarded – undo
3356 3356
     }
3357 3357
 
3358 3358
     /**
3359
-	 * Recalculates the invoice subtotal.
3360
-	 *
3361
-	 * @since 1.0.19
3362
-	 * @return float The recalculated subtotal
3363
-	 */
3364
-	public function recalculate_subtotal() {
3359
+     * Recalculates the invoice subtotal.
3360
+     *
3361
+     * @since 1.0.19
3362
+     * @return float The recalculated subtotal
3363
+     */
3364
+    public function recalculate_subtotal() {
3365 3365
         $items     = $this->get_items();
3366
-		$subtotal  = 0;
3367
-		$recurring = 0;
3366
+        $subtotal  = 0;
3367
+        $recurring = 0;
3368 3368
 
3369 3369
         foreach ( $items as $item ) {
3370
-			$subtotal  += $item->get_sub_total();
3371
-			$recurring += $item->get_recurring_sub_total();
3370
+            $subtotal  += $item->get_sub_total();
3371
+            $recurring += $item->get_recurring_sub_total();
3372 3372
         }
3373 3373
 
3374
-		if ( $this->is_renewal() ) {
3375
-			$this->set_subtotal( $recurring );
3376
-		} else {
3377
-			$this->set_subtotal( $subtotal );
3378
-		}
3374
+        if ( $this->is_renewal() ) {
3375
+            $this->set_subtotal( $recurring );
3376
+        } else {
3377
+            $this->set_subtotal( $subtotal );
3378
+        }
3379 3379
 
3380
-		$this->totals['subtotal'] = array(
3381
-			'initial'   => $subtotal,
3382
-			'recurring' => $recurring,
3383
-		);
3380
+        $this->totals['subtotal'] = array(
3381
+            'initial'   => $subtotal,
3382
+            'recurring' => $recurring,
3383
+        );
3384 3384
 
3385 3385
         return $this->is_renewal() ? $recurring : $subtotal;
3386 3386
     }
3387 3387
 
3388 3388
     /**
3389
-	 * Recalculates the invoice discount total.
3390
-	 *
3391
-	 * @since 1.0.19
3392
-	 * @return float The recalculated discount
3393
-	 */
3394
-	public function recalculate_total_discount() {
3389
+     * Recalculates the invoice discount total.
3390
+     *
3391
+     * @since 1.0.19
3392
+     * @return float The recalculated discount
3393
+     */
3394
+    public function recalculate_total_discount() {
3395 3395
         $discounts = $this->get_discounts();
3396
-		$discount  = 0;
3397
-		$recurring = 0;
3396
+        $discount  = 0;
3397
+        $recurring = 0;
3398 3398
 
3399 3399
         foreach ( $discounts as $data ) {
3400 3400
 
3401
-			if ( $data['recurring'] ) {
3402
-				$recurring += $data['amount'];
3403
-			} else {
3404
-				$discount += $data['amount'];
3405
-			}
3401
+            if ( $data['recurring'] ) {
3402
+                $recurring += $data['amount'];
3403
+            } else {
3404
+                $discount += $data['amount'];
3405
+            }
3406 3406
 
3407
-		}
3407
+        }
3408 3408
 
3409
-		if ( $this->is_renewal() ) {
3410
-			$this->set_total_discount( $recurring );
3411
-		} else {
3412
-			$this->set_total_discount( $discount );
3413
-		}
3409
+        if ( $this->is_renewal() ) {
3410
+            $this->set_total_discount( $recurring );
3411
+        } else {
3412
+            $this->set_total_discount( $discount );
3413
+        }
3414 3414
 
3415
-		$this->totals['discount'] = array(
3416
-			'initial'   => $discount,
3417
-			'recurring' => $recurring,
3418
-		);
3415
+        $this->totals['discount'] = array(
3416
+            'initial'   => $discount,
3417
+            'recurring' => $recurring,
3418
+        );
3419 3419
 
3420
-		return $this->is_renewal() ? $recurring : $discount;
3420
+        return $this->is_renewal() ? $recurring : $discount;
3421 3421
 
3422 3422
     }
3423 3423
 
3424 3424
     /**
3425
-	 * Recalculates the invoice tax total.
3426
-	 *
3427
-	 * @since 1.0.19
3428
-	 * @return float The recalculated tax
3429
-	 */
3430
-	public function recalculate_total_tax() {
3425
+     * Recalculates the invoice tax total.
3426
+     *
3427
+     * @since 1.0.19
3428
+     * @return float The recalculated tax
3429
+     */
3430
+    public function recalculate_total_tax() {
3431 3431
         $taxes     = $this->get_taxes();
3432
-		$tax       = 0;
3433
-		$recurring = 0;
3432
+        $tax       = 0;
3433
+        $recurring = 0;
3434 3434
 
3435 3435
         foreach ( $taxes as $data ) {
3436 3436
 
3437
-			if ( $data['recurring'] ) {
3438
-				$recurring += $data['amount'];
3439
-			} else {
3440
-				$tax += $data['amount'];
3441
-			}
3437
+            if ( $data['recurring'] ) {
3438
+                $recurring += $data['amount'];
3439
+            } else {
3440
+                $tax += $data['amount'];
3441
+            }
3442 3442
 
3443
-		}
3443
+        }
3444 3444
 
3445
-		if ( $this->is_renewal() ) {
3446
-			$this->set_total_tax( $recurring );
3447
-		} else {
3448
-			$this->set_total_tax( $tax );
3449
-		}
3445
+        if ( $this->is_renewal() ) {
3446
+            $this->set_total_tax( $recurring );
3447
+        } else {
3448
+            $this->set_total_tax( $tax );
3449
+        }
3450 3450
 
3451
-		$this->totals['tax'] = array(
3452
-			'initial'   => $tax,
3453
-			'recurring' => $recurring,
3454
-		);
3451
+        $this->totals['tax'] = array(
3452
+            'initial'   => $tax,
3453
+            'recurring' => $recurring,
3454
+        );
3455 3455
 
3456
-		return $this->is_renewal() ? $recurring : $tax;
3456
+        return $this->is_renewal() ? $recurring : $tax;
3457 3457
 
3458 3458
     }
3459 3459
 
3460 3460
     /**
3461
-	 * Recalculates the invoice fees total.
3462
-	 *
3463
-	 * @since 1.0.19
3464
-	 * @return float The recalculated fee
3465
-	 */
3466
-	public function recalculate_total_fees() {
3467
-		$fees      = $this->get_fees();
3468
-		$fee       = 0;
3469
-		$recurring = 0;
3461
+     * Recalculates the invoice fees total.
3462
+     *
3463
+     * @since 1.0.19
3464
+     * @return float The recalculated fee
3465
+     */
3466
+    public function recalculate_total_fees() {
3467
+        $fees      = $this->get_fees();
3468
+        $fee       = 0;
3469
+        $recurring = 0;
3470 3470
 
3471 3471
         foreach ( $fees as $data ) {
3472 3472
 
3473
-			if ( $data['recurring'] ) {
3474
-				$recurring += $data['amount'];
3475
-			} else {
3476
-				$fee += $data['amount'];
3477
-			}
3473
+            if ( $data['recurring'] ) {
3474
+                $recurring += $data['amount'];
3475
+            } else {
3476
+                $fee += $data['amount'];
3477
+            }
3478 3478
 
3479
-		}
3479
+        }
3480 3480
 
3481 3481
         if ( $this->is_renewal() ) {
3482
-			$this->set_total_fees( $recurring );
3483
-		} else {
3484
-			$this->set_total_fees( $fee );
3485
-		}
3482
+            $this->set_total_fees( $recurring );
3483
+        } else {
3484
+            $this->set_total_fees( $fee );
3485
+        }
3486 3486
 
3487
-		$this->totals['fee'] = array(
3488
-			'initial'   => $fee,
3489
-			'recurring' => $recurring,
3490
-		);
3487
+        $this->totals['fee'] = array(
3488
+            'initial'   => $fee,
3489
+            'recurring' => $recurring,
3490
+        );
3491 3491
 
3492 3492
         $this->set_total_fees( $fee );
3493 3493
         return $this->is_renewal() ? $recurring : $fee;
3494 3494
     }
3495 3495
 
3496 3496
     /**
3497
-	 * Recalculates the invoice total.
3498
-	 *
3499
-	 * @since 1.0.19
3497
+     * Recalculates the invoice total.
3498
+     *
3499
+     * @since 1.0.19
3500 3500
      * @return float The invoice total
3501
-	 */
3502
-	public function recalculate_total() {
3501
+     */
3502
+    public function recalculate_total() {
3503 3503
         $this->recalculate_subtotal();
3504 3504
         $this->recalculate_total_fees();
3505 3505
         $this->recalculate_total_discount();
3506 3506
         $this->recalculate_total_tax();
3507
-		return $this->get_total();
3508
-	}
3507
+        return $this->get_total();
3508
+    }
3509 3509
 
3510
-	/**
3511
-	 * @deprecated
3512
-	 */
3510
+    /**
3511
+     * @deprecated
3512
+     */
3513 3513
     public function recalculate_totals( $temp = false ) {
3514 3514
         $this->update_items( $temp );
3515 3515
         $this->save( true );
@@ -3527,7 +3527,7 @@  discard block
 block discarded – undo
3527 3527
      * Adds a note to an invoice.
3528 3528
      *
3529 3529
      * @param string $note The note being added.
3530
-	 * @return int|false The new note's ID on success, false on failure.
3530
+     * @return int|false The new note's ID on success, false on failure.
3531 3531
      *
3532 3532
      */
3533 3533
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3537,23 +3537,23 @@  discard block
 block discarded – undo
3537 3537
             return false;
3538 3538
         }
3539 3539
 
3540
-		// If this is an admin comment or it has been added by the user.
3541
-		if ( is_user_logged_in() && ( wpinv_current_user_can_manage_invoicing() || $added_by_user ) ) {
3542
-			$user         = get_user_by( 'id', get_current_user_id() );
3540
+        // If this is an admin comment or it has been added by the user.
3541
+        if ( is_user_logged_in() && ( wpinv_current_user_can_manage_invoicing() || $added_by_user ) ) {
3542
+            $user         = get_user_by( 'id', get_current_user_id() );
3543 3543
             $author       = $user->display_name;
3544 3544
             $author_email = $user->user_email;
3545
-		} 
3545
+        } 
3546 3546
 
3547
-		if ( $system ) {
3548
-			$author       = 'System';
3547
+        if ( $system ) {
3548
+            $author       = 'System';
3549 3549
             $author_email = '[email protected]';
3550
-		}
3550
+        }
3551 3551
 
3552
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3552
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3553 3553
 
3554
-	}
3554
+    }
3555 3555
 
3556
-	/**
3556
+    /**
3557 3557
      * Generates a unique key for the invoice.
3558 3558
      */
3559 3559
     public function generate_key( $string = '' ) {
@@ -3573,106 +3573,106 @@  discard block
 block discarded – undo
3573 3573
             $number = wpinv_get_next_invoice_number( $this->post_type );
3574 3574
         }
3575 3575
 
3576
-		$number = wpinv_format_invoice_number( $number, $this->post_type );
3576
+        $number = wpinv_format_invoice_number( $number, $this->post_type );
3577 3577
 
3578
-		return $number;
3579
-	}
3578
+        return $number;
3579
+    }
3580 3580
 
3581
-	/**
3582
-	 * Handle the status transition.
3583
-	 */
3584
-	protected function status_transition() {
3585
-		$status_transition = $this->status_transition;
3581
+    /**
3582
+     * Handle the status transition.
3583
+     */
3584
+    protected function status_transition() {
3585
+        $status_transition = $this->status_transition;
3586 3586
 
3587
-		// Reset status transition variable.
3588
-		$this->status_transition = false;
3587
+        // Reset status transition variable.
3588
+        $this->status_transition = false;
3589 3589
 
3590
-		if ( $status_transition ) {
3591
-			try {
3590
+        if ( $status_transition ) {
3591
+            try {
3592 3592
 
3593
-				// Fire a hook for the status change.
3594
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3593
+                // Fire a hook for the status change.
3594
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3595 3595
 
3596
-				// @deprecated this is deprecated and will be removed in the future.
3597
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3596
+                // @deprecated this is deprecated and will be removed in the future.
3597
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3598 3598
 
3599
-				if ( ! empty( $status_transition['from'] ) ) {
3599
+                if ( ! empty( $status_transition['from'] ) ) {
3600 3600
 
3601
-					/* translators: 1: old invoice status 2: new invoice status */
3602
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3601
+                    /* translators: 1: old invoice status 2: new invoice status */
3602
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3603 3603
 
3604
-					// Fire another hook.
3605
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3606
-					do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3604
+                    // Fire another hook.
3605
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3606
+                    do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3607 3607
 
3608
-					// @deprecated this is deprecated and will be removed in the future.
3609
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3608
+                    // @deprecated this is deprecated and will be removed in the future.
3609
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3610 3610
 
3611
-					// Note the transition occurred.
3612
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3611
+                    // Note the transition occurred.
3612
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3613 3613
 
3614
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3615
-					if (
3616
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3617
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3618
-					) {
3619
-						do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3620
-					}
3621
-				} else {
3622
-					/* translators: %s: new invoice status */
3623
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3614
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3615
+                    if (
3616
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3617
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3618
+                    ) {
3619
+                        do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3620
+                    }
3621
+                } else {
3622
+                    /* translators: %s: new invoice status */
3623
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3624 3624
 
3625
-					// Note the transition occurred.
3626
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3625
+                    // Note the transition occurred.
3626
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3627 3627
 
3628
-				}
3629
-			} catch ( Exception $e ) {
3630
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3631
-			}
3632
-		}
3633
-	}
3628
+                }
3629
+            } catch ( Exception $e ) {
3630
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3631
+            }
3632
+        }
3633
+    }
3634 3634
 
3635
-	/**
3636
-	 * Updates an invoice status.
3637
-	 */
3638
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3635
+    /**
3636
+     * Updates an invoice status.
3637
+     */
3638
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3639 3639
 
3640
-		// Fires before updating a status.
3641
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3640
+        // Fires before updating a status.
3641
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3642 3642
 
3643
-		// Update the status.
3644
-		$this->set_status( $new_status, $note, $manual );
3643
+        // Update the status.
3644
+        $this->set_status( $new_status, $note, $manual );
3645 3645
 
3646
-		// Save the order.
3647
-		return $this->save();
3646
+        // Save the order.
3647
+        return $this->save();
3648 3648
 
3649
-	}
3649
+    }
3650 3650
 
3651
-	/**
3652
-	 * @deprecated
3653
-	 */
3654
-	public function refresh_item_ids() {
3651
+    /**
3652
+     * @deprecated
3653
+     */
3654
+    public function refresh_item_ids() {
3655 3655
         $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3656 3656
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3657
-	}
3657
+    }
3658 3658
 
3659
-	/**
3660
-	 * @deprecated
3661
-	 */
3662
-	public function update_items( $temp = false ) {
3659
+    /**
3660
+     * @deprecated
3661
+     */
3662
+    public function update_items( $temp = false ) {
3663 3663
 
3664
-		$this->set_items( $this->get_items() );
3664
+        $this->set_items( $this->get_items() );
3665 3665
 
3666
-		if ( ! $temp ) {
3667
-			$this->save();
3668
-		}
3666
+        if ( ! $temp ) {
3667
+            $this->save();
3668
+        }
3669 3669
 
3670 3670
         return $this;
3671
-	}
3671
+    }
3672 3672
 
3673
-	/**
3674
-	 * @deprecated
3675
-	 */
3673
+    /**
3674
+     * @deprecated
3675
+     */
3676 3676
     public function validate_discount() {
3677 3677
 
3678 3678
         $discount_code = $this->get_discount_code();
@@ -3688,86 +3688,86 @@  discard block
 block discarded – undo
3688 3688
 
3689 3689
     }
3690 3690
 
3691
-	/**
3692
-	 * Refunds an invoice.
3693
-	 */
3691
+    /**
3692
+     * Refunds an invoice.
3693
+     */
3694 3694
     public function refund() {
3695
-		$this->set_status( 'wpi-refunded' );
3695
+        $this->set_status( 'wpi-refunded' );
3696 3696
         $this->save();
3697
-	}
3697
+    }
3698 3698
 
3699
-	/**
3700
-	 * Marks an invoice as paid.
3701
-	 * 
3702
-	 * @param string $transaction_id
3703
-	 */
3699
+    /**
3700
+     * Marks an invoice as paid.
3701
+     * 
3702
+     * @param string $transaction_id
3703
+     */
3704 3704
     public function mark_paid( $transaction_id = null, $note = '' ) {
3705 3705
 
3706
-		// Set the transaction id.
3707
-		if ( empty( $transaction_id ) ) {
3708
-			$transaction_id = $this->generate_key('trans_');
3709
-		}
3706
+        // Set the transaction id.
3707
+        if ( empty( $transaction_id ) ) {
3708
+            $transaction_id = $this->generate_key('trans_');
3709
+        }
3710 3710
 
3711
-		if ( ! $this->get_transaction_id() ) {
3712
-			$this->set_transaction_id( $transaction_id );
3713
-		}
3711
+        if ( ! $this->get_transaction_id() ) {
3712
+            $this->set_transaction_id( $transaction_id );
3713
+        }
3714 3714
 
3715
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3716
-			return $this->save();
3717
-		}
3715
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3716
+            return $this->save();
3717
+        }
3718 3718
 
3719
-		// Set the completed date.
3720
-		$this->set_date_completed( current_time( 'mysql' ) );
3719
+        // Set the completed date.
3720
+        $this->set_date_completed( current_time( 'mysql' ) );
3721 3721
 
3722
-		// Set the new status.
3723
-		if ( $this->is_renewal() ) {
3722
+        // Set the new status.
3723
+        if ( $this->is_renewal() ) {
3724 3724
 
3725
-			$_note = sprintf(
3726
-				__( 'Renewed via %s', 'invoicing' ),
3727
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3728
-			);
3725
+            $_note = sprintf(
3726
+                __( 'Renewed via %s', 'invoicing' ),
3727
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3728
+            );
3729 3729
 
3730
-			if ( 'none' == $this->get_gateway() ) {
3731
-				$_note = $note;
3732
-			}
3730
+            if ( 'none' == $this->get_gateway() ) {
3731
+                $_note = $note;
3732
+            }
3733 3733
 
3734
-			$this->set_status( 'wpi-renewal', $_note );
3734
+            $this->set_status( 'wpi-renewal', $_note );
3735 3735
 
3736
-		} else {
3736
+        } else {
3737 3737
 
3738
-			$_note = sprintf(
3739
-				__( 'Paid via %s', 'invoicing' ),
3740
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3741
-			);
3738
+            $_note = sprintf(
3739
+                __( 'Paid via %s', 'invoicing' ),
3740
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3741
+            );
3742 3742
 
3743
-			if ( 'none' == $this->get_gateway() ) {
3744
-				$_note = $note;
3745
-			}
3743
+            if ( 'none' == $this->get_gateway() ) {
3744
+                $_note = $note;
3745
+            }
3746 3746
 
3747
-			$this->set_status( 'publish',$_note );
3747
+            $this->set_status( 'publish',$_note );
3748 3748
 
3749
-		}
3749
+        }
3750 3750
 
3751
-		// Set checkout mode.
3752
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3753
-		$this->set_mode( $mode );
3751
+        // Set checkout mode.
3752
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3753
+        $this->set_mode( $mode );
3754 3754
 
3755
-		// Save the invoice.
3755
+        // Save the invoice.
3756 3756
         $this->save();
3757
-	}
3758
-
3759
-
3760
-	/**
3761
-	 * Save data to the database.
3762
-	 *
3763
-	 * @since 1.0.19
3764
-	 * @return int invoice ID
3765
-	 */
3766
-	public function save() {
3767
-		$this->maybe_set_date_paid();
3768
-		parent::save();
3769
-		$this->status_transition();
3770
-		return $this->get_id();
3771
-	}
3757
+    }
3758
+
3759
+
3760
+    /**
3761
+     * Save data to the database.
3762
+     *
3763
+     * @since 1.0.19
3764
+     * @return int invoice ID
3765
+     */
3766
+    public function save() {
3767
+        $this->maybe_set_date_paid();
3768
+        parent::save();
3769
+        $this->status_transition();
3770
+        return $this->get_id();
3771
+    }
3772 3772
 
3773 3773
 }
Please login to merge, or discard this patch.
Spacing   +753 added lines, -753 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Invoice class.
@@ -133,40 +133,40 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
135 135
 	 */
136
-    public function __construct( $invoice = false ) {
136
+    public function __construct($invoice = false) {
137 137
 
138
-        parent::__construct( $invoice );
138
+        parent::__construct($invoice);
139 139
 
140
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
141
-			$this->set_id( $invoice );
142
-		} elseif ( $invoice instanceof self ) {
143
-			$this->set_id( $invoice->get_id() );
144
-		} elseif ( ! empty( $invoice->ID ) ) {
145
-			$this->set_id( $invoice->ID );
146
-		} elseif ( is_array( $invoice ) ) {
147
-			$this->set_props( $invoice );
140
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) {
141
+			$this->set_id($invoice);
142
+		} elseif ($invoice instanceof self) {
143
+			$this->set_id($invoice->get_id());
144
+		} elseif (!empty($invoice->ID)) {
145
+			$this->set_id($invoice->ID);
146
+		} elseif (is_array($invoice)) {
147
+			$this->set_props($invoice);
148 148
 
149
-			if ( isset( $invoice['ID'] ) ) {
150
-				$this->set_id( $invoice['ID'] );
149
+			if (isset($invoice['ID'])) {
150
+				$this->set_id($invoice['ID']);
151 151
 			}
152 152
 
153
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
154
-			$this->set_id( $invoice_id );
155
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
156
-			$this->set_id( $invoice_id );
157
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
158
-			$this->set_id( $invoice_id );
159
-		}else {
160
-			$this->set_object_read( true );
153
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
154
+			$this->set_id($invoice_id);
155
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
156
+			$this->set_id($invoice_id);
157
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
158
+			$this->set_id($invoice_id);
159
+		} else {
160
+			$this->set_object_read(true);
161 161
 		}
162 162
 
163 163
         // Load the datastore.
164
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
164
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
165 165
 
166
-		if ( $this->get_id() > 0 ) {
167
-            $this->post = get_post( $this->get_id() );
166
+		if ($this->get_id() > 0) {
167
+            $this->post = get_post($this->get_id());
168 168
             $this->ID   = $this->get_id();
169
-			$this->data_store->read( $this );
169
+			$this->data_store->read($this);
170 170
         }
171 171
 
172 172
     }
@@ -181,42 +181,42 @@  discard block
 block discarded – undo
181 181
 	 * @since 1.0.15
182 182
 	 * @return int
183 183
 	 */
184
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
184
+	public static function get_invoice_id_by_field($value, $field = 'key') {
185 185
         global $wpdb;
186 186
 
187 187
 		// Trim the value.
188
-		$value = trim( $value );
188
+		$value = trim($value);
189 189
 
190
-		if ( empty( $value ) ) {
190
+		if (empty($value)) {
191 191
 			return 0;
192 192
 		}
193 193
 
194 194
         // Valid fields.
195
-        $fields = array( 'key', 'number', 'transaction_id' );
195
+        $fields = array('key', 'number', 'transaction_id');
196 196
 
197 197
 		// Ensure a field has been passed.
198
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
198
+		if (empty($field) || !in_array($field, $fields)) {
199 199
 			return 0;
200 200
 		}
201 201
 
202 202
 		// Maybe retrieve from the cache.
203
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
204
-		if ( ! empty( $invoice_id ) ) {
203
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
204
+		if (!empty($invoice_id)) {
205 205
 			return $invoice_id;
206 206
 		}
207 207
 
208 208
         // Fetch from the db.
209 209
         $table       = $wpdb->prefix . 'getpaid_invoices';
210 210
         $invoice_id  = $wpdb->get_var(
211
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
211
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
212 212
         );
213 213
 
214
-		if ( empty( $invoice_id ) ) {
214
+		if (empty($invoice_id)) {
215 215
 			return 0;
216 216
 		}
217 217
 
218 218
 		// Update the cache with our data
219
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
219
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
220 220
 
221 221
 		return $invoice_id;
222 222
     }
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
     /**
225 225
      * Checks if an invoice key is set.
226 226
      */
227
-    public function _isset( $key ) {
228
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
227
+    public function _isset($key) {
228
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
229 229
     }
230 230
 
231 231
     /*
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
 	 * @param  string $context View or edit context.
251 251
 	 * @return int
252 252
 	 */
253
-	public function get_parent_id( $context = 'view' ) {
254
-		return (int) $this->get_prop( 'parent_id', $context );
253
+	public function get_parent_id($context = 'view') {
254
+		return (int) $this->get_prop('parent_id', $context);
255 255
     }
256 256
 
257 257
     /**
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @return WPInv_Invoice
262 262
 	 */
263 263
     public function get_parent_payment() {
264
-        return new WPInv_Invoice( $this->get_parent_id() );
264
+        return new WPInv_Invoice($this->get_parent_id());
265 265
     }
266 266
 
267 267
     /**
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @param  string $context View or edit context.
282 282
 	 * @return string
283 283
 	 */
284
-	public function get_status( $context = 'view' ) {
285
-		return $this->get_prop( 'status', $context );
284
+	public function get_status($context = 'view') {
285
+		return $this->get_prop('status', $context);
286 286
 	}
287 287
 	
288 288
 	/**
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 	 */
294 294
 	public function get_all_statuses() {
295 295
 
296
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
296
+		$statuses = wpinv_get_invoice_statuses(true, true, $this);
297 297
 
298 298
 		// For backwards compatibility.
299
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
299
+		if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) {
300 300
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
301 301
 		}
302 302
 
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
     public function get_status_nicename() {
313 313
 		$statuses = $this->get_all_statuses();
314 314
 
315
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
315
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
316 316
 
317
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
317
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
318 318
     }
319 319
 
320 320
     /**
@@ -324,27 +324,27 @@  discard block
 block discarded – undo
324 324
 	 * @param  string $context View or edit context.
325 325
 	 * @return string
326 326
 	 */
327
-	public function get_version( $context = 'view' ) {
328
-		return $this->get_prop( 'version', $context );
327
+	public function get_version($context = 'view') {
328
+		return $this->get_prop('version', $context);
329 329
 	}
330 330
 
331 331
 	/**
332 332
 	 * @deprecated
333 333
 	 */
334
-	public function get_invoice_date( $formatted = true ) {
334
+	public function get_invoice_date($formatted = true) {
335 335
         $date_completed = $this->get_date_completed();
336 336
         $invoice_date   = $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
337 337
 
338
-        if ( $invoice_date == '' ) {
338
+        if ($invoice_date == '') {
339 339
             $date_created   = $this->get_date_created();
340 340
             $invoice_date   = $date_created != '0000-00-00 00:00:00' ? $date_created : '';
341 341
         }
342 342
 
343
-        if ( $formatted && $invoice_date ) {
344
-            $invoice_date   = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) );
343
+        if ($formatted && $invoice_date) {
344
+            $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date));
345 345
         }
346 346
 
347
-        return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this );
347
+        return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this);
348 348
     }
349 349
 
350 350
     /**
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 	 * @param  string $context View or edit context.
355 355
 	 * @return string
356 356
 	 */
357
-	public function get_date_created( $context = 'view' ) {
358
-		return $this->get_prop( 'date_created', $context );
357
+	public function get_date_created($context = 'view') {
358
+		return $this->get_prop('date_created', $context);
359 359
 	}
360 360
 	
361 361
 	/**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param  string $context View or edit context.
366 366
 	 * @return string
367 367
 	 */
368
-	public function get_created_date( $context = 'view' ) {
369
-		return $this->get_date_created( $context );
368
+	public function get_created_date($context = 'view') {
369
+		return $this->get_date_created($context);
370 370
     }
371 371
 
372 372
     /**
@@ -376,11 +376,11 @@  discard block
 block discarded – undo
376 376
 	 * @param  string $context View or edit context.
377 377
 	 * @return string
378 378
 	 */
379
-	public function get_date_created_gmt( $context = 'view' ) {
380
-        $date = $this->get_date_created( $context );
379
+	public function get_date_created_gmt($context = 'view') {
380
+        $date = $this->get_date_created($context);
381 381
 
382
-        if ( $date ) {
383
-            $date = get_gmt_from_date( $date );
382
+        if ($date) {
383
+            $date = get_gmt_from_date($date);
384 384
         }
385 385
 		return $date;
386 386
     }
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 	 * @param  string $context View or edit context.
393 393
 	 * @return string
394 394
 	 */
395
-	public function get_date_modified( $context = 'view' ) {
396
-		return $this->get_prop( 'date_modified', $context );
395
+	public function get_date_modified($context = 'view') {
396
+		return $this->get_prop('date_modified', $context);
397 397
 	}
398 398
 
399 399
 	/**
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 	 * @param  string $context View or edit context.
404 404
 	 * @return string
405 405
 	 */
406
-	public function get_modified_date( $context = 'view' ) {
407
-		return $this->get_date_modified( $context );
406
+	public function get_modified_date($context = 'view') {
407
+		return $this->get_date_modified($context);
408 408
     }
409 409
 
410 410
     /**
@@ -414,11 +414,11 @@  discard block
 block discarded – undo
414 414
 	 * @param  string $context View or edit context.
415 415
 	 * @return string
416 416
 	 */
417
-	public function get_date_modified_gmt( $context = 'view' ) {
418
-        $date = $this->get_date_modified( $context );
417
+	public function get_date_modified_gmt($context = 'view') {
418
+        $date = $this->get_date_modified($context);
419 419
 
420
-        if ( $date ) {
421
-            $date = get_gmt_from_date( $date );
420
+        if ($date) {
421
+            $date = get_gmt_from_date($date);
422 422
         }
423 423
 		return $date;
424 424
     }
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
 	 * @param  string $context View or edit context.
431 431
 	 * @return string
432 432
 	 */
433
-	public function get_due_date( $context = 'view' ) {
434
-		return $this->get_prop( 'due_date', $context );
433
+	public function get_due_date($context = 'view') {
434
+		return $this->get_prop('due_date', $context);
435 435
     }
436 436
 
437 437
     /**
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 * @param  string $context View or edit context.
442 442
 	 * @return string
443 443
 	 */
444
-	public function get_date_due( $context = 'view' ) {
445
-		return $this->get_due_date( $context );
444
+	public function get_date_due($context = 'view') {
445
+		return $this->get_due_date($context);
446 446
     }
447 447
 
448 448
     /**
@@ -452,11 +452,11 @@  discard block
 block discarded – undo
452 452
 	 * @param  string $context View or edit context.
453 453
 	 * @return string
454 454
 	 */
455
-	public function get_due_date_gmt( $context = 'view' ) {
456
-        $date = $this->get_due_date( $context );
455
+	public function get_due_date_gmt($context = 'view') {
456
+        $date = $this->get_due_date($context);
457 457
 
458
-        if ( $date ) {
459
-            $date = get_gmt_from_date( $date );
458
+        if ($date) {
459
+            $date = get_gmt_from_date($date);
460 460
         }
461 461
 		return $date;
462 462
     }
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
 	 * @param  string $context View or edit context.
469 469
 	 * @return string
470 470
 	 */
471
-	public function get_gmt_date_due( $context = 'view' ) {
472
-		return $this->get_due_date_gmt( $context );
471
+	public function get_gmt_date_due($context = 'view') {
472
+		return $this->get_due_date_gmt($context);
473 473
     }
474 474
 
475 475
     /**
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 	 * @param  string $context View or edit context.
480 480
 	 * @return string
481 481
 	 */
482
-	public function get_completed_date( $context = 'view' ) {
483
-		return $this->get_prop( 'completed_date', $context );
482
+	public function get_completed_date($context = 'view') {
483
+		return $this->get_prop('completed_date', $context);
484 484
     }
485 485
 
486 486
     /**
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 	 * @param  string $context View or edit context.
491 491
 	 * @return string
492 492
 	 */
493
-	public function get_date_completed( $context = 'view' ) {
494
-		return $this->get_completed_date( $context );
493
+	public function get_date_completed($context = 'view') {
494
+		return $this->get_completed_date($context);
495 495
     }
496 496
 
497 497
     /**
@@ -501,11 +501,11 @@  discard block
 block discarded – undo
501 501
 	 * @param  string $context View or edit context.
502 502
 	 * @return string
503 503
 	 */
504
-	public function get_completed_date_gmt( $context = 'view' ) {
505
-        $date = $this->get_completed_date( $context );
504
+	public function get_completed_date_gmt($context = 'view') {
505
+        $date = $this->get_completed_date($context);
506 506
 
507
-        if ( $date ) {
508
-            $date = get_gmt_from_date( $date );
507
+        if ($date) {
508
+            $date = get_gmt_from_date($date);
509 509
         }
510 510
 		return $date;
511 511
     }
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
 	 * @param  string $context View or edit context.
518 518
 	 * @return string
519 519
 	 */
520
-	public function get_gmt_completed_date( $context = 'view' ) {
521
-		return $this->get_completed_date_gmt( $context );
520
+	public function get_gmt_completed_date($context = 'view') {
521
+		return $this->get_completed_date_gmt($context);
522 522
     }
523 523
 
524 524
     /**
@@ -528,12 +528,12 @@  discard block
 block discarded – undo
528 528
 	 * @param  string $context View or edit context.
529 529
 	 * @return string
530 530
 	 */
531
-	public function get_number( $context = 'view' ) {
532
-        $number = $this->get_prop( 'number', $context );
531
+	public function get_number($context = 'view') {
532
+        $number = $this->get_prop('number', $context);
533 533
 
534
-        if ( empty( $number ) ) {
534
+        if (empty($number)) {
535 535
             $number = $this->generate_number();
536
-            $this->set_number( $number );
536
+            $this->set_number($number);
537 537
         }
538 538
 
539 539
 		return $number;
@@ -546,12 +546,12 @@  discard block
 block discarded – undo
546 546
 	 * @param  string $context View or edit context.
547 547
 	 * @return string
548 548
 	 */
549
-	public function get_key( $context = 'view' ) {
550
-        $key = $this->get_prop( 'key', $context );
549
+	public function get_key($context = 'view') {
550
+        $key = $this->get_prop('key', $context);
551 551
 
552
-        if ( empty( $key ) ) {
553
-            $key = $this->generate_key( $this->get_type() . '_' );
554
-            $this->set_key( $key );
552
+        if (empty($key)) {
553
+            $key = $this->generate_key($this->get_type() . '_');
554
+            $this->set_key($key);
555 555
         }
556 556
 
557 557
 		return $key;
@@ -564,23 +564,23 @@  discard block
 block discarded – undo
564 564
 	 * @param  string $context View or edit context.
565 565
 	 * @return string
566 566
 	 */
567
-	public function get_type( $context = 'view' ) {
568
-        return $this->get_prop( 'type', $context );
567
+	public function get_type($context = 'view') {
568
+        return $this->get_prop('type', $context);
569 569
 	}
570 570
 
571 571
 	/**
572 572
 	 * @deprecated
573 573
 	 */
574
-	public function get_invoice_quote_type( $post_id ) {
575
-        if ( empty( $post_id ) ) {
574
+	public function get_invoice_quote_type($post_id) {
575
+        if (empty($post_id)) {
576 576
             return '';
577 577
         }
578 578
 
579
-        $type = get_post_type( $post_id );
579
+        $type = get_post_type($post_id);
580 580
 
581
-        if ( 'wpi_invoice' === $type ) {
581
+        if ('wpi_invoice' === $type) {
582 582
             $post_type = __('Invoice', 'invoicing');
583
-        } else{
583
+        } else {
584 584
             $post_type = __('Quote', 'invoicing');
585 585
         }
586 586
 
@@ -594,8 +594,8 @@  discard block
 block discarded – undo
594 594
 	 * @param  string $context View or edit context.
595 595
 	 * @return string
596 596
 	 */
597
-	public function get_post_type( $context = 'view' ) {
598
-        return $this->get_prop( 'post_type', $context );
597
+	public function get_post_type($context = 'view') {
598
+        return $this->get_prop('post_type', $context);
599 599
     }
600 600
 
601 601
     /**
@@ -605,8 +605,8 @@  discard block
 block discarded – undo
605 605
 	 * @param  string $context View or edit context.
606 606
 	 * @return string
607 607
 	 */
608
-	public function get_mode( $context = 'view' ) {
609
-        return $this->get_prop( 'mode', $context );
608
+	public function get_mode($context = 'view') {
609
+        return $this->get_prop('mode', $context);
610 610
     }
611 611
 
612 612
     /**
@@ -616,12 +616,12 @@  discard block
 block discarded – undo
616 616
 	 * @param  string $context View or edit context.
617 617
 	 * @return string
618 618
 	 */
619
-	public function get_path( $context = 'view' ) {
620
-        $path = $this->get_prop( 'path', $context );
619
+	public function get_path($context = 'view') {
620
+        $path = $this->get_prop('path', $context);
621 621
 
622
-        if ( empty( $path ) ) {
623
-            $prefix = apply_filters( 'wpinv_post_name_prefix', 'inv-', $this->post_type );
624
-            $path   = sanitize_title( $prefix . $this->get_id() );
622
+        if (empty($path)) {
623
+            $prefix = apply_filters('wpinv_post_name_prefix', 'inv-', $this->post_type);
624
+            $path   = sanitize_title($prefix . $this->get_id());
625 625
         }
626 626
 
627 627
 		return $path;
@@ -634,10 +634,10 @@  discard block
 block discarded – undo
634 634
 	 * @param  string $context View or edit context.
635 635
 	 * @return string
636 636
 	 */
637
-	public function get_name( $context = 'view' ) {
638
-        $name = $this->get_prop( 'title', $context );
637
+	public function get_name($context = 'view') {
638
+        $name = $this->get_prop('title', $context);
639 639
 
640
-		return empty( $name ) ? $this->get_number( $context ) : $name;
640
+		return empty($name) ? $this->get_number($context) : $name;
641 641
     }
642 642
 
643 643
     /**
@@ -647,8 +647,8 @@  discard block
 block discarded – undo
647 647
 	 * @param  string $context View or edit context.
648 648
 	 * @return string
649 649
 	 */
650
-	public function get_title( $context = 'view' ) {
651
-		return $this->get_name( $context );
650
+	public function get_title($context = 'view') {
651
+		return $this->get_name($context);
652 652
     }
653 653
 
654 654
     /**
@@ -658,8 +658,8 @@  discard block
 block discarded – undo
658 658
 	 * @param  string $context View or edit context.
659 659
 	 * @return string
660 660
 	 */
661
-	public function get_description( $context = 'view' ) {
662
-		return $this->get_prop( 'description', $context );
661
+	public function get_description($context = 'view') {
662
+		return $this->get_prop('description', $context);
663 663
     }
664 664
 
665 665
     /**
@@ -669,8 +669,8 @@  discard block
 block discarded – undo
669 669
 	 * @param  string $context View or edit context.
670 670
 	 * @return string
671 671
 	 */
672
-	public function get_excerpt( $context = 'view' ) {
673
-		return $this->get_description( $context );
672
+	public function get_excerpt($context = 'view') {
673
+		return $this->get_description($context);
674 674
     }
675 675
 
676 676
     /**
@@ -680,8 +680,8 @@  discard block
 block discarded – undo
680 680
 	 * @param  string $context View or edit context.
681 681
 	 * @return string
682 682
 	 */
683
-	public function get_summary( $context = 'view' ) {
684
-		return $this->get_description( $context );
683
+	public function get_summary($context = 'view') {
684
+		return $this->get_description($context);
685 685
     }
686 686
 
687 687
     /**
@@ -691,25 +691,25 @@  discard block
 block discarded – undo
691 691
      * @param  string $context View or edit context.
692 692
 	 * @return array
693 693
 	 */
694
-    public function get_user_info( $context = 'view' ) {
694
+    public function get_user_info($context = 'view') {
695 695
 
696 696
         $user_info = array(
697
-            'user_id'    => $this->get_user_id( $context ),
698
-            'email'      => $this->get_email( $context ),
699
-            'first_name' => $this->get_first_name( $context ),
700
-            'last_name'  => $this->get_last_name( $context ),
701
-            'address'    => $this->get_address( $context ),
702
-            'phone'      => $this->get_phone( $context ),
703
-            'city'       => $this->get_city( $context ),
704
-            'country'    => $this->get_country( $context ),
705
-            'state'      => $this->get_state( $context ),
706
-            'zip'        => $this->get_zip( $context ),
707
-            'company'    => $this->get_company( $context ),
708
-            'vat_number' => $this->get_vat_number( $context ),
709
-            'discount'   => $this->get_discount_code( $context ),
697
+            'user_id'    => $this->get_user_id($context),
698
+            'email'      => $this->get_email($context),
699
+            'first_name' => $this->get_first_name($context),
700
+            'last_name'  => $this->get_last_name($context),
701
+            'address'    => $this->get_address($context),
702
+            'phone'      => $this->get_phone($context),
703
+            'city'       => $this->get_city($context),
704
+            'country'    => $this->get_country($context),
705
+            'state'      => $this->get_state($context),
706
+            'zip'        => $this->get_zip($context),
707
+            'company'    => $this->get_company($context),
708
+            'vat_number' => $this->get_vat_number($context),
709
+            'discount'   => $this->get_discount_code($context),
710 710
 		);
711 711
 
712
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
712
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
713 713
 
714 714
     }
715 715
 
@@ -720,8 +720,8 @@  discard block
 block discarded – undo
720 720
 	 * @param  string $context View or edit context.
721 721
 	 * @return int
722 722
 	 */
723
-	public function get_author( $context = 'view' ) {
724
-		return (int) $this->get_prop( 'author', $context );
723
+	public function get_author($context = 'view') {
724
+		return (int) $this->get_prop('author', $context);
725 725
     }
726 726
 
727 727
     /**
@@ -731,8 +731,8 @@  discard block
 block discarded – undo
731 731
 	 * @param  string $context View or edit context.
732 732
 	 * @return int
733 733
 	 */
734
-	public function get_user_id( $context = 'view' ) {
735
-		return $this->get_author( $context );
734
+	public function get_user_id($context = 'view') {
735
+		return $this->get_author($context);
736 736
     }
737 737
 
738 738
      /**
@@ -742,8 +742,8 @@  discard block
 block discarded – undo
742 742
 	 * @param  string $context View or edit context.
743 743
 	 * @return int
744 744
 	 */
745
-	public function get_customer_id( $context = 'view' ) {
746
-		return $this->get_author( $context );
745
+	public function get_customer_id($context = 'view') {
746
+		return $this->get_author($context);
747 747
     }
748 748
 
749 749
     /**
@@ -753,8 +753,8 @@  discard block
 block discarded – undo
753 753
 	 * @param  string $context View or edit context.
754 754
 	 * @return string
755 755
 	 */
756
-	public function get_ip( $context = 'view' ) {
757
-		return $this->get_prop( 'user_ip', $context );
756
+	public function get_ip($context = 'view') {
757
+		return $this->get_prop('user_ip', $context);
758 758
     }
759 759
 
760 760
     /**
@@ -764,8 +764,8 @@  discard block
 block discarded – undo
764 764
 	 * @param  string $context View or edit context.
765 765
 	 * @return string
766 766
 	 */
767
-	public function get_user_ip( $context = 'view' ) {
768
-		return $this->get_ip( $context );
767
+	public function get_user_ip($context = 'view') {
768
+		return $this->get_ip($context);
769 769
     }
770 770
 
771 771
      /**
@@ -775,8 +775,8 @@  discard block
 block discarded – undo
775 775
 	 * @param  string $context View or edit context.
776 776
 	 * @return string
777 777
 	 */
778
-	public function get_customer_ip( $context = 'view' ) {
779
-		return $this->get_ip( $context );
778
+	public function get_customer_ip($context = 'view') {
779
+		return $this->get_ip($context);
780 780
     }
781 781
 
782 782
     /**
@@ -786,8 +786,8 @@  discard block
 block discarded – undo
786 786
 	 * @param  string $context View or edit context.
787 787
 	 * @return string
788 788
 	 */
789
-	public function get_first_name( $context = 'view' ) {
790
-		return $this->get_prop( 'first_name', $context );
789
+	public function get_first_name($context = 'view') {
790
+		return $this->get_prop('first_name', $context);
791 791
     }
792 792
 
793 793
     /**
@@ -797,8 +797,8 @@  discard block
 block discarded – undo
797 797
 	 * @param  string $context View or edit context.
798 798
 	 * @return int
799 799
 	 */
800
-	public function get_user_first_name( $context = 'view' ) {
801
-		return $this->get_first_name( $context );
800
+	public function get_user_first_name($context = 'view') {
801
+		return $this->get_first_name($context);
802 802
     }
803 803
 
804 804
      /**
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
 	 * @param  string $context View or edit context.
809 809
 	 * @return int
810 810
 	 */
811
-	public function get_customer_first_name( $context = 'view' ) {
812
-		return $this->get_first_name( $context );
811
+	public function get_customer_first_name($context = 'view') {
812
+		return $this->get_first_name($context);
813 813
     }
814 814
 
815 815
     /**
@@ -819,8 +819,8 @@  discard block
 block discarded – undo
819 819
 	 * @param  string $context View or edit context.
820 820
 	 * @return string
821 821
 	 */
822
-	public function get_last_name( $context = 'view' ) {
823
-		return $this->get_prop( 'last_name', $context );
822
+	public function get_last_name($context = 'view') {
823
+		return $this->get_prop('last_name', $context);
824 824
     }
825 825
 
826 826
     /**
@@ -830,8 +830,8 @@  discard block
 block discarded – undo
830 830
 	 * @param  string $context View or edit context.
831 831
 	 * @return int
832 832
 	 */
833
-	public function get_user_last_name( $context = 'view' ) {
834
-		return $this->get_last_name( $context );
833
+	public function get_user_last_name($context = 'view') {
834
+		return $this->get_last_name($context);
835 835
     }
836 836
 
837 837
     /**
@@ -841,8 +841,8 @@  discard block
 block discarded – undo
841 841
 	 * @param  string $context View or edit context.
842 842
 	 * @return int
843 843
 	 */
844
-	public function get_customer_last_name( $context = 'view' ) {
845
-		return $this->get_last_name( $context );
844
+	public function get_customer_last_name($context = 'view') {
845
+		return $this->get_last_name($context);
846 846
     }
847 847
 
848 848
     /**
@@ -852,8 +852,8 @@  discard block
 block discarded – undo
852 852
 	 * @param  string $context View or edit context.
853 853
 	 * @return string
854 854
 	 */
855
-	public function get_full_name( $context = 'view' ) {
856
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
855
+	public function get_full_name($context = 'view') {
856
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
857 857
     }
858 858
 
859 859
     /**
@@ -863,8 +863,8 @@  discard block
 block discarded – undo
863 863
 	 * @param  string $context View or edit context.
864 864
 	 * @return int
865 865
 	 */
866
-	public function get_user_full_name( $context = 'view' ) {
867
-		return $this->get_full_name( $context );
866
+	public function get_user_full_name($context = 'view') {
867
+		return $this->get_full_name($context);
868 868
     }
869 869
 
870 870
     /**
@@ -874,8 +874,8 @@  discard block
 block discarded – undo
874 874
 	 * @param  string $context View or edit context.
875 875
 	 * @return int
876 876
 	 */
877
-	public function get_customer_full_name( $context = 'view' ) {
878
-		return $this->get_full_name( $context );
877
+	public function get_customer_full_name($context = 'view') {
878
+		return $this->get_full_name($context);
879 879
     }
880 880
 
881 881
     /**
@@ -885,8 +885,8 @@  discard block
 block discarded – undo
885 885
 	 * @param  string $context View or edit context.
886 886
 	 * @return string
887 887
 	 */
888
-	public function get_phone( $context = 'view' ) {
889
-		return $this->get_prop( 'phone', $context );
888
+	public function get_phone($context = 'view') {
889
+		return $this->get_prop('phone', $context);
890 890
     }
891 891
 
892 892
     /**
@@ -896,8 +896,8 @@  discard block
 block discarded – undo
896 896
 	 * @param  string $context View or edit context.
897 897
 	 * @return int
898 898
 	 */
899
-	public function get_phone_number( $context = 'view' ) {
900
-		return $this->get_phone( $context );
899
+	public function get_phone_number($context = 'view') {
900
+		return $this->get_phone($context);
901 901
     }
902 902
 
903 903
     /**
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
 	 * @param  string $context View or edit context.
908 908
 	 * @return int
909 909
 	 */
910
-	public function get_user_phone( $context = 'view' ) {
911
-		return $this->get_phone( $context );
910
+	public function get_user_phone($context = 'view') {
911
+		return $this->get_phone($context);
912 912
     }
913 913
 
914 914
     /**
@@ -918,8 +918,8 @@  discard block
 block discarded – undo
918 918
 	 * @param  string $context View or edit context.
919 919
 	 * @return int
920 920
 	 */
921
-	public function get_customer_phone( $context = 'view' ) {
922
-		return $this->get_phone( $context );
921
+	public function get_customer_phone($context = 'view') {
922
+		return $this->get_phone($context);
923 923
     }
924 924
 
925 925
     /**
@@ -929,8 +929,8 @@  discard block
 block discarded – undo
929 929
 	 * @param  string $context View or edit context.
930 930
 	 * @return string
931 931
 	 */
932
-	public function get_email( $context = 'view' ) {
933
-		return $this->get_prop( 'email', $context );
932
+	public function get_email($context = 'view') {
933
+		return $this->get_prop('email', $context);
934 934
     }
935 935
 
936 936
     /**
@@ -940,8 +940,8 @@  discard block
 block discarded – undo
940 940
 	 * @param  string $context View or edit context.
941 941
 	 * @return string
942 942
 	 */
943
-	public function get_email_address( $context = 'view' ) {
944
-		return $this->get_email( $context );
943
+	public function get_email_address($context = 'view') {
944
+		return $this->get_email($context);
945 945
     }
946 946
 
947 947
     /**
@@ -951,8 +951,8 @@  discard block
 block discarded – undo
951 951
 	 * @param  string $context View or edit context.
952 952
 	 * @return int
953 953
 	 */
954
-	public function get_user_email( $context = 'view' ) {
955
-		return $this->get_email( $context );
954
+	public function get_user_email($context = 'view') {
955
+		return $this->get_email($context);
956 956
     }
957 957
 
958 958
     /**
@@ -962,8 +962,8 @@  discard block
 block discarded – undo
962 962
 	 * @param  string $context View or edit context.
963 963
 	 * @return int
964 964
 	 */
965
-	public function get_customer_email( $context = 'view' ) {
966
-		return $this->get_email( $context );
965
+	public function get_customer_email($context = 'view') {
966
+		return $this->get_email($context);
967 967
     }
968 968
 
969 969
     /**
@@ -973,9 +973,9 @@  discard block
 block discarded – undo
973 973
 	 * @param  string $context View or edit context.
974 974
 	 * @return string
975 975
 	 */
976
-	public function get_country( $context = 'view' ) {
977
-		$country = $this->get_prop( 'country', $context );
978
-		return empty( $country ) ? wpinv_get_default_country() : $country;
976
+	public function get_country($context = 'view') {
977
+		$country = $this->get_prop('country', $context);
978
+		return empty($country) ? wpinv_get_default_country() : $country;
979 979
     }
980 980
 
981 981
     /**
@@ -985,8 +985,8 @@  discard block
 block discarded – undo
985 985
 	 * @param  string $context View or edit context.
986 986
 	 * @return int
987 987
 	 */
988
-	public function get_user_country( $context = 'view' ) {
989
-		return $this->get_country( $context );
988
+	public function get_user_country($context = 'view') {
989
+		return $this->get_country($context);
990 990
     }
991 991
 
992 992
     /**
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
 	 * @param  string $context View or edit context.
997 997
 	 * @return int
998 998
 	 */
999
-	public function get_customer_country( $context = 'view' ) {
1000
-		return $this->get_country( $context );
999
+	public function get_customer_country($context = 'view') {
1000
+		return $this->get_country($context);
1001 1001
     }
1002 1002
 
1003 1003
     /**
@@ -1007,9 +1007,9 @@  discard block
 block discarded – undo
1007 1007
 	 * @param  string $context View or edit context.
1008 1008
 	 * @return string
1009 1009
 	 */
1010
-	public function get_state( $context = 'view' ) {
1011
-		$state = $this->get_prop( 'state', $context );
1012
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1010
+	public function get_state($context = 'view') {
1011
+		$state = $this->get_prop('state', $context);
1012
+		return empty($state) ? wpinv_get_default_state() : $state;
1013 1013
     }
1014 1014
 
1015 1015
     /**
@@ -1019,8 +1019,8 @@  discard block
 block discarded – undo
1019 1019
 	 * @param  string $context View or edit context.
1020 1020
 	 * @return int
1021 1021
 	 */
1022
-	public function get_user_state( $context = 'view' ) {
1023
-		return $this->get_state( $context );
1022
+	public function get_user_state($context = 'view') {
1023
+		return $this->get_state($context);
1024 1024
     }
1025 1025
 
1026 1026
     /**
@@ -1030,8 +1030,8 @@  discard block
 block discarded – undo
1030 1030
 	 * @param  string $context View or edit context.
1031 1031
 	 * @return int
1032 1032
 	 */
1033
-	public function get_customer_state( $context = 'view' ) {
1034
-		return $this->get_state( $context );
1033
+	public function get_customer_state($context = 'view') {
1034
+		return $this->get_state($context);
1035 1035
     }
1036 1036
 
1037 1037
     /**
@@ -1041,8 +1041,8 @@  discard block
 block discarded – undo
1041 1041
 	 * @param  string $context View or edit context.
1042 1042
 	 * @return string
1043 1043
 	 */
1044
-	public function get_city( $context = 'view' ) {
1045
-		return $this->get_prop( 'city', $context );
1044
+	public function get_city($context = 'view') {
1045
+		return $this->get_prop('city', $context);
1046 1046
     }
1047 1047
 
1048 1048
     /**
@@ -1052,8 +1052,8 @@  discard block
 block discarded – undo
1052 1052
 	 * @param  string $context View or edit context.
1053 1053
 	 * @return string
1054 1054
 	 */
1055
-	public function get_user_city( $context = 'view' ) {
1056
-		return $this->get_city( $context );
1055
+	public function get_user_city($context = 'view') {
1056
+		return $this->get_city($context);
1057 1057
     }
1058 1058
 
1059 1059
     /**
@@ -1063,8 +1063,8 @@  discard block
 block discarded – undo
1063 1063
 	 * @param  string $context View or edit context.
1064 1064
 	 * @return string
1065 1065
 	 */
1066
-	public function get_customer_city( $context = 'view' ) {
1067
-		return $this->get_city( $context );
1066
+	public function get_customer_city($context = 'view') {
1067
+		return $this->get_city($context);
1068 1068
     }
1069 1069
 
1070 1070
     /**
@@ -1074,8 +1074,8 @@  discard block
 block discarded – undo
1074 1074
 	 * @param  string $context View or edit context.
1075 1075
 	 * @return string
1076 1076
 	 */
1077
-	public function get_zip( $context = 'view' ) {
1078
-		return $this->get_prop( 'zip', $context );
1077
+	public function get_zip($context = 'view') {
1078
+		return $this->get_prop('zip', $context);
1079 1079
     }
1080 1080
 
1081 1081
     /**
@@ -1085,8 +1085,8 @@  discard block
 block discarded – undo
1085 1085
 	 * @param  string $context View or edit context.
1086 1086
 	 * @return string
1087 1087
 	 */
1088
-	public function get_user_zip( $context = 'view' ) {
1089
-		return $this->get_zip( $context );
1088
+	public function get_user_zip($context = 'view') {
1089
+		return $this->get_zip($context);
1090 1090
     }
1091 1091
 
1092 1092
     /**
@@ -1096,8 +1096,8 @@  discard block
 block discarded – undo
1096 1096
 	 * @param  string $context View or edit context.
1097 1097
 	 * @return string
1098 1098
 	 */
1099
-	public function get_customer_zip( $context = 'view' ) {
1100
-		return $this->get_zip( $context );
1099
+	public function get_customer_zip($context = 'view') {
1100
+		return $this->get_zip($context);
1101 1101
     }
1102 1102
 
1103 1103
     /**
@@ -1107,8 +1107,8 @@  discard block
 block discarded – undo
1107 1107
 	 * @param  string $context View or edit context.
1108 1108
 	 * @return string
1109 1109
 	 */
1110
-	public function get_company( $context = 'view' ) {
1111
-		return $this->get_prop( 'company', $context );
1110
+	public function get_company($context = 'view') {
1111
+		return $this->get_prop('company', $context);
1112 1112
     }
1113 1113
 
1114 1114
     /**
@@ -1118,8 +1118,8 @@  discard block
 block discarded – undo
1118 1118
 	 * @param  string $context View or edit context.
1119 1119
 	 * @return string
1120 1120
 	 */
1121
-	public function get_user_company( $context = 'view' ) {
1122
-		return $this->get_company( $context );
1121
+	public function get_user_company($context = 'view') {
1122
+		return $this->get_company($context);
1123 1123
     }
1124 1124
 
1125 1125
     /**
@@ -1129,8 +1129,8 @@  discard block
 block discarded – undo
1129 1129
 	 * @param  string $context View or edit context.
1130 1130
 	 * @return string
1131 1131
 	 */
1132
-	public function get_customer_company( $context = 'view' ) {
1133
-		return $this->get_company( $context );
1132
+	public function get_customer_company($context = 'view') {
1133
+		return $this->get_company($context);
1134 1134
     }
1135 1135
 
1136 1136
     /**
@@ -1140,8 +1140,8 @@  discard block
 block discarded – undo
1140 1140
 	 * @param  string $context View or edit context.
1141 1141
 	 * @return string
1142 1142
 	 */
1143
-	public function get_vat_number( $context = 'view' ) {
1144
-		return $this->get_prop( 'vat_number', $context );
1143
+	public function get_vat_number($context = 'view') {
1144
+		return $this->get_prop('vat_number', $context);
1145 1145
     }
1146 1146
 
1147 1147
     /**
@@ -1151,8 +1151,8 @@  discard block
 block discarded – undo
1151 1151
 	 * @param  string $context View or edit context.
1152 1152
 	 * @return string
1153 1153
 	 */
1154
-	public function get_user_vat_number( $context = 'view' ) {
1155
-		return $this->get_vat_number( $context );
1154
+	public function get_user_vat_number($context = 'view') {
1155
+		return $this->get_vat_number($context);
1156 1156
     }
1157 1157
 
1158 1158
     /**
@@ -1162,8 +1162,8 @@  discard block
 block discarded – undo
1162 1162
 	 * @param  string $context View or edit context.
1163 1163
 	 * @return string
1164 1164
 	 */
1165
-	public function get_customer_vat_number( $context = 'view' ) {
1166
-		return $this->get_vat_number( $context );
1165
+	public function get_customer_vat_number($context = 'view') {
1166
+		return $this->get_vat_number($context);
1167 1167
     }
1168 1168
 
1169 1169
     /**
@@ -1173,8 +1173,8 @@  discard block
 block discarded – undo
1173 1173
 	 * @param  string $context View or edit context.
1174 1174
 	 * @return string
1175 1175
 	 */
1176
-	public function get_vat_rate( $context = 'view' ) {
1177
-		return $this->get_prop( 'vat_rate', $context );
1176
+	public function get_vat_rate($context = 'view') {
1177
+		return $this->get_prop('vat_rate', $context);
1178 1178
     }
1179 1179
 
1180 1180
     /**
@@ -1184,8 +1184,8 @@  discard block
 block discarded – undo
1184 1184
 	 * @param  string $context View or edit context.
1185 1185
 	 * @return string
1186 1186
 	 */
1187
-	public function get_user_vat_rate( $context = 'view' ) {
1188
-		return $this->get_vat_rate( $context );
1187
+	public function get_user_vat_rate($context = 'view') {
1188
+		return $this->get_vat_rate($context);
1189 1189
     }
1190 1190
 
1191 1191
     /**
@@ -1195,8 +1195,8 @@  discard block
 block discarded – undo
1195 1195
 	 * @param  string $context View or edit context.
1196 1196
 	 * @return string
1197 1197
 	 */
1198
-	public function get_customer_vat_rate( $context = 'view' ) {
1199
-		return $this->get_vat_rate( $context );
1198
+	public function get_customer_vat_rate($context = 'view') {
1199
+		return $this->get_vat_rate($context);
1200 1200
     }
1201 1201
 
1202 1202
     /**
@@ -1206,8 +1206,8 @@  discard block
 block discarded – undo
1206 1206
 	 * @param  string $context View or edit context.
1207 1207
 	 * @return string
1208 1208
 	 */
1209
-	public function get_address( $context = 'view' ) {
1210
-		return $this->get_prop( 'address', $context );
1209
+	public function get_address($context = 'view') {
1210
+		return $this->get_prop('address', $context);
1211 1211
     }
1212 1212
 
1213 1213
     /**
@@ -1217,8 +1217,8 @@  discard block
 block discarded – undo
1217 1217
 	 * @param  string $context View or edit context.
1218 1218
 	 * @return string
1219 1219
 	 */
1220
-	public function get_user_address( $context = 'view' ) {
1221
-		return $this->get_address( $context );
1220
+	public function get_user_address($context = 'view') {
1221
+		return $this->get_address($context);
1222 1222
     }
1223 1223
 
1224 1224
     /**
@@ -1228,8 +1228,8 @@  discard block
 block discarded – undo
1228 1228
 	 * @param  string $context View or edit context.
1229 1229
 	 * @return string
1230 1230
 	 */
1231
-	public function get_customer_address( $context = 'view' ) {
1232
-		return $this->get_address( $context );
1231
+	public function get_customer_address($context = 'view') {
1232
+		return $this->get_address($context);
1233 1233
     }
1234 1234
 
1235 1235
     /**
@@ -1239,8 +1239,8 @@  discard block
 block discarded – undo
1239 1239
 	 * @param  string $context View or edit context.
1240 1240
 	 * @return bool
1241 1241
 	 */
1242
-	public function get_is_viewed( $context = 'view' ) {
1243
-		return (bool) $this->get_prop( 'is_viewed', $context );
1242
+	public function get_is_viewed($context = 'view') {
1243
+		return (bool) $this->get_prop('is_viewed', $context);
1244 1244
 	}
1245 1245
 
1246 1246
 	/**
@@ -1250,8 +1250,8 @@  discard block
 block discarded – undo
1250 1250
 	 * @param  string $context View or edit context.
1251 1251
 	 * @return bool
1252 1252
 	 */
1253
-	public function get_email_cc( $context = 'view' ) {
1254
-		return $this->get_prop( 'email_cc', $context );
1253
+	public function get_email_cc($context = 'view') {
1254
+		return $this->get_prop('email_cc', $context);
1255 1255
 	}
1256 1256
 
1257 1257
 	/**
@@ -1261,8 +1261,8 @@  discard block
 block discarded – undo
1261 1261
 	 * @param  string $context View or edit context.
1262 1262
 	 * @return bool
1263 1263
 	 */
1264
-	public function get_template( $context = 'view' ) {
1265
-		return $this->get_prop( 'template', $context );
1264
+	public function get_template($context = 'view') {
1265
+		return $this->get_prop('template', $context);
1266 1266
 	}
1267 1267
 
1268 1268
 	/**
@@ -1272,8 +1272,8 @@  discard block
 block discarded – undo
1272 1272
 	 * @param  string $context View or edit context.
1273 1273
 	 * @return bool
1274 1274
 	 */
1275
-	public function get_address_confirmed( $context = 'view' ) {
1276
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1275
+	public function get_address_confirmed($context = 'view') {
1276
+		return (bool) $this->get_prop('address_confirmed', $context);
1277 1277
     }
1278 1278
 
1279 1279
     /**
@@ -1283,8 +1283,8 @@  discard block
 block discarded – undo
1283 1283
 	 * @param  string $context View or edit context.
1284 1284
 	 * @return bool
1285 1285
 	 */
1286
-	public function get_user_address_confirmed( $context = 'view' ) {
1287
-		return $this->get_address_confirmed( $context );
1286
+	public function get_user_address_confirmed($context = 'view') {
1287
+		return $this->get_address_confirmed($context);
1288 1288
     }
1289 1289
 
1290 1290
     /**
@@ -1294,8 +1294,8 @@  discard block
 block discarded – undo
1294 1294
 	 * @param  string $context View or edit context.
1295 1295
 	 * @return bool
1296 1296
 	 */
1297
-	public function get_customer_address_confirmed( $context = 'view' ) {
1298
-		return $this->get_address_confirmed( $context );
1297
+	public function get_customer_address_confirmed($context = 'view') {
1298
+		return $this->get_address_confirmed($context);
1299 1299
     }
1300 1300
 
1301 1301
     /**
@@ -1305,12 +1305,12 @@  discard block
 block discarded – undo
1305 1305
 	 * @param  string $context View or edit context.
1306 1306
 	 * @return float
1307 1307
 	 */
1308
-	public function get_subtotal( $context = 'view' ) {
1309
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1308
+	public function get_subtotal($context = 'view') {
1309
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1310 1310
 
1311 1311
         // Backwards compatibility.
1312
-        if ( is_bool( $context ) && $context ) {
1313
-            return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() );
1312
+        if (is_bool($context) && $context) {
1313
+            return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency());
1314 1314
         }
1315 1315
 
1316 1316
         return $subtotal;
@@ -1323,8 +1323,8 @@  discard block
 block discarded – undo
1323 1323
 	 * @param  string $context View or edit context.
1324 1324
 	 * @return float
1325 1325
 	 */
1326
-	public function get_total_discount( $context = 'view' ) {
1327
-		return (float) $this->get_prop( 'total_discount', $context );
1326
+	public function get_total_discount($context = 'view') {
1327
+		return (float) $this->get_prop('total_discount', $context);
1328 1328
     }
1329 1329
 
1330 1330
     /**
@@ -1334,18 +1334,18 @@  discard block
 block discarded – undo
1334 1334
 	 * @param  string $context View or edit context.
1335 1335
 	 * @return float
1336 1336
 	 */
1337
-	public function get_total_tax( $context = 'view' ) {
1338
-		return (float) $this->get_prop( 'total_tax', $context );
1337
+	public function get_total_tax($context = 'view') {
1338
+		return (float) $this->get_prop('total_tax', $context);
1339 1339
 	}
1340 1340
 
1341 1341
 	/**
1342 1342
 	 * @deprecated
1343 1343
 	 */
1344
-	public function get_final_tax( $currency = false ) {
1344
+	public function get_final_tax($currency = false) {
1345 1345
 		$tax = $this->get_total_tax();
1346 1346
 
1347
-        if ( $currency ) {
1348
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1347
+        if ($currency) {
1348
+			return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency());
1349 1349
         }
1350 1350
 
1351 1351
         return $tax;
@@ -1358,8 +1358,8 @@  discard block
 block discarded – undo
1358 1358
 	 * @param  string $context View or edit context.
1359 1359
 	 * @return float
1360 1360
 	 */
1361
-	public function get_total_fees( $context = 'view' ) {
1362
-		return (float) $this->get_prop( 'total_fees', $context );
1361
+	public function get_total_fees($context = 'view') {
1362
+		return (float) $this->get_prop('total_fees', $context);
1363 1363
     }
1364 1364
 
1365 1365
     /**
@@ -1369,8 +1369,8 @@  discard block
 block discarded – undo
1369 1369
 	 * @param  string $context View or edit context.
1370 1370
 	 * @return float
1371 1371
 	 */
1372
-	public function get_fees_total( $context = 'view' ) {
1373
-		return $this->get_total_fees( $context );
1372
+	public function get_fees_total($context = 'view') {
1373
+		return $this->get_total_fees($context);
1374 1374
     }
1375 1375
 
1376 1376
     /**
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 	 */
1382 1382
 	public function get_total() {
1383 1383
 		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1384
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1384
+		return apply_filters('getpaid_get_invoice_total_amount', $total, $this);
1385 1385
 	}
1386 1386
 	
1387 1387
 	/**
@@ -1403,7 +1403,7 @@  discard block
 block discarded – undo
1403 1403
 	 */
1404 1404
     public function get_initial_total() {
1405 1405
 
1406
-		if ( empty( $this->totals ) ) {
1406
+		if (empty($this->totals)) {
1407 1407
 			$this->recalculate_total();
1408 1408
 		}
1409 1409
 
@@ -1413,11 +1413,11 @@  discard block
 block discarded – undo
1413 1413
 		$subtotal = $this->totals['subtotal']['initial'];
1414 1414
 		$total    = $tax + $fee - $discount + $subtotal;
1415 1415
 
1416
-		if ( 0 > $total ) {
1416
+		if (0 > $total) {
1417 1417
 			$total = 0;
1418 1418
 		}
1419 1419
 
1420
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1420
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1421 1421
 	}
1422 1422
 
1423 1423
 	/**
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
 	 */
1430 1430
     public function get_recurring_total() {
1431 1431
 
1432
-		if ( empty( $this->totals ) ) {
1432
+		if (empty($this->totals)) {
1433 1433
 			$this->recalculate_total();
1434 1434
 		}
1435 1435
 
@@ -1439,11 +1439,11 @@  discard block
 block discarded – undo
1439 1439
 		$subtotal = $this->totals['subtotal']['recurring'];
1440 1440
 		$total    = $tax + $fee - $discount + $subtotal;
1441 1441
 
1442
-		if ( 0 > $total ) {
1442
+		if (0 > $total) {
1443 1443
 			$total = 0;
1444 1444
 		}
1445 1445
 
1446
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1446
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1447 1447
 	}
1448 1448
 
1449 1449
 	/**
@@ -1454,10 +1454,10 @@  discard block
 block discarded – undo
1454 1454
 	 * @param string $currency Whether to include the currency.
1455 1455
      * @return float
1456 1456
 	 */
1457
-    public function get_recurring_details( $field = '', $currency = false ) {
1457
+    public function get_recurring_details($field = '', $currency = false) {
1458 1458
 
1459 1459
 		// Maybe recalculate totals.
1460
-		if ( empty( $this->totals ) ) {
1460
+		if (empty($this->totals)) {
1461 1461
 			$this->recalculate_total();
1462 1462
 		}
1463 1463
 
@@ -1477,8 +1477,8 @@  discard block
 block discarded – undo
1477 1477
 			$currency
1478 1478
 		);
1479 1479
 
1480
-        if ( isset( $data[$field] ) ) {
1481
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1480
+        if (isset($data[$field])) {
1481
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1482 1482
         }
1483 1483
 
1484 1484
         return $data;
@@ -1491,8 +1491,8 @@  discard block
 block discarded – undo
1491 1491
 	 * @param  string $context View or edit context.
1492 1492
 	 * @return array
1493 1493
 	 */
1494
-	public function get_fees( $context = 'view' ) {
1495
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1494
+	public function get_fees($context = 'view') {
1495
+		return wpinv_parse_list($this->get_prop('fees', $context));
1496 1496
     }
1497 1497
 
1498 1498
     /**
@@ -1502,8 +1502,8 @@  discard block
 block discarded – undo
1502 1502
 	 * @param  string $context View or edit context.
1503 1503
 	 * @return array
1504 1504
 	 */
1505
-	public function get_discounts( $context = 'view' ) {
1506
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1505
+	public function get_discounts($context = 'view') {
1506
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1507 1507
     }
1508 1508
 
1509 1509
     /**
@@ -1513,8 +1513,8 @@  discard block
 block discarded – undo
1513 1513
 	 * @param  string $context View or edit context.
1514 1514
 	 * @return array
1515 1515
 	 */
1516
-	public function get_taxes( $context = 'view' ) {
1517
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1516
+	public function get_taxes($context = 'view') {
1517
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1518 1518
     }
1519 1519
 
1520 1520
     /**
@@ -1524,8 +1524,8 @@  discard block
 block discarded – undo
1524 1524
 	 * @param  string $context View or edit context.
1525 1525
 	 * @return GetPaid_Form_Item[]
1526 1526
 	 */
1527
-	public function get_items( $context = 'view' ) {
1528
-        return $this->get_prop( 'items', $context );
1527
+	public function get_items($context = 'view') {
1528
+        return $this->get_prop('items', $context);
1529 1529
     }
1530 1530
 
1531 1531
     /**
@@ -1535,8 +1535,8 @@  discard block
 block discarded – undo
1535 1535
 	 * @param  string $context View or edit context.
1536 1536
 	 * @return int
1537 1537
 	 */
1538
-	public function get_payment_form( $context = 'view' ) {
1539
-		return intval( $this->get_prop( 'payment_form', $context ) );
1538
+	public function get_payment_form($context = 'view') {
1539
+		return intval($this->get_prop('payment_form', $context));
1540 1540
     }
1541 1541
 
1542 1542
     /**
@@ -1546,8 +1546,8 @@  discard block
 block discarded – undo
1546 1546
 	 * @param  string $context View or edit context.
1547 1547
 	 * @return string
1548 1548
 	 */
1549
-	public function get_submission_id( $context = 'view' ) {
1550
-		return $this->get_prop( 'submission_id', $context );
1549
+	public function get_submission_id($context = 'view') {
1550
+		return $this->get_prop('submission_id', $context);
1551 1551
     }
1552 1552
 
1553 1553
     /**
@@ -1557,8 +1557,8 @@  discard block
 block discarded – undo
1557 1557
 	 * @param  string $context View or edit context.
1558 1558
 	 * @return string
1559 1559
 	 */
1560
-	public function get_discount_code( $context = 'view' ) {
1561
-		return $this->get_prop( 'discount_code', $context );
1560
+	public function get_discount_code($context = 'view') {
1561
+		return $this->get_prop('discount_code', $context);
1562 1562
     }
1563 1563
 
1564 1564
     /**
@@ -1568,8 +1568,8 @@  discard block
 block discarded – undo
1568 1568
 	 * @param  string $context View or edit context.
1569 1569
 	 * @return string
1570 1570
 	 */
1571
-	public function get_gateway( $context = 'view' ) {
1572
-		return $this->get_prop( 'gateway', $context );
1571
+	public function get_gateway($context = 'view') {
1572
+		return $this->get_prop('gateway', $context);
1573 1573
     }
1574 1574
 
1575 1575
     /**
@@ -1579,8 +1579,8 @@  discard block
 block discarded – undo
1579 1579
 	 * @return string
1580 1580
 	 */
1581 1581
     public function get_gateway_title() {
1582
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1583
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1582
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1583
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1584 1584
     }
1585 1585
 
1586 1586
     /**
@@ -1590,8 +1590,8 @@  discard block
 block discarded – undo
1590 1590
 	 * @param  string $context View or edit context.
1591 1591
 	 * @return string
1592 1592
 	 */
1593
-	public function get_transaction_id( $context = 'view' ) {
1594
-		return $this->get_prop( 'transaction_id', $context );
1593
+	public function get_transaction_id($context = 'view') {
1594
+		return $this->get_prop('transaction_id', $context);
1595 1595
     }
1596 1596
 
1597 1597
     /**
@@ -1601,9 +1601,9 @@  discard block
 block discarded – undo
1601 1601
 	 * @param  string $context View or edit context.
1602 1602
 	 * @return string
1603 1603
 	 */
1604
-	public function get_currency( $context = 'view' ) {
1605
-        $currency = $this->get_prop( 'currency', $context );
1606
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1604
+	public function get_currency($context = 'view') {
1605
+        $currency = $this->get_prop('currency', $context);
1606
+        return empty($currency) ? wpinv_get_currency() : $currency;
1607 1607
     }
1608 1608
 
1609 1609
     /**
@@ -1613,8 +1613,8 @@  discard block
 block discarded – undo
1613 1613
 	 * @param  string $context View or edit context.
1614 1614
 	 * @return bool
1615 1615
 	 */
1616
-	public function get_disable_taxes( $context = 'view' ) {
1617
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1616
+	public function get_disable_taxes($context = 'view') {
1617
+        return (bool) $this->get_prop('disable_taxes', $context);
1618 1618
     }
1619 1619
 
1620 1620
     /**
@@ -1624,12 +1624,12 @@  discard block
 block discarded – undo
1624 1624
 	 * @param  string $context View or edit context.
1625 1625
 	 * @return int
1626 1626
 	 */
1627
-    public function get_subscription_id( $context = 'view' ) {
1628
-        $subscription_id = $this->get_prop( 'subscription_id', $context );
1627
+    public function get_subscription_id($context = 'view') {
1628
+        $subscription_id = $this->get_prop('subscription_id', $context);
1629 1629
 
1630
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1630
+        if (empty($subscription_id) && $this->is_renewal()) {
1631 1631
             $parent = $this->get_parent();
1632
-            return $parent->get_subscription_id( $context );
1632
+            return $parent->get_subscription_id($context);
1633 1633
         }
1634 1634
 
1635 1635
         return $subscription_id;
@@ -1642,20 +1642,20 @@  discard block
 block discarded – undo
1642 1642
 	 * @param  string $context View or edit context.
1643 1643
 	 * @return array
1644 1644
 	 */
1645
-    public function get_payment_meta( $context = 'view' ) {
1645
+    public function get_payment_meta($context = 'view') {
1646 1646
 
1647 1647
         return array(
1648
-            'price'        => $this->get_total( $context ),
1649
-            'date'         => $this->get_date_created( $context ),
1650
-            'user_email'   => $this->get_email( $context ),
1651
-            'invoice_key'  => $this->get_key( $context ),
1652
-            'currency'     => $this->get_currency( $context ),
1653
-            'items'        => $this->get_items( $context ),
1654
-            'user_info'    => $this->get_user_info( $context ),
1648
+            'price'        => $this->get_total($context),
1649
+            'date'         => $this->get_date_created($context),
1650
+            'user_email'   => $this->get_email($context),
1651
+            'invoice_key'  => $this->get_key($context),
1652
+            'currency'     => $this->get_currency($context),
1653
+            'items'        => $this->get_items($context),
1654
+            'user_info'    => $this->get_user_info($context),
1655 1655
             'cart_details' => $this->get_cart_details(),
1656
-            'status'       => $this->get_status( $context ),
1657
-            'fees'         => $this->get_fees( $context ),
1658
-            'taxes'        => $this->get_taxes( $context ),
1656
+            'status'       => $this->get_status($context),
1657
+            'fees'         => $this->get_fees($context),
1658
+            'taxes'        => $this->get_taxes($context),
1659 1659
         );
1660 1660
 
1661 1661
     }
@@ -1670,7 +1670,7 @@  discard block
 block discarded – undo
1670 1670
         $items        = $this->get_items();
1671 1671
         $cart_details = array();
1672 1672
 
1673
-        foreach ( $items as $item_id => $item ) {
1673
+        foreach ($items as $item_id => $item) {
1674 1674
             $cart_details[] = $item->prepare_data_for_saving();
1675 1675
         }
1676 1676
 
@@ -1682,11 +1682,11 @@  discard block
 block discarded – undo
1682 1682
 	 *
1683 1683
 	 * @return null|GetPaid_Form_Item|int
1684 1684
 	 */
1685
-	public function get_recurring( $object = false ) {
1685
+	public function get_recurring($object = false) {
1686 1686
 
1687 1687
 		// Are we returning an object?
1688
-        if ( $object ) {
1689
-            return $this->get_item( $this->recurring_item );
1688
+        if ($object) {
1689
+            return $this->get_item($this->recurring_item);
1690 1690
         }
1691 1691
 
1692 1692
         return $this->recurring_item;
@@ -1701,15 +1701,15 @@  discard block
 block discarded – undo
1701 1701
 	public function get_subscription_name() {
1702 1702
 
1703 1703
 		// Retrieve the recurring name
1704
-        $item = $this->get_recurring( true );
1704
+        $item = $this->get_recurring(true);
1705 1705
 
1706 1706
 		// Abort if it does not exist.
1707
-        if ( empty( $item ) ) {
1707
+        if (empty($item)) {
1708 1708
             return '';
1709 1709
         }
1710 1710
 
1711 1711
 		// Return the item name.
1712
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1712
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1713 1713
 	}
1714 1714
 
1715 1715
 	/**
@@ -1719,9 +1719,9 @@  discard block
 block discarded – undo
1719 1719
 	 * @return string
1720 1720
 	 */
1721 1721
 	public function get_view_url() {
1722
-        $invoice_url = get_permalink( $this->get_id() );
1723
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1724
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1722
+        $invoice_url = get_permalink($this->get_id());
1723
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1724
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1725 1725
 	}
1726 1726
 
1727 1727
 	/**
@@ -1730,25 +1730,25 @@  discard block
 block discarded – undo
1730 1730
 	 * @since 1.0.19
1731 1731
 	 * @return string
1732 1732
 	 */
1733
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1733
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1734 1734
 
1735 1735
 		// Retrieve the checkout url.
1736 1736
         $pay_url = wpinv_get_checkout_uri();
1737 1737
 
1738 1738
 		// Maybe force ssl.
1739
-        if ( is_ssl() ) {
1740
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1739
+        if (is_ssl()) {
1740
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1741 1741
         }
1742 1742
 
1743 1743
 		// Add the invoice key.
1744
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1744
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1745 1745
 
1746 1746
 		// (Maybe?) add a secret
1747
-        if ( $secret ) {
1748
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1747
+        if ($secret) {
1748
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1749 1749
         }
1750 1750
 
1751
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1751
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1752 1752
 	}
1753 1753
 	
1754 1754
 	/**
@@ -1763,14 +1763,14 @@  discard block
 block discarded – undo
1763 1763
         $receipt_url = wpinv_get_success_page_uri();
1764 1764
 
1765 1765
 		// Maybe force ssl.
1766
-        if ( is_ssl() ) {
1767
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1766
+        if (is_ssl()) {
1767
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1768 1768
         }
1769 1769
 
1770 1770
 		// Add the invoice key.
1771
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1771
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1772 1772
 
1773
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1773
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1774 1774
     }
1775 1775
 
1776 1776
     /**
@@ -1783,8 +1783,8 @@  discard block
 block discarded – undo
1783 1783
 	 * @param  string $context View or edit context.
1784 1784
 	 * @return mixed Value of the given invoice property (if set).
1785 1785
 	 */
1786
-	public function get( $key, $context = 'view' ) {
1787
-        return $this->get_prop( $key, $context );
1786
+	public function get($key, $context = 'view') {
1787
+        return $this->get_prop($key, $context);
1788 1788
 	}
1789 1789
 
1790 1790
     /*
@@ -1807,11 +1807,11 @@  discard block
 block discarded – undo
1807 1807
 	 * @param  mixed $value new value.
1808 1808
 	 * @return mixed Value of the given invoice property (if set).
1809 1809
 	 */
1810
-	public function set( $key, $value ) {
1810
+	public function set($key, $value) {
1811 1811
 
1812 1812
         $setter = "set_$key";
1813
-        if ( is_callable( array( $this, $setter ) ) ) {
1814
-            $this->{$setter}( $value );
1813
+        if (is_callable(array($this, $setter))) {
1814
+            $this->{$setter}($value);
1815 1815
         }
1816 1816
 
1817 1817
 	}
@@ -1825,48 +1825,48 @@  discard block
 block discarded – undo
1825 1825
 	 * @param bool   $manual_update Is this a manual status change?.
1826 1826
 	 * @return array details of change.
1827 1827
 	 */
1828
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1828
+	public function set_status($new_status, $note = '', $manual_update = false) {
1829 1829
 		$old_status = $this->get_status();
1830 1830
 
1831 1831
 		$statuses = $this->get_all_statuses();
1832 1832
 
1833
-		if ( isset( $statuses[ 'draft' ] ) ) {
1834
-			unset( $statuses[ 'draft' ] );
1833
+		if (isset($statuses['draft'])) {
1834
+			unset($statuses['draft']);
1835 1835
 		}
1836 1836
 
1837 1837
 
1838
-		$this->set_prop( 'status', $new_status );
1838
+		$this->set_prop('status', $new_status);
1839 1839
 
1840 1840
 		// If setting the status, ensure it's set to a valid status.
1841
-		if ( true === $this->object_read ) {
1841
+		if (true === $this->object_read) {
1842 1842
 
1843 1843
 			// Only allow valid new status.
1844
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1844
+			if (!array_key_exists($new_status, $statuses)) {
1845 1845
 				$new_status = 'wpi-pending';
1846 1846
 			}
1847 1847
 
1848 1848
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1849
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1849
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1850 1850
 				$old_status = 'wpi-pending';
1851 1851
 			}
1852 1852
 
1853 1853
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1854
-			if ( $new_status == 'wpi-renewal' && $old_status == 'publish' ) {
1854
+			if ($new_status == 'wpi-renewal' && $old_status == 'publish') {
1855 1855
 				$old_status = 'wpi-pending';
1856 1856
 			}
1857 1857
 
1858 1858
 		}
1859 1859
 
1860
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1860
+		if (true === $this->object_read && $old_status !== $new_status) {
1861 1861
 			$this->status_transition = array(
1862
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1862
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1863 1863
 				'to'     => $new_status,
1864 1864
 				'note'   => $note,
1865 1865
 				'manual' => (bool) $manual_update,
1866 1866
 			);
1867 1867
 
1868
-			if ( $manual_update ) {
1869
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1868
+			if ($manual_update) {
1869
+				do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1870 1870
 			}
1871 1871
 
1872 1872
 			$this->maybe_set_date_paid();
@@ -1889,8 +1889,8 @@  discard block
 block discarded – undo
1889 1889
 	 */
1890 1890
 	public function maybe_set_date_paid() {
1891 1891
 
1892
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1893
-			$this->set_date_completed( current_time( 'mysql' ) );
1892
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
1893
+			$this->set_date_completed(current_time('mysql'));
1894 1894
 		}
1895 1895
 	}
1896 1896
 
@@ -1899,11 +1899,11 @@  discard block
 block discarded – undo
1899 1899
 	 *
1900 1900
 	 * @since 1.0.19
1901 1901
 	 */
1902
-	public function set_parent_id( $value ) {
1903
-		if ( $value && ( $value === $this->get_id() ) ) {
1902
+	public function set_parent_id($value) {
1903
+		if ($value && ($value === $this->get_id())) {
1904 1904
 			return;
1905 1905
 		}
1906
-		$this->set_prop( 'parent_id', absint( $value ) );
1906
+		$this->set_prop('parent_id', absint($value));
1907 1907
     }
1908 1908
 
1909 1909
     /**
@@ -1911,8 +1911,8 @@  discard block
 block discarded – undo
1911 1911
 	 *
1912 1912
 	 * @since 1.0.19
1913 1913
 	 */
1914
-	public function set_version( $value ) {
1915
-		$this->set_prop( 'version', $value );
1914
+	public function set_version($value) {
1915
+		$this->set_prop('version', $value);
1916 1916
     }
1917 1917
 
1918 1918
     /**
@@ -1922,15 +1922,15 @@  discard block
 block discarded – undo
1922 1922
 	 * @param string $value Value to set.
1923 1923
      * @return bool Whether or not the date was set.
1924 1924
 	 */
1925
-	public function set_date_created( $value ) {
1926
-        $date = strtotime( $value );
1925
+	public function set_date_created($value) {
1926
+        $date = strtotime($value);
1927 1927
 
1928
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1929
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
1928
+        if ($date && $value !== '0000-00-00 00:00:00') {
1929
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
1930 1930
             return true;
1931 1931
         }
1932 1932
 
1933
-        return $this->set_prop( 'date_created', '' );
1933
+        return $this->set_prop('date_created', '');
1934 1934
 
1935 1935
     }
1936 1936
 
@@ -1941,15 +1941,15 @@  discard block
 block discarded – undo
1941 1941
 	 * @param string $value Value to set.
1942 1942
      * @return bool Whether or not the date was set.
1943 1943
 	 */
1944
-	public function set_due_date( $value ) {
1945
-        $date = strtotime( $value );
1944
+	public function set_due_date($value) {
1945
+        $date = strtotime($value);
1946 1946
 
1947
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1948
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
1947
+        if ($date && $value !== '0000-00-00 00:00:00') {
1948
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
1949 1949
             return true;
1950 1950
         }
1951 1951
 
1952
-		$this->set_prop( 'due_date', '' );
1952
+		$this->set_prop('due_date', '');
1953 1953
         return false;
1954 1954
 
1955 1955
     }
@@ -1960,8 +1960,8 @@  discard block
 block discarded – undo
1960 1960
 	 * @since 1.0.19
1961 1961
 	 * @param  string $value New name.
1962 1962
 	 */
1963
-	public function set_date_due( $value ) {
1964
-		$this->set_due_date( $value );
1963
+	public function set_date_due($value) {
1964
+		$this->set_due_date($value);
1965 1965
     }
1966 1966
 
1967 1967
     /**
@@ -1971,15 +1971,15 @@  discard block
 block discarded – undo
1971 1971
 	 * @param string $value Value to set.
1972 1972
      * @return bool Whether or not the date was set.
1973 1973
 	 */
1974
-	public function set_completed_date( $value ) {
1975
-        $date = strtotime( $value );
1974
+	public function set_completed_date($value) {
1975
+        $date = strtotime($value);
1976 1976
 
1977
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
1978
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
1977
+        if ($date && $value !== '0000-00-00 00:00:00') {
1978
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
1979 1979
             return true;
1980 1980
         }
1981 1981
 
1982
-		$this->set_prop( 'completed_date', '' );
1982
+		$this->set_prop('completed_date', '');
1983 1983
         return false;
1984 1984
 
1985 1985
     }
@@ -1990,8 +1990,8 @@  discard block
 block discarded – undo
1990 1990
 	 * @since 1.0.19
1991 1991
 	 * @param  string $value New name.
1992 1992
 	 */
1993
-	public function set_date_completed( $value ) {
1994
-		$this->set_completed_date( $value );
1993
+	public function set_date_completed($value) {
1994
+		$this->set_completed_date($value);
1995 1995
     }
1996 1996
 
1997 1997
     /**
@@ -2001,15 +2001,15 @@  discard block
 block discarded – undo
2001 2001
 	 * @param string $value Value to set.
2002 2002
      * @return bool Whether or not the date was set.
2003 2003
 	 */
2004
-	public function set_date_modified( $value ) {
2005
-        $date = strtotime( $value );
2004
+	public function set_date_modified($value) {
2005
+        $date = strtotime($value);
2006 2006
 
2007
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2008
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2007
+        if ($date && $value !== '0000-00-00 00:00:00') {
2008
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2009 2009
             return true;
2010 2010
         }
2011 2011
 
2012
-		$this->set_prop( 'date_modified', '' );
2012
+		$this->set_prop('date_modified', '');
2013 2013
         return false;
2014 2014
 
2015 2015
     }
@@ -2020,9 +2020,9 @@  discard block
 block discarded – undo
2020 2020
 	 * @since 1.0.19
2021 2021
 	 * @param  string $value New number.
2022 2022
 	 */
2023
-	public function set_number( $value ) {
2024
-        $number = sanitize_text_field( $value );
2025
-		$this->set_prop( 'number', $number );
2023
+	public function set_number($value) {
2024
+        $number = sanitize_text_field($value);
2025
+		$this->set_prop('number', $number);
2026 2026
     }
2027 2027
 
2028 2028
     /**
@@ -2031,9 +2031,9 @@  discard block
 block discarded – undo
2031 2031
 	 * @since 1.0.19
2032 2032
 	 * @param  string $value Type.
2033 2033
 	 */
2034
-	public function set_type( $value ) {
2035
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2036
-		$this->set_prop( 'type', $type );
2034
+	public function set_type($value) {
2035
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2036
+		$this->set_prop('type', $type);
2037 2037
 	}
2038 2038
 
2039 2039
     /**
@@ -2042,10 +2042,10 @@  discard block
 block discarded – undo
2042 2042
 	 * @since 1.0.19
2043 2043
 	 * @param  string $value Post type.
2044 2044
 	 */
2045
-	public function set_post_type( $value ) {
2046
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2047
-			$this->set_type( $value );
2048
-            $this->set_prop( 'post_type', $value );
2045
+	public function set_post_type($value) {
2046
+        if (getpaid_is_invoice_post_type($value)) {
2047
+			$this->set_type($value);
2048
+            $this->set_prop('post_type', $value);
2049 2049
         }
2050 2050
     }
2051 2051
 
@@ -2055,9 +2055,9 @@  discard block
 block discarded – undo
2055 2055
 	 * @since 1.0.19
2056 2056
 	 * @param  string $value New key.
2057 2057
 	 */
2058
-	public function set_key( $value ) {
2059
-        $key = sanitize_text_field( $value );
2060
-		$this->set_prop( 'key', $key );
2058
+	public function set_key($value) {
2059
+        $key = sanitize_text_field($value);
2060
+		$this->set_prop('key', $key);
2061 2061
     }
2062 2062
 
2063 2063
     /**
@@ -2066,9 +2066,9 @@  discard block
 block discarded – undo
2066 2066
 	 * @since 1.0.19
2067 2067
 	 * @param  string $value mode.
2068 2068
 	 */
2069
-	public function set_mode( $value ) {
2070
-        if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2071
-            $this->set_prop( 'value', $value );
2069
+	public function set_mode($value) {
2070
+        if (!in_array($value, array('live', 'test'))) {
2071
+            $this->set_prop('value', $value);
2072 2072
         }
2073 2073
     }
2074 2074
 
@@ -2078,8 +2078,8 @@  discard block
 block discarded – undo
2078 2078
 	 * @since 1.0.19
2079 2079
 	 * @param  string $value path.
2080 2080
 	 */
2081
-	public function set_path( $value ) {
2082
-        $this->set_prop( 'path', $value );
2081
+	public function set_path($value) {
2082
+        $this->set_prop('path', $value);
2083 2083
     }
2084 2084
 
2085 2085
     /**
@@ -2088,9 +2088,9 @@  discard block
 block discarded – undo
2088 2088
 	 * @since 1.0.19
2089 2089
 	 * @param  string $value New name.
2090 2090
 	 */
2091
-	public function set_name( $value ) {
2092
-        $name = sanitize_text_field( $value );
2093
-		$this->set_prop( 'name', $name );
2091
+	public function set_name($value) {
2092
+        $name = sanitize_text_field($value);
2093
+		$this->set_prop('name', $name);
2094 2094
     }
2095 2095
 
2096 2096
     /**
@@ -2099,8 +2099,8 @@  discard block
 block discarded – undo
2099 2099
 	 * @since 1.0.19
2100 2100
 	 * @param  string $value New name.
2101 2101
 	 */
2102
-	public function set_title( $value ) {
2103
-		$this->set_name( $value );
2102
+	public function set_title($value) {
2103
+		$this->set_name($value);
2104 2104
     }
2105 2105
 
2106 2106
     /**
@@ -2109,9 +2109,9 @@  discard block
 block discarded – undo
2109 2109
 	 * @since 1.0.19
2110 2110
 	 * @param  string $value New description.
2111 2111
 	 */
2112
-	public function set_description( $value ) {
2113
-        $description = wp_kses_post( $value );
2114
-		return $this->set_prop( 'description', $description );
2112
+	public function set_description($value) {
2113
+        $description = wp_kses_post($value);
2114
+		return $this->set_prop('description', $description);
2115 2115
     }
2116 2116
 
2117 2117
     /**
@@ -2120,8 +2120,8 @@  discard block
 block discarded – undo
2120 2120
 	 * @since 1.0.19
2121 2121
 	 * @param  string $value New description.
2122 2122
 	 */
2123
-	public function set_excerpt( $value ) {
2124
-		$this->set_description( $value );
2123
+	public function set_excerpt($value) {
2124
+		$this->set_description($value);
2125 2125
     }
2126 2126
 
2127 2127
     /**
@@ -2130,8 +2130,8 @@  discard block
 block discarded – undo
2130 2130
 	 * @since 1.0.19
2131 2131
 	 * @param  string $value New description.
2132 2132
 	 */
2133
-	public function set_summary( $value ) {
2134
-		$this->set_description( $value );
2133
+	public function set_summary($value) {
2134
+		$this->set_description($value);
2135 2135
     }
2136 2136
 
2137 2137
     /**
@@ -2140,12 +2140,12 @@  discard block
 block discarded – undo
2140 2140
 	 * @since 1.0.19
2141 2141
 	 * @param  int $value New author.
2142 2142
 	 */
2143
-	public function set_author( $value ) {
2144
-		$user = get_user_by( 'id', (int) $value );
2143
+	public function set_author($value) {
2144
+		$user = get_user_by('id', (int) $value);
2145 2145
 
2146
-		if ( $user && $user->ID ) {
2147
-			$this->set_prop( 'author', $user->ID );
2148
-			$this->set_prop( 'email', $user->user_email );
2146
+		if ($user && $user->ID) {
2147
+			$this->set_prop('author', $user->ID);
2148
+			$this->set_prop('email', $user->user_email);
2149 2149
 		}
2150 2150
 		
2151 2151
     }
@@ -2156,8 +2156,8 @@  discard block
 block discarded – undo
2156 2156
 	 * @since 1.0.19
2157 2157
 	 * @param  int $value New user id.
2158 2158
 	 */
2159
-	public function set_user_id( $value ) {
2160
-		$this->set_author( $value );
2159
+	public function set_user_id($value) {
2160
+		$this->set_author($value);
2161 2161
     }
2162 2162
 
2163 2163
     /**
@@ -2166,8 +2166,8 @@  discard block
 block discarded – undo
2166 2166
 	 * @since 1.0.19
2167 2167
 	 * @param  int $value New user id.
2168 2168
 	 */
2169
-	public function set_customer_id( $value ) {
2170
-		$this->set_author( $value );
2169
+	public function set_customer_id($value) {
2170
+		$this->set_author($value);
2171 2171
     }
2172 2172
 
2173 2173
     /**
@@ -2176,8 +2176,8 @@  discard block
 block discarded – undo
2176 2176
 	 * @since 1.0.19
2177 2177
 	 * @param  string $value ip address.
2178 2178
 	 */
2179
-	public function set_ip( $value ) {
2180
-		$this->set_prop( 'ip', $value );
2179
+	public function set_ip($value) {
2180
+		$this->set_prop('ip', $value);
2181 2181
     }
2182 2182
 
2183 2183
     /**
@@ -2186,8 +2186,8 @@  discard block
 block discarded – undo
2186 2186
 	 * @since 1.0.19
2187 2187
 	 * @param  string $value ip address.
2188 2188
 	 */
2189
-	public function set_user_ip( $value ) {
2190
-		$this->set_ip( $value );
2189
+	public function set_user_ip($value) {
2190
+		$this->set_ip($value);
2191 2191
     }
2192 2192
 
2193 2193
     /**
@@ -2196,8 +2196,8 @@  discard block
 block discarded – undo
2196 2196
 	 * @since 1.0.19
2197 2197
 	 * @param  string $value first name.
2198 2198
 	 */
2199
-	public function set_first_name( $value ) {
2200
-		$this->set_prop( 'first_name', $value );
2199
+	public function set_first_name($value) {
2200
+		$this->set_prop('first_name', $value);
2201 2201
     }
2202 2202
 
2203 2203
     /**
@@ -2206,8 +2206,8 @@  discard block
 block discarded – undo
2206 2206
 	 * @since 1.0.19
2207 2207
 	 * @param  string $value first name.
2208 2208
 	 */
2209
-	public function set_user_first_name( $value ) {
2210
-		$this->set_first_name( $value );
2209
+	public function set_user_first_name($value) {
2210
+		$this->set_first_name($value);
2211 2211
     }
2212 2212
 
2213 2213
     /**
@@ -2216,8 +2216,8 @@  discard block
 block discarded – undo
2216 2216
 	 * @since 1.0.19
2217 2217
 	 * @param  string $value first name.
2218 2218
 	 */
2219
-	public function set_customer_first_name( $value ) {
2220
-		$this->set_first_name( $value );
2219
+	public function set_customer_first_name($value) {
2220
+		$this->set_first_name($value);
2221 2221
     }
2222 2222
 
2223 2223
     /**
@@ -2226,8 +2226,8 @@  discard block
 block discarded – undo
2226 2226
 	 * @since 1.0.19
2227 2227
 	 * @param  string $value last name.
2228 2228
 	 */
2229
-	public function set_last_name( $value ) {
2230
-		$this->set_prop( 'last_name', $value );
2229
+	public function set_last_name($value) {
2230
+		$this->set_prop('last_name', $value);
2231 2231
     }
2232 2232
 
2233 2233
     /**
@@ -2236,8 +2236,8 @@  discard block
 block discarded – undo
2236 2236
 	 * @since 1.0.19
2237 2237
 	 * @param  string $value last name.
2238 2238
 	 */
2239
-	public function set_user_last_name( $value ) {
2240
-		$this->set_last_name( $value );
2239
+	public function set_user_last_name($value) {
2240
+		$this->set_last_name($value);
2241 2241
     }
2242 2242
 
2243 2243
     /**
@@ -2246,8 +2246,8 @@  discard block
 block discarded – undo
2246 2246
 	 * @since 1.0.19
2247 2247
 	 * @param  string $value last name.
2248 2248
 	 */
2249
-	public function set_customer_last_name( $value ) {
2250
-		$this->set_last_name( $value );
2249
+	public function set_customer_last_name($value) {
2250
+		$this->set_last_name($value);
2251 2251
     }
2252 2252
 
2253 2253
     /**
@@ -2256,8 +2256,8 @@  discard block
 block discarded – undo
2256 2256
 	 * @since 1.0.19
2257 2257
 	 * @param  string $value phone.
2258 2258
 	 */
2259
-	public function set_phone( $value ) {
2260
-		$this->set_prop( 'phone', $value );
2259
+	public function set_phone($value) {
2260
+		$this->set_prop('phone', $value);
2261 2261
     }
2262 2262
 
2263 2263
     /**
@@ -2266,8 +2266,8 @@  discard block
 block discarded – undo
2266 2266
 	 * @since 1.0.19
2267 2267
 	 * @param  string $value phone.
2268 2268
 	 */
2269
-	public function set_user_phone( $value ) {
2270
-		$this->set_phone( $value );
2269
+	public function set_user_phone($value) {
2270
+		$this->set_phone($value);
2271 2271
     }
2272 2272
 
2273 2273
     /**
@@ -2276,8 +2276,8 @@  discard block
 block discarded – undo
2276 2276
 	 * @since 1.0.19
2277 2277
 	 * @param  string $value phone.
2278 2278
 	 */
2279
-	public function set_customer_phone( $value ) {
2280
-		$this->set_phone( $value );
2279
+	public function set_customer_phone($value) {
2280
+		$this->set_phone($value);
2281 2281
     }
2282 2282
 
2283 2283
     /**
@@ -2286,8 +2286,8 @@  discard block
 block discarded – undo
2286 2286
 	 * @since 1.0.19
2287 2287
 	 * @param  string $value phone.
2288 2288
 	 */
2289
-	public function set_phone_number( $value ) {
2290
-		$this->set_phone( $value );
2289
+	public function set_phone_number($value) {
2290
+		$this->set_phone($value);
2291 2291
     }
2292 2292
 
2293 2293
     /**
@@ -2296,8 +2296,8 @@  discard block
 block discarded – undo
2296 2296
 	 * @since 1.0.19
2297 2297
 	 * @param  string $value email address.
2298 2298
 	 */
2299
-	public function set_email( $value ) {
2300
-		$this->set_prop( 'email', $value );
2299
+	public function set_email($value) {
2300
+		$this->set_prop('email', $value);
2301 2301
     }
2302 2302
 
2303 2303
     /**
@@ -2306,8 +2306,8 @@  discard block
 block discarded – undo
2306 2306
 	 * @since 1.0.19
2307 2307
 	 * @param  string $value email address.
2308 2308
 	 */
2309
-	public function set_user_email( $value ) {
2310
-		$this->set_email( $value );
2309
+	public function set_user_email($value) {
2310
+		$this->set_email($value);
2311 2311
     }
2312 2312
 
2313 2313
     /**
@@ -2316,8 +2316,8 @@  discard block
 block discarded – undo
2316 2316
 	 * @since 1.0.19
2317 2317
 	 * @param  string $value email address.
2318 2318
 	 */
2319
-	public function set_email_address( $value ) {
2320
-		$this->set_email( $value );
2319
+	public function set_email_address($value) {
2320
+		$this->set_email($value);
2321 2321
     }
2322 2322
 
2323 2323
     /**
@@ -2326,8 +2326,8 @@  discard block
 block discarded – undo
2326 2326
 	 * @since 1.0.19
2327 2327
 	 * @param  string $value email address.
2328 2328
 	 */
2329
-	public function set_customer_email( $value ) {
2330
-		$this->set_email( $value );
2329
+	public function set_customer_email($value) {
2330
+		$this->set_email($value);
2331 2331
     }
2332 2332
 
2333 2333
     /**
@@ -2336,8 +2336,8 @@  discard block
 block discarded – undo
2336 2336
 	 * @since 1.0.19
2337 2337
 	 * @param  string $value country.
2338 2338
 	 */
2339
-	public function set_country( $value ) {
2340
-		$this->set_prop( 'country', $value );
2339
+	public function set_country($value) {
2340
+		$this->set_prop('country', $value);
2341 2341
     }
2342 2342
 
2343 2343
     /**
@@ -2346,8 +2346,8 @@  discard block
 block discarded – undo
2346 2346
 	 * @since 1.0.19
2347 2347
 	 * @param  string $value country.
2348 2348
 	 */
2349
-	public function set_user_country( $value ) {
2350
-		$this->set_country( $value );
2349
+	public function set_user_country($value) {
2350
+		$this->set_country($value);
2351 2351
     }
2352 2352
 
2353 2353
     /**
@@ -2356,8 +2356,8 @@  discard block
 block discarded – undo
2356 2356
 	 * @since 1.0.19
2357 2357
 	 * @param  string $value country.
2358 2358
 	 */
2359
-	public function set_customer_country( $value ) {
2360
-		$this->set_country( $value );
2359
+	public function set_customer_country($value) {
2360
+		$this->set_country($value);
2361 2361
     }
2362 2362
 
2363 2363
     /**
@@ -2366,8 +2366,8 @@  discard block
 block discarded – undo
2366 2366
 	 * @since 1.0.19
2367 2367
 	 * @param  string $value state.
2368 2368
 	 */
2369
-	public function set_state( $value ) {
2370
-		$this->set_prop( 'state', $value );
2369
+	public function set_state($value) {
2370
+		$this->set_prop('state', $value);
2371 2371
     }
2372 2372
 
2373 2373
     /**
@@ -2376,8 +2376,8 @@  discard block
 block discarded – undo
2376 2376
 	 * @since 1.0.19
2377 2377
 	 * @param  string $value state.
2378 2378
 	 */
2379
-	public function set_user_state( $value ) {
2380
-		$this->set_state( $value );
2379
+	public function set_user_state($value) {
2380
+		$this->set_state($value);
2381 2381
     }
2382 2382
 
2383 2383
     /**
@@ -2386,8 +2386,8 @@  discard block
 block discarded – undo
2386 2386
 	 * @since 1.0.19
2387 2387
 	 * @param  string $value state.
2388 2388
 	 */
2389
-	public function set_customer_state( $value ) {
2390
-		$this->set_state( $value );
2389
+	public function set_customer_state($value) {
2390
+		$this->set_state($value);
2391 2391
     }
2392 2392
 
2393 2393
     /**
@@ -2396,8 +2396,8 @@  discard block
 block discarded – undo
2396 2396
 	 * @since 1.0.19
2397 2397
 	 * @param  string $value city.
2398 2398
 	 */
2399
-	public function set_city( $value ) {
2400
-		$this->set_prop( 'city', $value );
2399
+	public function set_city($value) {
2400
+		$this->set_prop('city', $value);
2401 2401
     }
2402 2402
 
2403 2403
     /**
@@ -2406,8 +2406,8 @@  discard block
 block discarded – undo
2406 2406
 	 * @since 1.0.19
2407 2407
 	 * @param  string $value city.
2408 2408
 	 */
2409
-	public function set_user_city( $value ) {
2410
-		$this->set_city( $value );
2409
+	public function set_user_city($value) {
2410
+		$this->set_city($value);
2411 2411
     }
2412 2412
 
2413 2413
     /**
@@ -2416,8 +2416,8 @@  discard block
 block discarded – undo
2416 2416
 	 * @since 1.0.19
2417 2417
 	 * @param  string $value city.
2418 2418
 	 */
2419
-	public function set_customer_city( $value ) {
2420
-		$this->set_city( $value );
2419
+	public function set_customer_city($value) {
2420
+		$this->set_city($value);
2421 2421
     }
2422 2422
 
2423 2423
     /**
@@ -2426,8 +2426,8 @@  discard block
 block discarded – undo
2426 2426
 	 * @since 1.0.19
2427 2427
 	 * @param  string $value zip.
2428 2428
 	 */
2429
-	public function set_zip( $value ) {
2430
-		$this->set_prop( 'zip', $value );
2429
+	public function set_zip($value) {
2430
+		$this->set_prop('zip', $value);
2431 2431
     }
2432 2432
 
2433 2433
     /**
@@ -2436,8 +2436,8 @@  discard block
 block discarded – undo
2436 2436
 	 * @since 1.0.19
2437 2437
 	 * @param  string $value zip.
2438 2438
 	 */
2439
-	public function set_user_zip( $value ) {
2440
-		$this->set_zip( $value );
2439
+	public function set_user_zip($value) {
2440
+		$this->set_zip($value);
2441 2441
     }
2442 2442
 
2443 2443
     /**
@@ -2446,8 +2446,8 @@  discard block
 block discarded – undo
2446 2446
 	 * @since 1.0.19
2447 2447
 	 * @param  string $value zip.
2448 2448
 	 */
2449
-	public function set_customer_zip( $value ) {
2450
-		$this->set_zip( $value );
2449
+	public function set_customer_zip($value) {
2450
+		$this->set_zip($value);
2451 2451
     }
2452 2452
 
2453 2453
     /**
@@ -2456,8 +2456,8 @@  discard block
 block discarded – undo
2456 2456
 	 * @since 1.0.19
2457 2457
 	 * @param  string $value company.
2458 2458
 	 */
2459
-	public function set_company( $value ) {
2460
-		$this->set_prop( 'company', $value );
2459
+	public function set_company($value) {
2460
+		$this->set_prop('company', $value);
2461 2461
     }
2462 2462
 
2463 2463
     /**
@@ -2466,8 +2466,8 @@  discard block
 block discarded – undo
2466 2466
 	 * @since 1.0.19
2467 2467
 	 * @param  string $value company.
2468 2468
 	 */
2469
-	public function set_user_company( $value ) {
2470
-		$this->set_company( $value );
2469
+	public function set_user_company($value) {
2470
+		$this->set_company($value);
2471 2471
     }
2472 2472
 
2473 2473
     /**
@@ -2476,8 +2476,8 @@  discard block
 block discarded – undo
2476 2476
 	 * @since 1.0.19
2477 2477
 	 * @param  string $value company.
2478 2478
 	 */
2479
-	public function set_customer_company( $value ) {
2480
-		$this->set_company( $value );
2479
+	public function set_customer_company($value) {
2480
+		$this->set_company($value);
2481 2481
     }
2482 2482
 
2483 2483
     /**
@@ -2486,8 +2486,8 @@  discard block
 block discarded – undo
2486 2486
 	 * @since 1.0.19
2487 2487
 	 * @param  string $value var number.
2488 2488
 	 */
2489
-	public function set_vat_number( $value ) {
2490
-		$this->set_prop( 'vat_number', $value );
2489
+	public function set_vat_number($value) {
2490
+		$this->set_prop('vat_number', $value);
2491 2491
     }
2492 2492
 
2493 2493
     /**
@@ -2496,8 +2496,8 @@  discard block
 block discarded – undo
2496 2496
 	 * @since 1.0.19
2497 2497
 	 * @param  string $value var number.
2498 2498
 	 */
2499
-	public function set_user_vat_number( $value ) {
2500
-		$this->set_vat_number( $value );
2499
+	public function set_user_vat_number($value) {
2500
+		$this->set_vat_number($value);
2501 2501
     }
2502 2502
 
2503 2503
     /**
@@ -2506,8 +2506,8 @@  discard block
 block discarded – undo
2506 2506
 	 * @since 1.0.19
2507 2507
 	 * @param  string $value var number.
2508 2508
 	 */
2509
-	public function set_customer_vat_number( $value ) {
2510
-		$this->set_vat_number( $value );
2509
+	public function set_customer_vat_number($value) {
2510
+		$this->set_vat_number($value);
2511 2511
     }
2512 2512
 
2513 2513
     /**
@@ -2516,8 +2516,8 @@  discard block
 block discarded – undo
2516 2516
 	 * @since 1.0.19
2517 2517
 	 * @param  string $value var rate.
2518 2518
 	 */
2519
-	public function set_vat_rate( $value ) {
2520
-		$this->set_prop( 'vat_rate', $value );
2519
+	public function set_vat_rate($value) {
2520
+		$this->set_prop('vat_rate', $value);
2521 2521
     }
2522 2522
 
2523 2523
     /**
@@ -2526,8 +2526,8 @@  discard block
 block discarded – undo
2526 2526
 	 * @since 1.0.19
2527 2527
 	 * @param  string $value var number.
2528 2528
 	 */
2529
-	public function set_user_vat_rate( $value ) {
2530
-		$this->set_vat_rate( $value );
2529
+	public function set_user_vat_rate($value) {
2530
+		$this->set_vat_rate($value);
2531 2531
     }
2532 2532
 
2533 2533
     /**
@@ -2536,8 +2536,8 @@  discard block
 block discarded – undo
2536 2536
 	 * @since 1.0.19
2537 2537
 	 * @param  string $value var number.
2538 2538
 	 */
2539
-	public function set_customer_vat_rate( $value ) {
2540
-		$this->set_vat_rate( $value );
2539
+	public function set_customer_vat_rate($value) {
2540
+		$this->set_vat_rate($value);
2541 2541
     }
2542 2542
 
2543 2543
     /**
@@ -2546,8 +2546,8 @@  discard block
 block discarded – undo
2546 2546
 	 * @since 1.0.19
2547 2547
 	 * @param  string $value address.
2548 2548
 	 */
2549
-	public function set_address( $value ) {
2550
-		$this->set_prop( 'address', $value );
2549
+	public function set_address($value) {
2550
+		$this->set_prop('address', $value);
2551 2551
     }
2552 2552
 
2553 2553
     /**
@@ -2556,8 +2556,8 @@  discard block
 block discarded – undo
2556 2556
 	 * @since 1.0.19
2557 2557
 	 * @param  string $value address.
2558 2558
 	 */
2559
-	public function set_user_address( $value ) {
2560
-		$this->set_address( $value );
2559
+	public function set_user_address($value) {
2560
+		$this->set_address($value);
2561 2561
     }
2562 2562
 
2563 2563
     /**
@@ -2566,8 +2566,8 @@  discard block
 block discarded – undo
2566 2566
 	 * @since 1.0.19
2567 2567
 	 * @param  string $value address.
2568 2568
 	 */
2569
-	public function set_customer_address( $value ) {
2570
-		$this->set_address( $value );
2569
+	public function set_customer_address($value) {
2570
+		$this->set_address($value);
2571 2571
     }
2572 2572
 
2573 2573
     /**
@@ -2576,8 +2576,8 @@  discard block
 block discarded – undo
2576 2576
 	 * @since 1.0.19
2577 2577
 	 * @param  int|bool $value confirmed.
2578 2578
 	 */
2579
-	public function set_is_viewed( $value ) {
2580
-		$this->set_prop( 'is_viewed', $value );
2579
+	public function set_is_viewed($value) {
2580
+		$this->set_prop('is_viewed', $value);
2581 2581
 	}
2582 2582
 
2583 2583
 	/**
@@ -2586,8 +2586,8 @@  discard block
 block discarded – undo
2586 2586
 	 * @since 1.0.19
2587 2587
 	 * @param  string $value email recipients.
2588 2588
 	 */
2589
-	public function set_email_cc( $value ) {
2590
-		$this->set_prop( 'email_cc', $value );
2589
+	public function set_email_cc($value) {
2590
+		$this->set_prop('email_cc', $value);
2591 2591
 	}
2592 2592
 
2593 2593
 	/**
@@ -2596,9 +2596,9 @@  discard block
 block discarded – undo
2596 2596
 	 * @since 1.0.19
2597 2597
 	 * @param  string $value email recipients.
2598 2598
 	 */
2599
-	public function set_template( $value ) {
2600
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2601
-			$this->set_prop( 'template', $value );
2599
+	public function set_template($value) {
2600
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2601
+			$this->set_prop('template', $value);
2602 2602
 		}
2603 2603
 	}
2604 2604
 
@@ -2608,8 +2608,8 @@  discard block
 block discarded – undo
2608 2608
 	 * @since 1.0.19
2609 2609
 	 * @param  int|bool $value confirmed.
2610 2610
 	 */
2611
-	public function set_address_confirmed( $value ) {
2612
-		$this->set_prop( 'address_confirmed', $value );
2611
+	public function set_address_confirmed($value) {
2612
+		$this->set_prop('address_confirmed', $value);
2613 2613
     }
2614 2614
 
2615 2615
     /**
@@ -2618,8 +2618,8 @@  discard block
 block discarded – undo
2618 2618
 	 * @since 1.0.19
2619 2619
 	 * @param  int|bool $value confirmed.
2620 2620
 	 */
2621
-	public function set_user_address_confirmed( $value ) {
2622
-		$this->set_address_confirmed( $value );
2621
+	public function set_user_address_confirmed($value) {
2622
+		$this->set_address_confirmed($value);
2623 2623
     }
2624 2624
 
2625 2625
     /**
@@ -2628,8 +2628,8 @@  discard block
 block discarded – undo
2628 2628
 	 * @since 1.0.19
2629 2629
 	 * @param  int|bool $value confirmed.
2630 2630
 	 */
2631
-	public function set_customer_address_confirmed( $value ) {
2632
-		$this->set_address_confirmed( $value );
2631
+	public function set_customer_address_confirmed($value) {
2632
+		$this->set_address_confirmed($value);
2633 2633
     }
2634 2634
 
2635 2635
     /**
@@ -2638,8 +2638,8 @@  discard block
 block discarded – undo
2638 2638
 	 * @since 1.0.19
2639 2639
 	 * @param  float $value sub total.
2640 2640
 	 */
2641
-	public function set_subtotal( $value ) {
2642
-		$this->set_prop( 'subtotal', $value );
2641
+	public function set_subtotal($value) {
2642
+		$this->set_prop('subtotal', $value);
2643 2643
     }
2644 2644
 
2645 2645
     /**
@@ -2648,8 +2648,8 @@  discard block
 block discarded – undo
2648 2648
 	 * @since 1.0.19
2649 2649
 	 * @param  float $value discount total.
2650 2650
 	 */
2651
-	public function set_total_discount( $value ) {
2652
-		$this->set_prop( 'total_discount', $value );
2651
+	public function set_total_discount($value) {
2652
+		$this->set_prop('total_discount', $value);
2653 2653
     }
2654 2654
 
2655 2655
     /**
@@ -2658,8 +2658,8 @@  discard block
 block discarded – undo
2658 2658
 	 * @since 1.0.19
2659 2659
 	 * @param  float $value discount total.
2660 2660
 	 */
2661
-	public function set_discount( $value ) {
2662
-		$this->set_total_discount( $value );
2661
+	public function set_discount($value) {
2662
+		$this->set_total_discount($value);
2663 2663
     }
2664 2664
 
2665 2665
     /**
@@ -2668,8 +2668,8 @@  discard block
 block discarded – undo
2668 2668
 	 * @since 1.0.19
2669 2669
 	 * @param  float $value tax total.
2670 2670
 	 */
2671
-	public function set_total_tax( $value ) {
2672
-		$this->set_prop( 'total_tax', $value );
2671
+	public function set_total_tax($value) {
2672
+		$this->set_prop('total_tax', $value);
2673 2673
     }
2674 2674
 
2675 2675
     /**
@@ -2678,8 +2678,8 @@  discard block
 block discarded – undo
2678 2678
 	 * @since 1.0.19
2679 2679
 	 * @param  float $value tax total.
2680 2680
 	 */
2681
-	public function set_tax_total( $value ) {
2682
-		$this->set_total_tax( $value );
2681
+	public function set_tax_total($value) {
2682
+		$this->set_total_tax($value);
2683 2683
     }
2684 2684
 
2685 2685
     /**
@@ -2688,8 +2688,8 @@  discard block
 block discarded – undo
2688 2688
 	 * @since 1.0.19
2689 2689
 	 * @param  float $value fees total.
2690 2690
 	 */
2691
-	public function set_total_fees( $value ) {
2692
-		$this->set_prop( 'total_fees', $value );
2691
+	public function set_total_fees($value) {
2692
+		$this->set_prop('total_fees', $value);
2693 2693
     }
2694 2694
 
2695 2695
     /**
@@ -2698,8 +2698,8 @@  discard block
 block discarded – undo
2698 2698
 	 * @since 1.0.19
2699 2699
 	 * @param  float $value fees total.
2700 2700
 	 */
2701
-	public function set_fees_total( $value ) {
2702
-		$this->set_total_fees( $value );
2701
+	public function set_fees_total($value) {
2702
+		$this->set_total_fees($value);
2703 2703
     }
2704 2704
 
2705 2705
     /**
@@ -2708,18 +2708,18 @@  discard block
 block discarded – undo
2708 2708
 	 * @since 1.0.19
2709 2709
 	 * @param  array $value fees.
2710 2710
 	 */
2711
-	public function set_fees( $value ) {
2711
+	public function set_fees($value) {
2712 2712
 
2713
-        $this->set_prop( 'fees', array() );
2713
+        $this->set_prop('fees', array());
2714 2714
 
2715 2715
         // Ensure that we have an array.
2716
-        if ( ! is_array( $value ) ) {
2716
+        if (!is_array($value)) {
2717 2717
             return;
2718 2718
         }
2719 2719
 
2720
-        foreach ( $value as $name => $data ) {
2721
-            if ( isset( $data['amount'] ) ) {
2722
-                $this->add_fee( $name, $data['amount'], $data['recurring'] );
2720
+        foreach ($value as $name => $data) {
2721
+            if (isset($data['amount'])) {
2722
+                $this->add_fee($name, $data['amount'], $data['recurring']);
2723 2723
             }
2724 2724
         }
2725 2725
 
@@ -2731,8 +2731,8 @@  discard block
 block discarded – undo
2731 2731
 	 * @since 1.0.19
2732 2732
 	 * @param  array $value taxes.
2733 2733
 	 */
2734
-	public function set_taxes( $value ) {
2735
-		$this->set_prop( 'taxes', $value );
2734
+	public function set_taxes($value) {
2735
+		$this->set_prop('taxes', $value);
2736 2736
     }
2737 2737
 
2738 2738
     /**
@@ -2741,17 +2741,17 @@  discard block
 block discarded – undo
2741 2741
 	 * @since 1.0.19
2742 2742
 	 * @param  array $value discounts.
2743 2743
 	 */
2744
-	public function set_discounts( $value ) {
2745
-		$this->set_prop( 'discounts', array() );
2744
+	public function set_discounts($value) {
2745
+		$this->set_prop('discounts', array());
2746 2746
 
2747 2747
         // Ensure that we have an array.
2748
-        if ( ! is_array( $value ) ) {
2748
+        if (!is_array($value)) {
2749 2749
             return;
2750 2750
         }
2751 2751
 
2752
-        foreach ( $value as $name => $data ) {
2753
-            if ( isset( $data['amount'] ) ) {
2754
-                $this->add_discount( $name, $data['amount'], $data['recurring'] );
2752
+        foreach ($value as $name => $data) {
2753
+            if (isset($data['amount'])) {
2754
+                $this->add_discount($name, $data['amount'], $data['recurring']);
2755 2755
             }
2756 2756
         }
2757 2757
     }
@@ -2762,18 +2762,18 @@  discard block
 block discarded – undo
2762 2762
 	 * @since 1.0.19
2763 2763
 	 * @param  GetPaid_Form_Item[] $value items.
2764 2764
 	 */
2765
-	public function set_items( $value ) {
2765
+	public function set_items($value) {
2766 2766
 
2767 2767
         // Remove existing items.
2768
-        $this->set_prop( 'items', array() );
2768
+        $this->set_prop('items', array());
2769 2769
 
2770 2770
         // Ensure that we have an array.
2771
-        if ( ! is_array( $value ) ) {
2771
+        if (!is_array($value)) {
2772 2772
             return;
2773 2773
         }
2774 2774
 
2775
-        foreach ( $value as $item ) {
2776
-            $this->add_item( $item );
2775
+        foreach ($value as $item) {
2776
+            $this->add_item($item);
2777 2777
         }
2778 2778
 
2779 2779
     }
@@ -2784,8 +2784,8 @@  discard block
 block discarded – undo
2784 2784
 	 * @since 1.0.19
2785 2785
 	 * @param  int $value payment form.
2786 2786
 	 */
2787
-	public function set_payment_form( $value ) {
2788
-		$this->set_prop( 'payment_form', $value );
2787
+	public function set_payment_form($value) {
2788
+		$this->set_prop('payment_form', $value);
2789 2789
     }
2790 2790
 
2791 2791
     /**
@@ -2794,8 +2794,8 @@  discard block
 block discarded – undo
2794 2794
 	 * @since 1.0.19
2795 2795
 	 * @param  string $value submission id.
2796 2796
 	 */
2797
-	public function set_submission_id( $value ) {
2798
-		$this->set_prop( 'submission_id', $value );
2797
+	public function set_submission_id($value) {
2798
+		$this->set_prop('submission_id', $value);
2799 2799
     }
2800 2800
 
2801 2801
     /**
@@ -2804,8 +2804,8 @@  discard block
 block discarded – undo
2804 2804
 	 * @since 1.0.19
2805 2805
 	 * @param  string $value discount code.
2806 2806
 	 */
2807
-	public function set_discount_code( $value ) {
2808
-		$this->set_prop( 'discount_code', $value );
2807
+	public function set_discount_code($value) {
2808
+		$this->set_prop('discount_code', $value);
2809 2809
     }
2810 2810
 
2811 2811
     /**
@@ -2814,8 +2814,8 @@  discard block
 block discarded – undo
2814 2814
 	 * @since 1.0.19
2815 2815
 	 * @param  string $value gateway.
2816 2816
 	 */
2817
-	public function set_gateway( $value ) {
2818
-		$this->set_prop( 'gateway', $value );
2817
+	public function set_gateway($value) {
2818
+		$this->set_prop('gateway', $value);
2819 2819
     }
2820 2820
 
2821 2821
     /**
@@ -2824,9 +2824,9 @@  discard block
 block discarded – undo
2824 2824
 	 * @since 1.0.19
2825 2825
 	 * @param  string $value transaction id.
2826 2826
 	 */
2827
-	public function set_transaction_id( $value ) {
2828
-		if ( ! empty( $value ) ) {
2829
-			$this->set_prop( 'transaction_id', $value );
2827
+	public function set_transaction_id($value) {
2828
+		if (!empty($value)) {
2829
+			$this->set_prop('transaction_id', $value);
2830 2830
 		}
2831 2831
     }
2832 2832
 
@@ -2836,8 +2836,8 @@  discard block
 block discarded – undo
2836 2836
 	 * @since 1.0.19
2837 2837
 	 * @param  string $value currency id.
2838 2838
 	 */
2839
-	public function set_currency( $value ) {
2840
-		$this->set_prop( 'currency', $value );
2839
+	public function set_currency($value) {
2840
+		$this->set_prop('currency', $value);
2841 2841
     }
2842 2842
 
2843 2843
 	/**
@@ -2846,8 +2846,8 @@  discard block
 block discarded – undo
2846 2846
 	 * @since 1.0.19
2847 2847
 	 * @param  bool $value value.
2848 2848
 	 */
2849
-	public function set_disable_taxes( $value ) {
2850
-		$this->set_prop( 'disable_taxes', (bool) $value );
2849
+	public function set_disable_taxes($value) {
2850
+		$this->set_prop('disable_taxes', (bool) $value);
2851 2851
 	}
2852 2852
 
2853 2853
     /**
@@ -2856,8 +2856,8 @@  discard block
 block discarded – undo
2856 2856
 	 * @since 1.0.19
2857 2857
 	 * @param  string $value subscription id.
2858 2858
 	 */
2859
-	public function set_subscription_id( $value ) {
2860
-		$this->set_prop( 'subscription_id', $value );
2859
+	public function set_subscription_id($value) {
2860
+		$this->set_prop('subscription_id', $value);
2861 2861
     }
2862 2862
 
2863 2863
     /*
@@ -2874,28 +2874,28 @@  discard block
 block discarded – undo
2874 2874
      */
2875 2875
     public function is_parent() {
2876 2876
         $parent = $this->get_parent_id();
2877
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
2877
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
2878 2878
     }
2879 2879
 
2880 2880
     /**
2881 2881
      * Checks if this is a renewal invoice.
2882 2882
      */
2883 2883
     public function is_renewal() {
2884
-        return ! $this->is_parent();
2884
+        return !$this->is_parent();
2885 2885
     }
2886 2886
 
2887 2887
     /**
2888 2888
      * Checks if this is a recurring invoice.
2889 2889
      */
2890 2890
     public function is_recurring() {
2891
-        return $this->is_renewal() || ! empty( $this->recurring_item );
2891
+        return $this->is_renewal() || !empty($this->recurring_item);
2892 2892
     }
2893 2893
 
2894 2894
     /**
2895 2895
      * Checks if this is a taxable invoice.
2896 2896
      */
2897 2897
     public function is_taxable() {
2898
-        return ! $this->get_disable_taxes();
2898
+        return !$this->get_disable_taxes();
2899 2899
 	}
2900 2900
 
2901 2901
 	/**
@@ -2906,57 +2906,57 @@  discard block
 block discarded – undo
2906 2906
 
2907 2907
         $requires_vat = false;
2908 2908
 
2909
-        if ( $this->country ) {
2909
+        if ($this->country) {
2910 2910
             $wpi_country        = $this->country;
2911
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2911
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2912 2912
         }
2913 2913
 
2914
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2914
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2915 2915
 	}
2916 2916
 
2917 2917
 	/**
2918 2918
 	 * Checks to see if the invoice requires payment.
2919 2919
 	 */
2920 2920
 	public function is_free() {
2921
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2921
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
2922 2922
 
2923
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2923
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
2924 2924
 			$is_free = false;
2925 2925
 		}
2926 2926
 
2927
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2927
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2928 2928
     }
2929 2929
 
2930 2930
     /**
2931 2931
      * Checks if the invoice is paid.
2932 2932
      */
2933 2933
     public function is_paid() {
2934
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2935
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2934
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2935
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2936 2936
 	}
2937 2937
 
2938 2938
 	/**
2939 2939
      * Checks if the invoice needs payment.
2940 2940
      */
2941 2941
 	public function needs_payment() {
2942
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2943
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2942
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
2943
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
2944 2944
     }
2945 2945
 
2946 2946
 	/**
2947 2947
      * Checks if the invoice is refunded.
2948 2948
      */
2949 2949
 	public function is_refunded() {
2950
-        $is_refunded = $this->has_status( 'wpi-refunded' );
2951
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2950
+        $is_refunded = $this->has_status('wpi-refunded');
2951
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
2952 2952
 	}
2953 2953
 
2954 2954
 	/**
2955 2955
      * Checks if the invoice is held.
2956 2956
      */
2957 2957
 	public function is_held() {
2958
-        $is_held = $this->has_status( 'wpi-onhold' );
2959
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2958
+        $is_held = $this->has_status('wpi-onhold');
2959
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
2960 2960
 	}
2961 2961
 
2962 2962
 	/**
@@ -2964,30 +2964,30 @@  discard block
 block discarded – undo
2964 2964
      */
2965 2965
 	public function is_due() {
2966 2966
 		$due_date = $this->get_due_date();
2967
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2967
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
2968 2968
 	}
2969 2969
 
2970 2970
 	/**
2971 2971
      * Checks if the invoice is draft.
2972 2972
      */
2973 2973
 	public function is_draft() {
2974
-        return $this->has_status( 'draft, auto-draft' );
2974
+        return $this->has_status('draft, auto-draft');
2975 2975
 	}
2976 2976
 
2977 2977
     /**
2978 2978
      * Checks if the invoice has a given status.
2979 2979
      */
2980
-    public function has_status( $status ) {
2981
-        $status = wpinv_parse_list( $status );
2982
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
2980
+    public function has_status($status) {
2981
+        $status = wpinv_parse_list($status);
2982
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
2983 2983
 	}
2984 2984
 
2985 2985
 	/**
2986 2986
      * Checks if the invoice is of a given type.
2987 2987
      */
2988
-    public function is_type( $type ) {
2989
-        $type = wpinv_parse_list( $type );
2990
-        return in_array( $this->get_type(), $type );
2988
+    public function is_type($type) {
2989
+        $type = wpinv_parse_list($type);
2990
+        return in_array($this->get_type(), $type);
2991 2991
     }
2992 2992
 
2993 2993
     /**
@@ -3019,8 +3019,8 @@  discard block
 block discarded – undo
3019 3019
      *
3020 3020
      */
3021 3021
 	public function is_initial_free() {
3022
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3023
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3022
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3023
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3024 3024
     }
3025 3025
 	
3026 3026
 	/**
@@ -3030,11 +3030,11 @@  discard block
 block discarded – undo
3030 3030
     public function item_has_free_trial() {
3031 3031
 
3032 3032
         // Ensure we have a recurring item.
3033
-        if ( ! $this->is_recurring() ) {
3033
+        if (!$this->is_recurring()) {
3034 3034
             return false;
3035 3035
         }
3036 3036
 
3037
-        $item = $this->get_recurring( true );
3037
+        $item = $this->get_recurring(true);
3038 3038
         return $item->has_free_trial();
3039 3039
 	}
3040 3040
 
@@ -3042,7 +3042,7 @@  discard block
 block discarded – undo
3042 3042
      * Check if the free trial is a result of a discount.
3043 3043
      */
3044 3044
     public function is_free_trial_from_discount() {
3045
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3045
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3046 3046
 	}
3047 3047
 	
3048 3048
 	/**
@@ -3051,17 +3051,17 @@  discard block
 block discarded – undo
3051 3051
     public function discount_first_payment_only() {
3052 3052
 
3053 3053
 		$discount_code = $this->get_discount_code();
3054
-        if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3054
+        if (empty($this->discount_code) || !$this->is_recurring()) {
3055 3055
             return true;
3056 3056
         }
3057 3057
 
3058
-        $discount = wpinv_get_discount_obj( $discount_code );
3058
+        $discount = wpinv_get_discount_obj($discount_code);
3059 3059
 
3060
-        if ( ! $discount || ! $discount->exists() ) {
3060
+        if (!$discount || !$discount->exists()) {
3061 3061
             return true;
3062 3062
         }
3063 3063
 
3064
-        return ! $discount->get_is_recurring();
3064
+        return !$discount->get_is_recurring();
3065 3065
     }
3066 3066
 
3067 3067
     /*
@@ -3079,27 +3079,27 @@  discard block
 block discarded – undo
3079 3079
      * @param GetPaid_Form_Item|array $item
3080 3080
      * @return WP_Error|Bool
3081 3081
      */
3082
-    public function add_item( $item ) {
3082
+    public function add_item($item) {
3083 3083
 
3084
-		if ( is_array( $item ) ) {
3085
-			$item = $this->process_array_item( $item );
3084
+		if (is_array($item)) {
3085
+			$item = $this->process_array_item($item);
3086 3086
 		}
3087 3087
 
3088
-		if ( is_numeric( $item ) ) {
3089
-			$item = new GetPaid_Form_Item( $item );
3088
+		if (is_numeric($item)) {
3089
+			$item = new GetPaid_Form_Item($item);
3090 3090
 		}
3091 3091
 
3092 3092
         // Make sure that it is available for purchase.
3093
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3094
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3093
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3094
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3095 3095
         }
3096 3096
 
3097 3097
         // Do we have a recurring item?
3098
-		if ( $item->is_recurring() ) {
3098
+		if ($item->is_recurring()) {
3099 3099
 
3100 3100
 			// An invoice can only contain one recurring item.
3101
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3102
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3101
+			if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) {
3102
+				return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing'));
3103 3103
 			}
3104 3104
 
3105 3105
 			$this->recurring_item = $item->get_id();
@@ -3110,9 +3110,9 @@  discard block
 block discarded – undo
3110 3110
 
3111 3111
         // Retrieve all items.
3112 3112
         $items = $this->get_items();
3113
-        $items[ (int) $item->get_id() ] = $item;
3113
+        $items[(int) $item->get_id()] = $item;
3114 3114
 
3115
-        $this->set_prop( 'items', $items );
3115
+        $this->set_prop('items', $items);
3116 3116
 		return true;
3117 3117
 	}
3118 3118
 	
@@ -3122,26 +3122,26 @@  discard block
 block discarded – undo
3122 3122
 	 * @since 1.0.19
3123 3123
 	 * @return GetPaid_Form_Item
3124 3124
 	 */
3125
-	protected function process_array_item( $array ) {
3125
+	protected function process_array_item($array) {
3126 3126
 
3127
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3128
-		$item    = new GetPaid_Form_Item( $item_id );
3127
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3128
+		$item    = new GetPaid_Form_Item($item_id);
3129 3129
 
3130 3130
 		// Set item data.
3131
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3132
-			if ( isset( $array[ "item_$key" ] ) ) {
3131
+		foreach (array('name', 'price', 'description') as $key) {
3132
+			if (isset($array["item_$key"])) {
3133 3133
 				$method = "set_$key";
3134
-				$item->$method( $array[ "item_$key" ] );
3134
+				$item->$method($array["item_$key"]);
3135 3135
 			}
3136 3136
 		}
3137 3137
 
3138
-		if ( isset( $array['quantity'] ) ) {
3139
-			$item->set_quantity( $array['quantity'] );
3138
+		if (isset($array['quantity'])) {
3139
+			$item->set_quantity($array['quantity']);
3140 3140
 		}
3141 3141
 
3142 3142
 		// Set item meta.
3143
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3144
-			$item->set_item_meta( $array['meta'] );
3143
+		if (isset($array['meta']) && is_array($array['meta'])) {
3144
+			$item->set_item_meta($array['meta']);
3145 3145
 		}
3146 3146
 
3147 3147
 		return $item;
@@ -3153,10 +3153,10 @@  discard block
 block discarded – undo
3153 3153
 	 *
3154 3154
 	 * @since 1.0.19
3155 3155
 	 */
3156
-	public function get_item( $item_id ) {
3156
+	public function get_item($item_id) {
3157 3157
 		$items   = $this->get_items();
3158 3158
 		$item_id = (int) $item_id;
3159
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3159
+		return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null;
3160 3160
     }
3161 3161
 
3162 3162
     /**
@@ -3164,17 +3164,17 @@  discard block
 block discarded – undo
3164 3164
 	 *
3165 3165
 	 * @since 1.0.19
3166 3166
 	 */
3167
-	public function remove_item( $item_id ) {
3167
+	public function remove_item($item_id) {
3168 3168
 		$items   = $this->get_items();
3169 3169
 		$item_id = (int) $item_id;
3170 3170
 
3171
-        if ( $item_id == $this->recurring_item ) {
3171
+        if ($item_id == $this->recurring_item) {
3172 3172
             $this->recurring_item = null;
3173 3173
         }
3174 3174
 
3175
-        if ( isset( $items[ $item_id ] ) ) {
3176
-            unset( $items[ $item_id ] );
3177
-            $this->set_prop( 'items', $items );
3175
+        if (isset($items[$item_id])) {
3176
+            unset($items[$item_id]);
3177
+            $this->set_prop('items', $items);
3178 3178
         }
3179 3179
     }
3180 3180
 
@@ -3185,27 +3185,27 @@  discard block
 block discarded – undo
3185 3185
      * @param float $value
3186 3186
      * @return WP_Error|Bool
3187 3187
      */
3188
-    public function add_fee( $fee, $value, $recurring = false ) {
3188
+    public function add_fee($fee, $value, $recurring = false) {
3189 3189
 
3190
-        $amount = wpinv_sanitize_amount( $value );
3190
+        $amount = wpinv_sanitize_amount($value);
3191 3191
         $fees   = $this->get_fees();
3192 3192
 
3193
-        if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3193
+        if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) {
3194 3194
 
3195
-            $amount = $fees[ $fee ]['amount'] += $amount;
3196
-			$fees[ $fee ] = array(
3195
+            $amount = $fees[$fee]['amount'] += $amount;
3196
+			$fees[$fee] = array(
3197 3197
 				'amount'    => $amount,
3198 3198
                 'recurring' => (bool) $recurring,
3199 3199
             );
3200 3200
 
3201 3201
 		} else {
3202
-			$fees[ $fee ] = array(
3202
+			$fees[$fee] = array(
3203 3203
                 'amount'    => $amount,
3204 3204
                 'recurring' => (bool) $recurring,
3205 3205
             );
3206 3206
 		}
3207 3207
 
3208
-        $this->set_prop( 'fees', $fee );
3208
+        $this->set_prop('fees', $fee);
3209 3209
 
3210 3210
     }
3211 3211
 
@@ -3214,9 +3214,9 @@  discard block
 block discarded – undo
3214 3214
 	 *
3215 3215
 	 * @since 1.0.19
3216 3216
 	 */
3217
-	public function get_fee( $fee ) {
3217
+	public function get_fee($fee) {
3218 3218
         $fees = $this->get_fees();
3219
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3219
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3220 3220
     }
3221 3221
 
3222 3222
     /**
@@ -3224,11 +3224,11 @@  discard block
 block discarded – undo
3224 3224
 	 *
3225 3225
 	 * @since 1.0.19
3226 3226
 	 */
3227
-	public function remove_fee( $fee ) {
3227
+	public function remove_fee($fee) {
3228 3228
         $fees = $this->get_fees();
3229
-        if ( isset( $fees[ $fee ] ) ) {
3230
-            unset( $fees[ $fee ] );
3231
-            $this->set_prop( 'fees', $fees );
3229
+        if (isset($fees[$fee])) {
3230
+            unset($fees[$fee]);
3231
+            $this->set_prop('fees', $fees);
3232 3232
         }
3233 3233
     }
3234 3234
 
@@ -3239,27 +3239,27 @@  discard block
 block discarded – undo
3239 3239
      * @param float $value
3240 3240
      * @return WP_Error|Bool
3241 3241
      */
3242
-    public function add_discount( $discount, $value, $recurring = false ) {
3242
+    public function add_discount($discount, $value, $recurring = false) {
3243 3243
 
3244
-        $amount    = wpinv_sanitize_amount( $value );
3244
+        $amount    = wpinv_sanitize_amount($value);
3245 3245
         $discounts = $this->get_discounts();
3246 3246
 
3247
-        if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3247
+        if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) {
3248 3248
 
3249
-            $amount = $discounts[ $discount ]['amount'] += $amount;
3250
-			$discounts[ $discount ] = array(
3249
+            $amount = $discounts[$discount]['amount'] += $amount;
3250
+			$discounts[$discount] = array(
3251 3251
                 'amount'    => $amount,
3252 3252
                 'recurring' => (bool) $recurring,
3253 3253
             );
3254 3254
 
3255 3255
 		} else {
3256
-			$discounts[ $discount ] = array(
3256
+			$discounts[$discount] = array(
3257 3257
                 'amount'    => $amount,
3258 3258
                 'recurring' => (bool) $recurring,
3259 3259
             );
3260 3260
 		}
3261 3261
 
3262
-        $this->set_prop( 'discounts', $discount );
3262
+        $this->set_prop('discounts', $discount);
3263 3263
 
3264 3264
     }
3265 3265
 
@@ -3268,15 +3268,15 @@  discard block
 block discarded – undo
3268 3268
 	 *
3269 3269
 	 * @since 1.0.19
3270 3270
 	 */
3271
-	public function get_discount( $discount = false ) {
3271
+	public function get_discount($discount = false) {
3272 3272
 
3273 3273
 		// Backwards compatibilty.
3274
-		if ( empty( $discount ) ) {
3274
+		if (empty($discount)) {
3275 3275
 			return $this->get_total_discount();
3276 3276
 		}
3277 3277
 
3278 3278
         $discounts = $this->get_discounts();
3279
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3279
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3280 3280
     }
3281 3281
 
3282 3282
     /**
@@ -3284,11 +3284,11 @@  discard block
 block discarded – undo
3284 3284
 	 *
3285 3285
 	 * @since 1.0.19
3286 3286
 	 */
3287
-	public function remove_discount( $discount ) {
3287
+	public function remove_discount($discount) {
3288 3288
         $discounts = $this->get_discounts();
3289
-        if ( isset( $discounts[ $discount ] ) ) {
3290
-            unset( $discounts[ $discount ] );
3291
-            $this->set_prop( 'discounts', $discounts );
3289
+        if (isset($discounts[$discount])) {
3290
+            unset($discounts[$discount]);
3291
+            $this->set_prop('discounts', $discounts);
3292 3292
         }
3293 3293
     }
3294 3294
 
@@ -3298,31 +3298,31 @@  discard block
 block discarded – undo
3298 3298
      * @param string $tax
3299 3299
      * @param float $value
3300 3300
      */
3301
-    public function add_tax( $tax, $value, $recurring = true ) {
3301
+    public function add_tax($tax, $value, $recurring = true) {
3302 3302
 
3303
-        if ( ! $this->is_taxable() ) {
3303
+        if (!$this->is_taxable()) {
3304 3304
             return;
3305 3305
         }
3306 3306
 
3307
-        $amount    = wpinv_sanitize_amount( $value );
3307
+        $amount    = wpinv_sanitize_amount($value);
3308 3308
         $taxes     = $this->get_taxes();
3309 3309
 
3310
-        if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3310
+        if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) {
3311 3311
 
3312
-            $amount = $taxes[ $tax ]['amount'] += $amount;
3313
-			$taxes[ $tax ] = array(
3312
+            $amount = $taxes[$tax]['amount'] += $amount;
3313
+			$taxes[$tax] = array(
3314 3314
                 'amount'    => $amount,
3315 3315
                 'recurring' => (bool) $recurring,
3316 3316
             );
3317 3317
 
3318 3318
 		} else {
3319
-			$taxes[ $tax ] = array(
3319
+			$taxes[$tax] = array(
3320 3320
                 'amount'    => $amount,
3321 3321
                 'recurring' => (bool) $recurring,
3322 3322
             );
3323 3323
 		}
3324 3324
 
3325
-        $this->set_prop( 'taxes', $tax );
3325
+        $this->set_prop('taxes', $tax);
3326 3326
 
3327 3327
     }
3328 3328
 
@@ -3331,15 +3331,15 @@  discard block
 block discarded – undo
3331 3331
 	 *
3332 3332
 	 * @since 1.0.19
3333 3333
 	 */
3334
-	public function get_tax( $tax = null ) {
3334
+	public function get_tax($tax = null) {
3335 3335
 
3336 3336
 		// Backwards compatility.
3337
-		if ( empty( $tax ) ) {
3337
+		if (empty($tax)) {
3338 3338
 			return $this->get_total_tax();
3339 3339
 		}
3340 3340
 
3341 3341
         $taxes = $this->get_taxes();
3342
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3342
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3343 3343
     }
3344 3344
 
3345 3345
     /**
@@ -3347,11 +3347,11 @@  discard block
 block discarded – undo
3347 3347
 	 *
3348 3348
 	 * @since 1.0.19
3349 3349
 	 */
3350
-	public function remove_tax( $tax ) {
3350
+	public function remove_tax($tax) {
3351 3351
         $taxes = $this->get_discounts();
3352
-        if ( isset( $taxes[ $tax ] ) ) {
3353
-            unset( $taxes[ $tax ] );
3354
-            $this->set_prop( 'taxes', $taxes );
3352
+        if (isset($taxes[$tax])) {
3353
+            unset($taxes[$tax]);
3354
+            $this->set_prop('taxes', $taxes);
3355 3355
         }
3356 3356
     }
3357 3357
 
@@ -3362,19 +3362,19 @@  discard block
 block discarded – undo
3362 3362
 	 * @return float The recalculated subtotal
3363 3363
 	 */
3364 3364
 	public function recalculate_subtotal() {
3365
-        $items     = $this->get_items();
3365
+        $items = $this->get_items();
3366 3366
 		$subtotal  = 0;
3367 3367
 		$recurring = 0;
3368 3368
 
3369
-        foreach ( $items as $item ) {
3369
+        foreach ($items as $item) {
3370 3370
 			$subtotal  += $item->get_sub_total();
3371 3371
 			$recurring += $item->get_recurring_sub_total();
3372 3372
         }
3373 3373
 
3374
-		if ( $this->is_renewal() ) {
3375
-			$this->set_subtotal( $recurring );
3374
+		if ($this->is_renewal()) {
3375
+			$this->set_subtotal($recurring);
3376 3376
 		} else {
3377
-			$this->set_subtotal( $subtotal );
3377
+			$this->set_subtotal($subtotal);
3378 3378
 		}
3379 3379
 
3380 3380
 		$this->totals['subtotal'] = array(
@@ -3396,9 +3396,9 @@  discard block
 block discarded – undo
3396 3396
 		$discount  = 0;
3397 3397
 		$recurring = 0;
3398 3398
 
3399
-        foreach ( $discounts as $data ) {
3399
+        foreach ($discounts as $data) {
3400 3400
 
3401
-			if ( $data['recurring'] ) {
3401
+			if ($data['recurring']) {
3402 3402
 				$recurring += $data['amount'];
3403 3403
 			} else {
3404 3404
 				$discount += $data['amount'];
@@ -3406,10 +3406,10 @@  discard block
 block discarded – undo
3406 3406
 
3407 3407
 		}
3408 3408
 
3409
-		if ( $this->is_renewal() ) {
3410
-			$this->set_total_discount( $recurring );
3409
+		if ($this->is_renewal()) {
3410
+			$this->set_total_discount($recurring);
3411 3411
 		} else {
3412
-			$this->set_total_discount( $discount );
3412
+			$this->set_total_discount($discount);
3413 3413
 		}
3414 3414
 
3415 3415
 		$this->totals['discount'] = array(
@@ -3428,13 +3428,13 @@  discard block
 block discarded – undo
3428 3428
 	 * @return float The recalculated tax
3429 3429
 	 */
3430 3430
 	public function recalculate_total_tax() {
3431
-        $taxes     = $this->get_taxes();
3431
+        $taxes = $this->get_taxes();
3432 3432
 		$tax       = 0;
3433 3433
 		$recurring = 0;
3434 3434
 
3435
-        foreach ( $taxes as $data ) {
3435
+        foreach ($taxes as $data) {
3436 3436
 
3437
-			if ( $data['recurring'] ) {
3437
+			if ($data['recurring']) {
3438 3438
 				$recurring += $data['amount'];
3439 3439
 			} else {
3440 3440
 				$tax += $data['amount'];
@@ -3442,10 +3442,10 @@  discard block
 block discarded – undo
3442 3442
 
3443 3443
 		}
3444 3444
 
3445
-		if ( $this->is_renewal() ) {
3446
-			$this->set_total_tax( $recurring );
3445
+		if ($this->is_renewal()) {
3446
+			$this->set_total_tax($recurring);
3447 3447
 		} else {
3448
-			$this->set_total_tax( $tax );
3448
+			$this->set_total_tax($tax);
3449 3449
 		}
3450 3450
 
3451 3451
 		$this->totals['tax'] = array(
@@ -3468,9 +3468,9 @@  discard block
 block discarded – undo
3468 3468
 		$fee       = 0;
3469 3469
 		$recurring = 0;
3470 3470
 
3471
-        foreach ( $fees as $data ) {
3471
+        foreach ($fees as $data) {
3472 3472
 
3473
-			if ( $data['recurring'] ) {
3473
+			if ($data['recurring']) {
3474 3474
 				$recurring += $data['amount'];
3475 3475
 			} else {
3476 3476
 				$fee += $data['amount'];
@@ -3478,10 +3478,10 @@  discard block
 block discarded – undo
3478 3478
 
3479 3479
 		}
3480 3480
 
3481
-        if ( $this->is_renewal() ) {
3482
-			$this->set_total_fees( $recurring );
3481
+        if ($this->is_renewal()) {
3482
+			$this->set_total_fees($recurring);
3483 3483
 		} else {
3484
-			$this->set_total_fees( $fee );
3484
+			$this->set_total_fees($fee);
3485 3485
 		}
3486 3486
 
3487 3487
 		$this->totals['fee'] = array(
@@ -3489,7 +3489,7 @@  discard block
 block discarded – undo
3489 3489
 			'recurring' => $recurring,
3490 3490
 		);
3491 3491
 
3492
-        $this->set_total_fees( $fee );
3492
+        $this->set_total_fees($fee);
3493 3493
         return $this->is_renewal() ? $recurring : $fee;
3494 3494
     }
3495 3495
 
@@ -3510,9 +3510,9 @@  discard block
 block discarded – undo
3510 3510
 	/**
3511 3511
 	 * @deprecated
3512 3512
 	 */
3513
-    public function recalculate_totals( $temp = false ) {
3514
-        $this->update_items( $temp );
3515
-        $this->save( true );
3513
+    public function recalculate_totals($temp = false) {
3514
+        $this->update_items($temp);
3515
+        $this->save(true);
3516 3516
         return $this;
3517 3517
     }
3518 3518
 
@@ -3530,36 +3530,36 @@  discard block
 block discarded – undo
3530 3530
 	 * @return int|false The new note's ID on success, false on failure.
3531 3531
      *
3532 3532
      */
3533
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3533
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3534 3534
 
3535 3535
         // Bail if no note specified or this invoice is not yet saved.
3536
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3536
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3537 3537
             return false;
3538 3538
         }
3539 3539
 
3540 3540
 		// If this is an admin comment or it has been added by the user.
3541
-		if ( is_user_logged_in() && ( wpinv_current_user_can_manage_invoicing() || $added_by_user ) ) {
3542
-			$user         = get_user_by( 'id', get_current_user_id() );
3541
+		if (is_user_logged_in() && (wpinv_current_user_can_manage_invoicing() || $added_by_user)) {
3542
+			$user = get_user_by('id', get_current_user_id());
3543 3543
             $author       = $user->display_name;
3544 3544
             $author_email = $user->user_email;
3545 3545
 		} 
3546 3546
 
3547
-		if ( $system ) {
3548
-			$author       = 'System';
3547
+		if ($system) {
3548
+			$author = 'System';
3549 3549
             $author_email = '[email protected]';
3550 3550
 		}
3551 3551
 
3552
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3552
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3553 3553
 
3554 3554
 	}
3555 3555
 
3556 3556
 	/**
3557 3557
      * Generates a unique key for the invoice.
3558 3558
      */
3559
-    public function generate_key( $string = '' ) {
3560
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3559
+    public function generate_key($string = '') {
3560
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3561 3561
         return strtolower(
3562
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3562
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3563 3563
         );
3564 3564
     }
3565 3565
 
@@ -3569,11 +3569,11 @@  discard block
 block discarded – undo
3569 3569
     public function generate_number() {
3570 3570
         $number = $this->get_id();
3571 3571
 
3572
-        if ( $this->has_status( 'auto-draft' ) && wpinv_sequential_number_active( $this->post_type ) ) {
3573
-            $number = wpinv_get_next_invoice_number( $this->post_type );
3572
+        if ($this->has_status('auto-draft') && wpinv_sequential_number_active($this->post_type)) {
3573
+            $number = wpinv_get_next_invoice_number($this->post_type);
3574 3574
         }
3575 3575
 
3576
-		$number = wpinv_format_invoice_number( $number, $this->post_type );
3576
+		$number = wpinv_format_invoice_number($number, $this->post_type);
3577 3577
 
3578 3578
 		return $number;
3579 3579
 	}
@@ -3587,47 +3587,47 @@  discard block
 block discarded – undo
3587 3587
 		// Reset status transition variable.
3588 3588
 		$this->status_transition = false;
3589 3589
 
3590
-		if ( $status_transition ) {
3590
+		if ($status_transition) {
3591 3591
 			try {
3592 3592
 
3593 3593
 				// Fire a hook for the status change.
3594
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3594
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition);
3595 3595
 
3596 3596
 				// @deprecated this is deprecated and will be removed in the future.
3597
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3597
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3598 3598
 
3599
-				if ( ! empty( $status_transition['from'] ) ) {
3599
+				if (!empty($status_transition['from'])) {
3600 3600
 
3601 3601
 					/* translators: 1: old invoice status 2: new invoice status */
3602
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3602
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to']));
3603 3603
 
3604 3604
 					// Fire another hook.
3605
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3606
-					do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3605
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this);
3606
+					do_action('getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this);
3607 3607
 
3608 3608
 					// @deprecated this is deprecated and will be removed in the future.
3609
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3609
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3610 3610
 
3611 3611
 					// Note the transition occurred.
3612
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3612
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3613 3613
 
3614 3614
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3615 3615
 					if (
3616
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3617
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3616
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded'), true)
3617
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3618 3618
 					) {
3619
-						do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3619
+						do_action('getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition);
3620 3620
 					}
3621 3621
 				} else {
3622 3622
 					/* translators: %s: new invoice status */
3623
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3623
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to']));
3624 3624
 
3625 3625
 					// Note the transition occurred.
3626
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3626
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3627 3627
 
3628 3628
 				}
3629
-			} catch ( Exception $e ) {
3630
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3629
+			} catch (Exception $e) {
3630
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3631 3631
 			}
3632 3632
 		}
3633 3633
 	}
@@ -3635,13 +3635,13 @@  discard block
 block discarded – undo
3635 3635
 	/**
3636 3636
 	 * Updates an invoice status.
3637 3637
 	 */
3638
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3638
+	public function update_status($new_status = false, $note = '', $manual = false) {
3639 3639
 
3640 3640
 		// Fires before updating a status.
3641
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3641
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3642 3642
 
3643 3643
 		// Update the status.
3644
-		$this->set_status( $new_status, $note, $manual );
3644
+		$this->set_status($new_status, $note, $manual);
3645 3645
 
3646 3646
 		// Save the order.
3647 3647
 		return $this->save();
@@ -3652,18 +3652,18 @@  discard block
 block discarded – undo
3652 3652
 	 * @deprecated
3653 3653
 	 */
3654 3654
 	public function refresh_item_ids() {
3655
-        $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3656
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3655
+        $item_ids = implode(',', array_unique(array_keys($this->get_items())));
3656
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3657 3657
 	}
3658 3658
 
3659 3659
 	/**
3660 3660
 	 * @deprecated
3661 3661
 	 */
3662
-	public function update_items( $temp = false ) {
3662
+	public function update_items($temp = false) {
3663 3663
 
3664
-		$this->set_items( $this->get_items() );
3664
+		$this->set_items($this->get_items());
3665 3665
 
3666
-		if ( ! $temp ) {
3666
+		if (!$temp) {
3667 3667
 			$this->save();
3668 3668
 		}
3669 3669
 
@@ -3677,11 +3677,11 @@  discard block
 block discarded – undo
3677 3677
 
3678 3678
         $discount_code = $this->get_discount_code();
3679 3679
 
3680
-        if ( empty( $discount_code ) ) {
3680
+        if (empty($discount_code)) {
3681 3681
             return false;
3682 3682
         }
3683 3683
 
3684
-        $discount = wpinv_get_discount_obj( $discount_code );
3684
+        $discount = wpinv_get_discount_obj($discount_code);
3685 3685
 
3686 3686
         // Ensure it is active.
3687 3687
         return $discount->exists();
@@ -3692,7 +3692,7 @@  discard block
 block discarded – undo
3692 3692
 	 * Refunds an invoice.
3693 3693
 	 */
3694 3694
     public function refund() {
3695
-		$this->set_status( 'wpi-refunded' );
3695
+		$this->set_status('wpi-refunded');
3696 3696
         $this->save();
3697 3697
 	}
3698 3698
 
@@ -3701,56 +3701,56 @@  discard block
 block discarded – undo
3701 3701
 	 * 
3702 3702
 	 * @param string $transaction_id
3703 3703
 	 */
3704
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3704
+    public function mark_paid($transaction_id = null, $note = '') {
3705 3705
 
3706 3706
 		// Set the transaction id.
3707
-		if ( empty( $transaction_id ) ) {
3707
+		if (empty($transaction_id)) {
3708 3708
 			$transaction_id = $this->generate_key('trans_');
3709 3709
 		}
3710 3710
 
3711
-		if ( ! $this->get_transaction_id() ) {
3712
-			$this->set_transaction_id( $transaction_id );
3711
+		if (!$this->get_transaction_id()) {
3712
+			$this->set_transaction_id($transaction_id);
3713 3713
 		}
3714 3714
 
3715
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3715
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3716 3716
 			return $this->save();
3717 3717
 		}
3718 3718
 
3719 3719
 		// Set the completed date.
3720
-		$this->set_date_completed( current_time( 'mysql' ) );
3720
+		$this->set_date_completed(current_time('mysql'));
3721 3721
 
3722 3722
 		// Set the new status.
3723
-		if ( $this->is_renewal() ) {
3723
+		if ($this->is_renewal()) {
3724 3724
 
3725 3725
 			$_note = sprintf(
3726
-				__( 'Renewed via %s', 'invoicing' ),
3727
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3726
+				__('Renewed via %s', 'invoicing'),
3727
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3728 3728
 			);
3729 3729
 
3730
-			if ( 'none' == $this->get_gateway() ) {
3730
+			if ('none' == $this->get_gateway()) {
3731 3731
 				$_note = $note;
3732 3732
 			}
3733 3733
 
3734
-			$this->set_status( 'wpi-renewal', $_note );
3734
+			$this->set_status('wpi-renewal', $_note);
3735 3735
 
3736 3736
 		} else {
3737 3737
 
3738 3738
 			$_note = sprintf(
3739
-				__( 'Paid via %s', 'invoicing' ),
3740
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3739
+				__('Paid via %s', 'invoicing'),
3740
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3741 3741
 			);
3742 3742
 
3743
-			if ( 'none' == $this->get_gateway() ) {
3743
+			if ('none' == $this->get_gateway()) {
3744 3744
 				$_note = $note;
3745 3745
 			}
3746 3746
 
3747
-			$this->set_status( 'publish',$_note );
3747
+			$this->set_status('publish', $_note);
3748 3748
 
3749 3749
 		}
3750 3750
 
3751 3751
 		// Set checkout mode.
3752
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3753
-		$this->set_mode( $mode );
3752
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3753
+		$this->set_mode($mode);
3754 3754
 
3755 3755
 		// Save the invoice.
3756 3756
         $this->save();
Please login to merge, or discard this patch.
includes/admin/register-settings.php 1 patch
Spacing   +540 added lines, -540 removed lines patch added patch discarded remove patch
@@ -1,66 +1,66 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-function wpinv_get_option( $key = '', $default = false ) {
7
+function wpinv_get_option($key = '', $default = false) {
8 8
     global $wpinv_options;
9 9
 
10
-    $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default;
11
-    $value = apply_filters( 'wpinv_get_option', $value, $key, $default );
10
+    $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default;
11
+    $value = apply_filters('wpinv_get_option', $value, $key, $default);
12 12
 
13
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
13
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
14 14
 }
15 15
 
16
-function wpinv_update_option( $key = '', $value = false ) {
16
+function wpinv_update_option($key = '', $value = false) {
17 17
     // If no key, exit
18
-    if ( empty( $key ) ) {
18
+    if (empty($key)) {
19 19
         return false;
20 20
     }
21 21
 
22
-    if ( empty( $value ) ) {
23
-        $remove_option = wpinv_delete_option( $key );
22
+    if (empty($value)) {
23
+        $remove_option = wpinv_delete_option($key);
24 24
         return $remove_option;
25 25
     }
26 26
 
27 27
     // First let's grab the current settings
28
-    $options = get_option( 'wpinv_settings' );
28
+    $options = get_option('wpinv_settings');
29 29
 
30 30
     // Let other plugin alter the value
31
-    $value = apply_filters( 'wpinv_update_option', $value, $key );
31
+    $value = apply_filters('wpinv_update_option', $value, $key);
32 32
 
33 33
     // Next let's try to update the value
34
-    $options[ $key ] = $value;
35
-    $did_update = update_option( 'wpinv_settings', $options );
34
+    $options[$key] = $value;
35
+    $did_update = update_option('wpinv_settings', $options);
36 36
 
37 37
     // If it's updated, let's update the global variable
38
-    if ( $did_update ) {
38
+    if ($did_update) {
39 39
         global $wpinv_options;
40
-        $wpinv_options[ $key ] = $value;
40
+        $wpinv_options[$key] = $value;
41 41
     }
42 42
 
43 43
     return $did_update;
44 44
 }
45 45
 
46
-function wpinv_delete_option( $key = '' ) {
46
+function wpinv_delete_option($key = '') {
47 47
     // If no key, exit
48
-    if ( empty( $key ) ) {
48
+    if (empty($key)) {
49 49
         return false;
50 50
     }
51 51
 
52 52
     // First let's grab the current settings
53
-    $options = get_option( 'wpinv_settings' );
53
+    $options = get_option('wpinv_settings');
54 54
 
55 55
     // Next let's try to update the value
56
-    if( isset( $options[ $key ] ) ) {
57
-        unset( $options[ $key ] );
56
+    if (isset($options[$key])) {
57
+        unset($options[$key]);
58 58
     }
59 59
 
60
-    $did_update = update_option( 'wpinv_settings', $options );
60
+    $did_update = update_option('wpinv_settings', $options);
61 61
 
62 62
     // If it updated, let's update the global variable
63
-    if ( $did_update ){
63
+    if ($did_update) {
64 64
         global $wpinv_options;
65 65
         $wpinv_options = $options;
66 66
     }
@@ -69,37 +69,37 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 function wpinv_get_settings() {
72
-    $settings = get_option( 'wpinv_settings' );
72
+    $settings = get_option('wpinv_settings');
73 73
 
74
-    if ( empty( $settings ) ) {
74
+    if (empty($settings)) {
75 75
         // Update old settings with new single option
76
-        $general_settings   = is_array( get_option( 'wpinv_settings_general' ) )    ? get_option( 'wpinv_settings_general' )    : array();
77
-        $gateways_settings  = is_array( get_option( 'wpinv_settings_gateways' ) )   ? get_option( 'wpinv_settings_gateways' )   : array();
78
-        $email_settings     = is_array( get_option( 'wpinv_settings_emails' ) )     ? get_option( 'wpinv_settings_emails' )     : array();
79
-        $tax_settings       = is_array( get_option( 'wpinv_settings_taxes' ) )      ? get_option( 'wpinv_settings_taxes' )      : array();
80
-        $misc_settings      = is_array( get_option( 'wpinv_settings_misc' ) )       ? get_option( 'wpinv_settings_misc' )       : array();
81
-        $tool_settings      = is_array( get_option( 'wpinv_settings_tools' ) )      ? get_option( 'wpinv_settings_tools' )      : array();
76
+        $general_settings   = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array();
77
+        $gateways_settings  = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array();
78
+        $email_settings     = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array();
79
+        $tax_settings       = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array();
80
+        $misc_settings      = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array();
81
+        $tool_settings      = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array();
82 82
 
83
-        $settings = array_merge( $general_settings, $gateways_settings, $email_settings, $tax_settings, $misc_settings, $tool_settings );
83
+        $settings = array_merge($general_settings, $gateways_settings, $email_settings, $tax_settings, $misc_settings, $tool_settings);
84 84
 
85
-        update_option( 'wpinv_settings', $settings );
85
+        update_option('wpinv_settings', $settings);
86 86
 
87 87
     }
88
-    return apply_filters( 'wpinv_get_settings', $settings );
88
+    return apply_filters('wpinv_get_settings', $settings);
89 89
 }
90 90
 
91 91
 function wpinv_register_settings() {
92
-    if ( false == get_option( 'wpinv_settings' ) ) {
93
-        add_option( 'wpinv_settings' );
92
+    if (false == get_option('wpinv_settings')) {
93
+        add_option('wpinv_settings');
94 94
     }
95 95
     
96 96
     $register_settings = wpinv_get_registered_settings();
97 97
     
98
-    foreach ( $register_settings as $tab => $sections ) {
99
-        foreach ( $sections as $section => $settings) {
98
+    foreach ($register_settings as $tab => $sections) {
99
+        foreach ($sections as $section => $settings) {
100 100
             // Check for backwards compatibility
101
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
102
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
101
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
102
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
103 103
                 $section = 'main';
104 104
                 $settings = $sections;
105 105
             }
@@ -111,41 +111,41 @@  discard block
 block discarded – undo
111 111
                 'wpinv_settings_' . $tab . '_' . $section
112 112
             );
113 113
 
114
-            foreach ( $settings as $option ) {
114
+            foreach ($settings as $option) {
115 115
                 // For backwards compatibility
116
-                if ( empty( $option['id'] ) ) {
116
+                if (empty($option['id'])) {
117 117
                     continue;
118 118
                 }
119 119
 
120
-                $name = isset( $option['name'] ) ? $option['name'] : '';
120
+                $name = isset($option['name']) ? $option['name'] : '';
121 121
 
122 122
                 add_settings_field(
123 123
                     'wpinv_settings[' . $option['id'] . ']',
124 124
                     $name,
125
-                    function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback',
125
+                    function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback',
126 126
                     'wpinv_settings_' . $tab . '_' . $section,
127 127
                     'wpinv_settings_' . $tab . '_' . $section,
128 128
                     array(
129 129
                         'section'     => $section,
130
-                        'id'          => isset( $option['id'] )          ? $option['id']          : null,
131
-                        'desc'        => ! empty( $option['desc'] )      ? $option['desc']        : '',
132
-                        'name'        => isset( $option['name'] )        ? $option['name']        : null,
133
-                        'size'        => isset( $option['size'] )        ? $option['size']        : null,
134
-                        'options'     => isset( $option['options'] )     ? $option['options']     : '',
135
-                        'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
136
-                        'std'         => isset( $option['std'] )         ? $option['std']         : '',
137
-                        'min'         => isset( $option['min'] )         ? $option['min']         : null,
138
-                        'max'         => isset( $option['max'] )         ? $option['max']         : null,
139
-                        'step'        => isset( $option['step'] )        ? $option['step']        : null,
140
-                        'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
141
-                        'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
142
-                        'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
143
-                        'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
144
-                        'onchange'    => !empty( $option['onchange'] )   ? $option['onchange']    : '',
145
-                        'custom'      => !empty( $option['custom'] )     ? $option['custom']      : '',
146
-                        'class'       =>  !empty( $option['class'] )     ? $option['class']      : '',
147
-                        'cols'        => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50,
148
-                        'rows'        => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5,
130
+                        'id'          => isset($option['id']) ? $option['id'] : null,
131
+                        'desc'        => !empty($option['desc']) ? $option['desc'] : '',
132
+                        'name'        => isset($option['name']) ? $option['name'] : null,
133
+                        'size'        => isset($option['size']) ? $option['size'] : null,
134
+                        'options'     => isset($option['options']) ? $option['options'] : '',
135
+                        'selected'    => isset($option['selected']) ? $option['selected'] : null,
136
+                        'std'         => isset($option['std']) ? $option['std'] : '',
137
+                        'min'         => isset($option['min']) ? $option['min'] : null,
138
+                        'max'         => isset($option['max']) ? $option['max'] : null,
139
+                        'step'        => isset($option['step']) ? $option['step'] : null,
140
+                        'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
141
+                        'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
142
+                        'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
143
+                        'faux'        => isset($option['faux']) ? $option['faux'] : false,
144
+                        'onchange'    => !empty($option['onchange']) ? $option['onchange'] : '',
145
+                        'custom'      => !empty($option['custom']) ? $option['custom'] : '',
146
+                        'class'       =>  !empty($option['class']) ? $option['class'] : '',
147
+                        'cols'        => !empty($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
148
+                        'rows'        => !empty($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
149 149
                     )
150 150
                 );
151 151
             }
@@ -153,203 +153,203 @@  discard block
 block discarded – undo
153 153
     }
154 154
 
155 155
     // Creates our settings in the options table
156
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
156
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
157 157
 }
158
-add_action( 'admin_init', 'wpinv_register_settings' );
158
+add_action('admin_init', 'wpinv_register_settings');
159 159
 
160 160
 function wpinv_get_registered_settings() {
161
-    $pages = wpinv_get_pages( true );
161
+    $pages = wpinv_get_pages(true);
162 162
     
163 163
     $currencies = wpinv_get_currencies();
164 164
     
165 165
     $currency_code_options = array();
166
-    foreach ( $currencies as $code => $name ) {
167
-        $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')';
166
+    foreach ($currencies as $code => $name) {
167
+        $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')';
168 168
     }
169 169
     
170 170
     $due_payment_options       = array();
171
-    $due_payment_options[0]    = __( 'Now', 'invoicing' );
172
-    for ( $i = 1; $i <= 30; $i++ ) {
171
+    $due_payment_options[0]    = __('Now', 'invoicing');
172
+    for ($i = 1; $i <= 30; $i++) {
173 173
         $due_payment_options[$i] = $i;
174 174
     }
175 175
     
176 176
     $invoice_number_padd_options = array();
177
-    for ( $i = 0; $i <= 20; $i++ ) {
177
+    for ($i = 0; $i <= 20; $i++) {
178 178
         $invoice_number_padd_options[$i] = $i;
179 179
     }
180 180
     
181 181
     $currency_symbol = wpinv_currency_symbol();
182 182
     
183 183
     $last_number = $reset_number = '';
184
-    if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) {
185
-        $last_invoice_number = is_numeric( $last_invoice_number ) ? $last_invoice_number : wpinv_clean_invoice_number( $last_invoice_number );
184
+    if ($last_invoice_number = get_option('wpinv_last_invoice_number')) {
185
+        $last_invoice_number = is_numeric($last_invoice_number) ? $last_invoice_number : wpinv_clean_invoice_number($last_invoice_number);
186 186
 
187
-        if ( !empty( $last_invoice_number ) ) {
188
-            $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number );
187
+        if (!empty($last_invoice_number)) {
188
+            $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number);
189 189
         }
190 190
 
191 191
         $nonce = wp_create_nonce('reset_invoice_count');
192
-        $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>';
192
+        $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>';
193 193
     }
194 194
     
195 195
     $alert_wrapper_start = '<p style="color: #F00">';
196 196
     $alert_wrapper_close = '</p>';
197 197
     $wpinv_settings = array(
198
-        'general' => apply_filters( 'wpinv_settings_general',
198
+        'general' => apply_filters('wpinv_settings_general',
199 199
             array(
200 200
                 'main' => array(
201 201
                     'location_settings' => array(
202 202
                         'id'   => 'location_settings',
203
-                        'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
203
+                        'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
204 204
                         'desc' => '',
205 205
                         'type' => 'header',
206 206
                     ),
207 207
                     'default_country' => array(
208 208
                         'id'      => 'default_country',
209
-                        'name'    => __( 'Default Country', 'invoicing' ),
210
-                        'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
209
+                        'name'    => __('Default Country', 'invoicing'),
210
+                        'desc'    => __('Where does your store operate from?', 'invoicing'),
211 211
                         'type'    => 'select',
212 212
                         'options' => wpinv_get_country_list(),
213 213
                         'std'     => 'GB',
214 214
                         'class'   => 'wpi_select2',
215
-                        'placeholder' => __( 'Select a country', 'invoicing' ),
215
+                        'placeholder' => __('Select a country', 'invoicing'),
216 216
                     ),
217 217
                     'default_state' => array(
218 218
                         'id'      => 'default_state',
219
-                        'name'    => __( 'Default State / Province', 'invoicing' ),
220
-                        'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
219
+                        'name'    => __('Default State / Province', 'invoicing'),
220
+                        'desc'    => __('What state / province does your store operate from?', 'invoicing'),
221 221
                         'type'    => 'country_states',
222 222
                         'class'   => 'wpi_select2',
223
-                        'placeholder' => __( 'Select a state', 'invoicing' ),
223
+                        'placeholder' => __('Select a state', 'invoicing'),
224 224
                     ),
225 225
                     'store_name' => array(
226 226
                         'id'   => 'store_name',
227
-                        'name' => __( 'Store Name', 'invoicing' ),
228
-                        'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
227
+                        'name' => __('Store Name', 'invoicing'),
228
+                        'desc' => __('Store name to print on invoices.', 'invoicing'),
229 229
                         'std'     => get_option('blogname'),
230 230
                         'type' => 'text',
231 231
                     ),
232 232
                     'logo' => array(
233 233
                         'id'   => 'logo',
234
-                        'name' => __( 'Logo URL', 'invoicing' ),
235
-                        'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
234
+                        'name' => __('Logo URL', 'invoicing'),
235
+                        'desc' => __('Store logo to print on invoices.', 'invoicing'),
236 236
                         'type' => 'text',
237 237
                     ),
238 238
                     'store_address' => array(
239 239
                         'id'   => 'store_address',
240
-                        'name' => __( 'Store Address', 'invoicing' ),
241
-                        'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
240
+                        'name' => __('Store Address', 'invoicing'),
241
+                        'desc' => __('Enter the store address to display on invoice', 'invoicing'),
242 242
                         'type' => 'textarea',
243 243
                     ),
244 244
                     'page_settings' => array(
245 245
                         'id'   => 'page_settings',
246
-                        'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
246
+                        'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
247 247
                         'desc' => '',
248 248
                         'type' => 'header',
249 249
                     ),
250 250
                     'checkout_page' => array(
251 251
                         'id'          => 'checkout_page',
252
-                        'name'        => __( 'Checkout Page', 'invoicing' ),
253
-                        'desc'        => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ),
252
+                        'name'        => __('Checkout Page', 'invoicing'),
253
+                        'desc'        => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'),
254 254
                         'type'        => 'select',
255 255
                         'options'     => $pages,
256 256
                         'class'       => 'wpi_select2',
257
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
257
+                        'placeholder' => __('Select a page', 'invoicing'),
258 258
                     ),
259 259
                     'tandc_page' => array(
260 260
                         'id'          => 'tandc_page',
261
-                        'name'        => __( 'Terms & Conditions', 'invoicing' ),
262
-                        'desc'        => __( 'If you select a "Terms & Conditions" page here the customer will be asked to accept them on checkout.', 'invoicing' ),
261
+                        'name'        => __('Terms & Conditions', 'invoicing'),
262
+                        'desc'        => __('If you select a "Terms & Conditions" page here the customer will be asked to accept them on checkout.', 'invoicing'),
263 263
                         'type'        => 'select',
264
-                        'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
264
+                        'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
265 265
                         'class'       => 'wpi_select2',
266
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
266
+                        'placeholder' => __('Select a page', 'invoicing'),
267 267
                     ),
268 268
                     'success_page' => array(
269 269
                         'id'          => 'success_page',
270
-                        'name'        => __( 'Success Page', 'invoicing' ),
271
-                        'desc'        => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ),
270
+                        'name'        => __('Success Page', 'invoicing'),
271
+                        'desc'        => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'),
272 272
                         'type'        => 'select',
273 273
                         'options'     => $pages,
274 274
                         'class'       => 'wpi_select2',
275
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
275
+                        'placeholder' => __('Select a page', 'invoicing'),
276 276
                     ),
277 277
                     'failure_page' => array(
278 278
                         'id'          => 'failure_page',
279
-                        'name'        => __( 'Failed Transaction Page', 'invoicing' ),
280
-                        'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ),
279
+                        'name'        => __('Failed Transaction Page', 'invoicing'),
280
+                        'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'),
281 281
                         'type'        => 'select',
282 282
                         'options'     => $pages,
283 283
                         'class'       => 'wpi_select2',
284
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
284
+                        'placeholder' => __('Select a page', 'invoicing'),
285 285
                     ),
286 286
                     'invoice_history_page' => array(
287 287
                         'id'          => 'invoice_history_page',
288
-                        'name'        => __( 'Invoice History Page', 'invoicing' ),
289
-                        'desc'        => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ),
288
+                        'name'        => __('Invoice History Page', 'invoicing'),
289
+                        'desc'        => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'),
290 290
                         'type'        => 'select',
291 291
                         'options'     => $pages,
292 292
                         'class'       => 'wpi_select2',
293
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
293
+                        'placeholder' => __('Select a page', 'invoicing'),
294 294
                     ),
295 295
                     'invoice_subscription_page' => array(
296 296
                         'id'          => 'invoice_subscription_page',
297
-                        'name'        => __( 'Invoice Subscriptions Page', 'invoicing' ),
298
-                        'desc'        => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ),
297
+                        'name'        => __('Invoice Subscriptions Page', 'invoicing'),
298
+                        'desc'        => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'),
299 299
                         'type'        => 'select',
300 300
                         'options'     => $pages,
301 301
                         'class'       => 'wpi_select2',
302
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
302
+                        'placeholder' => __('Select a page', 'invoicing'),
303 303
                     ),
304 304
                 ),
305 305
                 'currency_section' => array(
306 306
                     'currency_settings' => array(
307 307
                         'id'   => 'currency_settings',
308
-                        'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
308
+                        'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
309 309
                         'desc' => '',
310 310
                         'type' => 'header',
311 311
                     ),
312 312
                     'currency' => array(
313 313
                         'id'      => 'currency',
314
-                        'name'    => __( 'Currency', 'invoicing' ),
315
-                        'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
314
+                        'name'    => __('Currency', 'invoicing'),
315
+                        'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
316 316
                         'type'    => 'select',
317 317
                         'class'       => 'wpi_select2',
318 318
                         'options' => $currency_code_options,
319 319
                     ),
320 320
                     'currency_position' => array(
321 321
                         'id'      => 'currency_position',
322
-                        'name'    => __( 'Currency Position', 'invoicing' ),
323
-                        'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
322
+                        'name'    => __('Currency Position', 'invoicing'),
323
+                        'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
324 324
                         'type'    => 'select',
325 325
                         'class'   => 'wpi_select2',
326 326
                         'options'  => array(
327
-                            'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
328
-                            'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
329
-                            'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
330
-                            'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
327
+                            'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
328
+                            'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
329
+                            'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
330
+                            'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
331 331
                         )
332 332
                     ),
333 333
                     'thousands_separator' => array(
334 334
                         'id'   => 'thousands_separator',
335
-                        'name' => __( 'Thousands Separator', 'invoicing' ),
336
-                        'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
335
+                        'name' => __('Thousands Separator', 'invoicing'),
336
+                        'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
337 337
                         'type' => 'text',
338 338
                         'size' => 'small',
339 339
                         'std'  => ',',
340 340
                     ),
341 341
                     'decimal_separator' => array(
342 342
                         'id'   => 'decimal_separator',
343
-                        'name' => __( 'Decimal Separator', 'invoicing' ),
344
-                        'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
343
+                        'name' => __('Decimal Separator', 'invoicing'),
344
+                        'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
345 345
                         'type' => 'text',
346 346
                         'size' => 'small',
347 347
                         'std'  => '.',
348 348
                     ),
349 349
                     'decimals' => array(
350 350
                         'id'   => 'decimals',
351
-                        'name' => __( 'Number of Decimals', 'invoicing' ),
352
-                        'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
351
+                        'name' => __('Number of Decimals', 'invoicing'),
352
+                        'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
353 353
                         'type' => 'number',
354 354
                         'size' => 'small',
355 355
                         'std'  => '2',
@@ -361,29 +361,29 @@  discard block
 block discarded – undo
361 361
                 'labels' => array(
362 362
                     'labels' => array(
363 363
                         'id'   => 'labels_settings',
364
-                        'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
364
+                        'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
365 365
                         'desc' => '',
366 366
                         'type' => 'header',
367 367
                     ),
368 368
                     'vat_name' => array(
369 369
                         'id' => 'vat_name',
370
-                        'name' => __( 'VAT Name', 'invoicing' ),
371
-                        'desc' => __( 'Enter the VAT name', 'invoicing' ),
370
+                        'name' => __('VAT Name', 'invoicing'),
371
+                        'desc' => __('Enter the VAT name', 'invoicing'),
372 372
                         'type' => 'text',
373 373
                         'size' => 'regular',
374
-                        'std' => __( 'VAT', 'invoicing' ),
374
+                        'std' => __('VAT', 'invoicing'),
375 375
                     ),
376 376
                     'vat_invoice_notice_label' => array(
377 377
                         'id' => 'vat_invoice_notice_label',
378
-                        'name' => __( 'Invoice Notice Label', 'invoicing' ),
379
-                        'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
378
+                        'name' => __('Invoice Notice Label', 'invoicing'),
379
+                        'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
380 380
                         'type' => 'text',
381 381
                         'size' => 'regular',
382 382
                     ),
383 383
                     'vat_invoice_notice' => array(
384 384
                         'id' => 'vat_invoice_notice',
385
-                        'name' => __( 'Invoice notice', 'invoicing' ),
386
-                        'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
385
+                        'name' => __('Invoice notice', 'invoicing'),
386
+                        'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
387 387
                         'type' => 'text',
388 388
                         'size' => 'regular',
389 389
                     ),
@@ -395,22 +395,22 @@  discard block
 block discarded – undo
395 395
                 'main' => array(
396 396
                     'gateway_settings' => array(
397 397
                         'id'   => 'api_header',
398
-                        'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
398
+                        'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
399 399
                         'desc' => '',
400 400
                         'type' => 'header',
401 401
                     ),
402 402
                     'gateways' => array(
403 403
                         'id'      => 'gateways',
404
-                        'name'    => __( 'Payment Gateways', 'invoicing' ),
405
-                        'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
404
+                        'name'    => __('Payment Gateways', 'invoicing'),
405
+                        'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
406 406
                         'type'    => 'gateways',
407 407
                         'std'     => array('manual'=>1),
408 408
                         'options' => wpinv_get_payment_gateways(),
409 409
                     ),
410 410
                     'default_gateway' => array(
411 411
                         'id'      => 'default_gateway',
412
-                        'name'    => __( 'Default Gateway', 'invoicing' ),
413
-                        'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
412
+                        'name'    => __('Default Gateway', 'invoicing'),
413
+                        'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
414 414
                         'type'    => 'gateway_select',
415 415
                         'std'     => 'manual',
416 416
                         'class'   => 'wpi_select2',
@@ -425,19 +425,19 @@  discard block
 block discarded – undo
425 425
                 'main' => array(
426 426
                     'tax_settings' => array(
427 427
                         'id'   => 'tax_settings',
428
-                        'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
428
+                        'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
429 429
                         'type' => 'header',
430 430
                     ),
431 431
                     'enable_taxes' => array(
432 432
                         'id'   => 'enable_taxes',
433
-                        'name' => __( 'Enable Taxes', 'invoicing' ),
434
-                        'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ),
433
+                        'name' => __('Enable Taxes', 'invoicing'),
434
+                        'desc' => __('Check this to enable taxes on invoices.', 'invoicing'),
435 435
                         'type' => 'checkbox',
436 436
                     ),
437 437
                     'tax_rate' => array(
438 438
                         'id'   => 'tax_rate',
439
-                        'name' => __( 'Fallback Tax Rate', 'invoicing' ),
440
-                        'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
439
+                        'name' => __('Fallback Tax Rate', 'invoicing'),
440
+                        'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
441 441
                         'type' => 'number',
442 442
                         'size' => 'small',
443 443
                         'min'  => '0',
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
                 'rates' => array(
450 450
                     'tax_rates' => array(
451 451
                         'id'   => 'tax_rates',
452
-                        'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
453
-                        'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
452
+                        'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
453
+                        'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
454 454
                         'type' => 'tax_rates',
455 455
                     ),
456 456
                 )
@@ -462,68 +462,68 @@  discard block
 block discarded – undo
462 462
                 'main' => array(
463 463
                     'email_settings_header' => array(
464 464
                         'id'   => 'email_settings_header',
465
-                        'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
465
+                        'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
466 466
                         'type' => 'header',
467 467
                     ),
468 468
                     'email_from_name' => array(
469 469
                         'id'   => 'email_from_name',
470
-                        'name' => __( 'From Name', 'invoicing' ),
471
-                        'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
472
-                        'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
470
+                        'name' => __('From Name', 'invoicing'),
471
+                        'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
472
+                        'std' => esc_attr(get_bloginfo('name', 'display')),
473 473
                         'type' => 'text',
474 474
                     ),
475 475
                     'email_from' => array(
476 476
                         'id'   => 'email_from',
477
-                        'name' => __( 'From Email', 'invoicing' ),
478
-                        'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close),
479
-                        'std' => get_option( 'admin_email' ),
477
+                        'name' => __('From Email', 'invoicing'),
478
+                        'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close),
479
+                        'std' => get_option('admin_email'),
480 480
                         'type' => 'text',
481 481
                     ),
482 482
                     'admin_email' => array(
483 483
                         'id'   => 'admin_email',
484
-                        'name' => __( 'Admin Email', 'invoicing' ),
485
-                        'desc' => __( 'Where should we send admin notifications?', 'invoicing' ),
486
-                        'std' => get_option( 'admin_email' ),
484
+                        'name' => __('Admin Email', 'invoicing'),
485
+                        'desc' => __('Where should we send admin notifications?', 'invoicing'),
486
+                        'std' => get_option('admin_email'),
487 487
                         'type' => 'text',
488 488
                     ),
489 489
                     'overdue_settings_header' => array(
490 490
                         'id'   => 'overdue_settings_header',
491
-                        'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
491
+                        'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
492 492
                         'type' => 'header',
493 493
                     ),
494 494
                     'overdue_active' => array(
495 495
                         'id'   => 'overdue_active',
496
-                        'name' => __( 'Enable Due Date', 'invoicing' ),
497
-                        'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
496
+                        'name' => __('Enable Due Date', 'invoicing'),
497
+                        'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
498 498
                         'type' => 'checkbox',
499 499
                         'std'  => false,
500 500
                     ),
501 501
                     'overdue_days' => array(
502 502
                         'id'          => 'overdue_days',
503
-                        'name'        => __( 'Default Due Date', 'invoicing' ),
504
-                        'desc'        => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ),
503
+                        'name'        => __('Default Due Date', 'invoicing'),
504
+                        'desc'        => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'),
505 505
                         'type'        => 'select',
506 506
                         'options'     => $due_payment_options,
507 507
                         'std'         => 0,
508
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
508
+                        'placeholder' => __('Select a page', 'invoicing'),
509 509
                     ),
510 510
                     'email_template_header' => array(
511 511
                         'id'   => 'email_template_header',
512
-                        'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
512
+                        'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
513 513
                         'type' => 'header',
514 514
                     ),
515 515
                     'email_header_image' => array(
516 516
                         'id'   => 'email_header_image',
517
-                        'name' => __( 'Header Image', 'invoicing' ),
518
-                        'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
517
+                        'name' => __('Header Image', 'invoicing'),
518
+                        'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
519 519
                         'std' => '',
520 520
                         'type' => 'text',
521 521
                     ),
522 522
                     'email_footer_text' => array(
523 523
                         'id'   => 'email_footer_text',
524
-                        'name' => __( 'Footer Text', 'invoicing' ),
525
-                        'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
526
-                        'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ),
524
+                        'name' => __('Footer Text', 'invoicing'),
525
+                        'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
526
+                        'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'),
527 527
                         'type' => 'textarea',
528 528
                         'class' => 'regular-text',
529 529
                         'rows' => 2,
@@ -531,29 +531,29 @@  discard block
 block discarded – undo
531 531
                     ),
532 532
                     'email_base_color' => array(
533 533
                         'id'   => 'email_base_color',
534
-                        'name' => __( 'Base Color', 'invoicing' ),
535
-                        'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
534
+                        'name' => __('Base Color', 'invoicing'),
535
+                        'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
536 536
                         'std' => '#557da2',
537 537
                         'type' => 'color',
538 538
                     ),
539 539
                     'email_background_color' => array(
540 540
                         'id'   => 'email_background_color',
541
-                        'name' => __( 'Background Color', 'invoicing' ),
542
-                        'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
541
+                        'name' => __('Background Color', 'invoicing'),
542
+                        'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
543 543
                         'std' => '#f5f5f5',
544 544
                         'type' => 'color',
545 545
                     ),
546 546
                     'email_body_background_color' => array(
547 547
                         'id'   => 'email_body_background_color',
548
-                        'name' => __( 'Body Background Color', 'invoicing' ),
549
-                        'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
548
+                        'name' => __('Body Background Color', 'invoicing'),
549
+                        'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
550 550
                         'std' => '#fdfdfd',
551 551
                         'type' => 'color',
552 552
                     ),
553 553
                     'email_text_color' => array(
554 554
                         'id'   => 'email_text_color',
555
-                        'name' => __( 'Body Text Color', 'invoicing' ),
556
-                        'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
555
+                        'name' => __('Body Text Color', 'invoicing'),
556
+                        'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
557 557
                         'std' => '#505050',
558 558
                         'type' => 'color',
559 559
                     ),
@@ -572,17 +572,17 @@  discard block
 block discarded – undo
572 572
                 'main' => array(
573 573
                     'invoicing_privacy_policy_settings' => array(
574 574
                         'id'   => 'invoicing_privacy_policy_settings',
575
-                        'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>',
575
+                        'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>',
576 576
                         'type' => 'header',
577 577
                     ),
578 578
                     'privacy_page' => array(
579 579
                         'id'          => 'privacy_page',
580
-                        'name'        => __( 'Privacy Page', 'invoicing' ),
581
-                        'desc'        => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ),
580
+                        'name'        => __('Privacy Page', 'invoicing'),
581
+                        'desc'        => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'),
582 582
                         'type'        => 'select',
583
-                        'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
583
+                        'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
584 584
                         'class'       => 'wpi_select2',
585
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
585
+                        'placeholder' => __('Select a page', 'invoicing'),
586 586
                     ),
587 587
                 ),
588 588
             )
@@ -593,19 +593,19 @@  discard block
 block discarded – undo
593 593
                 'main' => array(
594 594
                     'invoice_number_format_settings' => array(
595 595
                         'id'   => 'invoice_number_format_settings',
596
-                        'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
596
+                        'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
597 597
                         'type' => 'header',
598 598
                     ),
599 599
                     'sequential_invoice_number' => array(
600 600
                         'id'   => 'sequential_invoice_number',
601
-                        'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
602
-                        'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number,
601
+                        'name' => __('Sequential Invoice Numbers', 'invoicing'),
602
+                        'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number,
603 603
                         'type' => 'checkbox',
604 604
                     ),
605 605
                     'invoice_sequence_start' => array(
606 606
                         'id'   => 'invoice_sequence_start',
607
-                        'name' => __( 'Sequential Starting Number', 'invoicing' ),
608
-                        'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number,
607
+                        'name' => __('Sequential Starting Number', 'invoicing'),
608
+                        'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number,
609 609
                         'type' => 'number',
610 610
                         'size' => 'small',
611 611
                         'std'  => '1',
@@ -613,8 +613,8 @@  discard block
 block discarded – undo
613 613
                     ),
614 614
                     'invoice_number_padd' => array(
615 615
                         'id'      => 'invoice_number_padd',
616
-                        'name'    => __( 'Minimum Digits', 'invoicing' ),
617
-                        'desc'    => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ),
616
+                        'name'    => __('Minimum Digits', 'invoicing'),
617
+                        'desc'    => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'),
618 618
                         'type'    => 'select',
619 619
                         'options' => $invoice_number_padd_options,
620 620
                         'std'     => 5,
@@ -622,8 +622,8 @@  discard block
 block discarded – undo
622 622
                     ),
623 623
                     'invoice_number_prefix' => array(
624 624
                         'id' => 'invoice_number_prefix',
625
-                        'name' => __( 'Invoice Number Prefix', 'invoicing' ),
626
-                        'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ),
625
+                        'name' => __('Invoice Number Prefix', 'invoicing'),
626
+                        'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'),
627 627
                         'type' => 'text',
628 628
                         'size' => 'regular',
629 629
                         'std' => 'INV-',
@@ -631,32 +631,32 @@  discard block
 block discarded – undo
631 631
                     ),
632 632
                     'invoice_number_postfix' => array(
633 633
                         'id' => 'invoice_number_postfix',
634
-                        'name' => __( 'Invoice Number Postfix', 'invoicing' ),
635
-                        'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
634
+                        'name' => __('Invoice Number Postfix', 'invoicing'),
635
+                        'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
636 636
                         'type' => 'text',
637 637
                         'size' => 'regular',
638 638
                         'std' => ''
639 639
                     ),
640 640
                     'checkout_settings' => array(
641 641
                         'id'   => 'checkout_settings',
642
-                        'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>',
642
+                        'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>',
643 643
                         'type' => 'header',
644 644
                     ),
645 645
                     'login_to_checkout' => array(
646 646
                         'id'   => 'login_to_checkout',
647
-                        'name' => __( 'Require Login To Checkout', 'invoicing' ),
648
-                        'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ),
647
+                        'name' => __('Require Login To Checkout', 'invoicing'),
648
+                        'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'),
649 649
                         'type' => 'checkbox',
650 650
                     ),
651 651
                     'uninstall_settings' => array(
652 652
                         'id'   => 'uninstall_settings',
653
-                        'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
653
+                        'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
654 654
                         'type' => 'header',
655 655
                     ),
656 656
                     'remove_data_on_unistall' => array(
657 657
                         'id'   => 'remove_data_on_unistall',
658
-                        'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
659
-                        'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
658
+                        'name' => __('Remove Data on Uninstall?', 'invoicing'),
659
+                        'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
660 660
                         'type' => 'checkbox',
661 661
                         'std'  => ''
662 662
                     ),
@@ -664,20 +664,20 @@  discard block
 block discarded – undo
664 664
                 'fields' => array(
665 665
                     'address_autofill_settings' => array(
666 666
                         'id'   => 'address_autofill_settings',
667
-                        'name' => '<h3>' . __( 'Google Address Auto Complete', 'invoicing' ) . '</h3>',
667
+                        'name' => '<h3>' . __('Google Address Auto Complete', 'invoicing') . '</h3>',
668 668
                         'type' => 'header',
669 669
                     ),
670 670
                     'address_autofill_active' => array(
671 671
                         'id'   => 'address_autofill_active',
672
-                        'name' => __( 'Enable/Disable', 'invoicing' ),
673
-                        'desc' => __( 'Enable google address auto complete', 'invoicing' ),
672
+                        'name' => __('Enable/Disable', 'invoicing'),
673
+                        'desc' => __('Enable google address auto complete', 'invoicing'),
674 674
                         'type' => 'checkbox',
675 675
                         'std'  => 0
676 676
                     ),
677 677
                     'address_autofill_api' => array(
678 678
                         'id' => 'address_autofill_api',
679
-                        'name' => __( 'Google Place API Key', 'invoicing' ),
680
-                        'desc' => wp_sprintf(__( 'Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing' ), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>' ),
679
+                        'name' => __('Google Place API Key', 'invoicing'),
680
+                        'desc' => wp_sprintf(__('Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing'), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>'),
681 681
                         'type' => 'text',
682 682
                         'size' => 'regular',
683 683
                         'std' => ''
@@ -686,13 +686,13 @@  discard block
 block discarded – undo
686 686
                 'custom-css' => array(
687 687
                     'css_settings' => array(
688 688
                         'id'   => 'css_settings',
689
-                        'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>',
689
+                        'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>',
690 690
                         'type' => 'header',
691 691
                     ),
692 692
                     'template_custom_css' => array(
693 693
                         'id' => 'template_custom_css',
694
-                        'name' => __( 'Invoice Template CSS', 'invoicing' ),
695
-                        'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ),
694
+                        'name' => __('Invoice Template CSS', 'invoicing'),
695
+                        'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'),
696 696
                         'type' => 'textarea',
697 697
                         'class'=> 'regular-text',
698 698
                         'rows' => 10,
@@ -706,8 +706,8 @@  discard block
 block discarded – undo
706 706
                 'main' => array(
707 707
                     'tool_settings' => array(
708 708
                         'id'   => 'tool_settings',
709
-                        'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
710
-                        'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
709
+                        'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
710
+                        'desc' => __('Invoicing diagnostic tools', 'invoicing'),
711 711
                         'type' => 'tools',
712 712
                     ),
713 713
                 ),
@@ -715,135 +715,135 @@  discard block
 block discarded – undo
715 715
         )
716 716
     );
717 717
 
718
-    return apply_filters( 'wpinv_registered_settings', $wpinv_settings );
718
+    return apply_filters('wpinv_registered_settings', $wpinv_settings);
719 719
 }
720 720
 
721
-function wpinv_settings_sanitize( $input = array() ) {
721
+function wpinv_settings_sanitize($input = array()) {
722 722
     global $wpinv_options;
723 723
 
724
-    if ( empty( wp_get_raw_referer() ) ) {
724
+    if (empty(wp_get_raw_referer())) {
725 725
         return $input;
726 726
     }
727 727
 
728
-    wp_parse_str( wp_get_raw_referer(), $referrer );
728
+    wp_parse_str(wp_get_raw_referer(), $referrer);
729 729
 
730 730
     $settings = wpinv_get_registered_settings();
731
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
732
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
731
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
732
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
733 733
 
734 734
     $input = $input ? $input : array();
735
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
736
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
735
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
736
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
737 737
 
738 738
     // Loop through each setting being saved and pass it through a sanitization filter
739
-    foreach ( $input as $key => $value ) {
739
+    foreach ($input as $key => $value) {
740 740
         // Get the setting type (checkbox, select, etc)
741
-        $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false;
741
+        $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false;
742 742
 
743
-        if ( $type ) {
743
+        if ($type) {
744 744
             // Field type specific filter
745
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
745
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
746 746
         }
747 747
 
748 748
         // General filter
749
-        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
749
+        $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
750 750
     }
751 751
 
752 752
     // Loop through the whitelist and unset any that are empty for the tab being saved
753
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
754
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
753
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
754
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
755 755
 
756
-    $found_settings = array_merge( $main_settings, $section_settings );
756
+    $found_settings = array_merge($main_settings, $section_settings);
757 757
 
758
-    if ( ! empty( $found_settings ) ) {
759
-        foreach ( $found_settings as $key => $value ) {
758
+    if (!empty($found_settings)) {
759
+        foreach ($found_settings as $key => $value) {
760 760
 
761 761
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
762
-            if ( is_numeric( $key ) ) {
762
+            if (is_numeric($key)) {
763 763
                 $key = $value['id'];
764 764
             }
765 765
 
766
-            if ( empty( $input[ $key ] ) ) {
767
-                unset( $wpinv_options[ $key ] );
766
+            if (empty($input[$key])) {
767
+                unset($wpinv_options[$key]);
768 768
             }
769 769
         }
770 770
     }
771 771
 
772 772
     // Merge our new settings with the existing
773
-    $output = array_merge( $wpinv_options, $input );
773
+    $output = array_merge($wpinv_options, $input);
774 774
 
775
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
775
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
776 776
 
777 777
     return $output;
778 778
 }
779 779
 
780
-function wpinv_settings_sanitize_misc_accounting( $input ) {
780
+function wpinv_settings_sanitize_misc_accounting($input) {
781 781
 
782
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
782
+    if (!wpinv_current_user_can_manage_invoicing()) {
783 783
         return $input;
784 784
     }
785 785
 
786
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
786
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
787 787
         // Shows an admin notice about upgrading previous order numbers
788
-        getpaid_session()->set( 'upgrade_sequential', '1' );
788
+        getpaid_session()->set('upgrade_sequential', '1');
789 789
     }
790 790
 
791 791
     return $input;
792 792
 }
793
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
793
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
794 794
 
795
-function wpinv_settings_sanitize_tax_rates( $input ) {
796
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
795
+function wpinv_settings_sanitize_tax_rates($input) {
796
+    if (!wpinv_current_user_can_manage_invoicing()) {
797 797
         return $input;
798 798
     }
799 799
 
800
-    $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
800
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
801 801
 
802 802
     $tax_rates = array();
803 803
 
804
-    if ( !empty( $new_rates ) ) {
805
-        foreach ( $new_rates as $rate ) {
806
-            if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) {
804
+    if (!empty($new_rates)) {
805
+        foreach ($new_rates as $rate) {
806
+            if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) {
807 807
                 continue;
808 808
             }
809 809
             
810
-            $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 );
810
+            $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4);
811 811
             
812 812
             $tax_rates[] = $rate;
813 813
         }
814 814
     }
815 815
 
816
-    update_option( 'wpinv_tax_rates', $tax_rates );
816
+    update_option('wpinv_tax_rates', $tax_rates);
817 817
 
818 818
     return $input;
819 819
 }
820
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
820
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
821 821
 
822
-function wpinv_sanitize_text_field( $input ) {
823
-    return trim( $input );
822
+function wpinv_sanitize_text_field($input) {
823
+    return trim($input);
824 824
 }
825
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
825
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
826 826
 
827 827
 function wpinv_get_settings_tabs() {
828 828
     $tabs             = array();
829
-    $tabs['general']  = __( 'General', 'invoicing' );
830
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
831
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
832
-    $tabs['emails']   = __( 'Emails', 'invoicing' );
833
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
834
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
835
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
836
-
837
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
829
+    $tabs['general']  = __('General', 'invoicing');
830
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
831
+    $tabs['taxes']    = __('Taxes', 'invoicing');
832
+    $tabs['emails']   = __('Emails', 'invoicing');
833
+    $tabs['privacy']  = __('Privacy', 'invoicing');
834
+    $tabs['misc']     = __('Misc', 'invoicing');
835
+    $tabs['tools']    = __('Tools', 'invoicing');
836
+
837
+    return apply_filters('wpinv_settings_tabs', $tabs);
838 838
 }
839 839
 
840
-function wpinv_get_settings_tab_sections( $tab = false ) {
840
+function wpinv_get_settings_tab_sections($tab = false) {
841 841
     $tabs     = false;
842 842
     $sections = wpinv_get_registered_settings_sections();
843 843
 
844
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
845
-        $tabs = $sections[ $tab ];
846
-    } else if ( $tab ) {
844
+    if ($tab && !empty($sections[$tab])) {
845
+        $tabs = $sections[$tab];
846
+    } else if ($tab) {
847 847
         $tabs = false;
848 848
     }
849 849
 
@@ -853,143 +853,143 @@  discard block
 block discarded – undo
853 853
 function wpinv_get_registered_settings_sections() {
854 854
     static $sections = false;
855 855
 
856
-    if ( false !== $sections ) {
856
+    if (false !== $sections) {
857 857
         return $sections;
858 858
     }
859 859
 
860 860
     $sections = array(
861
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
862
-            'main' => __( 'General Settings', 'invoicing' ),
863
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
864
-            'labels' => __( 'Label Texts', 'invoicing' ),
865
-        ) ),
866
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
867
-            'main' => __( 'Gateway Settings', 'invoicing' ),
868
-        ) ),
869
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
870
-            'main' => __( 'Tax Settings', 'invoicing' ),
871
-            'rates' => __( 'Tax Rates', 'invoicing' ),
872
-        ) ),
873
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
874
-            'main' => __( 'Email Settings', 'invoicing' ),
875
-        ) ),
876
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
877
-            'main' => __( 'Privacy policy', 'invoicing' ),
878
-        ) ),
879
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
880
-            'main' => __( 'Miscellaneous', 'invoicing' ),
881
-            'fields' => __( 'Fields Settings', 'invoicing' ),
882
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
883
-        ) ),
884
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
885
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
886
-        ) ),
861
+        'general' => apply_filters('wpinv_settings_sections_general', array(
862
+            'main' => __('General Settings', 'invoicing'),
863
+            'currency_section' => __('Currency Settings', 'invoicing'),
864
+            'labels' => __('Label Texts', 'invoicing'),
865
+        )),
866
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
867
+            'main' => __('Gateway Settings', 'invoicing'),
868
+        )),
869
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
870
+            'main' => __('Tax Settings', 'invoicing'),
871
+            'rates' => __('Tax Rates', 'invoicing'),
872
+        )),
873
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
874
+            'main' => __('Email Settings', 'invoicing'),
875
+        )),
876
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
877
+            'main' => __('Privacy policy', 'invoicing'),
878
+        )),
879
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
880
+            'main' => __('Miscellaneous', 'invoicing'),
881
+            'fields' => __('Fields Settings', 'invoicing'),
882
+            'custom-css' => __('Custom CSS', 'invoicing'),
883
+        )),
884
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
885
+            'main' => __('Diagnostic Tools', 'invoicing'),
886
+        )),
887 887
     );
888 888
 
889
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
889
+    $sections = apply_filters('wpinv_settings_sections', $sections);
890 890
 
891 891
     return $sections;
892 892
 }
893 893
 
894
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
894
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
895 895
 	$pages_options = array();
896 896
 
897
-	if( $default_label !== NULL && $default_label !== false ) {
898
-		$pages_options = array( '' => $default_label ); // Blank option
897
+	if ($default_label !== NULL && $default_label !== false) {
898
+		$pages_options = array('' => $default_label); // Blank option
899 899
 	}
900 900
 
901 901
 	$pages = get_pages();
902
-	if ( $pages ) {
903
-		foreach ( $pages as $page ) {
902
+	if ($pages) {
903
+		foreach ($pages as $page) {
904 904
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
905
-            $pages_options[ $page->ID ] = $title;
905
+            $pages_options[$page->ID] = $title;
906 906
 		}
907 907
 	}
908 908
 
909 909
 	return $pages_options;
910 910
 }
911 911
 
912
-function wpinv_header_callback( $args ) {
913
-	if ( !empty( $args['desc'] ) ) {
912
+function wpinv_header_callback($args) {
913
+	if (!empty($args['desc'])) {
914 914
         echo $args['desc'];
915 915
     }
916 916
 }
917 917
 
918
-function wpinv_hidden_callback( $args ) {
918
+function wpinv_hidden_callback($args) {
919 919
 	global $wpinv_options;
920 920
 
921
-	if ( isset( $args['set_value'] ) ) {
921
+	if (isset($args['set_value'])) {
922 922
 		$value = $args['set_value'];
923
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
924
-		$value = $wpinv_options[ $args['id'] ];
923
+	} elseif (isset($wpinv_options[$args['id']])) {
924
+		$value = $wpinv_options[$args['id']];
925 925
 	} else {
926
-		$value = isset( $args['std'] ) ? $args['std'] : '';
926
+		$value = isset($args['std']) ? $args['std'] : '';
927 927
 	}
928 928
 
929
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
929
+	if (isset($args['faux']) && true === $args['faux']) {
930 930
 		$args['readonly'] = true;
931
-		$value = isset( $args['std'] ) ? $args['std'] : '';
931
+		$value = isset($args['std']) ? $args['std'] : '';
932 932
 		$name  = '';
933 933
 	} else {
934
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
934
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
935 935
 	}
936 936
 
937
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
937
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
938 938
     
939 939
 	echo $html;
940 940
 }
941 941
 
942
-function wpinv_checkbox_callback( $args ) {
942
+function wpinv_checkbox_callback($args) {
943 943
 	global $wpinv_options;
944 944
     
945
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
945
+    $sanitize_id = wpinv_sanitize_key($args['id']);
946 946
 
947
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
947
+	if (isset($args['faux']) && true === $args['faux']) {
948 948
 		$name = '';
949 949
 	} else {
950 950
 		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
951 951
 	}
952 952
 
953
-	$checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : '';
953
+	$checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : '';
954 954
 	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
955
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
955
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
956 956
 
957 957
 	echo $html;
958 958
 }
959 959
 
960
-function wpinv_multicheck_callback( $args ) {
960
+function wpinv_multicheck_callback($args) {
961 961
 	global $wpinv_options;
962 962
 
963
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
964
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
963
+	$sanitize_id = wpinv_sanitize_key($args['id']);
964
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
965 965
 
966
-	if ( ! empty( $args['options'] ) ) {
966
+	if (!empty($args['options'])) {
967 967
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
968
-        foreach( $args['options'] as $key => $option ):
969
-			$sanitize_key = wpinv_sanitize_key( $key );
970
-			if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { 
968
+        foreach ($args['options'] as $key => $option):
969
+			$sanitize_key = wpinv_sanitize_key($key);
970
+			if (isset($wpinv_options[$args['id']][$sanitize_key])) { 
971 971
 				$enabled = $sanitize_key;
972 972
 			} else { 
973 973
 				$enabled = NULL; 
974 974
 			}
975
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
976
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
975
+			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
976
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
977 977
 		endforeach;
978 978
 		echo '</div>';
979 979
 		echo '<p class="description">' . $args['desc'] . '</p>';
980 980
 	}
981 981
 }
982 982
 
983
-function wpinv_payment_icons_callback( $args ) {
983
+function wpinv_payment_icons_callback($args) {
984 984
 	global $wpinv_options;
985 985
     
986
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
986
+    $sanitize_id = wpinv_sanitize_key($args['id']);
987 987
 
988
-	if ( ! empty( $args['options'] ) ) {
989
-		foreach( $args['options'] as $key => $option ) {
990
-            $sanitize_key = wpinv_sanitize_key( $key );
988
+	if (!empty($args['options'])) {
989
+		foreach ($args['options'] as $key => $option) {
990
+            $sanitize_key = wpinv_sanitize_key($key);
991 991
             
992
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
992
+			if (isset($wpinv_options[$args['id']][$key])) {
993 993
 				$enabled = $option;
994 994
 			} else {
995 995
 				$enabled = NULL;
@@ -997,197 +997,197 @@  discard block
 block discarded – undo
997 997
 
998 998
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
999 999
 
1000
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
1000
+				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
1001 1001
 
1002
-				if ( wpinv_string_is_image_url( $key ) ) {
1003
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1002
+				if (wpinv_string_is_image_url($key)) {
1003
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1004 1004
 				} else {
1005
-					$card = strtolower( str_replace( ' ', '', $option ) );
1005
+					$card = strtolower(str_replace(' ', '', $option));
1006 1006
 
1007
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
1008
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
1007
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
1008
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
1009 1009
 					} else {
1010
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
1010
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
1011 1011
 						$content_dir = WP_CONTENT_DIR;
1012 1012
 
1013
-						if ( function_exists( 'wp_normalize_path' ) ) {
1013
+						if (function_exists('wp_normalize_path')) {
1014 1014
 							// Replaces backslashes with forward slashes for Windows systems
1015
-							$image = wp_normalize_path( $image );
1016
-							$content_dir = wp_normalize_path( $content_dir );
1015
+							$image = wp_normalize_path($image);
1016
+							$content_dir = wp_normalize_path($content_dir);
1017 1017
 						}
1018 1018
 
1019
-						$image = str_replace( $content_dir, content_url(), $image );
1019
+						$image = str_replace($content_dir, content_url(), $image);
1020 1020
 					}
1021 1021
 
1022
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1022
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1023 1023
 				}
1024 1024
 			echo $option . '</label>';
1025 1025
 		}
1026
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
1026
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
1027 1027
 	}
1028 1028
 }
1029 1029
 
1030
-function wpinv_radio_callback( $args ) {
1030
+function wpinv_radio_callback($args) {
1031 1031
 	global $wpinv_options;
1032 1032
     
1033
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1033
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1034 1034
     
1035
-    foreach ( $args['options'] as $key => $option ) :
1036
-		$sanitize_key = wpinv_sanitize_key( $key );
1035
+    foreach ($args['options'] as $key => $option) :
1036
+		$sanitize_key = wpinv_sanitize_key($key);
1037 1037
         
1038 1038
         $checked = false;
1039 1039
 
1040
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
1040
+		if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key)
1041 1041
 			$checked = true;
1042
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
1042
+		elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']]))
1043 1043
 			$checked = true;
1044 1044
 
1045 1045
 		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
1046
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
1046
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>';
1047 1047
 	endforeach;
1048 1048
 
1049
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
1049
+	echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
1050 1050
 }
1051 1051
 
1052
-function wpinv_gateways_callback( $args ) {
1052
+function wpinv_gateways_callback($args) {
1053 1053
 	global $wpinv_options;
1054 1054
     
1055
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1055
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1056 1056
 
1057
-	foreach ( $args['options'] as $key => $option ) :
1058
-		$sanitize_key = wpinv_sanitize_key( $key );
1057
+	foreach ($args['options'] as $key => $option) :
1058
+		$sanitize_key = wpinv_sanitize_key($key);
1059 1059
         
1060
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
1060
+        if (isset($wpinv_options['gateways'][$key]))
1061 1061
 			$enabled = '1';
1062 1062
 		else
1063 1063
 			$enabled = null;
1064 1064
 
1065
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
1066
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
1065
+		echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
1066
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
1067 1067
 	endforeach;
1068 1068
 }
1069 1069
 
1070 1070
 function wpinv_gateway_select_callback($args) {
1071 1071
 	global $wpinv_options;
1072 1072
     
1073
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1074
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
1073
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1074
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
1075 1075
 
1076
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
1076
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
1077 1077
 
1078
-	foreach ( $args['options'] as $key => $option ) :
1079
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1080
-            $selected = selected( $key, $args['selected'], false );
1078
+	foreach ($args['options'] as $key => $option) :
1079
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1080
+            $selected = selected($key, $args['selected'], false);
1081 1081
         } else {
1082
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
1082
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
1083 1083
         }
1084
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1084
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
1085 1085
 	endforeach;
1086 1086
 
1087 1087
 	echo '</select>';
1088
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1088
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1089 1089
 }
1090 1090
 
1091
-function wpinv_text_callback( $args ) {
1091
+function wpinv_text_callback($args) {
1092 1092
 	global $wpinv_options;
1093 1093
     
1094
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1094
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1095 1095
 
1096
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1097
-		$value = $wpinv_options[ $args['id'] ];
1096
+	if (isset($wpinv_options[$args['id']])) {
1097
+		$value = $wpinv_options[$args['id']];
1098 1098
 	} else {
1099
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1099
+		$value = isset($args['std']) ? $args['std'] : '';
1100 1100
 	}
1101 1101
 
1102
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1102
+	if (isset($args['faux']) && true === $args['faux']) {
1103 1103
 		$args['readonly'] = true;
1104
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1104
+		$value = isset($args['std']) ? $args['std'] : '';
1105 1105
 		$name  = '';
1106 1106
 	} else {
1107
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1107
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1108 1108
 	}
1109
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1109
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1110 1110
 
1111 1111
 	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1112
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1113
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
1114
-	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1112
+	$size     = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1113
+	$html     = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>';
1114
+	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1115 1115
 
1116 1116
 	echo $html;
1117 1117
 }
1118 1118
 
1119
-function wpinv_number_callback( $args ) {
1119
+function wpinv_number_callback($args) {
1120 1120
 	global $wpinv_options;
1121 1121
     
1122
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1122
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1123 1123
 
1124
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1125
-		$value = $wpinv_options[ $args['id'] ];
1124
+	if (isset($wpinv_options[$args['id']])) {
1125
+		$value = $wpinv_options[$args['id']];
1126 1126
 	} else {
1127
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1127
+		$value = isset($args['std']) ? $args['std'] : '';
1128 1128
 	}
1129 1129
 
1130
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1130
+	if (isset($args['faux']) && true === $args['faux']) {
1131 1131
 		$args['readonly'] = true;
1132
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1132
+		$value = isset($args['std']) ? $args['std'] : '';
1133 1133
 		$name  = '';
1134 1134
 	} else {
1135
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1135
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1136 1136
 	}
1137 1137
 
1138
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
1139
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
1140
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
1141
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1138
+	$max  = isset($args['max']) ? $args['max'] : 999999;
1139
+	$min  = isset($args['min']) ? $args['min'] : 0;
1140
+	$step = isset($args['step']) ? $args['step'] : 1;
1141
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1142 1142
 
1143
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1144
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
1145
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1143
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1144
+	$html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>';
1145
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1146 1146
 
1147 1147
 	echo $html;
1148 1148
 }
1149 1149
 
1150
-function wpinv_textarea_callback( $args ) {
1150
+function wpinv_textarea_callback($args) {
1151 1151
 	global $wpinv_options;
1152 1152
     
1153
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1153
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1154 1154
 
1155
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1156
-		$value = $wpinv_options[ $args['id'] ];
1155
+	if (isset($wpinv_options[$args['id']])) {
1156
+		$value = $wpinv_options[$args['id']];
1157 1157
 	} else {
1158
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1158
+		$value = isset($args['std']) ? $args['std'] : '';
1159 1159
 	}
1160 1160
     
1161
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1162
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
1161
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1162
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
1163 1163
 
1164
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
1165
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1164
+	$html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
1165
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1166 1166
 
1167 1167
 	echo $html;
1168 1168
 }
1169 1169
 
1170
-function wpinv_password_callback( $args ) {
1170
+function wpinv_password_callback($args) {
1171 1171
 	global $wpinv_options;
1172 1172
     
1173
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1173
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1174 1174
 
1175
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1176
-		$value = $wpinv_options[ $args['id'] ];
1175
+	if (isset($wpinv_options[$args['id']])) {
1176
+		$value = $wpinv_options[$args['id']];
1177 1177
 	} else {
1178
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1178
+		$value = isset($args['std']) ? $args['std'] : '';
1179 1179
 	}
1180 1180
 
1181
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1182
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
1183
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1181
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1182
+	$html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
1183
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1184 1184
 
1185 1185
 	echo $html;
1186 1186
 }
1187 1187
 
1188 1188
 function wpinv_missing_callback($args) {
1189 1189
 	printf(
1190
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
1190
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
1191 1191
 		'<strong>' . $args['id'] . '</strong>'
1192 1192
 	);
1193 1193
 }
@@ -1195,133 +1195,133 @@  discard block
 block discarded – undo
1195 1195
 function wpinv_select_callback($args) {
1196 1196
 	global $wpinv_options;
1197 1197
     
1198
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1198
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1199 1199
 
1200
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1201
-		$value = $wpinv_options[ $args['id'] ];
1200
+	if (isset($wpinv_options[$args['id']])) {
1201
+		$value = $wpinv_options[$args['id']];
1202 1202
 	} else {
1203
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1203
+		$value = isset($args['std']) ? $args['std'] : '';
1204 1204
 	}
1205 1205
     
1206
-    if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1206
+    if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1207 1207
         $value = $args['selected'];
1208 1208
     }
1209 1209
 
1210
-	if ( isset( $args['placeholder'] ) ) {
1210
+	if (isset($args['placeholder'])) {
1211 1211
 		$placeholder = $args['placeholder'];
1212 1212
 	} else {
1213 1213
 		$placeholder = '';
1214 1214
 	}
1215 1215
     
1216
-    if( !empty( $args['onchange'] ) ) {
1217
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
1216
+    if (!empty($args['onchange'])) {
1217
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
1218 1218
     } else {
1219 1219
         $onchange = '';
1220 1220
     }
1221 1221
 
1222
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
1222
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
1223 1223
 
1224
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
1224
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '"  name="wpinv_settings[' . esc_attr($args['id']) . ']" data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />';
1225 1225
 
1226
-	foreach ( $args['options'] as $option => $name ) {
1227
-		$selected = selected( $option, $value, false );
1228
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1226
+	foreach ($args['options'] as $option => $name) {
1227
+		$selected = selected($option, $value, false);
1228
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1229 1229
 	}
1230 1230
 
1231 1231
 	$html .= '</select>';
1232
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1232
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1233 1233
 
1234 1234
 	echo $html;
1235 1235
 }
1236 1236
 
1237
-function wpinv_color_select_callback( $args ) {
1237
+function wpinv_color_select_callback($args) {
1238 1238
 	global $wpinv_options;
1239 1239
     
1240
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1240
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1241 1241
 
1242
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1243
-		$value = $wpinv_options[ $args['id'] ];
1242
+	if (isset($wpinv_options[$args['id']])) {
1243
+		$value = $wpinv_options[$args['id']];
1244 1244
 	} else {
1245
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1245
+		$value = isset($args['std']) ? $args['std'] : '';
1246 1246
 	}
1247 1247
 
1248
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
1248
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
1249 1249
 
1250
-	foreach ( $args['options'] as $option => $color ) {
1251
-		$selected = selected( $option, $value, false );
1252
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
1250
+	foreach ($args['options'] as $option => $color) {
1251
+		$selected = selected($option, $value, false);
1252
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
1253 1253
 	}
1254 1254
 
1255 1255
 	$html .= '</select>';
1256
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1256
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1257 1257
 
1258 1258
 	echo $html;
1259 1259
 }
1260 1260
 
1261
-function wpinv_rich_editor_callback( $args ) {
1261
+function wpinv_rich_editor_callback($args) {
1262 1262
 	global $wpinv_options, $wp_version;
1263 1263
     
1264
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1264
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1265 1265
 
1266
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1267
-		$value = $wpinv_options[ $args['id'] ];
1266
+	if (isset($wpinv_options[$args['id']])) {
1267
+		$value = $wpinv_options[$args['id']];
1268 1268
 
1269
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
1270
-			$value = isset( $args['std'] ) ? $args['std'] : '';
1269
+		if (empty($args['allow_blank']) && empty($value)) {
1270
+			$value = isset($args['std']) ? $args['std'] : '';
1271 1271
 		}
1272 1272
 	} else {
1273
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1273
+		$value = isset($args['std']) ? $args['std'] : '';
1274 1274
 	}
1275 1275
 
1276
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
1276
+	$rows = isset($args['size']) ? $args['size'] : 20;
1277 1277
 
1278
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
1278
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
1279 1279
 		ob_start();
1280
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
1280
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false));
1281 1281
 		$html = ob_get_clean();
1282 1282
 	} else {
1283
-		$html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
1283
+		$html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>';
1284 1284
 	}
1285 1285
 
1286
-	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1286
+	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1287 1287
 
1288 1288
 	echo $html;
1289 1289
 }
1290 1290
 
1291
-function wpinv_upload_callback( $args ) {
1291
+function wpinv_upload_callback($args) {
1292 1292
 	global $wpinv_options;
1293 1293
     
1294
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1294
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1295 1295
 
1296
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1296
+	if (isset($wpinv_options[$args['id']])) {
1297 1297
 		$value = $wpinv_options[$args['id']];
1298 1298
 	} else {
1299 1299
 		$value = isset($args['std']) ? $args['std'] : '';
1300 1300
 	}
1301 1301
 
1302
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1303
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
1304
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
1305
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1302
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1303
+	$html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
1304
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
1305
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1306 1306
 
1307 1307
 	echo $html;
1308 1308
 }
1309 1309
 
1310
-function wpinv_color_callback( $args ) {
1310
+function wpinv_color_callback($args) {
1311 1311
 	global $wpinv_options;
1312 1312
     
1313
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1313
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1314 1314
 
1315
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1316
-		$value = $wpinv_options[ $args['id'] ];
1315
+	if (isset($wpinv_options[$args['id']])) {
1316
+		$value = $wpinv_options[$args['id']];
1317 1317
 	} else {
1318
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1318
+		$value = isset($args['std']) ? $args['std'] : '';
1319 1319
 	}
1320 1320
 
1321
-	$default = isset( $args['std'] ) ? $args['std'] : '';
1321
+	$default = isset($args['std']) ? $args['std'] : '';
1322 1322
 
1323
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
1324
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1323
+	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />';
1324
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1325 1325
 
1326 1326
 	echo $html;
1327 1327
 }
@@ -1329,9 +1329,9 @@  discard block
 block discarded – undo
1329 1329
 function wpinv_country_states_callback($args) {
1330 1330
 	global $wpinv_options;
1331 1331
     
1332
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1332
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1333 1333
 
1334
-	if ( isset( $args['placeholder'] ) ) {
1334
+	if (isset($args['placeholder'])) {
1335 1335
 		$placeholder = $args['placeholder'];
1336 1336
 	} else {
1337 1337
 		$placeholder = '';
@@ -1339,16 +1339,16 @@  discard block
 block discarded – undo
1339 1339
 
1340 1340
 	$states = wpinv_get_country_states();
1341 1341
 
1342
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
1343
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
1342
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
1343
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
1344 1344
 
1345
-	foreach ( $states as $option => $name ) {
1346
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
1347
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1345
+	foreach ($states as $option => $name) {
1346
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
1347
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1348 1348
 	}
1349 1349
 
1350 1350
 	$html .= '</select>';
1351
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1351
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1352 1352
 
1353 1353
 	echo $html;
1354 1354
 }
@@ -1363,96 +1363,96 @@  discard block
 block discarded – undo
1363 1363
 	<table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts">
1364 1364
 		<thead>
1365 1365
 			<tr>
1366
-				<th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th>
1367
-				<th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th>
1368
-                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th>
1369
-                <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
1370
-                <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th>
1371
-				<th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th>
1366
+				<th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th>
1367
+				<th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th>
1368
+                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th>
1369
+                <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
1370
+                <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th>
1371
+				<th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th>
1372 1372
 			</tr>
1373 1373
 		</thead>
1374 1374
         <tbody>
1375
-		<?php if( !empty( $rates ) ) : ?>
1376
-			<?php foreach( $rates as $key => $rate ) : ?>
1375
+		<?php if (!empty($rates)) : ?>
1376
+			<?php foreach ($rates as $key => $rate) : ?>
1377 1377
             <?php 
1378
-            $sanitized_key = wpinv_sanitize_key( $key );
1378
+            $sanitized_key = wpinv_sanitize_key($key);
1379 1379
             ?>
1380 1380
 			<tr>
1381 1381
 				<td class="wpinv_tax_country">
1382 1382
 					<?php
1383
-					echo wpinv_html_select( array(
1384
-						'options'          => wpinv_get_country_list( true ),
1383
+					echo wpinv_html_select(array(
1384
+						'options'          => wpinv_get_country_list(true),
1385 1385
 						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
1386 1386
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
1387 1387
 						'selected'         => $rate['country'],
1388 1388
 						'show_option_all'  => false,
1389 1389
 						'show_option_none' => false,
1390 1390
 						'class'            => 'wpinv-tax-country wpi_select2',
1391
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1392
-					) );
1391
+						'placeholder'      => __('Choose a country', 'invoicing')
1392
+					));
1393 1393
 					?>
1394 1394
 				</td>
1395 1395
 				<td class="wpinv_tax_state">
1396 1396
 					<?php
1397
-					$states = wpinv_get_country_states( $rate['country'] );
1398
-					if( !empty( $states ) ) {
1399
-						echo wpinv_html_select( array(
1400
-							'options'          => array_merge( array( '' => '' ), $states ),
1397
+					$states = wpinv_get_country_states($rate['country']);
1398
+					if (!empty($states)) {
1399
+						echo wpinv_html_select(array(
1400
+							'options'          => array_merge(array('' => ''), $states),
1401 1401
 							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
1402 1402
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
1403 1403
 							'selected'         => $rate['state'],
1404 1404
 							'show_option_all'  => false,
1405 1405
 							'show_option_none' => false,
1406 1406
                             'class'            => 'wpi_select2',
1407
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
1408
-						) );
1407
+							'placeholder'      => __('Choose a state', 'invoicing')
1408
+						));
1409 1409
 					} else {
1410
-						echo wpinv_html_text( array(
1410
+						echo wpinv_html_text(array(
1411 1411
 							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
1412
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
1412
+							'value' => !empty($rate['state']) ? $rate['state'] : '',
1413 1413
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
1414
-						) );
1414
+						));
1415 1415
 					}
1416 1416
 					?>
1417 1417
 				</td>
1418 1418
 				<td class="wpinv_tax_global">
1419
-					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/>
1420
-					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1419
+					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/>
1420
+					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1421 1421
 				</td>
1422
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td>
1423
-                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td>
1424
-				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1422
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td>
1423
+                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td>
1424
+				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1425 1425
 			</tr>
1426 1426
 			<?php endforeach; ?>
1427 1427
 		<?php else : ?>
1428 1428
 			<tr>
1429 1429
 				<td class="wpinv_tax_country">
1430 1430
 					<?php
1431
-					echo wpinv_html_select( array(
1432
-						'options'          => wpinv_get_country_list( true ),
1431
+					echo wpinv_html_select(array(
1432
+						'options'          => wpinv_get_country_list(true),
1433 1433
 						'name'             => 'tax_rates[0][country]',
1434 1434
 						'show_option_all'  => false,
1435 1435
 						'show_option_none' => false,
1436 1436
 						'class'            => 'wpinv-tax-country wpi_select2',
1437
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1438
-					) ); ?>
1437
+						'placeholder'      => __('Choose a country', 'invoicing')
1438
+					)); ?>
1439 1439
 				</td>
1440 1440
 				<td class="wpinv_tax_state">
1441
-					<?php echo wpinv_html_text( array(
1441
+					<?php echo wpinv_html_text(array(
1442 1442
 						'name' => 'tax_rates[0][state]'
1443
-					) ); ?>
1443
+					)); ?>
1444 1444
 				</td>
1445 1445
 				<td class="wpinv_tax_global">
1446 1446
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
1447
-					<label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1447
+					<label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1448 1448
 				</td>
1449
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td>
1449
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float) wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float) wpinv_get_option('tax_rate', 0); ?>"/></td>
1450 1450
                 <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td>
1451
-				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1451
+				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1452 1452
 			</tr>
1453 1453
 		<?php endif; ?>
1454 1454
         </tbody>
1455
-        <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot>
1455
+        <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot>
1456 1456
 	</table>
1457 1457
 	<?php
1458 1458
 	echo ob_get_clean();
@@ -1463,76 +1463,76 @@  discard block
 block discarded – undo
1463 1463
     ob_start(); ?>
1464 1464
     </td><tr>
1465 1465
     <td colspan="2" class="wpinv_tools_tdbox">
1466
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1467
-    <?php do_action( 'wpinv_tools_before' ); ?>
1466
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1467
+    <?php do_action('wpinv_tools_before'); ?>
1468 1468
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
1469 1469
         <thead>
1470 1470
             <tr>
1471
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
1472
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
1473
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
1471
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
1472
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
1473
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
1474 1474
             </tr>
1475 1475
         </thead>
1476
-            <?php do_action( 'wpinv_tools_row' ); ?>
1476
+            <?php do_action('wpinv_tools_row'); ?>
1477 1477
         <tbody>
1478 1478
         </tbody>
1479 1479
     </table>
1480
-    <?php do_action( 'wpinv_tools_after' ); ?>
1480
+    <?php do_action('wpinv_tools_after'); ?>
1481 1481
     <?php
1482 1482
     echo ob_get_clean();
1483 1483
 }
1484 1484
 
1485
-function wpinv_descriptive_text_callback( $args ) {
1486
-	echo wp_kses_post( $args['desc'] );
1485
+function wpinv_descriptive_text_callback($args) {
1486
+	echo wp_kses_post($args['desc']);
1487 1487
 }
1488 1488
 
1489
-function wpinv_hook_callback( $args ) {
1490
-	do_action( 'wpinv_' . $args['id'], $args );
1489
+function wpinv_hook_callback($args) {
1490
+	do_action('wpinv_' . $args['id'], $args);
1491 1491
 }
1492 1492
 
1493 1493
 function wpinv_set_settings_cap() {
1494 1494
 	return wpinv_get_capability();
1495 1495
 }
1496
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1496
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1497 1497
 
1498
-function wpinv_settings_sanitize_input( $value, $key ) {
1499
-    if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) {
1500
-        $value = wpinv_sanitize_amount( $value, 4 );
1498
+function wpinv_settings_sanitize_input($value, $key) {
1499
+    if ($key == 'tax_rate' || $key == 'eu_fallback_rate') {
1500
+        $value = wpinv_sanitize_amount($value, 4);
1501 1501
         $value = $value >= 100 ? 99 : $value;
1502 1502
     }
1503 1503
         
1504 1504
     return $value;
1505 1505
 }
1506
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1506
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1507 1507
 
1508
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1509
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1510
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1508
+function wpinv_on_update_settings($old_value, $value, $option) {
1509
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1510
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1511 1511
     
1512
-    if ( $old != $new ) {
1513
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1512
+    if ($old != $new) {
1513
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1514 1514
     }
1515 1515
 }
1516
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1517
-add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1518
-add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1519
-add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1520
-add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1521
-add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1522
-add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1523
-add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1524
-add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1525
-add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1526
-add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1527
-
1528
-function wpinv_settings_tab_bottom_emails( $active_tab, $section ) {
1516
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1517
+add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1518
+add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1519
+add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1520
+add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1521
+add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1522
+add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1523
+add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1524
+add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1525
+add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2);
1526
+add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2);
1527
+
1528
+function wpinv_settings_tab_bottom_emails($active_tab, $section) {
1529 1529
     ?>
1530 1530
     <div class="wpinv-email-wc-row ">
1531 1531
         <div class="wpinv-email-wc-td">
1532
-            <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3>
1532
+            <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3>
1533 1533
             <p class="wpinv-email-wc-description">
1534 1534
                 <?php
1535
-                $description = __( 'The following wildcards can be used in email subjects, heading and content:<br>
1535
+                $description = __('The following wildcards can be used in email subjects, heading and content:<br>
1536 1536
                     <strong>{site_title} :</strong> Site Title<br>
1537 1537
                     <strong>{name} :</strong> Customer\'s full name<br>
1538 1538
                     <strong>{first_name} :</strong> Customer\'s first name<br>
@@ -1546,7 +1546,7 @@  discard block
 block discarded – undo
1546 1546
                     <strong>{invoice_due_date} :</strong> The date the invoice is due<br>
1547 1547
                     <strong>{date} :</strong> Today\'s date.<br>
1548 1548
                     <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br>
1549
-                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' );
1549
+                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing');
1550 1550
                 echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section);
1551 1551
                 ?>
1552 1552
             </p>
Please login to merge, or discard this patch.
includes/class-getpaid-post-types.php 2 patches
Indentation   +294 added lines, -294 removed lines patch added patch discarded remove patch
@@ -15,319 +15,319 @@
 block discarded – undo
15 15
 class GetPaid_Post_Types {
16 16
 
17 17
     /**
18
-	 * Hook in methods.
19
-	 */
20
-	public function __construct() {
21
-		add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 );
22
-		add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 );
23
-		add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
24
-		add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
25
-	}
18
+     * Hook in methods.
19
+     */
20
+    public function __construct() {
21
+        add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 );
22
+        add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 );
23
+        add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
24
+        add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
25
+    }
26 26
 
27
-	/**
28
-	 * Register core post types.
29
-	 */
30
-	public static function register_post_types() {
27
+    /**
28
+     * Register core post types.
29
+     */
30
+    public static function register_post_types() {
31 31
 
32
-		if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) {
33
-			return;
34
-		}
32
+        if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) {
33
+            return;
34
+        }
35 35
 
36
-		// Fires before registering post types.
37
-		do_action( 'getpaid_register_post_types' );
36
+        // Fires before registering post types.
37
+        do_action( 'getpaid_register_post_types' );
38 38
 
39
-		// Register item post type.
40
-		register_post_type(
41
-			'wpi_item',
42
-			apply_filters(
43
-				'wpinv_register_post_type_invoice_item',
44
-				array(
45
-					'labels'             => array(
46
-						'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
47
-						'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
48
-						'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
49
-						'name_admin_bar'     => _x( 'Item', 'add new on admin bar', 'invoicing' ),
50
-						'add_new'            => _x( 'Add New', 'Item', 'invoicing' ),
51
-						'add_new_item'       => __( 'Add New Item', 'invoicing' ),
52
-						'new_item'           => __( 'New Item', 'invoicing' ),
53
-						'edit_item'          => __( 'Edit Item', 'invoicing' ),
54
-						'view_item'          => __( 'View Item', 'invoicing' ),
55
-						'all_items'          => __( 'Items', 'invoicing' ),
56
-						'search_items'       => __( 'Search items', 'invoicing' ),
57
-						'parent_item_colon'  => __( 'Parent item:', 'invoicing' ),
58
-						'not_found'          => __( 'No items found.', 'invoicing' ),
59
-						'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
60
-					),
61
-					'description'           => __( 'This is where you can add new invoice items.', 'invoicing' ),
62
-					'public'                => false,
63
-					'has_archive'           => false,
64
-					'_builtin'              => false,
65
-					'show_ui'               => true,
66
-					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
67
-					'show_in_nav_menus'     => false,
68
-					'supports'              => array( 'title', 'excerpt' ),
69
-					'rewrite'               => false,
70
-					'query_var'             => false,
71
-					'capability_type'       => 'wpi_item',
72
-					'map_meta_cap'          => true,
73
-					'show_in_admin_bar'     => true,
74
-					'can_export'            => true,
75
-				)
76
-			)
77
-		);
39
+        // Register item post type.
40
+        register_post_type(
41
+            'wpi_item',
42
+            apply_filters(
43
+                'wpinv_register_post_type_invoice_item',
44
+                array(
45
+                    'labels'             => array(
46
+                        'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
47
+                        'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
48
+                        'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
49
+                        'name_admin_bar'     => _x( 'Item', 'add new on admin bar', 'invoicing' ),
50
+                        'add_new'            => _x( 'Add New', 'Item', 'invoicing' ),
51
+                        'add_new_item'       => __( 'Add New Item', 'invoicing' ),
52
+                        'new_item'           => __( 'New Item', 'invoicing' ),
53
+                        'edit_item'          => __( 'Edit Item', 'invoicing' ),
54
+                        'view_item'          => __( 'View Item', 'invoicing' ),
55
+                        'all_items'          => __( 'Items', 'invoicing' ),
56
+                        'search_items'       => __( 'Search items', 'invoicing' ),
57
+                        'parent_item_colon'  => __( 'Parent item:', 'invoicing' ),
58
+                        'not_found'          => __( 'No items found.', 'invoicing' ),
59
+                        'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
60
+                    ),
61
+                    'description'           => __( 'This is where you can add new invoice items.', 'invoicing' ),
62
+                    'public'                => false,
63
+                    'has_archive'           => false,
64
+                    '_builtin'              => false,
65
+                    'show_ui'               => true,
66
+                    'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
67
+                    'show_in_nav_menus'     => false,
68
+                    'supports'              => array( 'title', 'excerpt' ),
69
+                    'rewrite'               => false,
70
+                    'query_var'             => false,
71
+                    'capability_type'       => 'wpi_item',
72
+                    'map_meta_cap'          => true,
73
+                    'show_in_admin_bar'     => true,
74
+                    'can_export'            => true,
75
+                )
76
+            )
77
+        );
78 78
 
79
-		// Register payment form post type.
80
-		register_post_type(
81
-			'wpi_payment_form',
82
-			apply_filters(
83
-				'wpinv_register_post_type_payment_form',
84
-				array(
85
-					'labels'             => array(
86
-						'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
87
-						'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
88
-						'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
89
-						'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
90
-						'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
91
-						'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
92
-						'new_item'           => __( 'New Payment Form', 'invoicing' ),
93
-						'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
94
-						'view_item'          => __( 'View Payment Form', 'invoicing' ),
95
-						'all_items'          => __( 'Payment Forms', 'invoicing' ),
96
-						'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
97
-						'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
98
-						'not_found'          => __( 'No payment forms found.', 'invoicing' ),
99
-						'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' )
100
-					),
101
-					'description'        => __( 'Add new payment forms.', 'invoicing' ),
102
-					'public'             => false,
103
-					'show_ui'            => true,
104
-					'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true,
105
-					'show_in_nav_menus'  => false,
106
-					'query_var'          => false,
107
-					'rewrite'            => true,
108
-					'map_meta_cap'       => true,
109
-					'has_archive'        => false,
110
-					'hierarchical'       => false,
111
-					'menu_position'      => null,
112
-					'supports'           => array( 'title' ),
113
-					'menu_icon'          => 'dashicons-media-form',
114
-				)
115
-			)
116
-		);
79
+        // Register payment form post type.
80
+        register_post_type(
81
+            'wpi_payment_form',
82
+            apply_filters(
83
+                'wpinv_register_post_type_payment_form',
84
+                array(
85
+                    'labels'             => array(
86
+                        'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
87
+                        'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
88
+                        'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
89
+                        'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
90
+                        'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
91
+                        'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
92
+                        'new_item'           => __( 'New Payment Form', 'invoicing' ),
93
+                        'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
94
+                        'view_item'          => __( 'View Payment Form', 'invoicing' ),
95
+                        'all_items'          => __( 'Payment Forms', 'invoicing' ),
96
+                        'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
97
+                        'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
98
+                        'not_found'          => __( 'No payment forms found.', 'invoicing' ),
99
+                        'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' )
100
+                    ),
101
+                    'description'        => __( 'Add new payment forms.', 'invoicing' ),
102
+                    'public'             => false,
103
+                    'show_ui'            => true,
104
+                    'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true,
105
+                    'show_in_nav_menus'  => false,
106
+                    'query_var'          => false,
107
+                    'rewrite'            => true,
108
+                    'map_meta_cap'       => true,
109
+                    'has_archive'        => false,
110
+                    'hierarchical'       => false,
111
+                    'menu_position'      => null,
112
+                    'supports'           => array( 'title' ),
113
+                    'menu_icon'          => 'dashicons-media-form',
114
+                )
115
+            )
116
+        );
117 117
 
118
-		// Register invoice post type.
119
-		register_post_type(
120
-			'wpi_invoice',
121
-			apply_filters(
122
-				'wpinv_register_post_type_invoice',
123
-				array(
124
-					'labels'                 => array(
125
-						'name'                  => __( 'Invoices', 'invoicing' ),
126
-						'singular_name'         => __( 'Invoice', 'invoicing' ),
127
-						'all_items'             => __( 'Invoices', 'invoicing' ),
128
-						'menu_name'             => _x( 'Invoices', 'Admin menu name', 'invoicing' ),
129
-						'add_new'               => __( 'Add New', 'invoicing' ),
130
-						'add_new_item'          => __( 'Add new invoice', 'invoicing' ),
131
-						'edit'                  => __( 'Edit', 'invoicing' ),
132
-						'edit_item'             => __( 'Edit invoice', 'invoicing' ),
133
-						'new_item'              => __( 'New invoice', 'invoicing' ),
134
-						'view_item'             => __( 'View invoice', 'invoicing' ),
135
-						'view_items'            => __( 'View Invoices', 'invoicing' ),
136
-						'search_items'          => __( 'Search invoices', 'invoicing' ),
137
-						'not_found'             => __( 'No invoices found', 'invoicing' ),
138
-						'not_found_in_trash'    => __( 'No invoices found in trash', 'invoicing' ),
139
-						'parent'                => __( 'Parent invoice', 'invoicing' ),
140
-						'featured_image'        => __( 'Invoice image', 'invoicing' ),
141
-						'set_featured_image'    => __( 'Set invoice image', 'invoicing' ),
142
-						'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ),
143
-						'use_featured_image'    => __( 'Use as invoice image', 'invoicing' ),
144
-						'insert_into_item'      => __( 'Insert into invoice', 'invoicing' ),
145
-						'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ),
146
-						'filter_items_list'     => __( 'Filter invoices', 'invoicing' ),
147
-						'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ),
148
-						'items_list'            => __( 'Invoices list', 'invoicing' ),
149
-					),
150
-					'description'           => __( 'This is where invoices are stored.', 'invoicing' ),
151
-					'public'                => true,
152
-					'has_archive'           => false,
153
-					'publicly_queryable'    => true,
154
-        			'exclude_from_search'   => true,
155
-        			'show_ui'               => true,
156
-					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
157
-					'show_in_nav_menus'     => false,
158
-					'supports'              => array( 'title', 'author', 'excerpt'  ),
159
-					'rewrite'               => true,
160
-					'query_var'             => false,
161
-					'capability_type'       => 'wpi_invoice',
162
-					'map_meta_cap'          => true,
163
-					'show_in_admin_bar'     => true,
164
-					'can_export'            => true,
165
-					'hierarchical'          => false,
166
-					'menu_position'         => null,
167
-					'menu_icon'             => 'dashicons-media-spreadsheet',
168
-				)
169
-			)
170
-		);
118
+        // Register invoice post type.
119
+        register_post_type(
120
+            'wpi_invoice',
121
+            apply_filters(
122
+                'wpinv_register_post_type_invoice',
123
+                array(
124
+                    'labels'                 => array(
125
+                        'name'                  => __( 'Invoices', 'invoicing' ),
126
+                        'singular_name'         => __( 'Invoice', 'invoicing' ),
127
+                        'all_items'             => __( 'Invoices', 'invoicing' ),
128
+                        'menu_name'             => _x( 'Invoices', 'Admin menu name', 'invoicing' ),
129
+                        'add_new'               => __( 'Add New', 'invoicing' ),
130
+                        'add_new_item'          => __( 'Add new invoice', 'invoicing' ),
131
+                        'edit'                  => __( 'Edit', 'invoicing' ),
132
+                        'edit_item'             => __( 'Edit invoice', 'invoicing' ),
133
+                        'new_item'              => __( 'New invoice', 'invoicing' ),
134
+                        'view_item'             => __( 'View invoice', 'invoicing' ),
135
+                        'view_items'            => __( 'View Invoices', 'invoicing' ),
136
+                        'search_items'          => __( 'Search invoices', 'invoicing' ),
137
+                        'not_found'             => __( 'No invoices found', 'invoicing' ),
138
+                        'not_found_in_trash'    => __( 'No invoices found in trash', 'invoicing' ),
139
+                        'parent'                => __( 'Parent invoice', 'invoicing' ),
140
+                        'featured_image'        => __( 'Invoice image', 'invoicing' ),
141
+                        'set_featured_image'    => __( 'Set invoice image', 'invoicing' ),
142
+                        'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ),
143
+                        'use_featured_image'    => __( 'Use as invoice image', 'invoicing' ),
144
+                        'insert_into_item'      => __( 'Insert into invoice', 'invoicing' ),
145
+                        'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ),
146
+                        'filter_items_list'     => __( 'Filter invoices', 'invoicing' ),
147
+                        'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ),
148
+                        'items_list'            => __( 'Invoices list', 'invoicing' ),
149
+                    ),
150
+                    'description'           => __( 'This is where invoices are stored.', 'invoicing' ),
151
+                    'public'                => true,
152
+                    'has_archive'           => false,
153
+                    'publicly_queryable'    => true,
154
+                    'exclude_from_search'   => true,
155
+                    'show_ui'               => true,
156
+                    'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
157
+                    'show_in_nav_menus'     => false,
158
+                    'supports'              => array( 'title', 'author', 'excerpt'  ),
159
+                    'rewrite'               => true,
160
+                    'query_var'             => false,
161
+                    'capability_type'       => 'wpi_invoice',
162
+                    'map_meta_cap'          => true,
163
+                    'show_in_admin_bar'     => true,
164
+                    'can_export'            => true,
165
+                    'hierarchical'          => false,
166
+                    'menu_position'         => null,
167
+                    'menu_icon'             => 'dashicons-media-spreadsheet',
168
+                )
169
+            )
170
+        );
171 171
 
172
-		// Register discount post type.
173
-		register_post_type(
174
-			'wpi_discount',
175
-			apply_filters(
176
-				'wpinv_register_post_type_discount',
177
-				array(
178
-					'labels'                 => array(
179
-						'name'                  => __( 'Discounts', 'invoicing' ),
180
-						'singular_name'         => __( 'Discount', 'invoicing' ),
181
-						'all_items'             => __( 'Discounts', 'invoicing' ),
182
-						'menu_name'             => _x( 'Discounts', 'Admin menu name', 'invoicing' ),
183
-						'add_new'               => __( 'Add New', 'invoicing' ),
184
-						'add_new_item'          => __( 'Add new discount', 'invoicing' ),
185
-						'edit'                  => __( 'Edit', 'invoicing' ),
186
-						'edit_item'             => __( 'Edit discount', 'invoicing' ),
187
-						'new_item'              => __( 'New discount', 'invoicing' ),
188
-						'view_item'             => __( 'View discount', 'invoicing' ),
189
-						'view_items'            => __( 'View Discounts', 'invoicing' ),
190
-						'search_items'          => __( 'Search discounts', 'invoicing' ),
191
-						'not_found'             => __( 'No discounts found', 'invoicing' ),
192
-						'not_found_in_trash'    => __( 'No discounts found in trash', 'invoicing' ),
193
-						'parent'                => __( 'Parent discount', 'invoicing' ),
194
-						'featured_image'        => __( 'Discount image', 'invoicing' ),
195
-						'set_featured_image'    => __( 'Set discount image', 'invoicing' ),
196
-						'remove_featured_image' => __( 'Remove discount image', 'invoicing' ),
197
-						'use_featured_image'    => __( 'Use as discount image', 'invoicing' ),
198
-						'insert_into_item'      => __( 'Insert into discount', 'invoicing' ),
199
-						'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ),
200
-						'filter_items_list'     => __( 'Filter discounts', 'invoicing' ),
201
-						'items_list_navigation' => __( 'Discount navigation', 'invoicing' ),
202
-						'items_list'            => __( 'Discounts list', 'invoicing' ),
203
-					),
204
-					'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
205
-					'public'             => false,
206
-					'can_export'         => true,
207
-					'_builtin'           => false,
208
-					'publicly_queryable' => false,
209
-					'exclude_from_search'=> true,
210
-					'show_ui'            => true,
211
-					'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
212
-					'query_var'          => false,
213
-					'rewrite'            => false,
214
-					'capability_type'    => 'wpi_discount',
215
-					'map_meta_cap'       => true,
216
-					'has_archive'        => false,
217
-					'hierarchical'       => false,
218
-					'supports'           => array( 'title', 'excerpt' ),
219
-					'show_in_nav_menus'  => false,
220
-					'show_in_admin_bar'  => true,
221
-					'menu_position'      => null,
222
-				)
223
-			)
224
-		);
172
+        // Register discount post type.
173
+        register_post_type(
174
+            'wpi_discount',
175
+            apply_filters(
176
+                'wpinv_register_post_type_discount',
177
+                array(
178
+                    'labels'                 => array(
179
+                        'name'                  => __( 'Discounts', 'invoicing' ),
180
+                        'singular_name'         => __( 'Discount', 'invoicing' ),
181
+                        'all_items'             => __( 'Discounts', 'invoicing' ),
182
+                        'menu_name'             => _x( 'Discounts', 'Admin menu name', 'invoicing' ),
183
+                        'add_new'               => __( 'Add New', 'invoicing' ),
184
+                        'add_new_item'          => __( 'Add new discount', 'invoicing' ),
185
+                        'edit'                  => __( 'Edit', 'invoicing' ),
186
+                        'edit_item'             => __( 'Edit discount', 'invoicing' ),
187
+                        'new_item'              => __( 'New discount', 'invoicing' ),
188
+                        'view_item'             => __( 'View discount', 'invoicing' ),
189
+                        'view_items'            => __( 'View Discounts', 'invoicing' ),
190
+                        'search_items'          => __( 'Search discounts', 'invoicing' ),
191
+                        'not_found'             => __( 'No discounts found', 'invoicing' ),
192
+                        'not_found_in_trash'    => __( 'No discounts found in trash', 'invoicing' ),
193
+                        'parent'                => __( 'Parent discount', 'invoicing' ),
194
+                        'featured_image'        => __( 'Discount image', 'invoicing' ),
195
+                        'set_featured_image'    => __( 'Set discount image', 'invoicing' ),
196
+                        'remove_featured_image' => __( 'Remove discount image', 'invoicing' ),
197
+                        'use_featured_image'    => __( 'Use as discount image', 'invoicing' ),
198
+                        'insert_into_item'      => __( 'Insert into discount', 'invoicing' ),
199
+                        'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ),
200
+                        'filter_items_list'     => __( 'Filter discounts', 'invoicing' ),
201
+                        'items_list_navigation' => __( 'Discount navigation', 'invoicing' ),
202
+                        'items_list'            => __( 'Discounts list', 'invoicing' ),
203
+                    ),
204
+                    'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
205
+                    'public'             => false,
206
+                    'can_export'         => true,
207
+                    '_builtin'           => false,
208
+                    'publicly_queryable' => false,
209
+                    'exclude_from_search'=> true,
210
+                    'show_ui'            => true,
211
+                    'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
212
+                    'query_var'          => false,
213
+                    'rewrite'            => false,
214
+                    'capability_type'    => 'wpi_discount',
215
+                    'map_meta_cap'       => true,
216
+                    'has_archive'        => false,
217
+                    'hierarchical'       => false,
218
+                    'supports'           => array( 'title', 'excerpt' ),
219
+                    'show_in_nav_menus'  => false,
220
+                    'show_in_admin_bar'  => true,
221
+                    'menu_position'      => null,
222
+                )
223
+            )
224
+        );
225 225
 
226
-		do_action( 'getpaid_after_register_post_types' );
227
-	}
226
+        do_action( 'getpaid_after_register_post_types' );
227
+    }
228 228
 
229
-	/**
230
-	 * Register our custom post statuses.
231
-	 */
232
-	public static function register_post_status() {
229
+    /**
230
+     * Register our custom post statuses.
231
+     */
232
+    public static function register_post_status() {
233 233
 
234
-		$invoice_statuses = apply_filters(
235
-			'getpaid_register_invoice_post_statuses',
236
-			array(
234
+        $invoice_statuses = apply_filters(
235
+            'getpaid_register_invoice_post_statuses',
236
+            array(
237 237
 
238
-				'wpi-pending' => array(
239
-					'label'                     => _x( 'Pending Payment', 'Invoice status', 'invoicing' ),
240
-        			'public'                    => true,
241
-        			'exclude_from_search'       => true,
242
-        			'show_in_admin_all_list'    => true,
243
-					'show_in_admin_status_list' => true,
244
-					/* translators: %s: number of invoices */
245
-        			'label_count'               => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' )
246
-				),
238
+                'wpi-pending' => array(
239
+                    'label'                     => _x( 'Pending Payment', 'Invoice status', 'invoicing' ),
240
+                    'public'                    => true,
241
+                    'exclude_from_search'       => true,
242
+                    'show_in_admin_all_list'    => true,
243
+                    'show_in_admin_status_list' => true,
244
+                    /* translators: %s: number of invoices */
245
+                    'label_count'               => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' )
246
+                ),
247 247
 
248
-				'wpi-processing' => array(
249
-					'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
250
-        			'public'                    => true,
251
-        			'exclude_from_search'       => true,
252
-        			'show_in_admin_all_list'    => true,
253
-					'show_in_admin_status_list' => true,
254
-					/* translators: %s: number of invoices */
255
-        			'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
256
-				),
248
+                'wpi-processing' => array(
249
+                    'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
250
+                    'public'                    => true,
251
+                    'exclude_from_search'       => true,
252
+                    'show_in_admin_all_list'    => true,
253
+                    'show_in_admin_status_list' => true,
254
+                    /* translators: %s: number of invoices */
255
+                    'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
256
+                ),
257 257
 
258
-				'wpi-onhold' => array(
259
-					'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
260
-        			'public'                    => true,
261
-        			'exclude_from_search'       => true,
262
-        			'show_in_admin_all_list'    => true,
263
-					'show_in_admin_status_list' => true,
264
-					/* translators: %s: number of invoices */
265
-        			'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
266
-				),
258
+                'wpi-onhold' => array(
259
+                    'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
260
+                    'public'                    => true,
261
+                    'exclude_from_search'       => true,
262
+                    'show_in_admin_all_list'    => true,
263
+                    'show_in_admin_status_list' => true,
264
+                    /* translators: %s: number of invoices */
265
+                    'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
266
+                ),
267 267
 
268
-				'wpi-cancelled' => array(
269
-					'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
270
-        			'public'                    => true,
271
-        			'exclude_from_search'       => true,
272
-        			'show_in_admin_all_list'    => true,
273
-					'show_in_admin_status_list' => true,
274
-					/* translators: %s: number of invoices */
275
-        			'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
276
-				),
268
+                'wpi-cancelled' => array(
269
+                    'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
270
+                    'public'                    => true,
271
+                    'exclude_from_search'       => true,
272
+                    'show_in_admin_all_list'    => true,
273
+                    'show_in_admin_status_list' => true,
274
+                    /* translators: %s: number of invoices */
275
+                    'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
276
+                ),
277 277
 
278
-				'wpi-refunded' => array(
279
-					'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
280
-        			'public'                    => true,
281
-        			'exclude_from_search'       => true,
282
-        			'show_in_admin_all_list'    => true,
283
-					'show_in_admin_status_list' => true,
284
-					/* translators: %s: number of invoices */
285
-        			'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
286
-				),
278
+                'wpi-refunded' => array(
279
+                    'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
280
+                    'public'                    => true,
281
+                    'exclude_from_search'       => true,
282
+                    'show_in_admin_all_list'    => true,
283
+                    'show_in_admin_status_list' => true,
284
+                    /* translators: %s: number of invoices */
285
+                    'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
286
+                ),
287 287
 
288
-				'wpi-failed' => array(
289
-					'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
290
-        			'public'                    => true,
291
-        			'exclude_from_search'       => true,
292
-        			'show_in_admin_all_list'    => true,
293
-					'show_in_admin_status_list' => true,
294
-					/* translators: %s: number of invoices */
295
-        			'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
296
-				),
288
+                'wpi-failed' => array(
289
+                    'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
290
+                    'public'                    => true,
291
+                    'exclude_from_search'       => true,
292
+                    'show_in_admin_all_list'    => true,
293
+                    'show_in_admin_status_list' => true,
294
+                    /* translators: %s: number of invoices */
295
+                    'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
296
+                ),
297 297
 
298
-				'wpi-renewal' => array(
299
-					'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
300
-        			'public'                    => true,
301
-        			'exclude_from_search'       => true,
302
-        			'show_in_admin_all_list'    => true,
303
-					'show_in_admin_status_list' => true,
304
-					/* translators: %s: number of invoices */
305
-        			'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
306
-				)
307
-			)
308
-		);
298
+                'wpi-renewal' => array(
299
+                    'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
300
+                    'public'                    => true,
301
+                    'exclude_from_search'       => true,
302
+                    'show_in_admin_all_list'    => true,
303
+                    'show_in_admin_status_list' => true,
304
+                    /* translators: %s: number of invoices */
305
+                    'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
306
+                )
307
+            )
308
+        );
309 309
 
310
-		foreach ( $invoice_statuses as $invoice_statuse => $args ) {
311
-			register_post_status( $invoice_statuse, $args );
312
-		}
313
-	}
310
+        foreach ( $invoice_statuses as $invoice_statuse => $args ) {
311
+            register_post_status( $invoice_statuse, $args );
312
+        }
313
+    }
314 314
 
315
-	/**
316
-	 * Flush rewrite rules.
317
-	 */
318
-	public static function flush_rewrite_rules() {
319
-		flush_rewrite_rules();
320
-	}
315
+    /**
316
+     * Flush rewrite rules.
317
+     */
318
+    public static function flush_rewrite_rules() {
319
+        flush_rewrite_rules();
320
+    }
321 321
 
322
-	/**
323
-	 * Flush rules to prevent 404.
324
-	 *
325
-	 */
326
-	public static function maybe_flush_rewrite_rules() {
327
-		if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) {
328
-			update_option( 'getpaid_flushed_rewrite_rules', '1' );
329
-			self::flush_rewrite_rules();
330
-		}
331
-	}
322
+    /**
323
+     * Flush rules to prevent 404.
324
+     *
325
+     */
326
+    public static function maybe_flush_rewrite_rules() {
327
+        if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) {
328
+            update_option( 'getpaid_flushed_rewrite_rules', '1' );
329
+            self::flush_rewrite_rules();
330
+        }
331
+    }
332 332
 
333 333
 }
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Post types Class
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 	 * Hook in methods.
19 19
 	 */
20 20
 	public function __construct() {
21
-		add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 );
22
-		add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 );
23
-		add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
24
-		add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
21
+		add_action('init', array(__CLASS__, 'register_post_types'), 1);
22
+		add_action('init', array(__CLASS__, 'register_post_status'), 4);
23
+		add_action('getpaid_flush_rewrite_rules', array(__CLASS__, 'flush_rewrite_rules'));
24
+		add_action('getpaid_after_register_post_types', array(__CLASS__, 'maybe_flush_rewrite_rules'));
25 25
 	}
26 26
 
27 27
 	/**
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public static function register_post_types() {
31 31
 
32
-		if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) {
32
+		if (!is_blog_installed() || post_type_exists('wpi_item')) {
33 33
 			return;
34 34
 		}
35 35
 
36 36
 		// Fires before registering post types.
37
-		do_action( 'getpaid_register_post_types' );
37
+		do_action('getpaid_register_post_types');
38 38
 
39 39
 		// Register item post type.
40 40
 		register_post_type(
@@ -43,29 +43,29 @@  discard block
 block discarded – undo
43 43
 				'wpinv_register_post_type_invoice_item',
44 44
 				array(
45 45
 					'labels'             => array(
46
-						'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
47
-						'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
48
-						'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
49
-						'name_admin_bar'     => _x( 'Item', 'add new on admin bar', 'invoicing' ),
50
-						'add_new'            => _x( 'Add New', 'Item', 'invoicing' ),
51
-						'add_new_item'       => __( 'Add New Item', 'invoicing' ),
52
-						'new_item'           => __( 'New Item', 'invoicing' ),
53
-						'edit_item'          => __( 'Edit Item', 'invoicing' ),
54
-						'view_item'          => __( 'View Item', 'invoicing' ),
55
-						'all_items'          => __( 'Items', 'invoicing' ),
56
-						'search_items'       => __( 'Search items', 'invoicing' ),
57
-						'parent_item_colon'  => __( 'Parent item:', 'invoicing' ),
58
-						'not_found'          => __( 'No items found.', 'invoicing' ),
59
-						'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
46
+						'name'               => _x('Items', 'post type general name', 'invoicing'),
47
+						'singular_name'      => _x('Item', 'post type singular name', 'invoicing'),
48
+						'menu_name'          => _x('Items', 'admin menu', 'invoicing'),
49
+						'name_admin_bar'     => _x('Item', 'add new on admin bar', 'invoicing'),
50
+						'add_new'            => _x('Add New', 'Item', 'invoicing'),
51
+						'add_new_item'       => __('Add New Item', 'invoicing'),
52
+						'new_item'           => __('New Item', 'invoicing'),
53
+						'edit_item'          => __('Edit Item', 'invoicing'),
54
+						'view_item'          => __('View Item', 'invoicing'),
55
+						'all_items'          => __('Items', 'invoicing'),
56
+						'search_items'       => __('Search items', 'invoicing'),
57
+						'parent_item_colon'  => __('Parent item:', 'invoicing'),
58
+						'not_found'          => __('No items found.', 'invoicing'),
59
+						'not_found_in_trash' => __('No items found in trash.', 'invoicing')
60 60
 					),
61
-					'description'           => __( 'This is where you can add new invoice items.', 'invoicing' ),
61
+					'description'           => __('This is where you can add new invoice items.', 'invoicing'),
62 62
 					'public'                => false,
63 63
 					'has_archive'           => false,
64 64
 					'_builtin'              => false,
65 65
 					'show_ui'               => true,
66 66
 					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
67 67
 					'show_in_nav_menus'     => false,
68
-					'supports'              => array( 'title', 'excerpt' ),
68
+					'supports'              => array('title', 'excerpt'),
69 69
 					'rewrite'               => false,
70 70
 					'query_var'             => false,
71 71
 					'capability_type'       => 'wpi_item',
@@ -83,22 +83,22 @@  discard block
 block discarded – undo
83 83
 				'wpinv_register_post_type_payment_form',
84 84
 				array(
85 85
 					'labels'             => array(
86
-						'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
87
-						'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
88
-						'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
89
-						'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
90
-						'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
91
-						'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
92
-						'new_item'           => __( 'New Payment Form', 'invoicing' ),
93
-						'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
94
-						'view_item'          => __( 'View Payment Form', 'invoicing' ),
95
-						'all_items'          => __( 'Payment Forms', 'invoicing' ),
96
-						'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
97
-						'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
98
-						'not_found'          => __( 'No payment forms found.', 'invoicing' ),
99
-						'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' )
86
+						'name'               => _x('Payment Forms', 'post type general name', 'invoicing'),
87
+						'singular_name'      => _x('Payment Form', 'post type singular name', 'invoicing'),
88
+						'menu_name'          => _x('Payment Forms', 'admin menu', 'invoicing'),
89
+						'name_admin_bar'     => _x('Payment Form', 'add new on admin bar', 'invoicing'),
90
+						'add_new'            => _x('Add New', 'Payment Form', 'invoicing'),
91
+						'add_new_item'       => __('Add New Payment Form', 'invoicing'),
92
+						'new_item'           => __('New Payment Form', 'invoicing'),
93
+						'edit_item'          => __('Edit Payment Form', 'invoicing'),
94
+						'view_item'          => __('View Payment Form', 'invoicing'),
95
+						'all_items'          => __('Payment Forms', 'invoicing'),
96
+						'search_items'       => __('Search Payment Forms', 'invoicing'),
97
+						'parent_item_colon'  => __('Parent Payment Forms:', 'invoicing'),
98
+						'not_found'          => __('No payment forms found.', 'invoicing'),
99
+						'not_found_in_trash' => __('No payment forms found in trash.', 'invoicing')
100 100
 					),
101
-					'description'        => __( 'Add new payment forms.', 'invoicing' ),
101
+					'description'        => __('Add new payment forms.', 'invoicing'),
102 102
 					'public'             => false,
103 103
 					'show_ui'            => true,
104 104
 					'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true,
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 					'has_archive'        => false,
110 110
 					'hierarchical'       => false,
111 111
 					'menu_position'      => null,
112
-					'supports'           => array( 'title' ),
112
+					'supports'           => array('title'),
113 113
 					'menu_icon'          => 'dashicons-media-form',
114 114
 				)
115 115
 			)
@@ -122,32 +122,32 @@  discard block
 block discarded – undo
122 122
 				'wpinv_register_post_type_invoice',
123 123
 				array(
124 124
 					'labels'                 => array(
125
-						'name'                  => __( 'Invoices', 'invoicing' ),
126
-						'singular_name'         => __( 'Invoice', 'invoicing' ),
127
-						'all_items'             => __( 'Invoices', 'invoicing' ),
128
-						'menu_name'             => _x( 'Invoices', 'Admin menu name', 'invoicing' ),
129
-						'add_new'               => __( 'Add New', 'invoicing' ),
130
-						'add_new_item'          => __( 'Add new invoice', 'invoicing' ),
131
-						'edit'                  => __( 'Edit', 'invoicing' ),
132
-						'edit_item'             => __( 'Edit invoice', 'invoicing' ),
133
-						'new_item'              => __( 'New invoice', 'invoicing' ),
134
-						'view_item'             => __( 'View invoice', 'invoicing' ),
135
-						'view_items'            => __( 'View Invoices', 'invoicing' ),
136
-						'search_items'          => __( 'Search invoices', 'invoicing' ),
137
-						'not_found'             => __( 'No invoices found', 'invoicing' ),
138
-						'not_found_in_trash'    => __( 'No invoices found in trash', 'invoicing' ),
139
-						'parent'                => __( 'Parent invoice', 'invoicing' ),
140
-						'featured_image'        => __( 'Invoice image', 'invoicing' ),
141
-						'set_featured_image'    => __( 'Set invoice image', 'invoicing' ),
142
-						'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ),
143
-						'use_featured_image'    => __( 'Use as invoice image', 'invoicing' ),
144
-						'insert_into_item'      => __( 'Insert into invoice', 'invoicing' ),
145
-						'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ),
146
-						'filter_items_list'     => __( 'Filter invoices', 'invoicing' ),
147
-						'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ),
148
-						'items_list'            => __( 'Invoices list', 'invoicing' ),
125
+						'name'                  => __('Invoices', 'invoicing'),
126
+						'singular_name'         => __('Invoice', 'invoicing'),
127
+						'all_items'             => __('Invoices', 'invoicing'),
128
+						'menu_name'             => _x('Invoices', 'Admin menu name', 'invoicing'),
129
+						'add_new'               => __('Add New', 'invoicing'),
130
+						'add_new_item'          => __('Add new invoice', 'invoicing'),
131
+						'edit'                  => __('Edit', 'invoicing'),
132
+						'edit_item'             => __('Edit invoice', 'invoicing'),
133
+						'new_item'              => __('New invoice', 'invoicing'),
134
+						'view_item'             => __('View invoice', 'invoicing'),
135
+						'view_items'            => __('View Invoices', 'invoicing'),
136
+						'search_items'          => __('Search invoices', 'invoicing'),
137
+						'not_found'             => __('No invoices found', 'invoicing'),
138
+						'not_found_in_trash'    => __('No invoices found in trash', 'invoicing'),
139
+						'parent'                => __('Parent invoice', 'invoicing'),
140
+						'featured_image'        => __('Invoice image', 'invoicing'),
141
+						'set_featured_image'    => __('Set invoice image', 'invoicing'),
142
+						'remove_featured_image' => __('Remove invoice image', 'invoicing'),
143
+						'use_featured_image'    => __('Use as invoice image', 'invoicing'),
144
+						'insert_into_item'      => __('Insert into invoice', 'invoicing'),
145
+						'uploaded_to_this_item' => __('Uploaded to this invoice', 'invoicing'),
146
+						'filter_items_list'     => __('Filter invoices', 'invoicing'),
147
+						'items_list_navigation' => __('Invoices navigation', 'invoicing'),
148
+						'items_list'            => __('Invoices list', 'invoicing'),
149 149
 					),
150
-					'description'           => __( 'This is where invoices are stored.', 'invoicing' ),
150
+					'description'           => __('This is where invoices are stored.', 'invoicing'),
151 151
 					'public'                => true,
152 152
 					'has_archive'           => false,
153 153
 					'publicly_queryable'    => true,
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         			'show_ui'               => true,
156 156
 					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
157 157
 					'show_in_nav_menus'     => false,
158
-					'supports'              => array( 'title', 'author', 'excerpt'  ),
158
+					'supports'              => array('title', 'author', 'excerpt'),
159 159
 					'rewrite'               => true,
160 160
 					'query_var'             => false,
161 161
 					'capability_type'       => 'wpi_invoice',
@@ -176,32 +176,32 @@  discard block
 block discarded – undo
176 176
 				'wpinv_register_post_type_discount',
177 177
 				array(
178 178
 					'labels'                 => array(
179
-						'name'                  => __( 'Discounts', 'invoicing' ),
180
-						'singular_name'         => __( 'Discount', 'invoicing' ),
181
-						'all_items'             => __( 'Discounts', 'invoicing' ),
182
-						'menu_name'             => _x( 'Discounts', 'Admin menu name', 'invoicing' ),
183
-						'add_new'               => __( 'Add New', 'invoicing' ),
184
-						'add_new_item'          => __( 'Add new discount', 'invoicing' ),
185
-						'edit'                  => __( 'Edit', 'invoicing' ),
186
-						'edit_item'             => __( 'Edit discount', 'invoicing' ),
187
-						'new_item'              => __( 'New discount', 'invoicing' ),
188
-						'view_item'             => __( 'View discount', 'invoicing' ),
189
-						'view_items'            => __( 'View Discounts', 'invoicing' ),
190
-						'search_items'          => __( 'Search discounts', 'invoicing' ),
191
-						'not_found'             => __( 'No discounts found', 'invoicing' ),
192
-						'not_found_in_trash'    => __( 'No discounts found in trash', 'invoicing' ),
193
-						'parent'                => __( 'Parent discount', 'invoicing' ),
194
-						'featured_image'        => __( 'Discount image', 'invoicing' ),
195
-						'set_featured_image'    => __( 'Set discount image', 'invoicing' ),
196
-						'remove_featured_image' => __( 'Remove discount image', 'invoicing' ),
197
-						'use_featured_image'    => __( 'Use as discount image', 'invoicing' ),
198
-						'insert_into_item'      => __( 'Insert into discount', 'invoicing' ),
199
-						'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ),
200
-						'filter_items_list'     => __( 'Filter discounts', 'invoicing' ),
201
-						'items_list_navigation' => __( 'Discount navigation', 'invoicing' ),
202
-						'items_list'            => __( 'Discounts list', 'invoicing' ),
179
+						'name'                  => __('Discounts', 'invoicing'),
180
+						'singular_name'         => __('Discount', 'invoicing'),
181
+						'all_items'             => __('Discounts', 'invoicing'),
182
+						'menu_name'             => _x('Discounts', 'Admin menu name', 'invoicing'),
183
+						'add_new'               => __('Add New', 'invoicing'),
184
+						'add_new_item'          => __('Add new discount', 'invoicing'),
185
+						'edit'                  => __('Edit', 'invoicing'),
186
+						'edit_item'             => __('Edit discount', 'invoicing'),
187
+						'new_item'              => __('New discount', 'invoicing'),
188
+						'view_item'             => __('View discount', 'invoicing'),
189
+						'view_items'            => __('View Discounts', 'invoicing'),
190
+						'search_items'          => __('Search discounts', 'invoicing'),
191
+						'not_found'             => __('No discounts found', 'invoicing'),
192
+						'not_found_in_trash'    => __('No discounts found in trash', 'invoicing'),
193
+						'parent'                => __('Parent discount', 'invoicing'),
194
+						'featured_image'        => __('Discount image', 'invoicing'),
195
+						'set_featured_image'    => __('Set discount image', 'invoicing'),
196
+						'remove_featured_image' => __('Remove discount image', 'invoicing'),
197
+						'use_featured_image'    => __('Use as discount image', 'invoicing'),
198
+						'insert_into_item'      => __('Insert into discount', 'invoicing'),
199
+						'uploaded_to_this_item' => __('Uploaded to this discount', 'invoicing'),
200
+						'filter_items_list'     => __('Filter discounts', 'invoicing'),
201
+						'items_list_navigation' => __('Discount navigation', 'invoicing'),
202
+						'items_list'            => __('Discounts list', 'invoicing'),
203 203
 					),
204
-					'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
204
+					'description'        => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'),
205 205
 					'public'             => false,
206 206
 					'can_export'         => true,
207 207
 					'_builtin'           => false,
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 					'map_meta_cap'       => true,
216 216
 					'has_archive'        => false,
217 217
 					'hierarchical'       => false,
218
-					'supports'           => array( 'title', 'excerpt' ),
218
+					'supports'           => array('title', 'excerpt'),
219 219
 					'show_in_nav_menus'  => false,
220 220
 					'show_in_admin_bar'  => true,
221 221
 					'menu_position'      => null,
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 			)
224 224
 		);
225 225
 
226
-		do_action( 'getpaid_after_register_post_types' );
226
+		do_action('getpaid_after_register_post_types');
227 227
 	}
228 228
 
229 229
 	/**
@@ -236,79 +236,79 @@  discard block
 block discarded – undo
236 236
 			array(
237 237
 
238 238
 				'wpi-pending' => array(
239
-					'label'                     => _x( 'Pending Payment', 'Invoice status', 'invoicing' ),
239
+					'label'                     => _x('Pending Payment', 'Invoice status', 'invoicing'),
240 240
         			'public'                    => true,
241 241
         			'exclude_from_search'       => true,
242 242
         			'show_in_admin_all_list'    => true,
243 243
 					'show_in_admin_status_list' => true,
244 244
 					/* translators: %s: number of invoices */
245
-        			'label_count'               => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' )
245
+        			'label_count'               => _n_noop('Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing')
246 246
 				),
247 247
 
248 248
 				'wpi-processing' => array(
249
-					'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
249
+					'label'                     => _x('Processing', 'Invoice status', 'invoicing'),
250 250
         			'public'                    => true,
251 251
         			'exclude_from_search'       => true,
252 252
         			'show_in_admin_all_list'    => true,
253 253
 					'show_in_admin_status_list' => true,
254 254
 					/* translators: %s: number of invoices */
255
-        			'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
255
+        			'label_count'               => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing')
256 256
 				),
257 257
 
258 258
 				'wpi-onhold' => array(
259
-					'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
259
+					'label'                     => _x('On Hold', 'Invoice status', 'invoicing'),
260 260
         			'public'                    => true,
261 261
         			'exclude_from_search'       => true,
262 262
         			'show_in_admin_all_list'    => true,
263 263
 					'show_in_admin_status_list' => true,
264 264
 					/* translators: %s: number of invoices */
265
-        			'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
265
+        			'label_count'               => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing')
266 266
 				),
267 267
 
268 268
 				'wpi-cancelled' => array(
269
-					'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
269
+					'label'                     => _x('Cancelled', 'Invoice status', 'invoicing'),
270 270
         			'public'                    => true,
271 271
         			'exclude_from_search'       => true,
272 272
         			'show_in_admin_all_list'    => true,
273 273
 					'show_in_admin_status_list' => true,
274 274
 					/* translators: %s: number of invoices */
275
-        			'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
275
+        			'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing')
276 276
 				),
277 277
 
278 278
 				'wpi-refunded' => array(
279
-					'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
279
+					'label'                     => _x('Refunded', 'Invoice status', 'invoicing'),
280 280
         			'public'                    => true,
281 281
         			'exclude_from_search'       => true,
282 282
         			'show_in_admin_all_list'    => true,
283 283
 					'show_in_admin_status_list' => true,
284 284
 					/* translators: %s: number of invoices */
285
-        			'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
285
+        			'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing')
286 286
 				),
287 287
 
288 288
 				'wpi-failed' => array(
289
-					'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
289
+					'label'                     => _x('Failed', 'Invoice status', 'invoicing'),
290 290
         			'public'                    => true,
291 291
         			'exclude_from_search'       => true,
292 292
         			'show_in_admin_all_list'    => true,
293 293
 					'show_in_admin_status_list' => true,
294 294
 					/* translators: %s: number of invoices */
295
-        			'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
295
+        			'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing')
296 296
 				),
297 297
 
298 298
 				'wpi-renewal' => array(
299
-					'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
299
+					'label'                     => _x('Renewal', 'Invoice status', 'invoicing'),
300 300
         			'public'                    => true,
301 301
         			'exclude_from_search'       => true,
302 302
         			'show_in_admin_all_list'    => true,
303 303
 					'show_in_admin_status_list' => true,
304 304
 					/* translators: %s: number of invoices */
305
-        			'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
305
+        			'label_count'               => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing')
306 306
 				)
307 307
 			)
308 308
 		);
309 309
 
310
-		foreach ( $invoice_statuses as $invoice_statuse => $args ) {
311
-			register_post_status( $invoice_statuse, $args );
310
+		foreach ($invoice_statuses as $invoice_statuse => $args) {
311
+			register_post_status($invoice_statuse, $args);
312 312
 		}
313 313
 	}
314 314
 
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
 	 *
325 325
 	 */
326 326
 	public static function maybe_flush_rewrite_rules() {
327
-		if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) {
328
-			update_option( 'getpaid_flushed_rewrite_rules', '1' );
327
+		if (!get_option('getpaid_flushed_rewrite_rules')) {
328
+			update_option('getpaid_flushed_rewrite_rules', '1');
329 329
 			self::flush_rewrite_rules();
330 330
 		}
331 331
 	}
Please login to merge, or discard this patch.
includes/class-wpinv-notes.php 2 patches
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -12,118 +12,118 @@
 block discarded – undo
12 12
  */
13 13
 class WPInv_Notes {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 */
18
-	public function __construct() {
19
-
20
-		// Filter inovice notes.
21
-		add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 );
22
-		add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 );
23
-
24
-		// Fires after notes are loaded.
25
-		do_action( 'wpinv_notes_init', $this );
26
-	}
27
-
28
-	/**
29
-	 * Filters invoice notes query to only include our notes.
30
-	 *
31
-	 * @param WP_Comment_Query $query
32
-	 */
33
-	public function set_invoice_note_type( $query ) {
34
-		$post_id = ! empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
35
-
36
-		if ( $post_id && getpaid_is_invoice_post_type( get_post_type( $post_id ) ) ) {
37
-			$query->query_vars['type'] = 'wpinv_note';
38
-		} else {
39
-
40
-			if ( empty( $query->query_vars['type__not_in'] ) ) {
41
-				$query->query_vars['type__not_in'] = array();
42
-			}
43
-
44
-			$query->query_vars['type__not_in'] = wpinv_parse_list( $query->query_vars['type__not_in'] );
45
-			$query->query_vars['type__not_in'] = array_merge( array( 'wpinv_note' ), $query->query_vars['type__not_in'] );
46
-		}
47
-
48
-		return $query;
49
-	}
50
-
51
-	/**
52
-	 * Exclude notes from the comments feed.
53
-	 */
54
-	function wpinv_comment_feed_where( $where ){
55
-		return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' ";
56
-	}
57
-
58
-	/**
59
-	 * Returns an array of invoice notes.
60
-	 *
61
-	 * @param int $invoice_id The invoice ID whose notes to retrieve.
62
-	 * @param string $type Optional. Pass in customer to only return customer notes.
63
-	 * @return WP_Comment[]
64
-	 */
65
-	public function get_invoice_notes( $invoice_id = 0, $type = 'all' ) {
66
-
67
-		// Default comment args.
68
-		$args = array(
69
-			'post_id'   => $invoice_id,
70
-			'orderby'   => 'comment_ID',
71
-			'order'     => 'ASC',
72
-		);
73
-
74
-		// Maybe only show customer comments.
75
-		if ( $type == 'customer' ) {
76
-			$args['meta_key']   = '_wpi_customer_note';
77
-			$args['meta_value'] = 1;
78
-		}
79
-
80
-		$args = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type );
81
-
82
-		return get_comments( $args );
83
-	}
84
-
85
-	/**
86
-	 * Saves an invoice comment.
87
-	 * 
88
-	 * @param WPInv_Invoice $invoice The invoice to add the comment to.
89
-	 * @param string $note The note content.
90
-	 * @param string $note_author The name of the author of the note.
91
-	 * @param bool $for_customer Whether or not this comment is meant to be sent to the customer.
92
-	 * @return int|false The new note's ID on success, false on failure.
93
-	 */
94
-	function add_invoice_note( $invoice, $note, $note_author, $author_email, $for_customer = false ){
95
-
96
-		do_action( 'wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer );
97
-
98
-		/**
99
-		 * Insert the comment.
100
-		 */
101
-		$note_id = wp_insert_comment(
102
-			wp_filter_comment(
103
-				array(
104
-					'comment_post_ID'      => $invoice->get_id(),
105
-					'comment_content'      => $note,
106
-					'comment_agent'        => 'Invoicing',
107
-					'user_id'              => get_current_user_id(),
108
-					'comment_author'       => $note_author,
109
-					'comment_author_IP'    => wpinv_get_ip(),
110
-					'comment_author_email' => $author_email,
111
-					'comment_author_url'   => $invoice->get_view_url(),
112
-					'comment_type'         => 'wpinv_note',
113
-				)
114
-			)
115
-		);
116
-
117
-		do_action( 'wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer );
118
-
119
-		// Are we notifying the customer?
120
-		if ( empty( $note_id ) || empty( $for_customer ) ) {
121
-			return $note_id;
122
-		}
123
-
124
-		add_comment_meta( $note_id, '_wpi_customer_note', 1 );
125
-		do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $invoice->get_id(), 'user_note' => $note ) );
126
-		return $note_id;
127
-	}
15
+    /**
16
+     * Class constructor.
17
+     */
18
+    public function __construct() {
19
+
20
+        // Filter inovice notes.
21
+        add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 );
22
+        add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 );
23
+
24
+        // Fires after notes are loaded.
25
+        do_action( 'wpinv_notes_init', $this );
26
+    }
27
+
28
+    /**
29
+     * Filters invoice notes query to only include our notes.
30
+     *
31
+     * @param WP_Comment_Query $query
32
+     */
33
+    public function set_invoice_note_type( $query ) {
34
+        $post_id = ! empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
35
+
36
+        if ( $post_id && getpaid_is_invoice_post_type( get_post_type( $post_id ) ) ) {
37
+            $query->query_vars['type'] = 'wpinv_note';
38
+        } else {
39
+
40
+            if ( empty( $query->query_vars['type__not_in'] ) ) {
41
+                $query->query_vars['type__not_in'] = array();
42
+            }
43
+
44
+            $query->query_vars['type__not_in'] = wpinv_parse_list( $query->query_vars['type__not_in'] );
45
+            $query->query_vars['type__not_in'] = array_merge( array( 'wpinv_note' ), $query->query_vars['type__not_in'] );
46
+        }
47
+
48
+        return $query;
49
+    }
50
+
51
+    /**
52
+     * Exclude notes from the comments feed.
53
+     */
54
+    function wpinv_comment_feed_where( $where ){
55
+        return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' ";
56
+    }
57
+
58
+    /**
59
+     * Returns an array of invoice notes.
60
+     *
61
+     * @param int $invoice_id The invoice ID whose notes to retrieve.
62
+     * @param string $type Optional. Pass in customer to only return customer notes.
63
+     * @return WP_Comment[]
64
+     */
65
+    public function get_invoice_notes( $invoice_id = 0, $type = 'all' ) {
66
+
67
+        // Default comment args.
68
+        $args = array(
69
+            'post_id'   => $invoice_id,
70
+            'orderby'   => 'comment_ID',
71
+            'order'     => 'ASC',
72
+        );
73
+
74
+        // Maybe only show customer comments.
75
+        if ( $type == 'customer' ) {
76
+            $args['meta_key']   = '_wpi_customer_note';
77
+            $args['meta_value'] = 1;
78
+        }
79
+
80
+        $args = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type );
81
+
82
+        return get_comments( $args );
83
+    }
84
+
85
+    /**
86
+     * Saves an invoice comment.
87
+     * 
88
+     * @param WPInv_Invoice $invoice The invoice to add the comment to.
89
+     * @param string $note The note content.
90
+     * @param string $note_author The name of the author of the note.
91
+     * @param bool $for_customer Whether or not this comment is meant to be sent to the customer.
92
+     * @return int|false The new note's ID on success, false on failure.
93
+     */
94
+    function add_invoice_note( $invoice, $note, $note_author, $author_email, $for_customer = false ){
95
+
96
+        do_action( 'wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer );
97
+
98
+        /**
99
+         * Insert the comment.
100
+         */
101
+        $note_id = wp_insert_comment(
102
+            wp_filter_comment(
103
+                array(
104
+                    'comment_post_ID'      => $invoice->get_id(),
105
+                    'comment_content'      => $note,
106
+                    'comment_agent'        => 'Invoicing',
107
+                    'user_id'              => get_current_user_id(),
108
+                    'comment_author'       => $note_author,
109
+                    'comment_author_IP'    => wpinv_get_ip(),
110
+                    'comment_author_email' => $author_email,
111
+                    'comment_author_url'   => $invoice->get_view_url(),
112
+                    'comment_type'         => 'wpinv_note',
113
+                )
114
+            )
115
+        );
116
+
117
+        do_action( 'wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer );
118
+
119
+        // Are we notifying the customer?
120
+        if ( empty( $note_id ) || empty( $for_customer ) ) {
121
+            return $note_id;
122
+        }
123
+
124
+        add_comment_meta( $note_id, '_wpi_customer_note', 1 );
125
+        do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $invoice->get_id(), 'user_note' => $note ) );
126
+        return $note_id;
127
+    }
128 128
 
129 129
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Handles invoice notes.
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
 	public function __construct() {
19 19
 
20 20
 		// Filter inovice notes.
21
-		add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 );
22
-		add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 );
21
+		add_action('pre_get_comments', array($this, 'set_invoice_note_type'), 11, 1);
22
+		add_action('comment_feed_where', array($this, 'wpinv_comment_feed_where'), 10, 1);
23 23
 
24 24
 		// Fires after notes are loaded.
25
-		do_action( 'wpinv_notes_init', $this );
25
+		do_action('wpinv_notes_init', $this);
26 26
 	}
27 27
 
28 28
 	/**
@@ -30,19 +30,19 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @param WP_Comment_Query $query
32 32
 	 */
33
-	public function set_invoice_note_type( $query ) {
34
-		$post_id = ! empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
33
+	public function set_invoice_note_type($query) {
34
+		$post_id = !empty($query->query_vars['post_ID']) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
35 35
 
36
-		if ( $post_id && getpaid_is_invoice_post_type( get_post_type( $post_id ) ) ) {
36
+		if ($post_id && getpaid_is_invoice_post_type(get_post_type($post_id))) {
37 37
 			$query->query_vars['type'] = 'wpinv_note';
38 38
 		} else {
39 39
 
40
-			if ( empty( $query->query_vars['type__not_in'] ) ) {
40
+			if (empty($query->query_vars['type__not_in'])) {
41 41
 				$query->query_vars['type__not_in'] = array();
42 42
 			}
43 43
 
44
-			$query->query_vars['type__not_in'] = wpinv_parse_list( $query->query_vars['type__not_in'] );
45
-			$query->query_vars['type__not_in'] = array_merge( array( 'wpinv_note' ), $query->query_vars['type__not_in'] );
44
+			$query->query_vars['type__not_in'] = wpinv_parse_list($query->query_vars['type__not_in']);
45
+			$query->query_vars['type__not_in'] = array_merge(array('wpinv_note'), $query->query_vars['type__not_in']);
46 46
 		}
47 47
 
48 48
 		return $query;
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	/**
52 52
 	 * Exclude notes from the comments feed.
53 53
 	 */
54
-	function wpinv_comment_feed_where( $where ){
55
-		return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' ";
54
+	function wpinv_comment_feed_where($where) {
55
+		return $where . ($where ? ' AND ' : '') . " comment_type != 'wpinv_note' ";
56 56
 	}
57 57
 
58 58
 	/**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @param string $type Optional. Pass in customer to only return customer notes.
63 63
 	 * @return WP_Comment[]
64 64
 	 */
65
-	public function get_invoice_notes( $invoice_id = 0, $type = 'all' ) {
65
+	public function get_invoice_notes($invoice_id = 0, $type = 'all') {
66 66
 
67 67
 		// Default comment args.
68 68
 		$args = array(
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
 		);
73 73
 
74 74
 		// Maybe only show customer comments.
75
-		if ( $type == 'customer' ) {
75
+		if ($type == 'customer') {
76 76
 			$args['meta_key']   = '_wpi_customer_note';
77 77
 			$args['meta_value'] = 1;
78 78
 		}
79 79
 
80
-		$args = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type );
80
+		$args = apply_filters('wpinv_invoice_notes_args', $args, $this, $invoice_id, $type);
81 81
 
82
-		return get_comments( $args );
82
+		return get_comments($args);
83 83
 	}
84 84
 
85 85
 	/**
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 	 * @param bool $for_customer Whether or not this comment is meant to be sent to the customer.
92 92
 	 * @return int|false The new note's ID on success, false on failure.
93 93
 	 */
94
-	function add_invoice_note( $invoice, $note, $note_author, $author_email, $for_customer = false ){
94
+	function add_invoice_note($invoice, $note, $note_author, $author_email, $for_customer = false) {
95 95
 
96
-		do_action( 'wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer );
96
+		do_action('wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer);
97 97
 
98 98
 		/**
99 99
 		 * Insert the comment.
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
 			)
115 115
 		);
116 116
 
117
-		do_action( 'wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer );
117
+		do_action('wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer);
118 118
 
119 119
 		// Are we notifying the customer?
120
-		if ( empty( $note_id ) || empty( $for_customer ) ) {
120
+		if (empty($note_id) || empty($for_customer)) {
121 121
 			return $note_id;
122 122
 		}
123 123
 
124
-		add_comment_meta( $note_id, '_wpi_customer_note', 1 );
125
-		do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $invoice->get_id(), 'user_note' => $note ) );
124
+		add_comment_meta($note_id, '_wpi_customer_note', 1);
125
+		do_action('wpinv_new_customer_note', array('invoice_id' => $invoice->get_id(), 'user_note' => $note));
126 126
 		return $note_id;
127 127
 	}
128 128
 
Please login to merge, or discard this patch.
includes/wpinv-gateway-functions.php 1 patch
Spacing   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Contains gateway functions.
4 4
  *
5 5
  */
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Returns an array of payment gateways.
@@ -11,141 +11,141 @@  discard block
 block discarded – undo
11 11
  * @return array
12 12
  */
13 13
 function wpinv_get_payment_gateways() {
14
-    return apply_filters( 'wpinv_payment_gateways', array() );
14
+    return apply_filters('wpinv_payment_gateways', array());
15 15
 }
16 16
 
17
-function wpinv_payment_gateway_titles( $all_gateways ) {
17
+function wpinv_payment_gateway_titles($all_gateways) {
18 18
     global $wpinv_options;
19 19
 
20 20
     $gateways = array();
21
-    foreach ( $all_gateways as $key => $gateway ) {
22
-        if ( !empty( $wpinv_options[$key . '_title'] ) ) {
23
-            $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' );
21
+    foreach ($all_gateways as $key => $gateway) {
22
+        if (!empty($wpinv_options[$key . '_title'])) {
23
+            $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing');
24 24
         }
25 25
 
26
-        $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' );
26
+        $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : '');
27 27
     }
28 28
 
29
-    asort( $gateways );
29
+    asort($gateways);
30 30
 
31
-    foreach ( $gateways as $gateway => $key ) {
31
+    foreach ($gateways as $gateway => $key) {
32 32
         $gateways[$gateway] = $all_gateways[$gateway];
33 33
     }
34 34
 
35 35
     return $gateways;
36 36
 }
37
-add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 );
37
+add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1);
38 38
 
39
-function wpinv_get_enabled_payment_gateways( $sort = false ) {
39
+function wpinv_get_enabled_payment_gateways($sort = false) {
40 40
     $gateways = wpinv_get_payment_gateways();
41
-    $enabled  = wpinv_get_option( 'gateways', false );
41
+    $enabled  = wpinv_get_option('gateways', false);
42 42
 
43 43
     $gateway_list = array();
44 44
 
45
-    foreach ( $gateways as $key => $gateway ) {
46
-        if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
47
-            $gateway_list[ $key ] = $gateway;
45
+    foreach ($gateways as $key => $gateway) {
46
+        if (isset($enabled[$key]) && $enabled[$key] == 1) {
47
+            $gateway_list[$key] = $gateway;
48 48
         }
49 49
     }
50 50
 
51
-    if ( true === $sort ) {
52
-        uasort( $gateway_list, 'wpinv_sort_gateway_order' );
51
+    if (true === $sort) {
52
+        uasort($gateway_list, 'wpinv_sort_gateway_order');
53 53
         
54 54
         // Reorder our gateways so the default is first
55 55
         $default_gateway_id = wpinv_get_default_gateway();
56 56
 
57
-        if ( wpinv_is_gateway_active( $default_gateway_id ) ) {
58
-            $default_gateway    = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] );
59
-            unset( $gateway_list[ $default_gateway_id ] );
57
+        if (wpinv_is_gateway_active($default_gateway_id)) {
58
+            $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]);
59
+            unset($gateway_list[$default_gateway_id]);
60 60
 
61
-            $gateway_list = array_merge( $default_gateway, $gateway_list );
61
+            $gateway_list = array_merge($default_gateway, $gateway_list);
62 62
         }
63 63
     }
64 64
 
65
-    return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list );
65
+    return apply_filters('wpinv_enabled_payment_gateways', $gateway_list);
66 66
 }
67 67
 
68
-function wpinv_sort_gateway_order( $a, $b ) {
68
+function wpinv_sort_gateway_order($a, $b) {
69 69
     return $a['ordering'] - $b['ordering'];
70 70
 }
71 71
 
72
-function wpinv_is_gateway_active( $gateway ) {
72
+function wpinv_is_gateway_active($gateway) {
73 73
     $gateways = wpinv_get_enabled_payment_gateways();
74 74
 
75
-    $ret = is_array($gateways) && $gateway ?  array_key_exists( $gateway, $gateways ) : false;
75
+    $ret = is_array($gateways) && $gateway ?  array_key_exists($gateway, $gateways) : false;
76 76
 
77
-    return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways );
77
+    return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways);
78 78
 }
79 79
 
80 80
 function wpinv_get_default_gateway() {
81
-    $default = wpinv_get_option( 'default_gateway', 'paypal' );
81
+    $default = wpinv_get_option('default_gateway', 'paypal');
82 82
 
83
-    if ( !wpinv_is_gateway_active( $default ) ) {
83
+    if (!wpinv_is_gateway_active($default)) {
84 84
         $gateways = wpinv_get_enabled_payment_gateways();
85
-        $gateways = array_keys( $gateways );
86
-        $default  = reset( $gateways );
85
+        $gateways = array_keys($gateways);
86
+        $default  = reset($gateways);
87 87
     }
88 88
 
89
-    return apply_filters( 'wpinv_default_gateway', $default );
89
+    return apply_filters('wpinv_default_gateway', $default);
90 90
 }
91 91
 
92
-function wpinv_get_gateway_admin_label( $gateway ) {
92
+function wpinv_get_gateway_admin_label($gateway) {
93 93
     $gateways = wpinv_get_payment_gateways();
94
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
95
-    $payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
94
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
95
+    $payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
96 96
 
97
-    if( $gateway == 'manual' && $payment ) {
98
-        if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) {
99
-            $label = __( 'Free Purchase', 'invoicing' );
97
+    if ($gateway == 'manual' && $payment) {
98
+        if (!((float) wpinv_payment_total($payment) > 0)) {
99
+            $label = __('Free Purchase', 'invoicing');
100 100
         }
101 101
     }
102 102
 
103
-    return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway );
103
+    return apply_filters('wpinv_gateway_admin_label', $label, $gateway);
104 104
 }
105 105
 
106
-function wpinv_get_gateway_description( $gateway ) {
106
+function wpinv_get_gateway_description($gateway) {
107 107
     global $wpinv_options;
108 108
 
109
-    $description = ! empty( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : '';
109
+    $description = !empty($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : '';
110 110
 
111
-    return apply_filters( 'wpinv_gateway_description', $description, $gateway );
111
+    return apply_filters('wpinv_gateway_description', $description, $gateway);
112 112
 }
113 113
 
114
-function wpinv_get_gateway_button_label( $gateway ) {
115
-    return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' );
114
+function wpinv_get_gateway_button_label($gateway) {
115
+    return apply_filters('wpinv_gateway_' . $gateway . '_button_label', '');
116 116
 }
117 117
 
118
-function wpinv_get_gateway_checkout_label( $gateway ) {
118
+function wpinv_get_gateway_checkout_label($gateway) {
119 119
     $gateways = wpinv_get_payment_gateways();
120
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
120
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
121 121
 
122
-    if ( $gateway == 'none' ) {
123
-        $label = __( 'None', 'invoicing' );
122
+    if ($gateway == 'none') {
123
+        $label = __('None', 'invoicing');
124 124
     }
125 125
 
126
-    return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway );
126
+    return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway);
127 127
 }
128 128
 
129
-function wpinv_settings_sections_gateways( $settings ) {
129
+function wpinv_settings_sections_gateways($settings) {
130 130
     $gateways = wpinv_get_payment_gateways();
131 131
     
132 132
     if (!empty($gateways)) {
133
-        foreach  ($gateways as $key => $gateway) {
133
+        foreach ($gateways as $key => $gateway) {
134 134
             $settings[$key] = $gateway['admin_label'];
135 135
         }
136 136
     }
137 137
     
138 138
     return $settings;    
139 139
 }
140
-add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 );
140
+add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1);
141 141
 
142 142
 /**
143 143
  * Adds GateWay settings.
144 144
  */
145
-function wpinv_settings_gateways( $settings ) {
145
+function wpinv_settings_gateways($settings) {
146 146
 
147 147
     // Loop through each gateway.
148
-    foreach  ( wpinv_get_payment_gateways() as $key => $gateway ) {
148
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
149 149
 
150 150
         $gateway_settings = array(
151 151
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             "{$key}_header" => array(
154 154
 
155 155
                 'id'     => "{$key}_gateway_header",
156
-                'name'   => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>',
156
+                'name'   => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>',
157 157
                 'custom' => $key,
158 158
                 'type'   => 'gateway_header',
159 159
 
@@ -162,56 +162,56 @@  discard block
 block discarded – undo
162 162
             // Activate/Deactivate a gateway.
163 163
             "{$key}_active" => array(
164 164
                 'id'   => $key . '_active',
165
-                'name' => __( 'Activate', 'invoicing' ),
166
-                'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ),
165
+                'name' => __('Activate', 'invoicing'),
166
+                'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']),
167 167
                 'type' => 'checkbox',
168 168
             ),
169 169
 
170 170
             // Activate/Deactivate sandbox.
171 171
             "{$key}_sandbox" => array(
172 172
                 'id'   => $key . '_sandbox',
173
-                'name' => __( 'Sandbox', 'invoicing' ),
174
-                'desc' => __( 'Enable sandbox to test payments', 'invoicing' ),
173
+                'name' => __('Sandbox', 'invoicing'),
174
+                'desc' => __('Enable sandbox to test payments', 'invoicing'),
175 175
                 'type' => 'checkbox',
176 176
             ),
177 177
 
178 178
             // Checkout title.
179 179
             "{$key}_title" => array(
180 180
                 'id'   => $key . '_title',
181
-                'name' => __( 'Checkout Title', 'invoicing' ),
182
-                'std'  => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '',
181
+                'name' => __('Checkout Title', 'invoicing'),
182
+                'std'  => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '',
183 183
                 'type' => 'text',
184 184
             ),
185 185
 
186 186
             // Checkout description.
187 187
             "{$key}_desc" => array(
188 188
                 'id'   => $key . '_desc',
189
-                'name' => __( 'Checkout Description', 'invoicing' ),
190
-                'std'  => apply_filters( "getpaid_default_{$key}_checkout_description", '' ),
189
+                'name' => __('Checkout Description', 'invoicing'),
190
+                'std'  => apply_filters("getpaid_default_{$key}_checkout_description", ''),
191 191
                 'type' => 'text',
192 192
             ),
193 193
 
194 194
             // Checkout order.
195 195
             "{$key}_ordering" => array(
196 196
                 'id'   => $key . '_ordering',
197
-                'name' => __( 'Priority', 'invoicing' ),
198
-                'std'  => apply_filters( "getpaid_default_{$key}_checkout_description", '' ),
197
+                'name' => __('Priority', 'invoicing'),
198
+                'std'  => apply_filters("getpaid_default_{$key}_checkout_description", ''),
199 199
                 'type' => 'number',
200 200
                 'step' => '1',
201 201
                 'min'  => '-100000',
202 202
                 'max'  => '100000',
203
-                'std'  => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10',
203
+                'std'  => isset($gateway['ordering']) ? $gateway['ordering'] : '10',
204 204
             ),
205 205
 
206 206
         );
207 207
 
208 208
         // Maybe remove the sandbox.
209
-        if ( ! apply_filters( "wpinv_{$key}_supports_sandbox", false ) ) {
210
-            unset( $gateway_settings["{$key}_sandbox"] );
209
+        if (!apply_filters("wpinv_{$key}_supports_sandbox", false)) {
210
+            unset($gateway_settings["{$key}_sandbox"]);
211 211
         }
212 212
   
213
-        $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway );
214
-        $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway );
213
+        $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway);
214
+        $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway);
215 215
         
216 216
         $settings[$key] = $gateway_settings;
217 217
     }
@@ -219,38 +219,38 @@  discard block
 block discarded – undo
219 219
     return $settings;
220 220
 
221 221
 }
222
-add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 );
222
+add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1);
223 223
 
224
-function wpinv_gateway_header_callback( $args ) {
225
-    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />';
224
+function wpinv_gateway_header_callback($args) {
225
+    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />';
226 226
 }
227 227
 
228
-function wpinv_get_gateway_supports( $gateway ) {
228
+function wpinv_get_gateway_supports($gateway) {
229 229
     $gateways = wpinv_get_enabled_payment_gateways();
230
-    $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
231
-    return apply_filters( 'wpinv_gateway_supports', $supports, $gateway );
230
+    $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
231
+    return apply_filters('wpinv_gateway_supports', $supports, $gateway);
232 232
 }
233 233
 
234
-function wpinv_gateway_supports_buy_now( $gateway ) {
235
-    $supports = wpinv_get_gateway_supports( $gateway );
236
-    $ret = in_array( 'buy_now', $supports );
237
-    return apply_filters( 'wpinv_gateway_supports_buy_now', $ret, $gateway );
234
+function wpinv_gateway_supports_buy_now($gateway) {
235
+    $supports = wpinv_get_gateway_supports($gateway);
236
+    $ret = in_array('buy_now', $supports);
237
+    return apply_filters('wpinv_gateway_supports_buy_now', $ret, $gateway);
238 238
 }
239 239
 
240 240
 function wpinv_shop_supports_buy_now() {
241 241
     $gateways = wpinv_get_enabled_payment_gateways();
242 242
     $ret      = false;
243 243
 
244
-    if ( !wpinv_use_taxes()  && $gateways ) {
245
-        foreach ( $gateways as $gateway_id => $gateway ) {
246
-            if ( wpinv_gateway_supports_buy_now( $gateway_id ) ) {
244
+    if (!wpinv_use_taxes() && $gateways) {
245
+        foreach ($gateways as $gateway_id => $gateway) {
246
+            if (wpinv_gateway_supports_buy_now($gateway_id)) {
247 247
                 $ret = true;
248 248
                 break;
249 249
             }
250 250
         }
251 251
     }
252 252
 
253
-    return apply_filters( 'wpinv_shop_supports_buy_now', $ret );
253
+    return apply_filters('wpinv_shop_supports_buy_now', $ret);
254 254
 }
255 255
 
256 256
 
@@ -258,61 +258,61 @@  discard block
 block discarded – undo
258 258
     $gateways = wpinv_get_enabled_payment_gateways();
259 259
     $show_gateways = false;
260 260
 
261
-    $chosen_gateway = isset( $_GET['payment-mode'] ) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode'] ) : false;
261
+    $chosen_gateway = isset($_GET['payment-mode']) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode']) : false;
262 262
 
263
-    if ( count( $gateways ) > 1 && empty( $chosen_gateway ) ) {
263
+    if (count($gateways) > 1 && empty($chosen_gateway)) {
264 264
         $show_gateways = true;
265
-        if ( wpinv_get_cart_total() <= 0 ) {
265
+        if (wpinv_get_cart_total() <= 0) {
266 266
             $show_gateways = false;
267 267
         }
268 268
     }
269 269
     
270
-    if ( !$show_gateways && wpinv_cart_has_recurring_item() ) {
270
+    if (!$show_gateways && wpinv_cart_has_recurring_item()) {
271 271
         $show_gateways = true;
272 272
     }
273 273
 
274
-    return apply_filters( 'wpinv_show_gateways', $show_gateways );
274
+    return apply_filters('wpinv_show_gateways', $show_gateways);
275 275
 }
276 276
 
277
-function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
278
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
277
+function wpinv_get_chosen_gateway($invoice_id = 0) {
278
+	$gateways = array_keys(wpinv_get_enabled_payment_gateways());
279 279
 
280 280
     $chosen = false;
281
-    if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
281
+    if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) {
282 282
         $chosen = $invoice->get_gateway();
283 283
     }
284 284
 
285
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
285
+	$chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen;
286 286
 
287
-	if ( false !== $chosen ) {
288
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
287
+	if (false !== $chosen) {
288
+		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen);
289 289
 	}
290 290
 
291
-	if ( ! empty ( $chosen ) ) {
292
-		$enabled_gateway = urldecode( $chosen );
293
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
291
+	if (!empty ($chosen)) {
292
+		$enabled_gateway = urldecode($chosen);
293
+	} else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) {
294 294
 		$enabled_gateway = 'manual';
295 295
 	} else {
296 296
 		$enabled_gateway = wpinv_get_default_gateway();
297 297
 	}
298 298
     
299
-    if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
300
-        if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
299
+    if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) {
300
+        if (wpinv_is_gateway_active(wpinv_get_default_gateway())) {
301 301
             $enabled_gateway = wpinv_get_default_gateway();
302
-        }else{
302
+        } else {
303 303
             $enabled_gateway = $gateways[0];
304 304
         }
305 305
 
306 306
     }
307 307
 
308
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
308
+	return apply_filters('wpinv_chosen_gateway', $enabled_gateway);
309 309
 }
310 310
 
311
-function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
312
-    return wpinv_error_log( $message, $title );
311
+function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) {
312
+    return wpinv_error_log($message, $title);
313 313
 }
314 314
 
315
-function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
315
+function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
316 316
 	$ret  = 0;
317 317
 	$args = array(
318 318
 		'meta_key'    => '_wpinv_gateway',
@@ -323,48 +323,48 @@  discard block
 block discarded – undo
323 323
 		'fields'      => 'ids'
324 324
 	);
325 325
 
326
-	$payments = new WP_Query( $args );
326
+	$payments = new WP_Query($args);
327 327
 
328
-	if( $payments )
328
+	if ($payments)
329 329
 		$ret = $payments->post_count;
330 330
 	return $ret;
331 331
 }
332 332
 
333
-function wpinv_settings_update_gateways( $input ) {
333
+function wpinv_settings_update_gateways($input) {
334 334
     global $wpinv_options;
335 335
     
336
-    if ( !empty( $input['save_gateway'] ) ) {
337
-        $gateways = wpinv_get_option( 'gateways', false );
336
+    if (!empty($input['save_gateway'])) {
337
+        $gateways = wpinv_get_option('gateways', false);
338 338
         $gateways = !empty($gateways) ? $gateways : array();
339 339
         $gateway = $input['save_gateway'];
340 340
         
341
-        if ( !empty( $input[$gateway . '_active'] ) ) {
341
+        if (!empty($input[$gateway . '_active'])) {
342 342
             $gateways[$gateway] = 1;
343 343
         } else {
344
-            if ( isset( $gateways[$gateway] ) ) {
345
-                unset( $gateways[$gateway] );
344
+            if (isset($gateways[$gateway])) {
345
+                unset($gateways[$gateway]);
346 346
             }
347 347
         }
348 348
         
349 349
         $input['gateways'] = $gateways;
350 350
     }
351 351
     
352
-    if ( !empty( $input['default_gateway'] ) ) {
352
+    if (!empty($input['default_gateway'])) {
353 353
         $gateways = wpinv_get_payment_gateways();
354 354
         
355
-        foreach ( $gateways as $key => $gateway ) {
356
-            $active   = 0;
357
-            if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) {
355
+        foreach ($gateways as $key => $gateway) {
356
+            $active = 0;
357
+            if (!empty($input['gateways']) && !empty($input['gateways'][$key])) {
358 358
                 $active = 1;
359 359
             }
360 360
             
361 361
             $input[$key . '_active'] = $active;
362 362
             
363
-            if ( empty( $wpinv_options[$key . '_title'] ) ) {
363
+            if (empty($wpinv_options[$key . '_title'])) {
364 364
                 $input[$key . '_title'] = $gateway['checkout_label'];
365 365
             }
366 366
             
367
-            if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) {
367
+            if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) {
368 368
                 $input[$key . '_ordering'] = $gateway['ordering'];
369 369
             }
370 370
         }
@@ -372,27 +372,27 @@  discard block
 block discarded – undo
372 372
     
373 373
     return $input;
374 374
 }
375
-add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 );
375
+add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1);
376 376
 
377 377
 // PayPal Standard settings
378
-function wpinv_gateway_settings_paypal( $setting ) {    
379
-    $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing' );
380
-    $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
378
+function wpinv_gateway_settings_paypal($setting) {    
379
+    $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __('( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing');
380
+    $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
381 381
     
382 382
     $setting['paypal_sandbox'] = array(
383 383
             'type' => 'checkbox',
384 384
             'id'   => 'paypal_sandbox',
385
-            'name' => __( 'PayPal Sandbox', 'invoicing' ),
386
-            'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ),
385
+            'name' => __('PayPal Sandbox', 'invoicing'),
386
+            'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'),
387 387
             'std'  => 1
388 388
         );
389 389
         
390 390
     $setting['paypal_email'] = array(
391 391
             'type' => 'text',
392 392
             'id'   => 'paypal_email',
393
-            'name' => __( 'PayPal Email', 'invoicing' ),
394
-            'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ),
395
-            'std' => __( '[email protected]', 'invoicing' ),
393
+            'name' => __('PayPal Email', 'invoicing'),
394
+            'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'),
395
+            'std' => __('[email protected]', 'invoicing'),
396 396
         );
397 397
     /*
398 398
     $setting['paypal_ipn_url'] = array(
@@ -406,18 +406,18 @@  discard block
 block discarded – undo
406 406
         
407 407
     return $setting;
408 408
 }
409
-add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 );
409
+add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1);
410 410
 
411 411
 /**
412 412
  * Displays the ipn url field.
413 413
  */
414
-function wpinv_ipn_url_callback( $args ) {
415
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
414
+function wpinv_ipn_url_callback($args) {
415
+    $sanitize_id = wpinv_sanitize_key($args['id']);
416 416
     
417 417
     $attrs = $args['readonly'] ? ' readonly' : '';
418 418
 
419
-    $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">';
420
-    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">'  . $args['desc'] . '</label>';
419
+    $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">';
420
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>';
421 421
 
422 422
     echo $html;
423 423
 }
@@ -429,9 +429,9 @@  discard block
 block discarded – undo
429 429
  * 
430 430
  * @return bool
431 431
  */
432
-function wpinv_is_test_mode( $gateway = '' ) {
433
-    $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", false );
434
-    return apply_filters( 'wpinv_is_test_mode', $sandbox, $gateway );
432
+function wpinv_is_test_mode($gateway = '') {
433
+    $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", false);
434
+    return apply_filters('wpinv_is_test_mode', $sandbox, $gateway);
435 435
 }
436 436
 
437 437
 /**
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
  * 
443 443
  * @return string
444 444
  */
445
-function wpinv_get_ipn_url( $gateway = false, $args = array() ) {
445
+function wpinv_get_ipn_url($gateway = false, $args = array()) {
446 446
     $args = wp_parse_args(
447 447
         array(
448 448
             'wpi-listener' => 'IPN',
@@ -451,24 +451,24 @@  discard block
 block discarded – undo
451 451
         $args
452 452
     );
453 453
 
454
-    return apply_filters( 'wpinv_ipn_url', add_query_arg( $args,  home_url( 'index.php' ) ), $gateway, $args );
454
+    return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args);
455 455
 
456 456
 }
457 457
 
458
-function wpinv_get_post_data( $method = 'request' ) {
458
+function wpinv_get_post_data($method = 'request') {
459 459
     $data       = array();
460 460
     $request    = $_REQUEST;
461 461
     
462
-    if ( $method == 'post' ) {
463
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
462
+    if ($method == 'post') {
463
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
464 464
             return $data;
465 465
         }
466 466
         
467 467
         $request = $_POST;
468 468
     }
469 469
     
470
-    if ( $method == 'get' ) {
471
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'GET' ) {
470
+    if ($method == 'get') {
471
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') {
472 472
             return $data;
473 473
         }
474 474
         
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
     $post_data = '';
480 480
     
481 481
     // Fallback just in case post_max_size is lower than needed
482
-    if ( ini_get( 'allow_url_fopen' ) ) {
483
-        $post_data = file_get_contents( 'php://input' );
482
+    if (ini_get('allow_url_fopen')) {
483
+        $post_data = file_get_contents('php://input');
484 484
     } else {
485 485
         // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
486
-        ini_set( 'post_max_size', '12M' );
486
+        ini_set('post_max_size', '12M');
487 487
     }
488 488
     // Start the encoded data collection with notification command
489 489
     $encoded_data = 'cmd=_notify-validate';
@@ -492,33 +492,33 @@  discard block
 block discarded – undo
492 492
     $arg_separator = wpinv_get_php_arg_separator_output();
493 493
 
494 494
     // Verify there is a post_data
495
-    if ( $post_data || strlen( $post_data ) > 0 ) {
495
+    if ($post_data || strlen($post_data) > 0) {
496 496
         // Append the data
497 497
         $encoded_data .= $arg_separator . $post_data;
498 498
     } else {
499 499
         // Check if POST is empty
500
-        if ( empty( $request ) ) {
500
+        if (empty($request)) {
501 501
             // Nothing to do
502 502
             return;
503 503
         } else {
504 504
             // Loop through each POST
505
-            foreach ( $request as $key => $value ) {
505
+            foreach ($request as $key => $value) {
506 506
                 // Encode the value and append the data
507
-                $encoded_data .= $arg_separator . "$key=" . urlencode( $value );
507
+                $encoded_data .= $arg_separator . "$key=" . urlencode($value);
508 508
             }
509 509
         }
510 510
     }
511 511
 
512 512
     // Convert collected post data to an array
513
-    wp_parse_str( $encoded_data, $data );
513
+    wp_parse_str($encoded_data, $data);
514 514
 
515
-    foreach ( $data as $key => $value ) {
516
-        if ( false !== strpos( $key, 'amp;' ) ) {
517
-            $new_key = str_replace( '&amp;', '&', $key );
518
-            $new_key = str_replace( 'amp;', '&' , $new_key );
515
+    foreach ($data as $key => $value) {
516
+        if (false !== strpos($key, 'amp;')) {
517
+            $new_key = str_replace('&amp;', '&', $key);
518
+            $new_key = str_replace('amp;', '&', $new_key);
519 519
 
520
-            unset( $data[ $key ] );
521
-            $data[ $new_key ] = sanitize_text_field( $value );
520
+            unset($data[$key]);
521
+            $data[$new_key] = sanitize_text_field($value);
522 522
         }
523 523
     }
524 524
     
@@ -528,12 +528,12 @@  discard block
 block discarded – undo
528 528
 /**
529 529
  * Checks if a given gateway supports subscription payments.
530 530
  */
531
-function wpinv_gateway_support_subscription( $gateway ) {
531
+function wpinv_gateway_support_subscription($gateway) {
532 532
     $supports = false;
533 533
 
534
-    if ( wpinv_is_gateway_active( $gateway ) ) {
535
-        $supports = apply_filters( 'wpinv_' . $gateway . '_support_subscription', $supports );
536
-        $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $gateway );
534
+    if (wpinv_is_gateway_active($gateway)) {
535
+        $supports = apply_filters('wpinv_' . $gateway . '_support_subscription', $supports);
536
+        $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $gateway);
537 537
     }
538 538
 
539 539
     return $supports;
@@ -545,14 +545,14 @@  discard block
 block discarded – undo
545 545
  * @param array $gateways an array of gateways.
546 546
  * @param GetPaid_Payment_Form $form payment form.
547 547
  */
548
-function wpinv_payment_gateways_on_cart( $gateways, $form ) {
548
+function wpinv_payment_gateways_on_cart($gateways, $form) {
549 549
 
550
-    if ( $form->is_recurring() ) {
550
+    if ($form->is_recurring()) {
551 551
 
552
-        foreach ( array_keys( $gateways ) as $gateway ) {
552
+        foreach (array_keys($gateways) as $gateway) {
553 553
 
554
-            if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
555
-                unset( $gateways[$gateway] );
554
+            if (!wpinv_gateway_support_subscription($gateway)) {
555
+                unset($gateways[$gateway]);
556 556
             }
557 557
 
558 558
         }
@@ -561,24 +561,24 @@  discard block
 block discarded – undo
561 561
 
562 562
     return $gateways;
563 563
 }
564
-add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 );
564
+add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2);
565 565
 
566 566
 /**
567 567
  * Validates checkout fields.
568 568
  *
569 569
  * @param GetPaid_Payment_Form_Submission $submission
570 570
  */
571
-function wpinv_checkout_validate_gateway( $submission ) {
571
+function wpinv_checkout_validate_gateway($submission) {
572 572
 
573 573
     $data = $submission->get_data();
574 574
 
575 575
     // Non-recurring gateways should not be allowed to process recurring invoices.
576
-    if ( $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
577
-        wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway does not support subscription payment.', 'invoicing' ) );
576
+    if ($submission->has_recurring && !wpinv_gateway_support_subscription($data['wpi-gateway'])) {
577
+        wpinv_set_error('invalid_gateway', __('The selected payment gateway does not support subscription payment.', 'invoicing'));
578 578
     }
579 579
 
580
-    if ( ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
581
-        wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
580
+    if (!wpinv_is_gateway_active($data['wpi-gateway'])) {
581
+        wpinv_set_error('invalid_gateway', __('The selected payment gateway is not active', 'invoicing'));
582 582
     }
583 583
 
584 584
 }
@@ -586,84 +586,84 @@  discard block
 block discarded – undo
586 586
 /**
587 587
  * Validates a zip code.
588 588
  */
589
-function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) {
589
+function wpinv_checkout_validate_cc_zip($zip = 0, $country_code = '') {
590 590
 
591
-    if ( empty( $zip ) || empty( $country_code ) ){
591
+    if (empty($zip) || empty($country_code)) {
592 592
         return false;
593 593
     }
594 594
 
595 595
     // Prepare the country code.
596
-    $country_code = strtoupper( trim( $country_code ) );
596
+    $country_code = strtoupper(trim($country_code));
597 597
 
598 598
     // Fetch the regexes.
599
-    $zip_regex = wpinv_get_data( 'zip-regexes' );
599
+    $zip_regex = wpinv_get_data('zip-regexes');
600 600
 
601 601
     // Check if it is valid.
602
-    $is_valid = ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip );
602
+    $is_valid = !isset ($zip_regex[$country_code]) || preg_match("/" . $zip_regex[$country_code] . "/i", $zip);
603 603
 
604
-    return apply_filters( 'wpinv_is_zip_valid', $is_valid, $zip, $country_code );
604
+    return apply_filters('wpinv_is_zip_valid', $is_valid, $zip, $country_code);
605 605
 }
606 606
 
607 607
 function wpinv_checkout_validate_agree_to_terms() {
608 608
     // Validate agree to terms
609
-    if ( ! isset( $_POST['wpi_agree_to_terms'] ) || $_POST['wpi_agree_to_terms'] != 1 ) {
609
+    if (!isset($_POST['wpi_agree_to_terms']) || $_POST['wpi_agree_to_terms'] != 1) {
610 610
         // User did not agree
611
-        wpinv_set_error( 'agree_to_terms', apply_filters( 'wpinv_agree_to_terms_text', __( 'You must agree to the terms of use', 'invoicing' ) ) );
611
+        wpinv_set_error('agree_to_terms', apply_filters('wpinv_agree_to_terms_text', __('You must agree to the terms of use', 'invoicing')));
612 612
     }
613 613
 }
614 614
 
615 615
 function wpinv_checkout_validate_invoice_user() {
616 616
     global $wpi_cart, $user_ID;
617 617
 
618
-    if(empty($wpi_cart)){
618
+    if (empty($wpi_cart)) {
619 619
         $wpi_cart = wpinv_get_invoice_cart();
620 620
     }
621 621
 
622
-    $invoice_user = (int)$wpi_cart->get_user_id();
622
+    $invoice_user = (int) $wpi_cart->get_user_id();
623 623
     $valid_user_data = array(
624 624
         'user_id' => $invoice_user
625 625
     );
626 626
 
627 627
     // If guest checkout allowed
628
-    if ( !wpinv_require_login_to_checkout() ) {
628
+    if (!wpinv_require_login_to_checkout()) {
629 629
         return $valid_user_data;
630 630
     }
631 631
     
632 632
     // Verify there is a user_ID
633
-    if ( $user_ID == $invoice_user ) {
633
+    if ($user_ID == $invoice_user) {
634 634
         // Get the logged in user data
635
-        $user_data = get_userdata( $user_ID );
636
-        $required_fields  = wpinv_checkout_required_fields();
635
+        $user_data = get_userdata($user_ID);
636
+        $required_fields = wpinv_checkout_required_fields();
637 637
 
638 638
         // Loop through required fields and show error messages
639
-         if ( !empty( $required_fields ) ) {
640
-            foreach ( $required_fields as $field_name => $value ) {
641
-                if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) {
642
-                    wpinv_set_error( $value['error_id'], $value['error_message'] );
639
+         if (!empty($required_fields)) {
640
+            foreach ($required_fields as $field_name => $value) {
641
+                if (in_array($value, $required_fields) && empty($_POST['wpinv_' . $field_name])) {
642
+                    wpinv_set_error($value['error_id'], $value['error_message']);
643 643
                 }
644 644
             }
645 645
         }
646 646
 
647 647
         // Verify data
648
-        if ( $user_data ) {
648
+        if ($user_data) {
649 649
             // Collected logged in user data
650 650
             $valid_user_data = array(
651 651
                 'user_id'     => $user_ID,
652
-                'email'       => isset( $_POST['wpinv_email'] ) ? sanitize_email( $_POST['wpinv_email'] ) : $user_data->user_email,
653
-                'first_name'  => isset( $_POST['wpinv_first_name'] ) && ! empty( $_POST['wpinv_first_name'] ) ? sanitize_text_field( $_POST['wpinv_first_name'] ) : $user_data->first_name,
654
-                'last_name'   => isset( $_POST['wpinv_last_name'] ) && ! empty( $_POST['wpinv_last_name']  ) ? sanitize_text_field( $_POST['wpinv_last_name']  ) : $user_data->last_name,
652
+                'email'       => isset($_POST['wpinv_email']) ? sanitize_email($_POST['wpinv_email']) : $user_data->user_email,
653
+                'first_name'  => isset($_POST['wpinv_first_name']) && !empty($_POST['wpinv_first_name']) ? sanitize_text_field($_POST['wpinv_first_name']) : $user_data->first_name,
654
+                'last_name'   => isset($_POST['wpinv_last_name']) && !empty($_POST['wpinv_last_name']) ? sanitize_text_field($_POST['wpinv_last_name']) : $user_data->last_name,
655 655
             );
656 656
 
657
-            if ( !empty( $_POST[ 'wpinv_email' ] ) && !is_email( $_POST[ 'wpinv_email' ] ) ) {
658
-                wpinv_set_error( 'invalid_email', __( 'Please enter a valid email address', 'invoicing' ) );
657
+            if (!empty($_POST['wpinv_email']) && !is_email($_POST['wpinv_email'])) {
658
+                wpinv_set_error('invalid_email', __('Please enter a valid email address', 'invoicing'));
659 659
             }
660 660
         } else {
661 661
             // Set invalid user error
662
-            wpinv_set_error( 'invalid_user', __( 'The user billing information is invalid', 'invoicing' ) );
662
+            wpinv_set_error('invalid_user', __('The user billing information is invalid', 'invoicing'));
663 663
         }
664 664
     } else {
665 665
         // Set invalid user error
666
-        wpinv_set_error( 'invalid_user_id', __( 'The invalid invoice user id', 'invoicing' ) );
666
+        wpinv_set_error('invalid_user_id', __('The invalid invoice user id', 'invoicing'));
667 667
     }
668 668
 
669 669
     // Return user data
@@ -675,18 +675,18 @@  discard block
 block discarded – undo
675 675
 
676 676
     $data = array();
677 677
     
678
-    if ( is_user_logged_in() ) {
679
-        if ( !wpinv_require_login_to_checkout() || ( wpinv_require_login_to_checkout() && (int)$wpi_cart->get_user_id() === (int)get_current_user_id() ) ) {
680
-            $data['user_id'] = (int)get_current_user_id();
678
+    if (is_user_logged_in()) {
679
+        if (!wpinv_require_login_to_checkout() || (wpinv_require_login_to_checkout() && (int) $wpi_cart->get_user_id() === (int) get_current_user_id())) {
680
+            $data['user_id'] = (int) get_current_user_id();
681 681
         } else {
682
-            wpinv_set_error( 'logged_in_only', __( 'You are not allowed to pay for this invoice', 'invoicing' ) );
682
+            wpinv_set_error('logged_in_only', __('You are not allowed to pay for this invoice', 'invoicing'));
683 683
         }
684 684
     } else {
685 685
         // If guest checkout allowed
686
-        if ( !wpinv_require_login_to_checkout() ) {
686
+        if (!wpinv_require_login_to_checkout()) {
687 687
             $data['user_id'] = 0;
688 688
         } else {
689
-            wpinv_set_error( 'logged_in_only', __( 'You must be logged in to pay for this invoice', 'invoicing' ) );
689
+            wpinv_set_error('logged_in_only', __('You must be logged in to pay for this invoice', 'invoicing'));
690 690
         }
691 691
     }
692 692
 
@@ -700,41 +700,41 @@  discard block
 block discarded – undo
700 700
  * @param WPInv_Invoice $invoice
701 701
  * @param GetPaid_Payment_Form_Submission $submission
702 702
  */
703
-function wpinv_process_checkout( $invoice, $submission ) {
703
+function wpinv_process_checkout($invoice, $submission) {
704 704
 
705 705
     // No need to send free invoices to the gateway.
706
-    if ( $invoice->is_free() ) {
707
-        $invoice->set_gateway( 'none' );
708
-        $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
706
+    if ($invoice->is_free()) {
707
+        $invoice->set_gateway('none');
708
+        $invoice->add_note(__("This is a free invoice and won't be sent to the payment gateway", 'invoicing'), false, false, true);
709 709
         $invoice->mark_paid();
710
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
710
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
711 711
     }
712 712
 
713 713
     // Clear an checkout errors.
714 714
     wpinv_clear_errors();
715 715
 
716 716
     // Fires before sending to the gateway.
717
-    do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
717
+    do_action('getpaid_checkout_before_gateway', $invoice, $submission);
718 718
 
719 719
     // Allow the sumission data to be modified before it is sent to the gateway.
720 720
     $submission_data    = $submission->get_data();
721
-    $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $submission_data['wpi-gateway'], $submission, $invoice );
722
-    $submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
721
+    $submission_gateway = apply_filters('getpaid_gateway_submission_gateway', $submission_data['wpi-gateway'], $submission, $invoice);
722
+    $submission_data    = apply_filters('getpaid_gateway_submission_data', $submission_data, $submission, $invoice);
723 723
 
724 724
     // Validate the currency.
725
-    if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
726
-        wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support the invoice currency', 'invoicing' ) );
725
+    if (!apply_filters("getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency())) {
726
+        wpinv_set_error('invalid_currency', __('The chosen payment gateway does not support the invoice currency', 'invoicing'));
727 727
     }
728 728
 
729 729
     // Check to see if we have any errors.
730
-    if ( wpinv_get_errors() ) {
730
+    if (wpinv_get_errors()) {
731 731
         wpinv_send_back_to_checkout();
732 732
     }
733 733
 
734 734
     // Send info to the gateway for payment processing
735
-    do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
735
+    do_action("getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission);
736 736
 
737 737
     // Backwards compatibility.
738
-    wpinv_send_to_gateway( $submission_gateway, $invoice->get_payment_meta() );
738
+    wpinv_send_to_gateway($submission_gateway, $invoice->get_payment_meta());
739 739
 
740 740
 }
Please login to merge, or discard this patch.
includes/class-wpinv-item.php 2 patches
Indentation   +735 added lines, -735 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,30 +10,30 @@  discard block
 block discarded – undo
10 10
 class WPInv_Item  extends GetPaid_Data {
11 11
 
12 12
     /**
13
-	 * Which data store to load.
14
-	 *
15
-	 * @var string
16
-	 */
13
+     * Which data store to load.
14
+     *
15
+     * @var string
16
+     */
17 17
     protected $data_store_name = 'item';
18 18
 
19 19
     /**
20
-	 * This is the name of this object type.
21
-	 *
22
-	 * @var string
23
-	 */
24
-	protected $object_type = 'item';
20
+     * This is the name of this object type.
21
+     *
22
+     * @var string
23
+     */
24
+    protected $object_type = 'item';
25 25
 
26 26
     /**
27
-	 * Item Data array. This is the core item data exposed in APIs.
28
-	 *
29
-	 * @since 1.0.19
30
-	 * @var array
31
-	 */
32
-	protected $data = array(
33
-		'parent_id'            => 0,
34
-		'status'               => 'draft',
35
-		'version'              => '',
36
-		'date_created'         => null,
27
+     * Item Data array. This is the core item data exposed in APIs.
28
+     *
29
+     * @since 1.0.19
30
+     * @var array
31
+     */
32
+    protected $data = array(
33
+        'parent_id'            => 0,
34
+        'status'               => 'draft',
35
+        'version'              => '',
36
+        'date_created'         => null,
37 37
         'date_modified'        => null,
38 38
         'name'                 => '',
39 39
         'description'          => '',
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
     );
59 59
 
60 60
     /**
61
-	 * Stores meta in cache for future reads.
62
-	 *
63
-	 * A group must be set to to enable caching.
64
-	 *
65
-	 * @var string
66
-	 */
67
-	protected $cache_group = 'getpaid_items';
61
+     * Stores meta in cache for future reads.
62
+     *
63
+     * A group must be set to to enable caching.
64
+     *
65
+     * @var string
66
+     */
67
+    protected $cache_group = 'getpaid_items';
68 68
 
69 69
     /**
70 70
      * Stores a reference to the original WP_Post object
@@ -74,37 +74,37 @@  discard block
 block discarded – undo
74 74
     protected $post = null;
75 75
 
76 76
     /**
77
-	 * Get the item if ID is passed, otherwise the item is new and empty.
78
-	 *
79
-	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80
-	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
-			$this->set_id( $item_id );
92
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
-			$this->set_id( $item_id );
94
-		} else {
95
-			$this->set_object_read( true );
96
-		}
77
+     * Get the item if ID is passed, otherwise the item is new and empty.
78
+     *
79
+     * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80
+     */
81
+    public function __construct( $item = 0 ) {
82
+        parent::__construct( $item );
83
+
84
+        if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
+            $this->set_id( $item );
86
+        } elseif ( $item instanceof self ) {
87
+            $this->set_id( $item->get_id() );
88
+        } elseif ( ! empty( $item->ID ) ) {
89
+            $this->set_id( $item->ID );
90
+        } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
+            $this->set_id( $item_id );
92
+        } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
+            $this->set_id( $item_id );
94
+        } else {
95
+            $this->set_object_read( true );
96
+        }
97 97
 
98 98
         // Load the datastore.
99
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
99
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
100 100
 
101
-		if ( $this->get_id() > 0 ) {
101
+        if ( $this->get_id() > 0 ) {
102 102
             $this->post = get_post( $this->get_id() );
103 103
             $this->ID   = $this->get_id();
104
-			$this->data_store->read( $this );
104
+            $this->data_store->read( $this );
105 105
         }
106 106
 
107
-	}
107
+    }
108 108
 
109 109
     /*
110 110
 	|--------------------------------------------------------------------------
@@ -122,401 +122,401 @@  discard block
 block discarded – undo
122 122
     */
123 123
 
124 124
     /**
125
-	 * Get parent item ID.
126
-	 *
127
-	 * @since 1.0.19
128
-	 * @param  string $context View or edit context.
129
-	 * @return int
130
-	 */
131
-	public function get_parent_id( $context = 'view' ) {
132
-		return (int) $this->get_prop( 'parent_id', $context );
125
+     * Get parent item ID.
126
+     *
127
+     * @since 1.0.19
128
+     * @param  string $context View or edit context.
129
+     * @return int
130
+     */
131
+    public function get_parent_id( $context = 'view' ) {
132
+        return (int) $this->get_prop( 'parent_id', $context );
133 133
     }
134 134
 
135 135
     /**
136
-	 * Get item status.
137
-	 *
138
-	 * @since 1.0.19
139
-	 * @param  string $context View or edit context.
140
-	 * @return string
141
-	 */
142
-	public function get_status( $context = 'view' ) {
143
-		return $this->get_prop( 'status', $context );
136
+     * Get item status.
137
+     *
138
+     * @since 1.0.19
139
+     * @param  string $context View or edit context.
140
+     * @return string
141
+     */
142
+    public function get_status( $context = 'view' ) {
143
+        return $this->get_prop( 'status', $context );
144 144
     }
145 145
 
146 146
     /**
147
-	 * Get plugin version when the item was created.
148
-	 *
149
-	 * @since 1.0.19
150
-	 * @param  string $context View or edit context.
151
-	 * @return string
152
-	 */
153
-	public function get_version( $context = 'view' ) {
154
-		return $this->get_prop( 'version', $context );
147
+     * Get plugin version when the item was created.
148
+     *
149
+     * @since 1.0.19
150
+     * @param  string $context View or edit context.
151
+     * @return string
152
+     */
153
+    public function get_version( $context = 'view' ) {
154
+        return $this->get_prop( 'version', $context );
155 155
     }
156 156
 
157 157
     /**
158
-	 * Get date when the item was created.
159
-	 *
160
-	 * @since 1.0.19
161
-	 * @param  string $context View or edit context.
162
-	 * @return string
163
-	 */
164
-	public function get_date_created( $context = 'view' ) {
165
-		return $this->get_prop( 'date_created', $context );
158
+     * Get date when the item was created.
159
+     *
160
+     * @since 1.0.19
161
+     * @param  string $context View or edit context.
162
+     * @return string
163
+     */
164
+    public function get_date_created( $context = 'view' ) {
165
+        return $this->get_prop( 'date_created', $context );
166 166
     }
167 167
 
168 168
     /**
169
-	 * Get GMT date when the item was created.
170
-	 *
171
-	 * @since 1.0.19
172
-	 * @param  string $context View or edit context.
173
-	 * @return string
174
-	 */
175
-	public function get_date_created_gmt( $context = 'view' ) {
169
+     * Get GMT date when the item was created.
170
+     *
171
+     * @since 1.0.19
172
+     * @param  string $context View or edit context.
173
+     * @return string
174
+     */
175
+    public function get_date_created_gmt( $context = 'view' ) {
176 176
         $date = $this->get_date_created( $context );
177 177
 
178 178
         if ( $date ) {
179 179
             $date = get_gmt_from_date( $date );
180 180
         }
181
-		return $date;
181
+        return $date;
182 182
     }
183 183
 
184 184
     /**
185
-	 * Get date when the item was last modified.
186
-	 *
187
-	 * @since 1.0.19
188
-	 * @param  string $context View or edit context.
189
-	 * @return string
190
-	 */
191
-	public function get_date_modified( $context = 'view' ) {
192
-		return $this->get_prop( 'date_modified', $context );
185
+     * Get date when the item was last modified.
186
+     *
187
+     * @since 1.0.19
188
+     * @param  string $context View or edit context.
189
+     * @return string
190
+     */
191
+    public function get_date_modified( $context = 'view' ) {
192
+        return $this->get_prop( 'date_modified', $context );
193 193
     }
194 194
 
195 195
     /**
196
-	 * Get GMT date when the item was last modified.
197
-	 *
198
-	 * @since 1.0.19
199
-	 * @param  string $context View or edit context.
200
-	 * @return string
201
-	 */
202
-	public function get_date_modified_gmt( $context = 'view' ) {
196
+     * Get GMT date when the item was last modified.
197
+     *
198
+     * @since 1.0.19
199
+     * @param  string $context View or edit context.
200
+     * @return string
201
+     */
202
+    public function get_date_modified_gmt( $context = 'view' ) {
203 203
         $date = $this->get_date_modified( $context );
204 204
 
205 205
         if ( $date ) {
206 206
             $date = get_gmt_from_date( $date );
207 207
         }
208
-		return $date;
208
+        return $date;
209 209
     }
210 210
 
211 211
     /**
212
-	 * Get the item name.
213
-	 *
214
-	 * @since 1.0.19
215
-	 * @param  string $context View or edit context.
216
-	 * @return string
217
-	 */
218
-	public function get_name( $context = 'view' ) {
219
-		return $this->get_prop( 'name', $context );
212
+     * Get the item name.
213
+     *
214
+     * @since 1.0.19
215
+     * @param  string $context View or edit context.
216
+     * @return string
217
+     */
218
+    public function get_name( $context = 'view' ) {
219
+        return $this->get_prop( 'name', $context );
220 220
     }
221 221
 
222 222
     /**
223
-	 * Alias of self::get_name().
224
-	 *
225
-	 * @since 1.0.19
226
-	 * @param  string $context View or edit context.
227
-	 * @return string
228
-	 */
229
-	public function get_title( $context = 'view' ) {
230
-		return $this->get_name( $context );
223
+     * Alias of self::get_name().
224
+     *
225
+     * @since 1.0.19
226
+     * @param  string $context View or edit context.
227
+     * @return string
228
+     */
229
+    public function get_title( $context = 'view' ) {
230
+        return $this->get_name( $context );
231 231
     }
232 232
 
233 233
     /**
234
-	 * Get the item description.
235
-	 *
236
-	 * @since 1.0.19
237
-	 * @param  string $context View or edit context.
238
-	 * @return string
239
-	 */
240
-	public function get_description( $context = 'view' ) {
241
-		return $this->get_prop( 'description', $context );
234
+     * Get the item description.
235
+     *
236
+     * @since 1.0.19
237
+     * @param  string $context View or edit context.
238
+     * @return string
239
+     */
240
+    public function get_description( $context = 'view' ) {
241
+        return $this->get_prop( 'description', $context );
242 242
     }
243 243
 
244 244
     /**
245
-	 * Alias of self::get_description().
246
-	 *
247
-	 * @since 1.0.19
248
-	 * @param  string $context View or edit context.
249
-	 * @return string
250
-	 */
251
-	public function get_excerpt( $context = 'view' ) {
252
-		return $this->get_description( $context );
245
+     * Alias of self::get_description().
246
+     *
247
+     * @since 1.0.19
248
+     * @param  string $context View or edit context.
249
+     * @return string
250
+     */
251
+    public function get_excerpt( $context = 'view' ) {
252
+        return $this->get_description( $context );
253 253
     }
254 254
 
255 255
     /**
256
-	 * Alias of self::get_description().
257
-	 *
258
-	 * @since 1.0.19
259
-	 * @param  string $context View or edit context.
260
-	 * @return string
261
-	 */
262
-	public function get_summary( $context = 'view' ) {
263
-		return $this->get_description( $context );
256
+     * Alias of self::get_description().
257
+     *
258
+     * @since 1.0.19
259
+     * @param  string $context View or edit context.
260
+     * @return string
261
+     */
262
+    public function get_summary( $context = 'view' ) {
263
+        return $this->get_description( $context );
264 264
     }
265 265
 
266 266
     /**
267
-	 * Get the owner of the item.
268
-	 *
269
-	 * @since 1.0.19
270
-	 * @param  string $context View or edit context.
271
-	 * @return int
272
-	 */
273
-	public function get_author( $context = 'view' ) {
274
-		return (int) $this->get_prop( 'author', $context );
275
-	}
267
+     * Get the owner of the item.
268
+     *
269
+     * @since 1.0.19
270
+     * @param  string $context View or edit context.
271
+     * @return int
272
+     */
273
+    public function get_author( $context = 'view' ) {
274
+        return (int) $this->get_prop( 'author', $context );
275
+    }
276 276
 	
277
-	/**
278
-	 * Alias of self::get_author().
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @param  string $context View or edit context.
282
-	 * @return int
283
-	 */
284
-	public function get_owner( $context = 'view' ) {
285
-		return $this->get_author( $context );
286
-    }
287
-
288
-    /**
289
-	 * Get the price of the item.
290
-	 *
291
-	 * @since 1.0.19
292
-	 * @param  string $context View or edit context.
293
-	 * @return float
294
-	 */
295
-	public function get_price( $context = 'view' ) {
277
+    /**
278
+     * Alias of self::get_author().
279
+     *
280
+     * @since 1.0.19
281
+     * @param  string $context View or edit context.
282
+     * @return int
283
+     */
284
+    public function get_owner( $context = 'view' ) {
285
+        return $this->get_author( $context );
286
+    }
287
+
288
+    /**
289
+     * Get the price of the item.
290
+     *
291
+     * @since 1.0.19
292
+     * @param  string $context View or edit context.
293
+     * @return float
294
+     */
295
+    public function get_price( $context = 'view' ) {
296 296
         return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
297
-	}
297
+    }
298 298
 	
299
-	/**
300
-	 * Get the inital price of the item.
301
-	 *
302
-	 * @since 1.0.19
303
-	 * @param  string $context View or edit context.
304
-	 * @return float
305
-	 */
306
-	public function get_initial_price( $context = 'view' ) {
299
+    /**
300
+     * Get the inital price of the item.
301
+     *
302
+     * @since 1.0.19
303
+     * @param  string $context View or edit context.
304
+     * @return float
305
+     */
306
+    public function get_initial_price( $context = 'view' ) {
307 307
 
308
-		$price = (float) $this->get_price( $context );
308
+        $price = (float) $this->get_price( $context );
309 309
 
310
-		if ( $this->has_free_trial() ) {
311
-			$price = 0;
312
-		}
310
+        if ( $this->has_free_trial() ) {
311
+            $price = 0;
312
+        }
313 313
 
314 314
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
315 315
     }
316 316
 
317 317
     /**
318
-	 * Returns a formated price.
319
-	 *
320
-	 * @since 1.0.19
321
-	 * @param  string $context View or edit context.
322
-	 * @return string
323
-	 */
318
+     * Returns a formated price.
319
+     *
320
+     * @since 1.0.19
321
+     * @param  string $context View or edit context.
322
+     * @return string
323
+     */
324 324
     public function get_the_price() {
325 325
         return wpinv_price( wpinv_format_amount( $this->get_price() ) );
326
-	}
327
-
328
-	/**
329
-	 * Returns the formated initial price.
330
-	 *
331
-	 * @since 1.0.19
332
-	 * @param  string $context View or edit context.
333
-	 * @return string
334
-	 */
326
+    }
327
+
328
+    /**
329
+     * Returns the formated initial price.
330
+     *
331
+     * @since 1.0.19
332
+     * @param  string $context View or edit context.
333
+     * @return string
334
+     */
335 335
     public function get_the_initial_price() {
336 336
         return wpinv_price( wpinv_format_amount( $this->get_initial_price() ) );
337 337
     }
338 338
 
339 339
     /**
340
-	 * Get the VAT rule of the item.
341
-	 *
342
-	 * @since 1.0.19
343
-	 * @param  string $context View or edit context.
344
-	 * @return string
345
-	 */
346
-	public function get_vat_rule( $context = 'view' ) {
340
+     * Get the VAT rule of the item.
341
+     *
342
+     * @since 1.0.19
343
+     * @param  string $context View or edit context.
344
+     * @return string
345
+     */
346
+    public function get_vat_rule( $context = 'view' ) {
347 347
         return $this->get_prop( 'vat_rule', $context );
348 348
     }
349 349
 
350 350
     /**
351
-	 * Get the VAT class of the item.
352
-	 *
353
-	 * @since 1.0.19
354
-	 * @param  string $context View or edit context.
355
-	 * @return string
356
-	 */
357
-	public function get_vat_class( $context = 'view' ) {
351
+     * Get the VAT class of the item.
352
+     *
353
+     * @since 1.0.19
354
+     * @param  string $context View or edit context.
355
+     * @return string
356
+     */
357
+    public function get_vat_class( $context = 'view' ) {
358 358
         return $this->get_prop( 'vat_class', $context );
359 359
     }
360 360
 
361 361
     /**
362
-	 * Get the type of the item.
363
-	 *
364
-	 * @since 1.0.19
365
-	 * @param  string $context View or edit context.
366
-	 * @return string
367
-	 */
368
-	public function get_type( $context = 'view' ) {
362
+     * Get the type of the item.
363
+     *
364
+     * @since 1.0.19
365
+     * @param  string $context View or edit context.
366
+     * @return string
367
+     */
368
+    public function get_type( $context = 'view' ) {
369 369
         return $this->get_prop( 'type', $context );
370 370
     }
371 371
 
372 372
     /**
373
-	 * Get the custom id of the item.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_custom_id( $context = 'view' ) {
373
+     * Get the custom id of the item.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_custom_id( $context = 'view' ) {
380 380
         return $this->get_prop( 'custom_id', $context );
381 381
     }
382 382
 
383 383
     /**
384
-	 * Get the custom name of the item.
385
-	 *
386
-	 * @since 1.0.19
387
-	 * @param  string $context View or edit context.
388
-	 * @return string
389
-	 */
390
-	public function get_custom_name( $context = 'view' ) {
384
+     * Get the custom name of the item.
385
+     *
386
+     * @since 1.0.19
387
+     * @param  string $context View or edit context.
388
+     * @return string
389
+     */
390
+    public function get_custom_name( $context = 'view' ) {
391 391
         return $this->get_prop( 'custom_name', $context );
392 392
     }
393 393
 
394 394
     /**
395
-	 * Get the custom singular name of the item.
396
-	 *
397
-	 * @since 1.0.19
398
-	 * @param  string $context View or edit context.
399
-	 * @return string
400
-	 */
401
-	public function get_custom_singular_name( $context = 'view' ) {
395
+     * Get the custom singular name of the item.
396
+     *
397
+     * @since 1.0.19
398
+     * @param  string $context View or edit context.
399
+     * @return string
400
+     */
401
+    public function get_custom_singular_name( $context = 'view' ) {
402 402
         return $this->get_prop( 'custom_singular_name', $context );
403 403
     }
404 404
 
405 405
     /**
406
-	 * Checks if an item is editable..
407
-	 *
408
-	 * @since 1.0.19
409
-	 * @param  string $context View or edit context.
410
-	 * @return int
411
-	 */
412
-	public function get_is_editable( $context = 'view' ) {
406
+     * Checks if an item is editable..
407
+     *
408
+     * @since 1.0.19
409
+     * @param  string $context View or edit context.
410
+     * @return int
411
+     */
412
+    public function get_is_editable( $context = 'view' ) {
413 413
         return (int) $this->get_prop( 'is_editable', $context );
414 414
     }
415 415
 
416 416
     /**
417
-	 * Alias of self::get_is_editable().
418
-	 *
419
-	 * @since 1.0.19
420
-	 * @param  string $context View or edit context.
421
-	 * @return int
422
-	 */
423
-	public function get_editable( $context = 'view' ) {
424
-		return $this->get_is_editable( $context );
417
+     * Alias of self::get_is_editable().
418
+     *
419
+     * @since 1.0.19
420
+     * @param  string $context View or edit context.
421
+     * @return int
422
+     */
423
+    public function get_editable( $context = 'view' ) {
424
+        return $this->get_is_editable( $context );
425 425
     }
426 426
 
427 427
     /**
428
-	 * Checks if dynamic pricing is enabled.
429
-	 *
430
-	 * @since 1.0.19
431
-	 * @param  string $context View or edit context.
432
-	 * @return int
433
-	 */
434
-	public function get_is_dynamic_pricing( $context = 'view' ) {
428
+     * Checks if dynamic pricing is enabled.
429
+     *
430
+     * @since 1.0.19
431
+     * @param  string $context View or edit context.
432
+     * @return int
433
+     */
434
+    public function get_is_dynamic_pricing( $context = 'view' ) {
435 435
         return (int) $this->get_prop( 'is_dynamic_pricing', $context );
436 436
     }
437 437
 
438 438
     /**
439
-	 * Returns the minimum price if dynamic pricing is enabled.
440
-	 *
441
-	 * @since 1.0.19
442
-	 * @param  string $context View or edit context.
443
-	 * @return float
444
-	 */
445
-	public function get_minimum_price( $context = 'view' ) {
439
+     * Returns the minimum price if dynamic pricing is enabled.
440
+     *
441
+     * @since 1.0.19
442
+     * @param  string $context View or edit context.
443
+     * @return float
444
+     */
445
+    public function get_minimum_price( $context = 'view' ) {
446 446
         return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
447 447
     }
448 448
 
449 449
     /**
450
-	 * Checks if this is a recurring item.
451
-	 *
452
-	 * @since 1.0.19
453
-	 * @param  string $context View or edit context.
454
-	 * @return int
455
-	 */
456
-	public function get_is_recurring( $context = 'view' ) {
450
+     * Checks if this is a recurring item.
451
+     *
452
+     * @since 1.0.19
453
+     * @param  string $context View or edit context.
454
+     * @return int
455
+     */
456
+    public function get_is_recurring( $context = 'view' ) {
457 457
         return (int) $this->get_prop( 'is_recurring', $context );
458
-	}
458
+    }
459 459
 	
460
-	/**
461
-	 * Get the recurring price of the item.
462
-	 *
463
-	 * @since 1.0.19
464
-	 * @param  string $context View or edit context.
465
-	 * @return float
466
-	 */
467
-	public function get_recurring_price( $context = 'view' ) {
468
-		$price = $this->get_price( $context );
460
+    /**
461
+     * Get the recurring price of the item.
462
+     *
463
+     * @since 1.0.19
464
+     * @param  string $context View or edit context.
465
+     * @return float
466
+     */
467
+    public function get_recurring_price( $context = 'view' ) {
468
+        $price = $this->get_price( $context );
469 469
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
470
-	}
471
-
472
-	/**
473
-	 * Get the formatted recurring price of the item.
474
-	 *
475
-	 * @since 1.0.19
476
-	 * @param  string $context View or edit context.
477
-	 * @return string
478
-	 */
470
+    }
471
+
472
+    /**
473
+     * Get the formatted recurring price of the item.
474
+     *
475
+     * @since 1.0.19
476
+     * @param  string $context View or edit context.
477
+     * @return string
478
+     */
479 479
     public function get_the_recurring_price() {
480 480
         return wpinv_price( wpinv_format_amount( $this->get_recurring_price() ) );
481
-	}
482
-
483
-	/**
484
-	 * Get the first renewal date (in timestamps) of the item.
485
-	 *
486
-	 * @since 1.0.19
487
-	 * @return int
488
-	 */
489
-	public function get_first_renewal_date() {
490
-
491
-		$periods = array(
492
-			'D' => 'days',
493
-			'W' => 'weeks',
494
-			'M' => 'months',
495
-			'Y' => 'years',
496
-		);
497
-
498
-		$period   = $this->get_recurring_period();
499
-		$interval = $this->get_recurring_interval();
500
-
501
-		if ( $this->has_free_trial() ) {
502
-			$period   = $this->get_trial_period();
503
-			$interval = $this->get_trial_interval();
504
-		}
505
-
506
-		$period       = $periods[ $period ];
507
-		$interval     = empty( $interval ) ? 1 : $interval;
508
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
481
+    }
482
+
483
+    /**
484
+     * Get the first renewal date (in timestamps) of the item.
485
+     *
486
+     * @since 1.0.19
487
+     * @return int
488
+     */
489
+    public function get_first_renewal_date() {
490
+
491
+        $periods = array(
492
+            'D' => 'days',
493
+            'W' => 'weeks',
494
+            'M' => 'months',
495
+            'Y' => 'years',
496
+        );
497
+
498
+        $period   = $this->get_recurring_period();
499
+        $interval = $this->get_recurring_interval();
500
+
501
+        if ( $this->has_free_trial() ) {
502
+            $period   = $this->get_trial_period();
503
+            $interval = $this->get_trial_interval();
504
+        }
505
+
506
+        $period       = $periods[ $period ];
507
+        $interval     = empty( $interval ) ? 1 : $interval;
508
+        $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
509 509
         return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
510 510
     }
511 511
 
512 512
     /**
513
-	 * Get the recurring period.
514
-	 *
515
-	 * @since 1.0.19
516
-	 * @param  bool $full Return abbreviation or in full.
517
-	 * @return string
518
-	 */
519
-	public function get_recurring_period( $full = false ) {
513
+     * Get the recurring period.
514
+     *
515
+     * @since 1.0.19
516
+     * @param  bool $full Return abbreviation or in full.
517
+     * @return string
518
+     */
519
+    public function get_recurring_period( $full = false ) {
520 520
         $period = $this->get_prop( 'recurring_period', 'view' );
521 521
 
522 522
         if ( $full && ! is_bool( $full ) ) {
@@ -527,63 +527,63 @@  discard block
 block discarded – undo
527 527
     }
528 528
 
529 529
     /**
530
-	 * Get the recurring interval.
531
-	 *
532
-	 * @since 1.0.19
533
-	 * @param  string $context View or edit context.
534
-	 * @return int
535
-	 */
536
-	public function get_recurring_interval( $context = 'view' ) {
537
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
530
+     * Get the recurring interval.
531
+     *
532
+     * @since 1.0.19
533
+     * @param  string $context View or edit context.
534
+     * @return int
535
+     */
536
+    public function get_recurring_interval( $context = 'view' ) {
537
+        $interval = absint( $this->get_prop( 'recurring_interval', $context ) );
538 538
 
539
-		if ( $interval < 1 ) {
540
-			$interval = 1;
541
-		}
539
+        if ( $interval < 1 ) {
540
+            $interval = 1;
541
+        }
542 542
 
543 543
         return $interval;
544 544
     }
545 545
 
546 546
     /**
547
-	 * Get the recurring limit.
548
-	 *
549
-	 * @since 1.0.19
550
-	 * @param  string $context View or edit context.
551
-	 * @return int
552
-	 */
553
-	public function get_recurring_limit( $context = 'view' ) {
547
+     * Get the recurring limit.
548
+     *
549
+     * @since 1.0.19
550
+     * @param  string $context View or edit context.
551
+     * @return int
552
+     */
553
+    public function get_recurring_limit( $context = 'view' ) {
554 554
         return (int) $this->get_prop( 'recurring_limit', $context );
555 555
     }
556 556
 
557 557
     /**
558
-	 * Checks if we have a free trial.
559
-	 *
560
-	 * @since 1.0.19
561
-	 * @param  string $context View or edit context.
562
-	 * @return int
563
-	 */
564
-	public function get_is_free_trial( $context = 'view' ) {
558
+     * Checks if we have a free trial.
559
+     *
560
+     * @since 1.0.19
561
+     * @param  string $context View or edit context.
562
+     * @return int
563
+     */
564
+    public function get_is_free_trial( $context = 'view' ) {
565 565
         return (int) $this->get_prop( 'is_free_trial', $context );
566 566
     }
567 567
 
568 568
     /**
569
-	 * Alias for self::get_is_free_trial().
570
-	 *
571
-	 * @since 1.0.19
572
-	 * @param  string $context View or edit context.
573
-	 * @return int
574
-	 */
575
-	public function get_free_trial( $context = 'view' ) {
569
+     * Alias for self::get_is_free_trial().
570
+     *
571
+     * @since 1.0.19
572
+     * @param  string $context View or edit context.
573
+     * @return int
574
+     */
575
+    public function get_free_trial( $context = 'view' ) {
576 576
         return $this->get_is_free_trial( $context );
577 577
     }
578 578
 
579 579
     /**
580
-	 * Get the trial period.
581
-	 *
582
-	 * @since 1.0.19
583
-	 * @param  bool $full Return abbreviation or in full.
584
-	 * @return string
585
-	 */
586
-	public function get_trial_period( $full = false ) {
580
+     * Get the trial period.
581
+     *
582
+     * @since 1.0.19
583
+     * @param  bool $full Return abbreviation or in full.
584
+     * @return string
585
+     */
586
+    public function get_trial_period( $full = false ) {
587 587
         $period = $this->get_prop( 'trial_period', 'view' );
588 588
 
589 589
         if ( $full && ! is_bool( $full ) ) {
@@ -594,104 +594,104 @@  discard block
 block discarded – undo
594 594
     }
595 595
 
596 596
     /**
597
-	 * Get the trial interval.
598
-	 *
599
-	 * @since 1.0.19
600
-	 * @param  string $context View or edit context.
601
-	 * @return int
602
-	 */
603
-	public function get_trial_interval( $context = 'view' ) {
597
+     * Get the trial interval.
598
+     *
599
+     * @since 1.0.19
600
+     * @param  string $context View or edit context.
601
+     * @return int
602
+     */
603
+    public function get_trial_interval( $context = 'view' ) {
604 604
         return (int) $this->get_prop( 'trial_interval', $context );
605
-	}
605
+    }
606 606
 	
607
-	/**
608
-	 * Get the item's edit url.
609
-	 *
610
-	 * @since 1.0.19
611
-	 * @return string
612
-	 */
613
-	public function get_edit_url() {
607
+    /**
608
+     * Get the item's edit url.
609
+     *
610
+     * @since 1.0.19
611
+     * @return string
612
+     */
613
+    public function get_edit_url() {
614 614
         return get_edit_post_link( $this->get_id() );
615
-	}
616
-
617
-	/**
618
-	 * Given an item's name/custom id, it returns its id.
619
-	 *
620
-	 *
621
-	 * @static
622
-	 * @param string $value The item name or custom id.
623
-	 * @param string $field Either name or custom_id.
624
-	 * @param string $type in case you need to search for a given type.
625
-	 * @since 1.0.15
626
-	 * @return int
627
-	 */
628
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
629
-
630
-		// Trim the value.
631
-		$value = trim( $value );
632
-
633
-		if ( empty( $value ) ) {
634
-			return 0;
635
-		}
615
+    }
616
+
617
+    /**
618
+     * Given an item's name/custom id, it returns its id.
619
+     *
620
+     *
621
+     * @static
622
+     * @param string $value The item name or custom id.
623
+     * @param string $field Either name or custom_id.
624
+     * @param string $type in case you need to search for a given type.
625
+     * @since 1.0.15
626
+     * @return int
627
+     */
628
+    public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
629
+
630
+        // Trim the value.
631
+        $value = trim( $value );
632
+
633
+        if ( empty( $value ) ) {
634
+            return 0;
635
+        }
636 636
 
637 637
         // Valid fields.
638 638
         $fields = array( 'custom_id', 'name', 'slug' );
639 639
 
640
-		// Ensure a field has been passed.
641
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
642
-			return 0;
643
-		}
644
-
645
-		if ( $field == 'name' ) {
646
-			$field = 'slug';
647
-		} 
648
-
649
-		// Maybe retrieve from the cache.
650
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
651
-		if ( ! empty( $item_id ) ) {
652
-			return $item_id;
653
-		}
654
-
655
-		// Fetch from the db.
656
-		if ( $field =='slug' ) {
657
-			$items = get_posts(
658
-				array(
659
-					'post_type'      => 'wpi_item',
660
-					'name'           => $value,
661
-					'posts_per_page' => 1,
662
-					'post_status'    => 'any',
663
-				)
664
-			);
665
-		}
666
-
667
-		if ( $field =='custom_id' ) {
668
-			$items = get_posts(
669
-				array(
670
-					'post_type'      => 'wpi_item',
671
-					'posts_per_page' => 1,
672
-					'post_status'    => 'any',
673
-					'meta_query'     => array(
674
-						array(
675
-							'key'   => '_wpinv_type',
676
-                			'value' => $type,
677
-						),
678
-						array(
679
-							'key'   => '_wpinv_custom_id',
680
-                			'value' => $type,
681
-						)
682
-					)
683
-				)
684
-			);
685
-		}
686
-
687
-		if ( empty( $items ) ) {
688
-			return 0;
689
-		}
690
-
691
-		// Update the cache with our data
692
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
693
-
694
-		return $items[0]->ID;
640
+        // Ensure a field has been passed.
641
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
642
+            return 0;
643
+        }
644
+
645
+        if ( $field == 'name' ) {
646
+            $field = 'slug';
647
+        } 
648
+
649
+        // Maybe retrieve from the cache.
650
+        $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
651
+        if ( ! empty( $item_id ) ) {
652
+            return $item_id;
653
+        }
654
+
655
+        // Fetch from the db.
656
+        if ( $field =='slug' ) {
657
+            $items = get_posts(
658
+                array(
659
+                    'post_type'      => 'wpi_item',
660
+                    'name'           => $value,
661
+                    'posts_per_page' => 1,
662
+                    'post_status'    => 'any',
663
+                )
664
+            );
665
+        }
666
+
667
+        if ( $field =='custom_id' ) {
668
+            $items = get_posts(
669
+                array(
670
+                    'post_type'      => 'wpi_item',
671
+                    'posts_per_page' => 1,
672
+                    'post_status'    => 'any',
673
+                    'meta_query'     => array(
674
+                        array(
675
+                            'key'   => '_wpinv_type',
676
+                            'value' => $type,
677
+                        ),
678
+                        array(
679
+                            'key'   => '_wpinv_custom_id',
680
+                            'value' => $type,
681
+                        )
682
+                    )
683
+                )
684
+            );
685
+        }
686
+
687
+        if ( empty( $items ) ) {
688
+            return 0;
689
+        }
690
+
691
+        // Update the cache with our data
692
+        wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
693
+
694
+        return $items[0]->ID;
695 695
     }
696 696
 
697 697
     /**
@@ -724,52 +724,52 @@  discard block
 block discarded – undo
724 724
     */
725 725
 
726 726
     /**
727
-	 * Set parent order ID.
728
-	 *
729
-	 * @since 1.0.19
730
-	 */
731
-	public function set_parent_id( $value ) {
732
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
733
-			return;
734
-		}
735
-		$this->set_prop( 'parent_id', absint( $value ) );
736
-	}
737
-
738
-    /**
739
-	 * Sets item status.
740
-	 *
741
-	 * @since 1.0.19
742
-	 * @param  string $status New status.
743
-	 * @return array details of change.
744
-	 */
745
-	public function set_status( $status ) {
727
+     * Set parent order ID.
728
+     *
729
+     * @since 1.0.19
730
+     */
731
+    public function set_parent_id( $value ) {
732
+        if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
733
+            return;
734
+        }
735
+        $this->set_prop( 'parent_id', absint( $value ) );
736
+    }
737
+
738
+    /**
739
+     * Sets item status.
740
+     *
741
+     * @since 1.0.19
742
+     * @param  string $status New status.
743
+     * @return array details of change.
744
+     */
745
+    public function set_status( $status ) {
746 746
         $old_status = $this->get_status();
747 747
 
748 748
         $this->set_prop( 'status', $status );
749 749
 
750
-		return array(
751
-			'from' => $old_status,
752
-			'to'   => $status,
753
-		);
750
+        return array(
751
+            'from' => $old_status,
752
+            'to'   => $status,
753
+        );
754 754
     }
755 755
 
756 756
     /**
757
-	 * Set plugin version when the item was created.
758
-	 *
759
-	 * @since 1.0.19
760
-	 */
761
-	public function set_version( $value ) {
762
-		$this->set_prop( 'version', $value );
757
+     * Set plugin version when the item was created.
758
+     *
759
+     * @since 1.0.19
760
+     */
761
+    public function set_version( $value ) {
762
+        $this->set_prop( 'version', $value );
763 763
     }
764 764
 
765 765
     /**
766
-	 * Set date when the item was created.
767
-	 *
768
-	 * @since 1.0.19
769
-	 * @param string $value Value to set.
766
+     * Set date when the item was created.
767
+     *
768
+     * @since 1.0.19
769
+     * @param string $value Value to set.
770 770
      * @return bool Whether or not the date was set.
771
-	 */
772
-	public function set_date_created( $value ) {
771
+     */
772
+    public function set_date_created( $value ) {
773 773
         $date = strtotime( $value );
774 774
 
775 775
         if ( $date ) {
@@ -782,13 +782,13 @@  discard block
 block discarded – undo
782 782
     }
783 783
 
784 784
     /**
785
-	 * Set date when the item was last modified.
786
-	 *
787
-	 * @since 1.0.19
788
-	 * @param string $value Value to set.
785
+     * Set date when the item was last modified.
786
+     *
787
+     * @since 1.0.19
788
+     * @param string $value Value to set.
789 789
      * @return bool Whether or not the date was set.
790
-	 */
791
-	public function set_date_modified( $value ) {
790
+     */
791
+    public function set_date_modified( $value ) {
792 792
         $date = strtotime( $value );
793 793
 
794 794
         if ( $date ) {
@@ -801,115 +801,115 @@  discard block
 block discarded – undo
801 801
     }
802 802
 
803 803
     /**
804
-	 * Set the item name.
805
-	 *
806
-	 * @since 1.0.19
807
-	 * @param  string $value New name.
808
-	 */
809
-	public function set_name( $value ) {
804
+     * Set the item name.
805
+     *
806
+     * @since 1.0.19
807
+     * @param  string $value New name.
808
+     */
809
+    public function set_name( $value ) {
810 810
         $name = sanitize_text_field( $value );
811
-		$this->set_prop( 'name', $name );
811
+        $this->set_prop( 'name', $name );
812 812
     }
813 813
 
814 814
     /**
815
-	 * Alias of self::set_name().
816
-	 *
817
-	 * @since 1.0.19
818
-	 * @param  string $value New name.
819
-	 */
820
-	public function set_title( $value ) {
821
-		$this->set_name( $value );
815
+     * Alias of self::set_name().
816
+     *
817
+     * @since 1.0.19
818
+     * @param  string $value New name.
819
+     */
820
+    public function set_title( $value ) {
821
+        $this->set_name( $value );
822 822
     }
823 823
 
824 824
     /**
825
-	 * Set the item description.
826
-	 *
827
-	 * @since 1.0.19
828
-	 * @param  string $value New description.
829
-	 */
830
-	public function set_description( $value ) {
825
+     * Set the item description.
826
+     *
827
+     * @since 1.0.19
828
+     * @param  string $value New description.
829
+     */
830
+    public function set_description( $value ) {
831 831
         $description = wp_kses_post( $value );
832
-		return $this->set_prop( 'description', $description );
832
+        return $this->set_prop( 'description', $description );
833 833
     }
834 834
 
835 835
     /**
836
-	 * Alias of self::set_description().
837
-	 *
838
-	 * @since 1.0.19
839
-	 * @param  string $value New description.
840
-	 */
841
-	public function set_excerpt( $value ) {
842
-		$this->set_description( $value );
836
+     * Alias of self::set_description().
837
+     *
838
+     * @since 1.0.19
839
+     * @param  string $value New description.
840
+     */
841
+    public function set_excerpt( $value ) {
842
+        $this->set_description( $value );
843 843
     }
844 844
 
845 845
     /**
846
-	 * Alias of self::set_description().
847
-	 *
848
-	 * @since 1.0.19
849
-	 * @param  string $value New description.
850
-	 */
851
-	public function set_summary( $value ) {
852
-		$this->set_description( $value );
846
+     * Alias of self::set_description().
847
+     *
848
+     * @since 1.0.19
849
+     * @param  string $value New description.
850
+     */
851
+    public function set_summary( $value ) {
852
+        $this->set_description( $value );
853 853
     }
854 854
 
855 855
     /**
856
-	 * Set the owner of the item.
857
-	 *
858
-	 * @since 1.0.19
859
-	 * @param  int $value New author.
860
-	 */
861
-	public function set_author( $value ) {
862
-		$this->set_prop( 'author', (int) $value );
863
-	}
856
+     * Set the owner of the item.
857
+     *
858
+     * @since 1.0.19
859
+     * @param  int $value New author.
860
+     */
861
+    public function set_author( $value ) {
862
+        $this->set_prop( 'author', (int) $value );
863
+    }
864 864
 	
865
-	/**
866
-	 * Alias of self::set_author().
867
-	 *
868
-	 * @since 1.0.19
869
-	 * @param  int $value New author.
870
-	 */
871
-	public function set_owner( $value ) {
872
-		$this->set_author( $value );
873
-    }
874
-
875
-    /**
876
-	 * Set the price of the item.
877
-	 *
878
-	 * @since 1.0.19
879
-	 * @param  float $value New price.
880
-	 */
881
-	public function set_price( $value ) {
865
+    /**
866
+     * Alias of self::set_author().
867
+     *
868
+     * @since 1.0.19
869
+     * @param  int $value New author.
870
+     */
871
+    public function set_owner( $value ) {
872
+        $this->set_author( $value );
873
+    }
874
+
875
+    /**
876
+     * Set the price of the item.
877
+     *
878
+     * @since 1.0.19
879
+     * @param  float $value New price.
880
+     */
881
+    public function set_price( $value ) {
882 882
         $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
883 883
     }
884 884
 
885 885
     /**
886
-	 * Set the VAT rule of the item.
887
-	 *
888
-	 * @since 1.0.19
889
-	 * @param  string $value new rule.
890
-	 */
891
-	public function set_vat_rule( $value ) {
886
+     * Set the VAT rule of the item.
887
+     *
888
+     * @since 1.0.19
889
+     * @param  string $value new rule.
890
+     */
891
+    public function set_vat_rule( $value ) {
892 892
         $this->set_prop( 'vat_rule', $value );
893 893
     }
894 894
 
895 895
     /**
896
-	 * Set the VAT class of the item.
897
-	 *
898
-	 * @since 1.0.19
899
-	 * @param  string $value new class.
900
-	 */
901
-	public function set_vat_class( $value ) {
896
+     * Set the VAT class of the item.
897
+     *
898
+     * @since 1.0.19
899
+     * @param  string $value new class.
900
+     */
901
+    public function set_vat_class( $value ) {
902 902
         $this->set_prop( 'vat_class', $value );
903 903
     }
904 904
 
905 905
     /**
906
-	 * Set the type of the item.
907
-	 *
908
-	 * @since 1.0.19
909
-	 * @param  string $value new item type.
910
-	 * @return string
911
-	 */
912
-	public function set_type( $value ) {
906
+     * Set the type of the item.
907
+     *
908
+     * @since 1.0.19
909
+     * @param  string $value new item type.
910
+     * @return string
911
+     */
912
+    public function set_type( $value ) {
913 913
 
914 914
         if ( empty( $value ) ) {
915 915
             $value = 'custom';
@@ -919,134 +919,134 @@  discard block
 block discarded – undo
919 919
     }
920 920
 
921 921
     /**
922
-	 * Set the custom id of the item.
923
-	 *
924
-	 * @since 1.0.19
925
-	 * @param  string $value new custom id.
926
-	 */
927
-	public function set_custom_id( $value ) {
922
+     * Set the custom id of the item.
923
+     *
924
+     * @since 1.0.19
925
+     * @param  string $value new custom id.
926
+     */
927
+    public function set_custom_id( $value ) {
928 928
         $this->set_prop( 'custom_id', $value );
929 929
     }
930 930
 
931 931
     /**
932
-	 * Set the custom name of the item.
933
-	 *
934
-	 * @since 1.0.19
935
-	 * @param  string $value new custom name.
936
-	 */
937
-	public function set_custom_name( $value ) {
932
+     * Set the custom name of the item.
933
+     *
934
+     * @since 1.0.19
935
+     * @param  string $value new custom name.
936
+     */
937
+    public function set_custom_name( $value ) {
938 938
         $this->set_prop( 'custom_name', $value );
939 939
     }
940 940
 
941 941
     /**
942
-	 * Set the custom singular name of the item.
943
-	 *
944
-	 * @since 1.0.19
945
-	 * @param  string $value new custom singular name.
946
-	 */
947
-	public function set_custom_singular_name( $value ) {
942
+     * Set the custom singular name of the item.
943
+     *
944
+     * @since 1.0.19
945
+     * @param  string $value new custom singular name.
946
+     */
947
+    public function set_custom_singular_name( $value ) {
948 948
         $this->set_prop( 'custom_singular_name', $value );
949 949
     }
950 950
 
951 951
     /**
952
-	 * Sets if an item is editable..
953
-	 *
954
-	 * @since 1.0.19
955
-	 * @param  int|bool $value whether or not the item is editable.
956
-	 */
957
-	public function set_is_editable( $value ) {
958
-		if ( is_numeric( $value ) ) {
959
-			$this->set_prop( 'is_editable', (int) $value );
960
-		}
952
+     * Sets if an item is editable..
953
+     *
954
+     * @since 1.0.19
955
+     * @param  int|bool $value whether or not the item is editable.
956
+     */
957
+    public function set_is_editable( $value ) {
958
+        if ( is_numeric( $value ) ) {
959
+            $this->set_prop( 'is_editable', (int) $value );
960
+        }
961 961
     }
962 962
 
963 963
     /**
964
-	 * Sets if dynamic pricing is enabled.
965
-	 *
966
-	 * @since 1.0.19
967
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
968
-	 */
969
-	public function set_is_dynamic_pricing( $value ) {
964
+     * Sets if dynamic pricing is enabled.
965
+     *
966
+     * @since 1.0.19
967
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
968
+     */
969
+    public function set_is_dynamic_pricing( $value ) {
970 970
         $this->set_prop( 'is_dynamic_pricing', (int) $value );
971 971
     }
972 972
 
973 973
     /**
974
-	 * Sets the minimum price if dynamic pricing is enabled.
975
-	 *
976
-	 * @since 1.0.19
977
-	 * @param  float $value minimum price.
978
-	 */
979
-	public function set_minimum_price( $value ) {
974
+     * Sets the minimum price if dynamic pricing is enabled.
975
+     *
976
+     * @since 1.0.19
977
+     * @param  float $value minimum price.
978
+     */
979
+    public function set_minimum_price( $value ) {
980 980
         $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
981 981
     }
982 982
 
983 983
     /**
984
-	 * Sets if this is a recurring item.
985
-	 *
986
-	 * @since 1.0.19
987
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
988
-	 */
989
-	public function set_is_recurring( $value ) {
984
+     * Sets if this is a recurring item.
985
+     *
986
+     * @since 1.0.19
987
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
988
+     */
989
+    public function set_is_recurring( $value ) {
990 990
         $this->set_prop( 'is_recurring', (int) $value );
991 991
     }
992 992
 
993 993
     /**
994
-	 * Set the recurring period.
995
-	 *
996
-	 * @since 1.0.19
997
-	 * @param  string $value new period.
998
-	 */
999
-	public function set_recurring_period( $value ) {
994
+     * Set the recurring period.
995
+     *
996
+     * @since 1.0.19
997
+     * @param  string $value new period.
998
+     */
999
+    public function set_recurring_period( $value ) {
1000 1000
         $this->set_prop( 'recurring_period', $value );
1001 1001
     }
1002 1002
 
1003 1003
     /**
1004
-	 * Set the recurring interval.
1005
-	 *
1006
-	 * @since 1.0.19
1007
-	 * @param  int $value recurring interval.
1008
-	 */
1009
-	public function set_recurring_interval( $value ) {
1004
+     * Set the recurring interval.
1005
+     *
1006
+     * @since 1.0.19
1007
+     * @param  int $value recurring interval.
1008
+     */
1009
+    public function set_recurring_interval( $value ) {
1010 1010
         return $this->set_prop( 'recurring_interval', (int) $value );
1011 1011
     }
1012 1012
 
1013 1013
     /**
1014
-	 * Get the recurring limit.
1015
-	 * @since 1.0.19
1016
-	 * @param  int $value The recurring limit.
1017
-	 * @return int
1018
-	 */
1019
-	public function set_recurring_limit( $value ) {
1014
+     * Get the recurring limit.
1015
+     * @since 1.0.19
1016
+     * @param  int $value The recurring limit.
1017
+     * @return int
1018
+     */
1019
+    public function set_recurring_limit( $value ) {
1020 1020
         $this->set_prop( 'recurring_limit', (int) $value );
1021 1021
     }
1022 1022
 
1023 1023
     /**
1024
-	 * Checks if we have a free trial.
1025
-	 *
1026
-	 * @since 1.0.19
1027
-	 * @param  int|bool $value whether or not it has a free trial.
1028
-	 */
1029
-	public function set_is_free_trial( $value ) {
1024
+     * Checks if we have a free trial.
1025
+     *
1026
+     * @since 1.0.19
1027
+     * @param  int|bool $value whether or not it has a free trial.
1028
+     */
1029
+    public function set_is_free_trial( $value ) {
1030 1030
         $this->set_prop( 'is_free_trial', (int) $value );
1031 1031
     }
1032 1032
 
1033 1033
     /**
1034
-	 * Set the trial period.
1035
-	 *
1036
-	 * @since 1.0.19
1037
-	 * @param  string $value trial period.
1038
-	 */
1039
-	public function set_trial_period( $value ) {
1034
+     * Set the trial period.
1035
+     *
1036
+     * @since 1.0.19
1037
+     * @param  string $value trial period.
1038
+     */
1039
+    public function set_trial_period( $value ) {
1040 1040
         $this->set_prop( 'trial_period', $value );
1041 1041
     }
1042 1042
 
1043 1043
     /**
1044
-	 * Set the trial interval.
1045
-	 *
1046
-	 * @since 1.0.19
1047
-	 * @param  int $value trial interval.
1048
-	 */
1049
-	public function set_trial_interval( $value ) {
1044
+     * Set the trial interval.
1045
+     *
1046
+     * @since 1.0.19
1047
+     * @param  int $value trial interval.
1048
+     */
1049
+    public function set_trial_interval( $value ) {
1050 1050
         $this->set_prop( 'trial_interval', $value );
1051 1051
     }
1052 1052
 
@@ -1054,17 +1054,17 @@  discard block
 block discarded – undo
1054 1054
      * Create an item. For backwards compatibilty.
1055 1055
      * 
1056 1056
      * @deprecated
1057
-	 * @return int item id
1057
+     * @return int item id
1058 1058
      */
1059 1059
     public function create( $data = array() ) {
1060 1060
 
1061
-		// Set the properties.
1062
-		if ( is_array( $data ) ) {
1063
-			$this->set_props( $data );
1064
-		}
1061
+        // Set the properties.
1062
+        if ( is_array( $data ) ) {
1063
+            $this->set_props( $data );
1064
+        }
1065 1065
 
1066
-		// Save the item.
1067
-		return $this->save();
1066
+        // Save the item.
1067
+        return $this->save();
1068 1068
 
1069 1069
     }
1070 1070
 
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
      * Updates an item. For backwards compatibilty.
1073 1073
      * 
1074 1074
      * @deprecated
1075
-	 * @return int item id
1075
+     * @return int item id
1076 1076
      */
1077 1077
     public function update( $data = array() ) {
1078 1078
         return $this->create( $data );
@@ -1088,84 +1088,84 @@  discard block
 block discarded – undo
1088 1088
 	*/
1089 1089
 
1090 1090
     /**
1091
-	 * Checks whether the item has enabled dynamic pricing.
1092
-	 *
1093
-	 * @since 1.0.19
1094
-	 * @return bool
1095
-	 */
1096
-	public function user_can_set_their_price() {
1091
+     * Checks whether the item has enabled dynamic pricing.
1092
+     *
1093
+     * @since 1.0.19
1094
+     * @return bool
1095
+     */
1096
+    public function user_can_set_their_price() {
1097 1097
         return (bool) $this->get_is_dynamic_pricing();
1098
-	}
1098
+    }
1099 1099
 	
1100
-	/**
1101
-	 * Checks whether the item is recurring.
1102
-	 *
1103
-	 * @since 1.0.19
1104
-	 * @return bool
1105
-	 */
1106
-	public function is_recurring() {
1100
+    /**
1101
+     * Checks whether the item is recurring.
1102
+     *
1103
+     * @since 1.0.19
1104
+     * @return bool
1105
+     */
1106
+    public function is_recurring() {
1107 1107
         return (bool) $this->get_is_recurring();
1108 1108
     }
1109 1109
 
1110 1110
     /**
1111
-	 * Checks whether the item has a free trial.
1112
-	 *
1113
-	 * @since 1.0.19
1114
-	 * @return bool
1115
-	 */
1111
+     * Checks whether the item has a free trial.
1112
+     *
1113
+     * @since 1.0.19
1114
+     * @return bool
1115
+     */
1116 1116
     public function has_free_trial() {
1117 1117
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1118 1118
         return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1119 1119
     }
1120 1120
 
1121 1121
     /**
1122
-	 * Checks whether the item is free.
1123
-	 *
1124
-	 * @since 1.0.19
1125
-	 * @return bool
1126
-	 */
1122
+     * Checks whether the item is free.
1123
+     *
1124
+     * @since 1.0.19
1125
+     * @return bool
1126
+     */
1127 1127
     public function is_free() {
1128 1128
         $is_free   = $this->get_price() == 0;
1129 1129
         return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1130 1130
     }
1131 1131
 
1132 1132
     /**
1133
-	 * Checks the item status against a passed in status.
1134
-	 *
1135
-	 * @param array|string $status Status to check.
1136
-	 * @return bool
1137
-	 */
1138
-	public function has_status( $status ) {
1139
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1140
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1133
+     * Checks the item status against a passed in status.
1134
+     *
1135
+     * @param array|string $status Status to check.
1136
+     * @return bool
1137
+     */
1138
+    public function has_status( $status ) {
1139
+        $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1140
+        return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1141 1141
     }
1142 1142
 
1143 1143
     /**
1144
-	 * Checks the item type against a passed in types.
1145
-	 *
1146
-	 * @param array|string $type Type to check.
1147
-	 * @return bool
1148
-	 */
1149
-	public function is_type( $type ) {
1150
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1151
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1152
-	}
1144
+     * Checks the item type against a passed in types.
1145
+     *
1146
+     * @param array|string $type Type to check.
1147
+     * @return bool
1148
+     */
1149
+    public function is_type( $type ) {
1150
+        $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1151
+        return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1152
+    }
1153 1153
 
1154 1154
     /**
1155
-	 * Checks whether the item is editable.
1156
-	 *
1157
-	 * @since 1.0.19
1158
-	 * @return bool
1159
-	 */
1155
+     * Checks whether the item is editable.
1156
+     *
1157
+     * @since 1.0.19
1158
+     * @return bool
1159
+     */
1160 1160
     public function is_editable() {
1161 1161
         $is_editable = $this->get_is_editable();
1162 1162
         return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1163
-	}
1163
+    }
1164 1164
 
1165
-	/**
1166
-	 * Returns an array of cart fees.
1167
-	 */
1168
-	public function get_fees( $type = 'fee', $item_id = 0 ) {
1165
+    /**
1166
+     * Returns an array of cart fees.
1167
+     */
1168
+    public function get_fees( $type = 'fee', $item_id = 0 ) {
1169 1169
         
1170 1170
         $fees = getpaid_session()->get( 'wpi_cart_fees' );
1171 1171
 
@@ -1208,11 +1208,11 @@  discard block
 block discarded – undo
1208 1208
     }
1209 1209
 
1210 1210
     /**
1211
-	 * Checks whether the item is purchasable.
1212
-	 *
1213
-	 * @since 1.0.19
1214
-	 * @return bool
1215
-	 */
1211
+     * Checks whether the item is purchasable.
1212
+     *
1213
+     * @since 1.0.19
1214
+     * @return bool
1215
+     */
1216 1216
     public function can_purchase() {
1217 1217
         $can_purchase = null !== $this->get_id();
1218 1218
 
@@ -1224,11 +1224,11 @@  discard block
 block discarded – undo
1224 1224
     }
1225 1225
 
1226 1226
     /**
1227
-	 * Checks whether the item supports dynamic pricing.
1228
-	 *
1229
-	 * @since 1.0.19
1230
-	 * @return bool
1231
-	 */
1227
+     * Checks whether the item supports dynamic pricing.
1228
+     *
1229
+     * @since 1.0.19
1230
+     * @return bool
1231
+     */
1232 1232
     public function supports_dynamic_pricing() {
1233 1233
         return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1234 1234
     }
Please login to merge, or discard this patch.
Spacing   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -78,30 +78,30 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80 80
 	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
-			$this->set_id( $item_id );
92
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
-			$this->set_id( $item_id );
81
+	public function __construct($item = 0) {
82
+		parent::__construct($item);
83
+
84
+		if (!empty($item) && is_numeric($item) && 'wpi_item' == get_post_type($item)) {
85
+			$this->set_id($item);
86
+		} elseif ($item instanceof self) {
87
+			$this->set_id($item->get_id());
88
+		} elseif (!empty($item->ID)) {
89
+			$this->set_id($item->ID);
90
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'custom_id')) {
91
+			$this->set_id($item_id);
92
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'name')) {
93
+			$this->set_id($item_id);
94 94
 		} else {
95
-			$this->set_object_read( true );
95
+			$this->set_object_read(true);
96 96
 		}
97 97
 
98 98
         // Load the datastore.
99
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
99
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
100 100
 
101
-		if ( $this->get_id() > 0 ) {
102
-            $this->post = get_post( $this->get_id() );
101
+		if ($this->get_id() > 0) {
102
+            $this->post = get_post($this->get_id());
103 103
             $this->ID   = $this->get_id();
104
-			$this->data_store->read( $this );
104
+			$this->data_store->read($this);
105 105
         }
106 106
 
107 107
 	}
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 * @param  string $context View or edit context.
129 129
 	 * @return int
130 130
 	 */
131
-	public function get_parent_id( $context = 'view' ) {
132
-		return (int) $this->get_prop( 'parent_id', $context );
131
+	public function get_parent_id($context = 'view') {
132
+		return (int) $this->get_prop('parent_id', $context);
133 133
     }
134 134
 
135 135
     /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 * @param  string $context View or edit context.
140 140
 	 * @return string
141 141
 	 */
142
-	public function get_status( $context = 'view' ) {
143
-		return $this->get_prop( 'status', $context );
142
+	public function get_status($context = 'view') {
143
+		return $this->get_prop('status', $context);
144 144
     }
145 145
 
146 146
     /**
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @param  string $context View or edit context.
151 151
 	 * @return string
152 152
 	 */
153
-	public function get_version( $context = 'view' ) {
154
-		return $this->get_prop( 'version', $context );
153
+	public function get_version($context = 'view') {
154
+		return $this->get_prop('version', $context);
155 155
     }
156 156
 
157 157
     /**
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 * @param  string $context View or edit context.
162 162
 	 * @return string
163 163
 	 */
164
-	public function get_date_created( $context = 'view' ) {
165
-		return $this->get_prop( 'date_created', $context );
164
+	public function get_date_created($context = 'view') {
165
+		return $this->get_prop('date_created', $context);
166 166
     }
167 167
 
168 168
     /**
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 	 * @param  string $context View or edit context.
173 173
 	 * @return string
174 174
 	 */
175
-	public function get_date_created_gmt( $context = 'view' ) {
176
-        $date = $this->get_date_created( $context );
175
+	public function get_date_created_gmt($context = 'view') {
176
+        $date = $this->get_date_created($context);
177 177
 
178
-        if ( $date ) {
179
-            $date = get_gmt_from_date( $date );
178
+        if ($date) {
179
+            $date = get_gmt_from_date($date);
180 180
         }
181 181
 		return $date;
182 182
     }
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 * @param  string $context View or edit context.
189 189
 	 * @return string
190 190
 	 */
191
-	public function get_date_modified( $context = 'view' ) {
192
-		return $this->get_prop( 'date_modified', $context );
191
+	public function get_date_modified($context = 'view') {
192
+		return $this->get_prop('date_modified', $context);
193 193
     }
194 194
 
195 195
     /**
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $context View or edit context.
200 200
 	 * @return string
201 201
 	 */
202
-	public function get_date_modified_gmt( $context = 'view' ) {
203
-        $date = $this->get_date_modified( $context );
202
+	public function get_date_modified_gmt($context = 'view') {
203
+        $date = $this->get_date_modified($context);
204 204
 
205
-        if ( $date ) {
206
-            $date = get_gmt_from_date( $date );
205
+        if ($date) {
206
+            $date = get_gmt_from_date($date);
207 207
         }
208 208
 		return $date;
209 209
     }
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 * @param  string $context View or edit context.
216 216
 	 * @return string
217 217
 	 */
218
-	public function get_name( $context = 'view' ) {
219
-		return $this->get_prop( 'name', $context );
218
+	public function get_name($context = 'view') {
219
+		return $this->get_prop('name', $context);
220 220
     }
221 221
 
222 222
     /**
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 * @param  string $context View or edit context.
227 227
 	 * @return string
228 228
 	 */
229
-	public function get_title( $context = 'view' ) {
230
-		return $this->get_name( $context );
229
+	public function get_title($context = 'view') {
230
+		return $this->get_name($context);
231 231
     }
232 232
 
233 233
     /**
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 * @param  string $context View or edit context.
238 238
 	 * @return string
239 239
 	 */
240
-	public function get_description( $context = 'view' ) {
241
-		return $this->get_prop( 'description', $context );
240
+	public function get_description($context = 'view') {
241
+		return $this->get_prop('description', $context);
242 242
     }
243 243
 
244 244
     /**
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param  string $context View or edit context.
249 249
 	 * @return string
250 250
 	 */
251
-	public function get_excerpt( $context = 'view' ) {
252
-		return $this->get_description( $context );
251
+	public function get_excerpt($context = 'view') {
252
+		return $this->get_description($context);
253 253
     }
254 254
 
255 255
     /**
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 * @param  string $context View or edit context.
260 260
 	 * @return string
261 261
 	 */
262
-	public function get_summary( $context = 'view' ) {
263
-		return $this->get_description( $context );
262
+	public function get_summary($context = 'view') {
263
+		return $this->get_description($context);
264 264
     }
265 265
 
266 266
     /**
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 * @param  string $context View or edit context.
271 271
 	 * @return int
272 272
 	 */
273
-	public function get_author( $context = 'view' ) {
274
-		return (int) $this->get_prop( 'author', $context );
273
+	public function get_author($context = 'view') {
274
+		return (int) $this->get_prop('author', $context);
275 275
 	}
276 276
 	
277 277
 	/**
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @param  string $context View or edit context.
282 282
 	 * @return int
283 283
 	 */
284
-	public function get_owner( $context = 'view' ) {
285
-		return $this->get_author( $context );
284
+	public function get_owner($context = 'view') {
285
+		return $this->get_author($context);
286 286
     }
287 287
 
288 288
     /**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @param  string $context View or edit context.
293 293
 	 * @return float
294 294
 	 */
295
-	public function get_price( $context = 'view' ) {
296
-        return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
295
+	public function get_price($context = 'view') {
296
+        return wpinv_sanitize_amount($this->get_prop('price', $context));
297 297
 	}
298 298
 	
299 299
 	/**
@@ -303,15 +303,15 @@  discard block
 block discarded – undo
303 303
 	 * @param  string $context View or edit context.
304 304
 	 * @return float
305 305
 	 */
306
-	public function get_initial_price( $context = 'view' ) {
306
+	public function get_initial_price($context = 'view') {
307 307
 
308
-		$price = (float) $this->get_price( $context );
308
+		$price = (float) $this->get_price($context);
309 309
 
310
-		if ( $this->has_free_trial() ) {
310
+		if ($this->has_free_trial()) {
311 311
 			$price = 0;
312 312
 		}
313 313
 
314
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
314
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_initial_item_price', $price, $this));
315 315
     }
316 316
 
317 317
     /**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @return string
323 323
 	 */
324 324
     public function get_the_price() {
325
-        return wpinv_price( wpinv_format_amount( $this->get_price() ) );
325
+        return wpinv_price(wpinv_format_amount($this->get_price()));
326 326
 	}
327 327
 
328 328
 	/**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 * @return string
334 334
 	 */
335 335
     public function get_the_initial_price() {
336
-        return wpinv_price( wpinv_format_amount( $this->get_initial_price() ) );
336
+        return wpinv_price(wpinv_format_amount($this->get_initial_price()));
337 337
     }
338 338
 
339 339
     /**
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	 * @param  string $context View or edit context.
344 344
 	 * @return string
345 345
 	 */
346
-	public function get_vat_rule( $context = 'view' ) {
347
-        return $this->get_prop( 'vat_rule', $context );
346
+	public function get_vat_rule($context = 'view') {
347
+        return $this->get_prop('vat_rule', $context);
348 348
     }
349 349
 
350 350
     /**
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 	 * @param  string $context View or edit context.
355 355
 	 * @return string
356 356
 	 */
357
-	public function get_vat_class( $context = 'view' ) {
358
-        return $this->get_prop( 'vat_class', $context );
357
+	public function get_vat_class($context = 'view') {
358
+        return $this->get_prop('vat_class', $context);
359 359
     }
360 360
 
361 361
     /**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param  string $context View or edit context.
366 366
 	 * @return string
367 367
 	 */
368
-	public function get_type( $context = 'view' ) {
369
-        return $this->get_prop( 'type', $context );
368
+	public function get_type($context = 'view') {
369
+        return $this->get_prop('type', $context);
370 370
     }
371 371
 
372 372
     /**
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * @param  string $context View or edit context.
377 377
 	 * @return string
378 378
 	 */
379
-	public function get_custom_id( $context = 'view' ) {
380
-        return $this->get_prop( 'custom_id', $context );
379
+	public function get_custom_id($context = 'view') {
380
+        return $this->get_prop('custom_id', $context);
381 381
     }
382 382
 
383 383
     /**
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 	 * @param  string $context View or edit context.
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_custom_name( $context = 'view' ) {
391
-        return $this->get_prop( 'custom_name', $context );
390
+	public function get_custom_name($context = 'view') {
391
+        return $this->get_prop('custom_name', $context);
392 392
     }
393 393
 
394 394
     /**
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
 	 * @param  string $context View or edit context.
399 399
 	 * @return string
400 400
 	 */
401
-	public function get_custom_singular_name( $context = 'view' ) {
402
-        return $this->get_prop( 'custom_singular_name', $context );
401
+	public function get_custom_singular_name($context = 'view') {
402
+        return $this->get_prop('custom_singular_name', $context);
403 403
     }
404 404
 
405 405
     /**
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 	 * @param  string $context View or edit context.
410 410
 	 * @return int
411 411
 	 */
412
-	public function get_is_editable( $context = 'view' ) {
413
-        return (int) $this->get_prop( 'is_editable', $context );
412
+	public function get_is_editable($context = 'view') {
413
+        return (int) $this->get_prop('is_editable', $context);
414 414
     }
415 415
 
416 416
     /**
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	 * @param  string $context View or edit context.
421 421
 	 * @return int
422 422
 	 */
423
-	public function get_editable( $context = 'view' ) {
424
-		return $this->get_is_editable( $context );
423
+	public function get_editable($context = 'view') {
424
+		return $this->get_is_editable($context);
425 425
     }
426 426
 
427 427
     /**
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @param  string $context View or edit context.
432 432
 	 * @return int
433 433
 	 */
434
-	public function get_is_dynamic_pricing( $context = 'view' ) {
435
-        return (int) $this->get_prop( 'is_dynamic_pricing', $context );
434
+	public function get_is_dynamic_pricing($context = 'view') {
435
+        return (int) $this->get_prop('is_dynamic_pricing', $context);
436 436
     }
437 437
 
438 438
     /**
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	 * @param  string $context View or edit context.
443 443
 	 * @return float
444 444
 	 */
445
-	public function get_minimum_price( $context = 'view' ) {
446
-        return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
445
+	public function get_minimum_price($context = 'view') {
446
+        return wpinv_sanitize_amount($this->get_prop('minimum_price', $context));
447 447
     }
448 448
 
449 449
     /**
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param  string $context View or edit context.
454 454
 	 * @return int
455 455
 	 */
456
-	public function get_is_recurring( $context = 'view' ) {
457
-        return (int) $this->get_prop( 'is_recurring', $context );
456
+	public function get_is_recurring($context = 'view') {
457
+        return (int) $this->get_prop('is_recurring', $context);
458 458
 	}
459 459
 	
460 460
 	/**
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 	 * @param  string $context View or edit context.
465 465
 	 * @return float
466 466
 	 */
467
-	public function get_recurring_price( $context = 'view' ) {
468
-		$price = $this->get_price( $context );
469
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
467
+	public function get_recurring_price($context = 'view') {
468
+		$price = $this->get_price($context);
469
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_recurring_item_price', $price, $this->ID));
470 470
 	}
471 471
 
472 472
 	/**
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * @return string
478 478
 	 */
479 479
     public function get_the_recurring_price() {
480
-        return wpinv_price( wpinv_format_amount( $this->get_recurring_price() ) );
480
+        return wpinv_price(wpinv_format_amount($this->get_recurring_price()));
481 481
 	}
482 482
 
483 483
 	/**
@@ -498,15 +498,15 @@  discard block
 block discarded – undo
498 498
 		$period   = $this->get_recurring_period();
499 499
 		$interval = $this->get_recurring_interval();
500 500
 
501
-		if ( $this->has_free_trial() ) {
501
+		if ($this->has_free_trial()) {
502 502
 			$period   = $this->get_trial_period();
503 503
 			$interval = $this->get_trial_interval();
504 504
 		}
505 505
 
506
-		$period       = $periods[ $period ];
507
-		$interval     = empty( $interval ) ? 1 : $interval;
508
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
509
-        return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
506
+		$period       = $periods[$period];
507
+		$interval     = empty($interval) ? 1 : $interval;
508
+		$next_renewal = strtotime("+$interval $period", current_time('timestamp'));
509
+        return apply_filters('wpinv_get_first_renewal_date', $next_renewal, $this);
510 510
     }
511 511
 
512 512
     /**
@@ -516,14 +516,14 @@  discard block
 block discarded – undo
516 516
 	 * @param  bool $full Return abbreviation or in full.
517 517
 	 * @return string
518 518
 	 */
519
-	public function get_recurring_period( $full = false ) {
520
-        $period = $this->get_prop( 'recurring_period', 'view' );
519
+	public function get_recurring_period($full = false) {
520
+        $period = $this->get_prop('recurring_period', 'view');
521 521
 
522
-        if ( $full && ! is_bool( $full ) ) {
522
+        if ($full && !is_bool($full)) {
523 523
             $full = false;
524 524
         }
525 525
 
526
-        return getpaid_sanitize_recurring_period( $period, $full );
526
+        return getpaid_sanitize_recurring_period($period, $full);
527 527
     }
528 528
 
529 529
     /**
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 * @param  string $context View or edit context.
534 534
 	 * @return int
535 535
 	 */
536
-	public function get_recurring_interval( $context = 'view' ) {
537
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
536
+	public function get_recurring_interval($context = 'view') {
537
+		$interval = absint($this->get_prop('recurring_interval', $context));
538 538
 
539
-		if ( $interval < 1 ) {
539
+		if ($interval < 1) {
540 540
 			$interval = 1;
541 541
 		}
542 542
 
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
 	 * @param  string $context View or edit context.
551 551
 	 * @return int
552 552
 	 */
553
-	public function get_recurring_limit( $context = 'view' ) {
554
-        return (int) $this->get_prop( 'recurring_limit', $context );
553
+	public function get_recurring_limit($context = 'view') {
554
+        return (int) $this->get_prop('recurring_limit', $context);
555 555
     }
556 556
 
557 557
     /**
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * @param  string $context View or edit context.
562 562
 	 * @return int
563 563
 	 */
564
-	public function get_is_free_trial( $context = 'view' ) {
565
-        return (int) $this->get_prop( 'is_free_trial', $context );
564
+	public function get_is_free_trial($context = 'view') {
565
+        return (int) $this->get_prop('is_free_trial', $context);
566 566
     }
567 567
 
568 568
     /**
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 	 * @param  string $context View or edit context.
573 573
 	 * @return int
574 574
 	 */
575
-	public function get_free_trial( $context = 'view' ) {
576
-        return $this->get_is_free_trial( $context );
575
+	public function get_free_trial($context = 'view') {
576
+        return $this->get_is_free_trial($context);
577 577
     }
578 578
 
579 579
     /**
@@ -583,14 +583,14 @@  discard block
 block discarded – undo
583 583
 	 * @param  bool $full Return abbreviation or in full.
584 584
 	 * @return string
585 585
 	 */
586
-	public function get_trial_period( $full = false ) {
587
-        $period = $this->get_prop( 'trial_period', 'view' );
586
+	public function get_trial_period($full = false) {
587
+        $period = $this->get_prop('trial_period', 'view');
588 588
 
589
-        if ( $full && ! is_bool( $full ) ) {
589
+        if ($full && !is_bool($full)) {
590 590
             $full = false;
591 591
         }
592 592
 
593
-        return getpaid_sanitize_recurring_period( $period, $full );
593
+        return getpaid_sanitize_recurring_period($period, $full);
594 594
     }
595 595
 
596 596
     /**
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 	 * @param  string $context View or edit context.
601 601
 	 * @return int
602 602
 	 */
603
-	public function get_trial_interval( $context = 'view' ) {
604
-        return (int) $this->get_prop( 'trial_interval', $context );
603
+	public function get_trial_interval($context = 'view') {
604
+        return (int) $this->get_prop('trial_interval', $context);
605 605
 	}
606 606
 	
607 607
 	/**
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	 * @return string
612 612
 	 */
613 613
 	public function get_edit_url() {
614
-        return get_edit_post_link( $this->get_id() );
614
+        return get_edit_post_link($this->get_id());
615 615
 	}
616 616
 
617 617
 	/**
@@ -625,35 +625,35 @@  discard block
 block discarded – undo
625 625
 	 * @since 1.0.15
626 626
 	 * @return int
627 627
 	 */
628
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
628
+	public static function get_item_id_by_field($value, $field = 'custom_id', $type = '') {
629 629
 
630 630
 		// Trim the value.
631
-		$value = trim( $value );
631
+		$value = trim($value);
632 632
 
633
-		if ( empty( $value ) ) {
633
+		if (empty($value)) {
634 634
 			return 0;
635 635
 		}
636 636
 
637 637
         // Valid fields.
638
-        $fields = array( 'custom_id', 'name', 'slug' );
638
+        $fields = array('custom_id', 'name', 'slug');
639 639
 
640 640
 		// Ensure a field has been passed.
641
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
641
+		if (empty($field) || !in_array($field, $fields)) {
642 642
 			return 0;
643 643
 		}
644 644
 
645
-		if ( $field == 'name' ) {
645
+		if ($field == 'name') {
646 646
 			$field = 'slug';
647 647
 		} 
648 648
 
649 649
 		// Maybe retrieve from the cache.
650
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
651
-		if ( ! empty( $item_id ) ) {
650
+		$item_id = wp_cache_get($value, "getpaid_{$type}_item_{$field}s_to_item_ids");
651
+		if (!empty($item_id)) {
652 652
 			return $item_id;
653 653
 		}
654 654
 
655 655
 		// Fetch from the db.
656
-		if ( $field =='slug' ) {
656
+		if ($field == 'slug') {
657 657
 			$items = get_posts(
658 658
 				array(
659 659
 					'post_type'      => 'wpi_item',
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 			);
665 665
 		}
666 666
 
667
-		if ( $field =='custom_id' ) {
667
+		if ($field == 'custom_id') {
668 668
 			$items = get_posts(
669 669
 				array(
670 670
 					'post_type'      => 'wpi_item',
@@ -684,12 +684,12 @@  discard block
 block discarded – undo
684 684
 			);
685 685
 		}
686 686
 
687
-		if ( empty( $items ) ) {
687
+		if (empty($items)) {
688 688
 			return 0;
689 689
 		}
690 690
 
691 691
 		// Update the cache with our data
692
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
692
+		wp_cache_set($value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids");
693 693
 
694 694
 		return $items[0]->ID;
695 695
     }
@@ -697,19 +697,19 @@  discard block
 block discarded – undo
697 697
     /**
698 698
      * Margic method for retrieving a property.
699 699
      */
700
-    public function __get( $key ) {
700
+    public function __get($key) {
701 701
 
702 702
         // Check if we have a helper method for that.
703
-        if ( method_exists( $this, 'get_' . $key ) ) {
704
-            return call_user_func( array( $this, 'get_' . $key ) );
703
+        if (method_exists($this, 'get_' . $key)) {
704
+            return call_user_func(array($this, 'get_' . $key));
705 705
         }
706 706
 
707 707
         // Check if the key is in the associated $post object.
708
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
708
+        if (!empty($this->post) && isset($this->post->$key)) {
709 709
             return $this->post->$key;
710 710
         }
711 711
 
712
-        return $this->get_prop( $key );
712
+        return $this->get_prop($key);
713 713
 
714 714
     }
715 715
 
@@ -728,11 +728,11 @@  discard block
 block discarded – undo
728 728
 	 *
729 729
 	 * @since 1.0.19
730 730
 	 */
731
-	public function set_parent_id( $value ) {
732
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
731
+	public function set_parent_id($value) {
732
+		if ($value && ($value === $this->get_id() || !get_post($value))) {
733 733
 			return;
734 734
 		}
735
-		$this->set_prop( 'parent_id', absint( $value ) );
735
+		$this->set_prop('parent_id', absint($value));
736 736
 	}
737 737
 
738 738
     /**
@@ -742,10 +742,10 @@  discard block
 block discarded – undo
742 742
 	 * @param  string $status New status.
743 743
 	 * @return array details of change.
744 744
 	 */
745
-	public function set_status( $status ) {
745
+	public function set_status($status) {
746 746
         $old_status = $this->get_status();
747 747
 
748
-        $this->set_prop( 'status', $status );
748
+        $this->set_prop('status', $status);
749 749
 
750 750
 		return array(
751 751
 			'from' => $old_status,
@@ -758,8 +758,8 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @since 1.0.19
760 760
 	 */
761
-	public function set_version( $value ) {
762
-		$this->set_prop( 'version', $value );
761
+	public function set_version($value) {
762
+		$this->set_prop('version', $value);
763 763
     }
764 764
 
765 765
     /**
@@ -769,11 +769,11 @@  discard block
 block discarded – undo
769 769
 	 * @param string $value Value to set.
770 770
      * @return bool Whether or not the date was set.
771 771
 	 */
772
-	public function set_date_created( $value ) {
773
-        $date = strtotime( $value );
772
+	public function set_date_created($value) {
773
+        $date = strtotime($value);
774 774
 
775
-        if ( $date ) {
776
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
775
+        if ($date) {
776
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
777 777
             return true;
778 778
         }
779 779
 
@@ -788,11 +788,11 @@  discard block
 block discarded – undo
788 788
 	 * @param string $value Value to set.
789 789
      * @return bool Whether or not the date was set.
790 790
 	 */
791
-	public function set_date_modified( $value ) {
792
-        $date = strtotime( $value );
791
+	public function set_date_modified($value) {
792
+        $date = strtotime($value);
793 793
 
794
-        if ( $date ) {
795
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
794
+        if ($date) {
795
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
796 796
             return true;
797 797
         }
798 798
 
@@ -806,9 +806,9 @@  discard block
 block discarded – undo
806 806
 	 * @since 1.0.19
807 807
 	 * @param  string $value New name.
808 808
 	 */
809
-	public function set_name( $value ) {
810
-        $name = sanitize_text_field( $value );
811
-		$this->set_prop( 'name', $name );
809
+	public function set_name($value) {
810
+        $name = sanitize_text_field($value);
811
+		$this->set_prop('name', $name);
812 812
     }
813 813
 
814 814
     /**
@@ -817,8 +817,8 @@  discard block
 block discarded – undo
817 817
 	 * @since 1.0.19
818 818
 	 * @param  string $value New name.
819 819
 	 */
820
-	public function set_title( $value ) {
821
-		$this->set_name( $value );
820
+	public function set_title($value) {
821
+		$this->set_name($value);
822 822
     }
823 823
 
824 824
     /**
@@ -827,9 +827,9 @@  discard block
 block discarded – undo
827 827
 	 * @since 1.0.19
828 828
 	 * @param  string $value New description.
829 829
 	 */
830
-	public function set_description( $value ) {
831
-        $description = wp_kses_post( $value );
832
-		return $this->set_prop( 'description', $description );
830
+	public function set_description($value) {
831
+        $description = wp_kses_post($value);
832
+		return $this->set_prop('description', $description);
833 833
     }
834 834
 
835 835
     /**
@@ -838,8 +838,8 @@  discard block
 block discarded – undo
838 838
 	 * @since 1.0.19
839 839
 	 * @param  string $value New description.
840 840
 	 */
841
-	public function set_excerpt( $value ) {
842
-		$this->set_description( $value );
841
+	public function set_excerpt($value) {
842
+		$this->set_description($value);
843 843
     }
844 844
 
845 845
     /**
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
 	 * @since 1.0.19
849 849
 	 * @param  string $value New description.
850 850
 	 */
851
-	public function set_summary( $value ) {
852
-		$this->set_description( $value );
851
+	public function set_summary($value) {
852
+		$this->set_description($value);
853 853
     }
854 854
 
855 855
     /**
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 	 * @since 1.0.19
859 859
 	 * @param  int $value New author.
860 860
 	 */
861
-	public function set_author( $value ) {
862
-		$this->set_prop( 'author', (int) $value );
861
+	public function set_author($value) {
862
+		$this->set_prop('author', (int) $value);
863 863
 	}
864 864
 	
865 865
 	/**
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
 	 * @since 1.0.19
869 869
 	 * @param  int $value New author.
870 870
 	 */
871
-	public function set_owner( $value ) {
872
-		$this->set_author( $value );
871
+	public function set_owner($value) {
872
+		$this->set_author($value);
873 873
     }
874 874
 
875 875
     /**
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
 	 * @since 1.0.19
879 879
 	 * @param  float $value New price.
880 880
 	 */
881
-	public function set_price( $value ) {
882
-        $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
881
+	public function set_price($value) {
882
+        $this->set_prop('price', (float) wpinv_sanitize_amount($value));
883 883
     }
884 884
 
885 885
     /**
@@ -888,8 +888,8 @@  discard block
 block discarded – undo
888 888
 	 * @since 1.0.19
889 889
 	 * @param  string $value new rule.
890 890
 	 */
891
-	public function set_vat_rule( $value ) {
892
-        $this->set_prop( 'vat_rule', $value );
891
+	public function set_vat_rule($value) {
892
+        $this->set_prop('vat_rule', $value);
893 893
     }
894 894
 
895 895
     /**
@@ -898,8 +898,8 @@  discard block
 block discarded – undo
898 898
 	 * @since 1.0.19
899 899
 	 * @param  string $value new class.
900 900
 	 */
901
-	public function set_vat_class( $value ) {
902
-        $this->set_prop( 'vat_class', $value );
901
+	public function set_vat_class($value) {
902
+        $this->set_prop('vat_class', $value);
903 903
     }
904 904
 
905 905
     /**
@@ -909,13 +909,13 @@  discard block
 block discarded – undo
909 909
 	 * @param  string $value new item type.
910 910
 	 * @return string
911 911
 	 */
912
-	public function set_type( $value ) {
912
+	public function set_type($value) {
913 913
 
914
-        if ( empty( $value ) ) {
914
+        if (empty($value)) {
915 915
             $value = 'custom';
916 916
         }
917 917
 
918
-        $this->set_prop( 'type', $value );
918
+        $this->set_prop('type', $value);
919 919
     }
920 920
 
921 921
     /**
@@ -924,8 +924,8 @@  discard block
 block discarded – undo
924 924
 	 * @since 1.0.19
925 925
 	 * @param  string $value new custom id.
926 926
 	 */
927
-	public function set_custom_id( $value ) {
928
-        $this->set_prop( 'custom_id', $value );
927
+	public function set_custom_id($value) {
928
+        $this->set_prop('custom_id', $value);
929 929
     }
930 930
 
931 931
     /**
@@ -934,8 +934,8 @@  discard block
 block discarded – undo
934 934
 	 * @since 1.0.19
935 935
 	 * @param  string $value new custom name.
936 936
 	 */
937
-	public function set_custom_name( $value ) {
938
-        $this->set_prop( 'custom_name', $value );
937
+	public function set_custom_name($value) {
938
+        $this->set_prop('custom_name', $value);
939 939
     }
940 940
 
941 941
     /**
@@ -944,8 +944,8 @@  discard block
 block discarded – undo
944 944
 	 * @since 1.0.19
945 945
 	 * @param  string $value new custom singular name.
946 946
 	 */
947
-	public function set_custom_singular_name( $value ) {
948
-        $this->set_prop( 'custom_singular_name', $value );
947
+	public function set_custom_singular_name($value) {
948
+        $this->set_prop('custom_singular_name', $value);
949 949
     }
950 950
 
951 951
     /**
@@ -954,9 +954,9 @@  discard block
 block discarded – undo
954 954
 	 * @since 1.0.19
955 955
 	 * @param  int|bool $value whether or not the item is editable.
956 956
 	 */
957
-	public function set_is_editable( $value ) {
958
-		if ( is_numeric( $value ) ) {
959
-			$this->set_prop( 'is_editable', (int) $value );
957
+	public function set_is_editable($value) {
958
+		if (is_numeric($value)) {
959
+			$this->set_prop('is_editable', (int) $value);
960 960
 		}
961 961
     }
962 962
 
@@ -966,8 +966,8 @@  discard block
 block discarded – undo
966 966
 	 * @since 1.0.19
967 967
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
968 968
 	 */
969
-	public function set_is_dynamic_pricing( $value ) {
970
-        $this->set_prop( 'is_dynamic_pricing', (int) $value );
969
+	public function set_is_dynamic_pricing($value) {
970
+        $this->set_prop('is_dynamic_pricing', (int) $value);
971 971
     }
972 972
 
973 973
     /**
@@ -976,8 +976,8 @@  discard block
 block discarded – undo
976 976
 	 * @since 1.0.19
977 977
 	 * @param  float $value minimum price.
978 978
 	 */
979
-	public function set_minimum_price( $value ) {
980
-        $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
979
+	public function set_minimum_price($value) {
980
+        $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value));
981 981
     }
982 982
 
983 983
     /**
@@ -986,8 +986,8 @@  discard block
 block discarded – undo
986 986
 	 * @since 1.0.19
987 987
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
988 988
 	 */
989
-	public function set_is_recurring( $value ) {
990
-        $this->set_prop( 'is_recurring', (int) $value );
989
+	public function set_is_recurring($value) {
990
+        $this->set_prop('is_recurring', (int) $value);
991 991
     }
992 992
 
993 993
     /**
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
 	 * @since 1.0.19
997 997
 	 * @param  string $value new period.
998 998
 	 */
999
-	public function set_recurring_period( $value ) {
1000
-        $this->set_prop( 'recurring_period', $value );
999
+	public function set_recurring_period($value) {
1000
+        $this->set_prop('recurring_period', $value);
1001 1001
     }
1002 1002
 
1003 1003
     /**
@@ -1006,8 +1006,8 @@  discard block
 block discarded – undo
1006 1006
 	 * @since 1.0.19
1007 1007
 	 * @param  int $value recurring interval.
1008 1008
 	 */
1009
-	public function set_recurring_interval( $value ) {
1010
-        return $this->set_prop( 'recurring_interval', (int) $value );
1009
+	public function set_recurring_interval($value) {
1010
+        return $this->set_prop('recurring_interval', (int) $value);
1011 1011
     }
1012 1012
 
1013 1013
     /**
@@ -1016,8 +1016,8 @@  discard block
 block discarded – undo
1016 1016
 	 * @param  int $value The recurring limit.
1017 1017
 	 * @return int
1018 1018
 	 */
1019
-	public function set_recurring_limit( $value ) {
1020
-        $this->set_prop( 'recurring_limit', (int) $value );
1019
+	public function set_recurring_limit($value) {
1020
+        $this->set_prop('recurring_limit', (int) $value);
1021 1021
     }
1022 1022
 
1023 1023
     /**
@@ -1026,8 +1026,8 @@  discard block
 block discarded – undo
1026 1026
 	 * @since 1.0.19
1027 1027
 	 * @param  int|bool $value whether or not it has a free trial.
1028 1028
 	 */
1029
-	public function set_is_free_trial( $value ) {
1030
-        $this->set_prop( 'is_free_trial', (int) $value );
1029
+	public function set_is_free_trial($value) {
1030
+        $this->set_prop('is_free_trial', (int) $value);
1031 1031
     }
1032 1032
 
1033 1033
     /**
@@ -1036,8 +1036,8 @@  discard block
 block discarded – undo
1036 1036
 	 * @since 1.0.19
1037 1037
 	 * @param  string $value trial period.
1038 1038
 	 */
1039
-	public function set_trial_period( $value ) {
1040
-        $this->set_prop( 'trial_period', $value );
1039
+	public function set_trial_period($value) {
1040
+        $this->set_prop('trial_period', $value);
1041 1041
     }
1042 1042
 
1043 1043
     /**
@@ -1046,8 +1046,8 @@  discard block
 block discarded – undo
1046 1046
 	 * @since 1.0.19
1047 1047
 	 * @param  int $value trial interval.
1048 1048
 	 */
1049
-	public function set_trial_interval( $value ) {
1050
-        $this->set_prop( 'trial_interval', $value );
1049
+	public function set_trial_interval($value) {
1050
+        $this->set_prop('trial_interval', $value);
1051 1051
     }
1052 1052
 
1053 1053
     /**
@@ -1056,11 +1056,11 @@  discard block
 block discarded – undo
1056 1056
      * @deprecated
1057 1057
 	 * @return int item id
1058 1058
      */
1059
-    public function create( $data = array() ) {
1059
+    public function create($data = array()) {
1060 1060
 
1061 1061
 		// Set the properties.
1062
-		if ( is_array( $data ) ) {
1063
-			$this->set_props( $data );
1062
+		if (is_array($data)) {
1063
+			$this->set_props($data);
1064 1064
 		}
1065 1065
 
1066 1066
 		// Save the item.
@@ -1074,8 +1074,8 @@  discard block
 block discarded – undo
1074 1074
      * @deprecated
1075 1075
 	 * @return int item id
1076 1076
      */
1077
-    public function update( $data = array() ) {
1078
-        return $this->create( $data );
1077
+    public function update($data = array()) {
1078
+        return $this->create($data);
1079 1079
     }
1080 1080
 
1081 1081
     /*
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 	 */
1116 1116
     public function has_free_trial() {
1117 1117
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1118
-        return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1118
+        return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this);
1119 1119
     }
1120 1120
 
1121 1121
     /**
@@ -1125,8 +1125,8 @@  discard block
 block discarded – undo
1125 1125
 	 * @return bool
1126 1126
 	 */
1127 1127
     public function is_free() {
1128
-        $is_free   = $this->get_price() == 0;
1129
-        return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1128
+        $is_free = $this->get_price() == 0;
1129
+        return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this);
1130 1130
     }
1131 1131
 
1132 1132
     /**
@@ -1135,9 +1135,9 @@  discard block
 block discarded – undo
1135 1135
 	 * @param array|string $status Status to check.
1136 1136
 	 * @return bool
1137 1137
 	 */
1138
-	public function has_status( $status ) {
1139
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1140
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1138
+	public function has_status($status) {
1139
+		$has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status;
1140
+		return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status);
1141 1141
     }
1142 1142
 
1143 1143
     /**
@@ -1146,9 +1146,9 @@  discard block
 block discarded – undo
1146 1146
 	 * @param array|string $type Type to check.
1147 1147
 	 * @return bool
1148 1148
 	 */
1149
-	public function is_type( $type ) {
1150
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1151
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1149
+	public function is_type($type) {
1150
+		$is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type;
1151
+		return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type);
1152 1152
 	}
1153 1153
 
1154 1154
     /**
@@ -1159,52 +1159,52 @@  discard block
 block discarded – undo
1159 1159
 	 */
1160 1160
     public function is_editable() {
1161 1161
         $is_editable = $this->get_is_editable();
1162
-        return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1162
+        return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this);
1163 1163
 	}
1164 1164
 
1165 1165
 	/**
1166 1166
 	 * Returns an array of cart fees.
1167 1167
 	 */
1168
-	public function get_fees( $type = 'fee', $item_id = 0 ) {
1168
+	public function get_fees($type = 'fee', $item_id = 0) {
1169 1169
         
1170
-        $fees = getpaid_session()->get( 'wpi_cart_fees' );
1170
+        $fees = getpaid_session()->get('wpi_cart_fees');
1171 1171
 
1172
-        if ( ! wpinv_get_cart_contents() ) {
1172
+        if (!wpinv_get_cart_contents()) {
1173 1173
             // We can only get item type fees when the cart is empty
1174 1174
             $type = 'custom';
1175 1175
         }
1176 1176
 
1177
-        if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) {
1178
-            foreach( $fees as $key => $fee ) {
1179
-                if( ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1180
-                    unset( $fees[ $key ] );
1177
+        if (!empty($fees) && !empty($type) && 'all' !== $type) {
1178
+            foreach ($fees as $key => $fee) {
1179
+                if (!empty($fee['type']) && $type != $fee['type']) {
1180
+                    unset($fees[$key]);
1181 1181
                 }
1182 1182
             }
1183 1183
         }
1184 1184
 
1185
-        if ( ! empty( $fees ) && ! empty( $item_id ) ) {
1185
+        if (!empty($fees) && !empty($item_id)) {
1186 1186
             // Remove fees that don't belong to the specified Item
1187
-            foreach ( $fees as $key => $fee ) {
1188
-                if ( (int) $item_id !== (int)$fee['custom_id'] ) {
1189
-                    unset( $fees[ $key ] );
1187
+            foreach ($fees as $key => $fee) {
1188
+                if ((int) $item_id !== (int) $fee['custom_id']) {
1189
+                    unset($fees[$key]);
1190 1190
                 }
1191 1191
             }
1192 1192
         }
1193 1193
 
1194
-        if ( ! empty( $fees ) ) {
1194
+        if (!empty($fees)) {
1195 1195
             // Remove fees that belong to a specific item but are not in the cart
1196
-            foreach( $fees as $key => $fee ) {
1197
-                if( empty( $fee['custom_id'] ) ) {
1196
+            foreach ($fees as $key => $fee) {
1197
+                if (empty($fee['custom_id'])) {
1198 1198
                     continue;
1199 1199
                 }
1200 1200
 
1201
-                if ( !wpinv_item_in_cart( $fee['custom_id'] ) ) {
1202
-                    unset( $fees[ $key ] );
1201
+                if (!wpinv_item_in_cart($fee['custom_id'])) {
1202
+                    unset($fees[$key]);
1203 1203
                 }
1204 1204
             }
1205 1205
         }
1206 1206
 
1207
-        return ! empty( $fees ) ? $fees : array();
1207
+        return !empty($fees) ? $fees : array();
1208 1208
     }
1209 1209
 
1210 1210
     /**
@@ -1216,11 +1216,11 @@  discard block
 block discarded – undo
1216 1216
     public function can_purchase() {
1217 1217
         $can_purchase = null !== $this->get_id();
1218 1218
 
1219
-        if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) {
1219
+        if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') {
1220 1220
             $can_purchase = false;
1221 1221
         }
1222 1222
 
1223
-        return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this );
1223
+        return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this);
1224 1224
     }
1225 1225
 
1226 1226
     /**
@@ -1230,6 +1230,6 @@  discard block
 block discarded – undo
1230 1230
 	 * @return bool
1231 1231
 	 */
1232 1232
     public function supports_dynamic_pricing() {
1233
-        return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1233
+        return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this);
1234 1234
     }
1235 1235
 }
Please login to merge, or discard this patch.