Passed
Pull Request — master (#390)
by Brian
04:21
created
includes/gateways/class-getpaid-authorize-net-gateway.php 2 patches
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -13,58 +13,58 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Authorize_Net_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'authorizenet';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array( 'subscription', 'sandbox', 'tokens' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34 34
     public $order = 4;
35 35
 
36 36
     /**
37
-	 * Endpoint for requests from Authorize.net.
38
-	 *
39
-	 * @var string
40
-	 */
41
-	protected $notify_url;
42
-
43
-	/**
44
-	 * Endpoint for requests to Authorize.net.
45
-	 *
46
-	 * @var string
47
-	 */
37
+     * Endpoint for requests from Authorize.net.
38
+     *
39
+     * @var string
40
+     */
41
+    protected $notify_url;
42
+
43
+    /**
44
+     * Endpoint for requests to Authorize.net.
45
+     *
46
+     * @var string
47
+     */
48 48
     protected $endpoint;
49 49
     
50 50
     /**
51
-	 * Currencies this gateway is allowed for.
52
-	 *
53
-	 * @var array
54
-	 */
55
-	public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
51
+     * Currencies this gateway is allowed for.
52
+     *
53
+     * @var array
54
+     */
55
+    public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
56 56
 
57 57
     /**
58
-	 * URL to view a transaction.
59
-	 *
60
-	 * @var string
61
-	 */
58
+     * URL to view a transaction.
59
+     *
60
+     * @var string
61
+     */
62 62
     public $view_transaction_url = 'https://{sandbox}authorize.net/ui/themes/sandbox/Transaction/TransactionReceipt.aspx?transid=%s';
63 63
 
64 64
     /**
65
-	 * Class constructor.
66
-	 */
67
-	public function __construct() {
65
+     * Class constructor.
66
+     */
67
+    public function __construct() {
68 68
 
69 69
         $this->title                = __( 'Credit Card / Debit Card', 'invoicing' );
70 70
         $this->method_title         = __( 'Authorize.Net', 'invoicing' );
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
     }
77 77
 
78 78
     /**
79
-	 * Displays the payment method select field.
80
-	 * 
81
-	 * @param int $invoice_id 0 or invoice id.
82
-	 * @param GetPaid_Payment_Form $form Current payment form.
83
-	 */
79
+     * Displays the payment method select field.
80
+     * 
81
+     * @param int $invoice_id 0 or invoice id.
82
+     * @param GetPaid_Payment_Form $form Current payment form.
83
+     */
84 84
     public function payment_fields( $invoice_id, $form ) {
85 85
 
86 86
         // Let the user select a payment method.
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
     }
92 92
 
93 93
     /**
94
-	 * Creates a customer profile.
95
-	 *
96
-	 *
97
-	 * @param WPInv_Invoice $invoice Invoice.
94
+     * Creates a customer profile.
95
+     *
96
+     *
97
+     * @param WPInv_Invoice $invoice Invoice.
98 98
      * @param array $submission_data Posted checkout fields.
99 99
      * @param bool $save Whether or not to save the payment as a token.
100 100
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
101
-	 * @return string|WP_Error Payment profile id.
102
-	 */
103
-	public function create_customer_profile( $invoice, $submission_data, $save = true ) {
101
+     * @return string|WP_Error Payment profile id.
102
+     */
103
+    public function create_customer_profile( $invoice, $submission_data, $save = true ) {
104 104
 
105 105
         // Remove non-digits from the number
106 106
         $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] );
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
     }
168 168
 
169 169
     /**
170
-	 * Retrieves a customer profile.
171
-	 *
172
-	 *
173
-	 * @param string $profile_id profile id.
174
-	 * @return string|WP_Error Profile id.
170
+     * Retrieves a customer profile.
171
+     *
172
+     *
173
+     * @param string $profile_id profile id.
174
+     * @return string|WP_Error Profile id.
175 175
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile
176
-	 */
177
-	public function get_customer_profile( $profile_id ) {
176
+     */
177
+    public function get_customer_profile( $profile_id ) {
178 178
 
179 179
         // Generate args.
180 180
         $args = array(
@@ -189,17 +189,17 @@  discard block
 block discarded – undo
189 189
     }
190 190
 
191 191
     /**
192
-	 * Creates a customer profile.
193
-	 *
194
-	 *
192
+     * Creates a customer profile.
193
+     *
194
+     *
195 195
      * @param string $profile_id profile id.
196
-	 * @param WPInv_Invoice $invoice Invoice.
196
+     * @param WPInv_Invoice $invoice Invoice.
197 197
      * @param array $submission_data Posted checkout fields.
198 198
      * @param bool $save Whether or not to save the payment as a token.
199 199
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
200
-	 * @return string|WP_Error Profile id.
201
-	 */
202
-	public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
200
+     * @return string|WP_Error Profile id.
201
+     */
202
+    public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
203 203
 
204 204
         // Remove non-digits from the number
205 205
         $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] );
@@ -259,15 +259,15 @@  discard block
 block discarded – undo
259 259
     }
260 260
 
261 261
     /**
262
-	 * Retrieves a customer payment profile.
263
-	 *
264
-	 *
265
-	 * @param string $customer_profile_id customer profile id.
262
+     * Retrieves a customer payment profile.
263
+     *
264
+     *
265
+     * @param string $customer_profile_id customer profile id.
266 266
      * @param string $payment_profile_id payment profile id.
267
-	 * @return string|WP_Error Profile id.
267
+     * @return string|WP_Error Profile id.
268 268
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile
269
-	 */
270
-	public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
269
+     */
270
+    public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
271 271
 
272 272
         // Generate args.
273 273
         $args = array(
@@ -283,15 +283,15 @@  discard block
 block discarded – undo
283 283
     }
284 284
 
285 285
     /**
286
-	 * Charges a customer payment profile.
287
-	 *
286
+     * Charges a customer payment profile.
287
+     *
288 288
      * @param string $customer_profile_id customer profile id.
289 289
      * @param string $payment_profile_id payment profile id.
290
-	 * @param WPInv_Invoice $invoice Invoice.
290
+     * @param WPInv_Invoice $invoice Invoice.
291 291
      * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile
292
-	 * @return WP_Error|object
293
-	 */
294
-	public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
292
+     * @return WP_Error|object
293
+     */
294
+    public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
295 295
 
296 296
         // Generate args.
297 297
         $args = array(
@@ -333,12 +333,12 @@  discard block
 block discarded – undo
333 333
     }
334 334
 
335 335
     /**
336
-	 * Processes a customer charge.
337
-	 *
336
+     * Processes a customer charge.
337
+     *
338 338
      * @param stdClass $result Api response.
339
-	 * @param WPInv_Invoice $invoice Invoice.
340
-	 */
341
-	public function process_charge_response( $result, $invoice ) {
339
+     * @param WPInv_Invoice $invoice Invoice.
340
+     */
341
+    public function process_charge_response( $result, $invoice ) {
342 342
 
343 343
         wpinv_clear_errors();
344 344
 
@@ -384,13 +384,13 @@  discard block
 block discarded – undo
384 384
     }
385 385
 
386 386
     /**
387
-	 * Returns payment information.
388
-	 *
389
-	 *
390
-	 * @param array $card Card details.
391
-	 * @return array
392
-	 */
393
-	public function get_payment_information( $card ) {
387
+     * Returns payment information.
388
+     *
389
+     *
390
+     * @param array $card Card details.
391
+     * @return array
392
+     */
393
+    public function get_payment_information( $card ) {
394 394
         return array(
395 395
 
396 396
             'creditCard'         => array (
@@ -403,13 +403,13 @@  discard block
 block discarded – undo
403 403
     }
404 404
 
405 405
     /**
406
-	 * Returns the card name.
407
-	 *
408
-	 *
409
-	 * @param string $card_number Card number.
410
-	 * @return string
411
-	 */
412
-	public function get_card_name( $card_number ) {
406
+     * Returns the card name.
407
+     *
408
+     *
409
+     * @param string $card_number Card number.
410
+     * @return string
411
+     */
412
+    public function get_card_name( $card_number ) {
413 413
 
414 414
         switch( $card_number ) {
415 415
 
@@ -439,34 +439,34 @@  discard block
 block discarded – undo
439 439
     }
440 440
 
441 441
     /**
442
-	 * Returns the customer profile meta name.
443
-	 *
444
-	 *
445
-	 * @param WPInv_Invoice $invoice Invoice.
446
-	 * @return string
447
-	 */
448
-	public function get_customer_profile_meta_name( $invoice ) {
442
+     * Returns the customer profile meta name.
443
+     *
444
+     *
445
+     * @param WPInv_Invoice $invoice Invoice.
446
+     * @return string
447
+     */
448
+    public function get_customer_profile_meta_name( $invoice ) {
449 449
         return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
450 450
     }
451 451
 
452 452
     /**
453
-	 * Returns the API URL.
454
-	 *
455
-	 *
456
-	 * @param WPInv_Invoice $invoice Invoice.
457
-	 * @return string
458
-	 */
459
-	public function get_api_url( $invoice ) {
453
+     * Returns the API URL.
454
+     *
455
+     *
456
+     * @param WPInv_Invoice $invoice Invoice.
457
+     * @return string
458
+     */
459
+    public function get_api_url( $invoice ) {
460 460
         return $this->is_sandbox( $invoice ) ? 'https://apitest.authorize.net/xml/v1/request.api' : 'https://api.authorize.net/xml/v1/request.api';
461 461
     }
462 462
 
463 463
     /**
464
-	 * Returns the API authentication params.
465
-	 *
466
-	 *
467
-	 * @return array
468
-	 */
469
-	public function get_auth_params() {
464
+     * Returns the API authentication params.
465
+     *
466
+     *
467
+     * @return array
468
+     */
469
+    public function get_auth_params() {
470 470
 
471 471
         return array(
472 472
             'name'           => $this->get_option( 'login_id' ),
@@ -476,14 +476,14 @@  discard block
 block discarded – undo
476 476
     }
477 477
 
478 478
     /**
479
-	 * Validates the submitted data.
480
-	 *
481
-	 *
482
-	 * @param array $submission_data Posted checkout fields.
479
+     * Validates the submitted data.
480
+     *
481
+     *
482
+     * @param array $submission_data Posted checkout fields.
483 483
      * @param WPInv_Invoice $invoice
484
-	 * @return WP_Error|string The payment profile id
485
-	 */
486
-	public function validate_submission_data( $submission_data, $invoice ) {
484
+     * @return WP_Error|string The payment profile id
485
+     */
486
+    public function validate_submission_data( $submission_data, $invoice ) {
487 487
 
488 488
         // Validate authentication details.
489 489
         $auth = $this->get_auth_params();
@@ -515,13 +515,13 @@  discard block
 block discarded – undo
515 515
     }
516 516
 
517 517
     /**
518
-	 * Returns invoice line items.
519
-	 *
520
-	 *
521
-	 * @param WPInv_Invoice $invoice Invoice.
522
-	 * @return array
523
-	 */
524
-	public function get_line_items( $invoice ) {
518
+     * Returns invoice line items.
519
+     *
520
+     *
521
+     * @param WPInv_Invoice $invoice Invoice.
522
+     * @return array
523
+     */
524
+    public function get_line_items( $invoice ) {
525 525
         $items = array();
526 526
 
527 527
         foreach ( $invoice->get_items() as $item ) {
@@ -541,13 +541,13 @@  discard block
 block discarded – undo
541 541
     }
542 542
 
543 543
     /**
544
-	 * Communicates with authorize.net
545
-	 *
546
-	 *
547
-	 * @param array $post Data to post.
544
+     * Communicates with authorize.net
545
+     *
546
+     *
547
+     * @param array $post Data to post.
548 548
      * @param WPInv_Invoice $invoice Invoice.
549
-	 * @return stdClass|WP_Error
550
-	 */
549
+     * @return stdClass|WP_Error
550
+     */
551 551
     public function post( $post, $invoice ){
552 552
 
553 553
         $url      = $this->get_api_url( $invoice );
@@ -589,15 +589,15 @@  discard block
 block discarded – undo
589 589
     }
590 590
 
591 591
     /**
592
-	 * Process Payment.
593
-	 *
594
-	 *
595
-	 * @param WPInv_Invoice $invoice Invoice.
596
-	 * @param array $submission_data Posted checkout fields.
597
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
598
-	 * @return array
599
-	 */
600
-	public function process_payment( $invoice, $submission_data, $submission ) {
592
+     * Process Payment.
593
+     *
594
+     *
595
+     * @param WPInv_Invoice $invoice Invoice.
596
+     * @param array $submission_data Posted checkout fields.
597
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
598
+     * @return array
599
+     */
600
+    public function process_payment( $invoice, $submission_data, $submission ) {
601 601
 
602 602
         // Validate the submitted data.
603 603
         $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice );
@@ -646,12 +646,12 @@  discard block
 block discarded – undo
646 646
     }
647 647
 
648 648
     /**
649
-	 * Processes recurring payments.
650
-	 *
649
+     * Processes recurring payments.
650
+     *
651 651
      * @param WPInv_Invoice $invoice Invoice.
652 652
      * @param WPInv_Subscription $subscription Subscription.
653
-	 */
654
-	public function process_subscription( $invoice, $subscription ) {
653
+     */
654
+    public function process_subscription( $invoice, $subscription ) {
655 655
 
656 656
         // Check if there is an initial amount to charge.
657 657
         if ( (float) $invoice->get_total() > 0 ) {
@@ -703,11 +703,11 @@  discard block
 block discarded – undo
703 703
     }
704 704
 
705 705
     /**
706
-	 * Renews a subscription.
707
-	 *
706
+     * Renews a subscription.
707
+     *
708 708
      * @param int $invoice Invoice id.
709
-	 */
710
-	public function renew_subscription( $invoice ) {
709
+     */
710
+    public function renew_subscription( $invoice ) {
711 711
 
712 712
         // Retrieve the subscription.
713 713
         $subscription = wpinv_get_subscription( $invoice );
@@ -800,13 +800,13 @@  discard block
 block discarded – undo
800 800
     }
801 801
 
802 802
     /**
803
-	 * Cancels a subscription remotely
804
-	 *
805
-	 *
806
-	 * @param WPInv_Subscription $subscription Subscription.
803
+     * Cancels a subscription remotely
804
+     *
805
+     *
806
+     * @param WPInv_Subscription $subscription Subscription.
807 807
      * @param WPInv_Invoice $invoice Invoice.
808
-	 */
809
-	public function cancel_subscription( $subscription, $invoice ) {
808
+     */
809
+    public function cancel_subscription( $subscription, $invoice ) {
810 810
 
811 811
         if ( as_unschedule_action( 'wpinv_renew_authorizenet_subscription_profile', array( $invoice->get_id() ), 'invoicing' ) ) {
812 812
             return;
@@ -826,17 +826,17 @@  discard block
 block discarded – undo
826 826
     }
827 827
 
828 828
     /**
829
-	 * Processes ipns.
830
-	 *
831
-	 * @return void
832
-	 */
833
-	public function verify_ipn() {
829
+     * Processes ipns.
830
+     *
831
+     * @return void
832
+     */
833
+    public function verify_ipn() {
834 834
 
835 835
         $this->maybe_process_old_ipn();
836 836
 
837 837
         // Validate the IPN.
838 838
         if ( empty( $_POST ) || ! $this->validate_ipn() ) {
839
-		    wp_die( 'Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array( 'response' => 500 ) );
839
+            wp_die( 'Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array( 'response' => 500 ) );
840 840
         }
841 841
 
842 842
         // Event type.
@@ -884,11 +884,11 @@  discard block
 block discarded – undo
884 884
     }
885 885
 
886 886
     /**
887
-	 * Backwards compatibility.
888
-	 *
889
-	 * @return void
890
-	 */
891
-	public function maybe_process_old_ipn() {
887
+     * Backwards compatibility.
888
+     *
889
+     * @return void
890
+     */
891
+    public function maybe_process_old_ipn() {
892 892
 
893 893
         // Ensure that we are using the old subscriptions.
894 894
         if ( empty( $_POST['x_subscription_id'] ) ) {
@@ -937,9 +937,9 @@  discard block
 block discarded – undo
937 937
     }
938 938
 
939 939
     /**
940
-	 * Check Authorize.NET IPN validity.
941
-	 */
942
-	public function validate_ipn() {
940
+     * Check Authorize.NET IPN validity.
941
+     */
942
+    public function validate_ipn() {
943 943
 
944 944
         wpinv_error_log( 'Validating Authorize.NET IPN response' );
945 945
 
@@ -984,11 +984,11 @@  discard block
 block discarded – undo
984 984
     }
985 985
 
986 986
     /**
987
-	 * Filters the gateway settings.
988
-	 * 
989
-	 * @param array $admin_settings
990
-	 */
991
-	public function admin_settings( $admin_settings ) {
987
+     * Filters the gateway settings.
988
+     * 
989
+     * @param array $admin_settings
990
+     */
991
+    public function admin_settings( $admin_settings ) {
992 992
 
993 993
         $currencies = sprintf(
994 994
             __( 'Supported Currencies: %s', 'invoicing' ),
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
             'readonly' => true,
1029 1029
         );
1030 1030
 
1031
-		return $admin_settings;
1032
-	}
1031
+        return $admin_settings;
1032
+    }
1033 1033
 
1034 1034
 }
Please login to merge, or discard this patch.
Spacing   +225 added lines, -225 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
  * Authorize.net Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'sandbox', 'tokens' );
27
+    protected $supports = array('subscription', 'sandbox', 'tokens');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @var array
54 54
 	 */
55
-	public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
55
+	public $currencies = array('USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD');
56 56
 
57 57
     /**
58 58
 	 * URL to view a transaction.
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function __construct() {
68 68
 
69
-        $this->title                = __( 'Credit Card / Debit Card', 'invoicing' );
70
-        $this->method_title         = __( 'Authorize.Net', 'invoicing' );
71
-        $this->notify_url           = wpinv_get_ipn_url( $this->id );
69
+        $this->title                = __('Credit Card / Debit Card', 'invoicing');
70
+        $this->method_title         = __('Authorize.Net', 'invoicing');
71
+        $this->notify_url           = wpinv_get_ipn_url($this->id);
72 72
 
73
-        add_filter( 'wpinv_renew_authorizenet_subscription_profile', array( $this, 'renew_subscription' ) );
74
-        add_filter( 'wpinv_gateway_description', array( $this, 'sandbox_notice' ), 10, 2 );
73
+        add_filter('wpinv_renew_authorizenet_subscription_profile', array($this, 'renew_subscription'));
74
+        add_filter('wpinv_gateway_description', array($this, 'sandbox_notice'), 10, 2);
75 75
         parent::__construct();
76 76
     }
77 77
 
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 	 * @param int $invoice_id 0 or invoice id.
82 82
 	 * @param GetPaid_Payment_Form $form Current payment form.
83 83
 	 */
84
-    public function payment_fields( $invoice_id, $form ) {
84
+    public function payment_fields($invoice_id, $form) {
85 85
 
86 86
         // Let the user select a payment method.
87 87
         echo $this->saved_payment_methods();
88 88
 
89 89
         // Show the credit card entry form.
90
-        echo $this->new_payment_method_entry( $this->get_cc_form( true ) );
90
+        echo $this->new_payment_method_entry($this->get_cc_form(true));
91 91
     }
92 92
 
93 93
     /**
@@ -100,64 +100,64 @@  discard block
 block discarded – undo
100 100
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
101 101
 	 * @return string|WP_Error Payment profile id.
102 102
 	 */
103
-	public function create_customer_profile( $invoice, $submission_data, $save = true ) {
103
+	public function create_customer_profile($invoice, $submission_data, $save = true) {
104 104
 
105 105
         // Remove non-digits from the number
106
-        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] );
106
+        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']);
107 107
 
108 108
         // Generate args.
109 109
         $args = array(
110 110
             'createCustomerProfileRequest' => array(
111 111
                 'merchantAuthentication'   => $this->get_auth_params(),
112 112
                 'profile'                  => array(
113
-                    'merchantCustomerId'   => getpaid_limit_length( $invoice->get_user_id(), 20 ),
114
-                    'description'          => getpaid_limit_length( $invoice->get_full_name(), 255 ),
115
-                    'email'                => getpaid_limit_length( $invoice->get_email(), 255 ),
113
+                    'merchantCustomerId'   => getpaid_limit_length($invoice->get_user_id(), 20),
114
+                    'description'          => getpaid_limit_length($invoice->get_full_name(), 255),
115
+                    'email'                => getpaid_limit_length($invoice->get_email(), 255),
116 116
                     'paymentProfiles'      => array(
117 117
                         'customerType'     => 'individual',
118 118
 
119 119
                         // Billing information.
120 120
                         'billTo'           => array(
121
-                            'firstName'    => getpaid_limit_length( $invoice->get_first_name(), 50 ),
122
-                            'lastName'     => getpaid_limit_length( $invoice->get_last_name(), 50 ),
123
-                            'address'      => getpaid_limit_length( $invoice->get_last_name(), 60 ),
124
-                            'city'         => getpaid_limit_length( $invoice->get_city(), 40 ),
125
-                            'state'        => getpaid_limit_length( $invoice->get_state(), 40 ),
126
-                            'zip'          => getpaid_limit_length( $invoice->get_zip(), 20 ),
127
-                            'country'      => getpaid_limit_length( $invoice->get_country(), 60 ),
121
+                            'firstName'    => getpaid_limit_length($invoice->get_first_name(), 50),
122
+                            'lastName'     => getpaid_limit_length($invoice->get_last_name(), 50),
123
+                            'address'      => getpaid_limit_length($invoice->get_last_name(), 60),
124
+                            'city'         => getpaid_limit_length($invoice->get_city(), 40),
125
+                            'state'        => getpaid_limit_length($invoice->get_state(), 40),
126
+                            'zip'          => getpaid_limit_length($invoice->get_zip(), 20),
127
+                            'country'      => getpaid_limit_length($invoice->get_country(), 60),
128 128
                         ),
129 129
 
130 130
                         // Payment information.
131
-                        'payment'          => $this->get_payment_information( $submission_data['authorizenet'] ),
131
+                        'payment'          => $this->get_payment_information($submission_data['authorizenet']),
132 132
                     )
133 133
                 ),
134
-                'validationMode'           => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', 
134
+                'validationMode'           => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', 
135 135
             )
136 136
         );
137 137
 
138
-        $response = $this->post( apply_filters( 'getpaid_authorizenet_customer_profile_args', $args, $invoice ), $invoice );
138
+        $response = $this->post(apply_filters('getpaid_authorizenet_customer_profile_args', $args, $invoice), $invoice);
139 139
 
140
-        if ( is_wp_error( $response ) ) {
140
+        if (is_wp_error($response)) {
141 141
             return $response;
142 142
         }
143 143
 
144
-        update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId );
144
+        update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId);
145 145
 
146 146
         // Save the payment token.
147
-        if ( $save ) {
147
+        if ($save) {
148 148
             $this->save_token(
149 149
                 array(
150 150
                     'id'      => $response->customerPaymentProfileIdList[0],
151
-                    'name'    => $this->get_card_name( $submission_data['authorizenet']['cc_number'] ) . '····' . substr( $submission_data['authorizenet']['cc_number'], -4 ),
151
+                    'name'    => $this->get_card_name($submission_data['authorizenet']['cc_number']) . '····' . substr($submission_data['authorizenet']['cc_number'], -4),
152 152
                     'default' => true,
153
-                    'type'    => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live',
153
+                    'type'    => $this->is_sandbox($invoice) ? 'sandbox' : 'live',
154 154
                 )
155 155
             );
156 156
         }
157 157
 
158 158
         // Add a note about the validation response.
159 159
         $invoice->add_note(
160
-            sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ),
160
+            sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]),
161 161
             false,
162 162
             false,
163 163
             true
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * @return string|WP_Error Profile id.
175 175
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile
176 176
 	 */
177
-	public function get_customer_profile( $profile_id ) {
177
+	public function get_customer_profile($profile_id) {
178 178
 
179 179
         // Generate args.
180 180
         $args = array(
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
             )
185 185
         );
186 186
 
187
-        return $this->post( $args, false );
187
+        return $this->post($args, false);
188 188
 
189 189
     }
190 190
 
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
200 200
 	 * @return string|WP_Error Profile id.
201 201
 	 */
202
-	public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
202
+	public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) {
203 203
 
204 204
         // Remove non-digits from the number
205
-        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] );
205
+        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']);
206 206
 
207 207
         // Generate args.
208 208
         $args = array(
@@ -213,34 +213,34 @@  discard block
 block discarded – undo
213 213
 
214 214
                     // Billing information.
215 215
                     'billTo'           => array(
216
-                        'firstName'    => getpaid_limit_length( $invoice->get_first_name(), 50 ),
217
-                        'lastName'     => getpaid_limit_length( $invoice->get_last_name(), 50 ),
218
-                        'address'      => getpaid_limit_length( $invoice->get_last_name(), 60 ),
219
-                        'city'         => getpaid_limit_length( $invoice->get_city(), 40 ),
220
-                        'state'        => getpaid_limit_length( $invoice->get_state(), 40 ),
221
-                        'zip'          => getpaid_limit_length( $invoice->get_zip(), 20 ),
222
-                        'country'      => getpaid_limit_length( $invoice->get_country(), 60 ),
216
+                        'firstName'    => getpaid_limit_length($invoice->get_first_name(), 50),
217
+                        'lastName'     => getpaid_limit_length($invoice->get_last_name(), 50),
218
+                        'address'      => getpaid_limit_length($invoice->get_last_name(), 60),
219
+                        'city'         => getpaid_limit_length($invoice->get_city(), 40),
220
+                        'state'        => getpaid_limit_length($invoice->get_state(), 40),
221
+                        'zip'          => getpaid_limit_length($invoice->get_zip(), 20),
222
+                        'country'      => getpaid_limit_length($invoice->get_country(), 60),
223 223
                     ),
224 224
 
225 225
                     // Payment information.
226
-                    'payment'          => $this->get_payment_information( $submission_data['authorizenet'] )
226
+                    'payment'          => $this->get_payment_information($submission_data['authorizenet'])
227 227
                 ),
228
-                'validationMode'       => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', 
228
+                'validationMode'       => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', 
229 229
             )
230 230
         );
231 231
 
232
-        $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice );
232
+        $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice);
233 233
 
234
-        if ( is_wp_error( $response ) ) {
234
+        if (is_wp_error($response)) {
235 235
             return $response;
236 236
         }
237 237
 
238 238
         // Save the payment token.
239
-        if ( $save ) {
239
+        if ($save) {
240 240
             $this->save_token(
241 241
                 array(
242 242
                     'id'      => $response->customerPaymentProfileId,
243
-                    'name'    => $this->get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' ···· ' . substr( $submission_data['authorizenet']['cc_number'], -4 ),
243
+                    'name'    => $this->get_card_name($submission_data['authorizenet']['cc_number']) . ' ···· ' . substr($submission_data['authorizenet']['cc_number'], -4),
244 244
                     'default' => true
245 245
                 )
246 246
             );
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
         // Add a note about the validation response.
250 250
         $invoice->add_note(
251
-            sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ),
251
+            sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse),
252 252
             false,
253 253
             false,
254 254
             true
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 * @return string|WP_Error Profile id.
268 268
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile
269 269
 	 */
270
-	public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
270
+	public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) {
271 271
 
272 272
         // Generate args.
273 273
         $args = array(
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
             )
279 279
         );
280 280
 
281
-        return $this->post( $args, false );
281
+        return $this->post($args, false);
282 282
 
283 283
     }
284 284
 
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
      * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile
292 292
 	 * @return WP_Error|object
293 293
 	 */
294
-	public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
294
+	public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) {
295 295
 
296 296
         // Generate args.
297 297
         $args = array(
@@ -311,24 +311,24 @@  discard block
 block discarded – undo
311 311
                         )
312 312
                     ),
313 313
                     'order'                    => array(
314
-                        'invoiceNumber'        => getpaid_limit_length( $invoice->get_number(), 20 ),
314
+                        'invoiceNumber'        => getpaid_limit_length($invoice->get_number(), 20),
315 315
                     ),
316
-                    'lineItems'                => array( 'lineItem' => $this->get_line_items( $invoice ) ),
316
+                    'lineItems'                => array('lineItem' => $this->get_line_items($invoice)),
317 317
                     'tax'                      => array(
318 318
                         'amount'               => $invoice->get_total_tax(),
319 319
                         'name'                 => getpaid_tax()->get_vat_name(),
320 320
                     ),
321
-                    'poNumber'                 => getpaid_limit_length( $invoice->get_number(), 25 ),
321
+                    'poNumber'                 => getpaid_limit_length($invoice->get_number(), 25),
322 322
                     'customer'                 => array(
323
-                        'id'                   => getpaid_limit_length( $invoice->get_user_id(), 25 ),
324
-                        'email'                => getpaid_limit_length( $invoice->get_email(), 25 ),
323
+                        'id'                   => getpaid_limit_length($invoice->get_user_id(), 25),
324
+                        'email'                => getpaid_limit_length($invoice->get_email(), 25),
325 325
                     ),
326 326
                     'customerIP'               => $invoice->get_ip(),
327 327
                 )
328 328
             )
329 329
         );
330
-log_noptin_message( $args );
331
-        return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice );
330
+log_noptin_message($args);
331
+        return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice);
332 332
 
333 333
     }
334 334
 
@@ -338,43 +338,43 @@  discard block
 block discarded – undo
338 338
      * @param stdClass $result Api response.
339 339
 	 * @param WPInv_Invoice $invoice Invoice.
340 340
 	 */
341
-	public function process_charge_response( $result, $invoice ) {
341
+	public function process_charge_response($result, $invoice) {
342 342
 
343 343
         wpinv_clear_errors();
344 344
 
345
-        switch ( (int) $result->transactionResponse->responseCode ) {
345
+        switch ((int) $result->transactionResponse->responseCode) {
346 346
 
347 347
             case 1:
348 348
             case 4:
349 349
 
350
-                if ( ! empty( $result->transactionResponse->transId ) ) {
351
-                    $invoice->set_transaction_id( $result->transactionResponse->transId );
350
+                if (!empty($result->transactionResponse->transId)) {
351
+                    $invoice->set_transaction_id($result->transactionResponse->transId);
352 352
                 }
353 353
 
354
-                if ( 1 == (int) $result->transactionResponse->responseCode ) {
354
+                if (1 == (int) $result->transactionResponse->responseCode) {
355 355
                     $invoice->mark_paid();
356 356
                 } else {
357
-                    $invoice->set_status( 'wpi-onhold' );
357
+                    $invoice->set_status('wpi-onhold');
358 358
                     $invoice->add_note( 
359 359
                         sprintf(
360
-                            __( 'Held for review: %s', 'invoicing' ),
360
+                            __('Held for review: %s', 'invoicing'),
361 361
                             $result->transactionResponse->messages->message[0]->description
362 362
                         )
363 363
                     );
364 364
                 }
365 365
 
366
-                $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true );
366
+                $invoice->add_note(sprintf(__('Authentication code: %s (%s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true);
367 367
                 $invoice->save();
368 368
 
369 369
                 return;
370 370
 
371 371
             case 2:
372 372
             case 3:
373
-                wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) );
373
+                wpinv_set_error('card_declined', __('Credit card declined.', 'invoicing'));
374 374
 
375
-                if ( ! empty( $result->transactionResponse->errors ) ) {
375
+                if (!empty($result->transactionResponse->errors)) {
376 376
                     $errors = (object) $result->transactionResponse->errors;
377
-                    wpinv_set_error( $errors->error[0]->errorCode, $errors->error[0]->errorText );
377
+                    wpinv_set_error($errors->error[0]->errorCode, $errors->error[0]->errorText);
378 378
                 }
379 379
 
380 380
                 return;
@@ -390,10 +390,10 @@  discard block
 block discarded – undo
390 390
 	 * @param array $card Card details.
391 391
 	 * @return array
392 392
 	 */
393
-	public function get_payment_information( $card ) {
393
+	public function get_payment_information($card) {
394 394
         return array(
395 395
 
396
-            'creditCard'         => array (
396
+            'creditCard'         => array(
397 397
                 'cardNumber'     => $card['cc_number'],
398 398
                 'expirationDate' => $card['cc_expire_year'] . '-' . $card['cc_expire_month'],
399 399
                 'cardCode'       => $card['cc_cvv2'],
@@ -409,30 +409,30 @@  discard block
 block discarded – undo
409 409
 	 * @param string $card_number Card number.
410 410
 	 * @return string
411 411
 	 */
412
-	public function get_card_name( $card_number ) {
412
+	public function get_card_name($card_number) {
413 413
 
414
-        switch( $card_number ) {
414
+        switch ($card_number) {
415 415
 
416
-            case( preg_match ( '/^4/', $card_number ) >= 1 ):
417
-                return __( 'Visa', 'invoicing' );
416
+            case(preg_match('/^4/', $card_number) >= 1):
417
+                return __('Visa', 'invoicing');
418 418
 
419
-            case( preg_match ( '/^5[1-5]/', $card_number ) >= 1 ):
420
-                return __( 'Mastercard', 'invoicing' );
419
+            case(preg_match('/^5[1-5]/', $card_number) >= 1):
420
+                return __('Mastercard', 'invoicing');
421 421
 
422
-            case( preg_match ( '/^3[47]/', $card_number ) >= 1 ):
423
-                return __( 'Amex', 'invoicing' );
422
+            case(preg_match('/^3[47]/', $card_number) >= 1):
423
+                return __('Amex', 'invoicing');
424 424
 
425
-            case( preg_match ( '/^3(?:0[0-5]|[68])/', $card_number ) >= 1 ):
426
-                return __( 'Diners Club', 'invoicing' );
425
+            case(preg_match('/^3(?:0[0-5]|[68])/', $card_number) >= 1):
426
+                return __('Diners Club', 'invoicing');
427 427
 
428
-            case( preg_match ( '/^6(?:011|5)/', $card_number ) >= 1 ):
429
-                return __( 'Discover', 'invoicing' );
428
+            case(preg_match('/^6(?:011|5)/', $card_number) >= 1):
429
+                return __('Discover', 'invoicing');
430 430
 
431
-            case( preg_match ( '/^(?:2131|1800|35\d{3})/', $card_number ) >= 1 ):
432
-                return __( 'JCB', 'invoicing' );
431
+            case(preg_match('/^(?:2131|1800|35\d{3})/', $card_number) >= 1):
432
+                return __('JCB', 'invoicing');
433 433
 
434 434
             default:
435
-            return __( 'Card', 'invoicing' );
435
+            return __('Card', 'invoicing');
436 436
                 break;
437 437
         }
438 438
 
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 	 * @param WPInv_Invoice $invoice Invoice.
446 446
 	 * @return string
447 447
 	 */
448
-	public function get_customer_profile_meta_name( $invoice ) {
449
-        return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
448
+	public function get_customer_profile_meta_name($invoice) {
449
+        return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
450 450
     }
451 451
 
452 452
     /**
@@ -456,8 +456,8 @@  discard block
 block discarded – undo
456 456
 	 * @param WPInv_Invoice $invoice Invoice.
457 457
 	 * @return string
458 458
 	 */
459
-	public function get_api_url( $invoice ) {
460
-        return $this->is_sandbox( $invoice ) ? 'https://apitest.authorize.net/xml/v1/request.api' : 'https://api.authorize.net/xml/v1/request.api';
459
+	public function get_api_url($invoice) {
460
+        return $this->is_sandbox($invoice) ? 'https://apitest.authorize.net/xml/v1/request.api' : 'https://api.authorize.net/xml/v1/request.api';
461 461
     }
462 462
 
463 463
     /**
@@ -469,8 +469,8 @@  discard block
 block discarded – undo
469 469
 	public function get_auth_params() {
470 470
 
471 471
         return array(
472
-            'name'           => $this->get_option( 'login_id' ),
473
-            'transactionKey' => $this->get_option( 'transaction_key' ),
472
+            'name'           => $this->get_option('login_id'),
473
+            'transactionKey' => $this->get_option('transaction_key'),
474 474
         );
475 475
 
476 476
     }
@@ -483,34 +483,34 @@  discard block
 block discarded – undo
483 483
      * @param WPInv_Invoice $invoice
484 484
 	 * @return WP_Error|string The payment profile id
485 485
 	 */
486
-	public function validate_submission_data( $submission_data, $invoice ) {
486
+	public function validate_submission_data($submission_data, $invoice) {
487 487
 
488 488
         // Validate authentication details.
489 489
         $auth = $this->get_auth_params();
490 490
 
491
-        if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) {
492
-            return new WP_Error( 'invalid_settings', __( 'This gateway has not been set up.', 'invoicing') );
491
+        if (empty($auth['name']) || empty($auth['transactionKey'])) {
492
+            return new WP_Error('invalid_settings', __('This gateway has not been set up.', 'invoicing'));
493 493
         }
494 494
 
495 495
         // Validate the payment method.
496
-        if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) {
497
-            return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing') );
496
+        if (empty($submission_data['getpaid-authorizenet-payment-method'])) {
497
+            return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing'));
498 498
         }
499 499
 
500 500
         // Are we adding a new payment method?
501
-        if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) {
501
+        if ('new' != $submission_data['getpaid-authorizenet-payment-method']) {
502 502
             return $submission_data['getpaid-authorizenet-payment-method'];
503 503
         }
504 504
 
505 505
         // Retrieve the customer profile id.
506
-        $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
506
+        $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
507 507
 
508 508
         // Create payment method.
509
-        if ( empty( $profile_id ) ) {
510
-            return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) );
509
+        if (empty($profile_id)) {
510
+            return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method']));
511 511
         }
512 512
 
513
-        return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) );
513
+        return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method']));
514 514
 
515 515
     }
516 516
 
@@ -521,15 +521,15 @@  discard block
 block discarded – undo
521 521
 	 * @param WPInv_Invoice $invoice Invoice.
522 522
 	 * @return array
523 523
 	 */
524
-	public function get_line_items( $invoice ) {
524
+	public function get_line_items($invoice) {
525 525
         $items = array();
526 526
 
527
-        foreach ( $invoice->get_items() as $item ) {
527
+        foreach ($invoice->get_items() as $item) {
528 528
 
529 529
             $items[] = array(
530
-                'itemId'      => getpaid_limit_length( $item->get_id(), 31 ),
531
-                'name'        => getpaid_limit_length( $item->get_raw_name(), 31 ),
532
-                'description' => getpaid_limit_length( $item->get_description(), 255 ),
530
+                'itemId'      => getpaid_limit_length($item->get_id(), 31),
531
+                'name'        => getpaid_limit_length($item->get_raw_name(), 31),
532
+                'description' => getpaid_limit_length($item->get_description(), 255),
533 533
                 'quantity'    => (int) $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(),
534 534
                 'unitPrice'   => (float) $item->get_price(),
535 535
                 'taxable'     => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(),
@@ -548,40 +548,40 @@  discard block
 block discarded – undo
548 548
      * @param WPInv_Invoice $invoice Invoice.
549 549
 	 * @return stdClass|WP_Error
550 550
 	 */
551
-    public function post( $post, $invoice ){
551
+    public function post($post, $invoice) {
552 552
 
553
-        $url      = $this->get_api_url( $invoice );
553
+        $url      = $this->get_api_url($invoice);
554 554
         $response = wp_remote_post(
555 555
             $url,
556 556
             array(
557 557
                 'headers'          => array(
558 558
                     'Content-Type' => 'application/json; charset=utf-8'
559 559
                 ),
560
-                'body'             => json_encode( $post ),
560
+                'body'             => json_encode($post),
561 561
                 'method'           => 'POST'
562 562
             )
563 563
         );
564 564
 
565
-        if ( is_wp_error( $response ) ) {
565
+        if (is_wp_error($response)) {
566 566
             return $response;
567 567
         }
568 568
 
569
-        $response = wp_unslash( wp_remote_retrieve_body( $response ) );
569
+        $response = wp_unslash(wp_remote_retrieve_body($response));
570 570
         $response = preg_replace('/\xEF\xBB\xBF/', '', $response); // https://community.developer.authorize.net/t5/Integration-and-Testing/JSON-issues/td-p/48851
571
-        $response = json_decode( $response );
571
+        $response = json_decode($response);
572 572
 
573
-        if ( empty( $response ) ) {
574
-            return new WP_Error( 'invalid_reponse', __( 'Invalid response', 'invoicing' ) );
573
+        if (empty($response)) {
574
+            return new WP_Error('invalid_reponse', __('Invalid response', 'invoicing'));
575 575
         }
576 576
 
577
-        if ( $response->messages->resultCode == 'Error' ) {
577
+        if ($response->messages->resultCode == 'Error') {
578 578
 
579
-            if ( ! empty( $response->transactionResponse ) && ! empty( $response->transactionResponse->errors ) ) {
579
+            if (!empty($response->transactionResponse) && !empty($response->transactionResponse->errors)) {
580 580
                 $error = $response->transactionResponse->errors[0];
581
-                return new WP_Error( $error->errorCode, $error->errorText );
581
+                return new WP_Error($error->errorCode, $error->errorText);
582 582
             }
583 583
 
584
-            return new WP_Error( $response->messages->message[0]->code, $response->messages->message[0]->text );
584
+            return new WP_Error($response->messages->message[0]->code, $response->messages->message[0]->text);
585 585
         }
586 586
 
587 587
         return $response;
@@ -597,49 +597,49 @@  discard block
 block discarded – undo
597 597
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
598 598
 	 * @return array
599 599
 	 */
600
-	public function process_payment( $invoice, $submission_data, $submission ) {
600
+	public function process_payment($invoice, $submission_data, $submission) {
601 601
 
602 602
         // Validate the submitted data.
603
-        $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice );
603
+        $payment_profile_id = $this->validate_submission_data($submission_data, $invoice);
604 604
 
605 605
         // Do we have an error?
606
-        if ( is_wp_error( $payment_profile_id ) ) {
607
-            wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() );
606
+        if (is_wp_error($payment_profile_id)) {
607
+            wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message());
608 608
             wpinv_send_back_to_checkout();
609 609
         }
610 610
 
611 611
         // Save the payment method to the order.
612
-        update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id );
612
+        update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id);
613 613
 
614 614
         // Check if this is a subscription or not.
615
-        if ( $invoice->is_recurring() && $subscription = wpinv_get_subscription( $invoice ) ) {
616
-            $this->process_subscription( $invoice, $subscription );
615
+        if ($invoice->is_recurring() && $subscription = wpinv_get_subscription($invoice)) {
616
+            $this->process_subscription($invoice, $subscription);
617 617
         }
618 618
 
619 619
         // If it is free, send to the success page.
620
-        if ( ! $invoice->needs_payment() ) {
620
+        if (!$invoice->needs_payment()) {
621 621
             $invoice->mark_paid();
622
-            wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
622
+            wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
623 623
         }
624 624
 
625 625
         // Charge the payment profile.
626
-        $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
627
-        $result           = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
626
+        $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
627
+        $result           = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice);
628 628
 
629 629
         // Do we have an error?
630
-        if ( is_wp_error( $result ) ) {
631
-            wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
630
+        if (is_wp_error($result)) {
631
+            wpinv_set_error($result->get_error_code(), $result->get_error_message());
632 632
             wpinv_send_back_to_checkout();
633 633
         }
634 634
 
635 635
         // Process the response.
636
-        $this->process_charge_response( $result, $invoice );
636
+        $this->process_charge_response($result, $invoice);
637 637
 
638
-        if ( wpinv_get_errors() ) {
638
+        if (wpinv_get_errors()) {
639 639
             wpinv_send_back_to_checkout();
640 640
         }
641 641
 
642
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
642
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
643 643
 
644 644
         exit;
645 645
 
@@ -651,40 +651,40 @@  discard block
 block discarded – undo
651 651
      * @param WPInv_Invoice $invoice Invoice.
652 652
      * @param WPInv_Subscription $subscription Subscription.
653 653
 	 */
654
-	public function process_subscription( $invoice, $subscription ) {
654
+	public function process_subscription($invoice, $subscription) {
655 655
 
656 656
         // Check if there is an initial amount to charge.
657
-        if ( (float) $invoice->get_total() > 0 ) {
657
+        if ((float) $invoice->get_total() > 0) {
658 658
 
659 659
             // Retrieve the payment method.
660
-            $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
661
-            $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
662
-            $result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
660
+            $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
661
+            $customer_profile   = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
662
+            $result             = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice);
663 663
 
664 664
             // Do we have an error?
665
-            if ( is_wp_error( $result ) ) {
666
-                wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
665
+            if (is_wp_error($result)) {
666
+                wpinv_set_error($result->get_error_code(), $result->get_error_message());
667 667
                 wpinv_send_back_to_checkout();
668 668
             }
669 669
 
670 670
             // Process the response.
671
-            $this->process_charge_response( $result, $invoice );
671
+            $this->process_charge_response($result, $invoice);
672 672
 
673
-            if ( wpinv_get_errors() ) {
673
+            if (wpinv_get_errors()) {
674 674
                 wpinv_send_back_to_checkout();
675 675
             }
676 676
 
677 677
         }
678 678
 
679 679
         // Recalculate the new subscription expiry.
680
-        $duration = strtotime( $subscription->expiration ) - strtotime( $subscription->created );
681
-        $expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
680
+        $duration = strtotime($subscription->expiration) - strtotime($subscription->created);
681
+        $expiry   = date('Y-m-d H:i:s', (current_time('timestamp') + $duration));
682 682
 
683 683
         // Schedule an action to run when the subscription expires.
684 684
         $action_id = as_schedule_single_action(
685
-            strtotime( $expiry ),
685
+            strtotime($expiry),
686 686
             'wpinv_renew_authorizenet_subscription_profile',
687
-            array( $invoice->get_id() ),
687
+            array($invoice->get_id()),
688 688
             'invoicing'
689 689
         );
690 690
 
@@ -693,12 +693,12 @@  discard block
 block discarded – undo
693 693
             array(
694 694
                 'profile_id' => $action_id,
695 695
                 'status'     => 'trialling' == $subscription->status ? 'trialling' : 'active',
696
-                'created'    => current_time( 'mysql' ),
696
+                'created'    => current_time('mysql'),
697 697
                 'expiration' => $expiry,
698 698
             )
699 699
         );
700 700
 
701
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
701
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
702 702
 
703 703
     }
704 704
 
@@ -707,45 +707,45 @@  discard block
 block discarded – undo
707 707
 	 *
708 708
      * @param int $invoice Invoice id.
709 709
 	 */
710
-	public function renew_subscription( $invoice ) {
710
+	public function renew_subscription($invoice) {
711 711
 
712 712
         // Retrieve the subscription.
713
-        $subscription = wpinv_get_subscription( $invoice );
714
-        if ( empty( $subscription ) ) {
713
+        $subscription = wpinv_get_subscription($invoice);
714
+        if (empty($subscription)) {
715 715
             return;
716 716
         }
717 717
 
718 718
         // Abort if it is canceled or complete.
719
-        if ( $subscription->status == 'completed' || $subscription->status == 'cancelled' ) {
719
+        if ($subscription->status == 'completed' || $subscription->status == 'cancelled') {
720 720
             return;
721 721
         }
722 722
 
723 723
         // Retrieve the invoice.
724
-        $invoice = new WPInv_Invoice( $invoice );
724
+        $invoice = new WPInv_Invoice($invoice);
725 725
 
726 726
         // If we have not maxed out on bill times...
727 727
         $times_billed = $subscription->get_times_billed();
728 728
         $max_bills    = $subscription->bill_times;
729 729
 
730
-        if ( empty( $max_bills ) || $max_bills > $times_billed ) {
730
+        if (empty($max_bills) || $max_bills > $times_billed) {
731 731
 
732 732
             $new_invoice = $subscription->create_payment();
733 733
 
734
-            if ( empty( $new_invoice ) ) {
735
-                $invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false );
734
+            if (empty($new_invoice)) {
735
+                $invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false);
736 736
                 $subscription->failing();
737 737
                 return;
738 738
             }
739 739
 
740 740
             // retrieve the payment method.
741
-            $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
742
-            $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
743
-            $result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice );
741
+            $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
742
+            $customer_profile   = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
743
+            $result             = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice);
744 744
 
745 745
             // Do we have an error?
746
-            if ( is_wp_error( $result ) ) {
746
+            if (is_wp_error($result)) {
747 747
                 $invoice->add_note(
748
-                    sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
748
+                    sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()),
749 749
                     true,
750 750
                     false,
751 751
                     true
@@ -755,12 +755,12 @@  discard block
 block discarded – undo
755 755
             }
756 756
 
757 757
             // Process the response.
758
-            $this->process_charge_response( $result, $new_invoice );
758
+            $this->process_charge_response($result, $new_invoice);
759 759
 
760
-            if ( wpinv_get_errors() ) {
760
+            if (wpinv_get_errors()) {
761 761
 
762 762
                 $invoice->add_note(
763
-                    sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
763
+                    sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()),
764 764
                     true,
765 765
                     false,
766 766
                     true
@@ -782,17 +782,17 @@  discard block
 block discarded – undo
782 782
             // Renew/Complete the subscription.
783 783
             $subscription->renew();
784 784
 
785
-            if ( 'completed' != $subscription->status ) {
785
+            if ('completed' != $subscription->status) {
786 786
 
787 787
                 // Schedule an action to run when the subscription expires.
788 788
                 $action_id = as_schedule_single_action(
789
-                    strtotime( $subscription->expiration ),
789
+                    strtotime($subscription->expiration),
790 790
                     'wpinv_renew_authorizenet_subscription_profile',
791
-                    array( $invoice->get_id() ),
791
+                    array($invoice->get_id()),
792 792
                     'invoicing'
793 793
                 );
794 794
     
795
-                $subscription->update( array( 'profile_id' => $action_id, ) );
795
+                $subscription->update(array('profile_id' => $action_id,));
796 796
     
797 797
             }
798 798
 
@@ -806,9 +806,9 @@  discard block
 block discarded – undo
806 806
 	 * @param WPInv_Subscription $subscription Subscription.
807 807
      * @param WPInv_Invoice $invoice Invoice.
808 808
 	 */
809
-	public function cancel_subscription( $subscription, $invoice ) {
809
+	public function cancel_subscription($subscription, $invoice) {
810 810
 
811
-        if ( as_unschedule_action( 'wpinv_renew_authorizenet_subscription_profile', array( $invoice->get_id() ), 'invoicing' ) ) {
811
+        if (as_unschedule_action('wpinv_renew_authorizenet_subscription_profile', array($invoice->get_id()), 'invoicing')) {
812 812
             return;
813 813
         }
814 814
 
@@ -835,45 +835,45 @@  discard block
 block discarded – undo
835 835
         $this->maybe_process_old_ipn();
836 836
 
837 837
         // Validate the IPN.
838
-        if ( empty( $_POST ) || ! $this->validate_ipn() ) {
839
-		    wp_die( 'Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array( 'response' => 500 ) );
838
+        if (empty($_POST) || !$this->validate_ipn()) {
839
+		    wp_die('Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array('response' => 500));
840 840
         }
841 841
 
842 842
         // Event type.
843
-        $posted = json_decode( file_get_contents('php://input') );
844
-        if ( empty( $posted ) ) {
845
-            wp_die( 'Invalid JSON', 'Authorize.NET IPN', array( 'response' => 500 ) );
843
+        $posted = json_decode(file_get_contents('php://input'));
844
+        if (empty($posted)) {
845
+            wp_die('Invalid JSON', 'Authorize.NET IPN', array('response' => 500));
846 846
         }
847 847
 
848 848
         // Process the IPN.
849
-        $posted = (object) wp_unslash( $posted );
849
+        $posted = (object) wp_unslash($posted);
850 850
 
851 851
         // Process refunds.
852
-        if ( 'net.authorize.payment.refund.created' == $posted->eventType ) {
853
-            $invoice = new WPInv_Invoice( $posted->payload->merchantReferenceId );
852
+        if ('net.authorize.payment.refund.created' == $posted->eventType) {
853
+            $invoice = new WPInv_Invoice($posted->payload->merchantReferenceId);
854 854
 
855
-            if ( $invoice->get_id() && $posted->payload->id == $invoice->get_transaction_id() ) {
855
+            if ($invoice->get_id() && $posted->payload->id == $invoice->get_transaction_id()) {
856 856
                 $invoice->refund();
857 857
             }
858 858
 
859 859
         }
860 860
 
861 861
         // Held funds approved.
862
-        if ( 'net.authorize.payment.fraud.approved' == $posted->eventType ) {
863
-            $invoice = new WPInv_Invoice( $posted->payload->id );
862
+        if ('net.authorize.payment.fraud.approved' == $posted->eventType) {
863
+            $invoice = new WPInv_Invoice($posted->payload->id);
864 864
 
865
-            if ( $invoice->get_id() && $posted->payload->id == $invoice->get_transaction_id() ) {
866
-                $invoice->mark_paid( false, __( 'Payment released', 'invoicing' ));
865
+            if ($invoice->get_id() && $posted->payload->id == $invoice->get_transaction_id()) {
866
+                $invoice->mark_paid(false, __('Payment released', 'invoicing'));
867 867
             }
868 868
 
869 869
         }
870 870
 
871 871
         // Held funds declined.
872
-        if ( 'net.authorize.payment.fraud.declined' == $posted->eventType ) {
873
-            $invoice = new WPInv_Invoice( $posted->payload->id );
872
+        if ('net.authorize.payment.fraud.declined' == $posted->eventType) {
873
+            $invoice = new WPInv_Invoice($posted->payload->id);
874 874
 
875
-            if ( $invoice->get_id() && $posted->payload->id == $invoice->get_transaction_id() ) {
876
-                $invoice->set_status( 'wpi-failed', __( 'Payment desclined', 'invoicing' ) );
875
+            if ($invoice->get_id() && $posted->payload->id == $invoice->get_transaction_id()) {
876
+                $invoice->set_status('wpi-failed', __('Payment desclined', 'invoicing'));
877 877
                 $invoice->save();
878 878
             }
879 879
 
@@ -891,41 +891,41 @@  discard block
 block discarded – undo
891 891
 	public function maybe_process_old_ipn() {
892 892
 
893 893
         // Ensure that we are using the old subscriptions.
894
-        if ( empty( $_POST['x_subscription_id'] ) ) {
894
+        if (empty($_POST['x_subscription_id'])) {
895 895
             return;
896 896
         }
897 897
 
898 898
         // Check validity.
899
-        $signature = $this->get_option( 'signature_key' );
900
-        if ( ! empty( $signature ) ) {
901
-            $login_id  = $this->get_option( 'login_id' );
899
+        $signature = $this->get_option('signature_key');
900
+        if (!empty($signature)) {
901
+            $login_id  = $this->get_option('login_id');
902 902
             $trans_id  = $_POST['x_trans_id'];
903 903
             $amount    = $_POST['x_amount'];
904
-            $hash      = hash_hmac ( 'sha512', "^$login_id^$trans_id^$amount^", hex2bin( $signature ) );
904
+            $hash      = hash_hmac('sha512', "^$login_id^$trans_id^$amount^", hex2bin($signature));
905 905
 
906
-            if ( ! hash_equals( $hash, $_POST['x_SHA2_Hash'] ) ) {
906
+            if (!hash_equals($hash, $_POST['x_SHA2_Hash'])) {
907 907
                 exit;
908 908
             }
909 909
 
910 910
         }
911 911
 
912 912
         // Fetch the associated subscription.
913
-        $subscription = new WPInv_Subscription( $_POST['x_subscription_id'], true );
913
+        $subscription = new WPInv_Subscription($_POST['x_subscription_id'], true);
914 914
 
915 915
         // Abort if it is missing or completed.
916
-        if ( empty( $subscription->id ) || $subscription->status == 'completed' ) {
916
+        if (empty($subscription->id) || $subscription->status == 'completed') {
917 917
             return;
918 918
         }
919 919
 
920 920
         // Payment status.
921
-        if ( 1 == $_POST['x_response_code'] ) {
921
+        if (1 == $_POST['x_response_code']) {
922 922
 
923 923
             $args = array(
924
-                'transaction_id' => wpinv_clean( $_POST['x_trans_id'] ),
924
+                'transaction_id' => wpinv_clean($_POST['x_trans_id']),
925 925
                 'gateway'        => $this->id
926 926
             );
927 927
 
928
-            $subscription->add_payment( $args );
928
+            $subscription->add_payment($args);
929 929
             $subscription->renew();
930 930
 
931 931
         } else {
@@ -941,28 +941,28 @@  discard block
 block discarded – undo
941 941
 	 */
942 942
 	public function validate_ipn() {
943 943
 
944
-        wpinv_error_log( 'Validating Authorize.NET IPN response' );
944
+        wpinv_error_log('Validating Authorize.NET IPN response');
945 945
 
946
-        if ( empty( $_SERVER['HTTP_X_ANET_SIGNATURE'] ) ) {
946
+        if (empty($_SERVER['HTTP_X_ANET_SIGNATURE'])) {
947 947
             return false;
948 948
         }
949 949
 
950
-        $signature = $this->get_option( 'signature_key' );
950
+        $signature = $this->get_option('signature_key');
951 951
 
952
-        if ( empty( $signature ) ) {
953
-            wpinv_error_log( 'Error: You have not set a signature key' );
952
+        if (empty($signature)) {
953
+            wpinv_error_log('Error: You have not set a signature key');
954 954
             return false;
955 955
         }
956 956
 
957
-        $hash  = hash_hmac ( 'sha512', file_get_contents('php://input'), hex2bin( $signature ) );
957
+        $hash = hash_hmac('sha512', file_get_contents('php://input'), hex2bin($signature));
958 958
 
959
-        if ( hash_equals( $hash, $_SERVER['HTTP_X_ANET_SIGNATURE'] ) ) {
960
-            wpinv_error_log( 'Successfully validated the IPN' );
959
+        if (hash_equals($hash, $_SERVER['HTTP_X_ANET_SIGNATURE'])) {
960
+            wpinv_error_log('Successfully validated the IPN');
961 961
             return true;
962 962
         }
963 963
 
964
-        wpinv_error_log( 'IPN hash is not valid' );
965
-        wpinv_error_log(  $_SERVER['HTTP_X_ANET_SIGNATURE']  );
964
+        wpinv_error_log('IPN hash is not valid');
965
+        wpinv_error_log($_SERVER['HTTP_X_ANET_SIGNATURE']);
966 966
         return false;
967 967
 
968 968
     }
@@ -970,11 +970,11 @@  discard block
 block discarded – undo
970 970
     /**
971 971
      * Displays a notice on the checkout page if sandbox is enabled.
972 972
      */
973
-    public function sandbox_notice( $description, $gateway ) {
973
+    public function sandbox_notice($description, $gateway) {
974 974
 
975
-        if ( $this->id == $gateway && wpinv_is_test_mode( $this->id ) ) {
975
+        if ($this->id == $gateway && wpinv_is_test_mode($this->id)) {
976 976
             $description .= '<br>' . sprintf(
977
-                __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing' ),
977
+                __('SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing'),
978 978
                 '<a href="https://developer.authorize.net/hello_world/testing_guide.html">',
979 979
                 '</a>'
980 980
             );
@@ -988,42 +988,42 @@  discard block
 block discarded – undo
988 988
 	 * 
989 989
 	 * @param array $admin_settings
990 990
 	 */
991
-	public function admin_settings( $admin_settings ) {
991
+	public function admin_settings($admin_settings) {
992 992
 
993 993
         $currencies = sprintf(
994
-            __( 'Supported Currencies: %s', 'invoicing' ),
995
-            implode( ', ', $this->currencies )
994
+            __('Supported Currencies: %s', 'invoicing'),
995
+            implode(', ', $this->currencies)
996 996
         );
997 997
 
998 998
         $admin_settings['authorizenet_active']['desc'] .= $admin_settings['authorizenet_active']['desc'] . " ($currencies)";
999
-        $admin_settings['authorizenet_desc']['std']     = __( 'Pay securely using your credit or debit card.', 'invoicing' );
999
+        $admin_settings['authorizenet_desc']['std']     = __('Pay securely using your credit or debit card.', 'invoicing');
1000 1000
 
1001 1001
         $admin_settings['authorizenet_login_id'] = array(
1002 1002
             'type' => 'text',
1003 1003
             'id'   => 'authorizenet_login_id',
1004
-            'name' => __( 'API Login ID', 'invoicing' ),
1005
-            'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __( 'How do I obtain my API Login ID and Transaction Key?', 'invoicing' ) . '</em></a>',
1004
+            'name' => __('API Login ID', 'invoicing'),
1005
+            'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __('How do I obtain my API Login ID and Transaction Key?', 'invoicing') . '</em></a>',
1006 1006
         );
1007 1007
 
1008 1008
         $admin_settings['authorizenet_transaction_key'] = array(
1009 1009
             'type' => 'text',
1010 1010
             'id'   => 'authorizenet_transaction_key',
1011
-            'name' => __( 'Transaction Key', 'invoicing' ),
1011
+            'name' => __('Transaction Key', 'invoicing'),
1012 1012
         );
1013 1013
 
1014 1014
         $admin_settings['authorizenet_signature_key'] = array(
1015 1015
             'type' => 'text',
1016 1016
             'id'   => 'authorizenet_signature_key',
1017
-            'name' => __( 'Signature Key', 'invoicing' ),
1018
-            'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
1017
+            'name' => __('Signature Key', 'invoicing'),
1018
+            'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
1019 1019
         );
1020 1020
 
1021 1021
         $admin_settings['authorizenet_ipn_url'] = array(
1022 1022
             'type'     => 'ipn_url',
1023 1023
             'id'       => 'authorizenet_ipn_url',
1024
-            'name'     => __( 'Webhook URL', 'invoicing' ),
1024
+            'name'     => __('Webhook URL', 'invoicing'),
1025 1025
             'std'      => $this->notify_url,
1026
-            'desc'     => __( 'Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing' ) . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
1026
+            'desc'     => __('Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing') . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
1027 1027
             'custom'   => 'authorizenet',
1028 1028
             'readonly' => true,
1029 1029
         );
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2171 added lines, -2171 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() {
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 295
 		
296
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
296
+        $statuses = wpinv_get_invoice_statuses( true, true, $this );
297 297
 
298
-		// For backwards compatibility.
299
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
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 );
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 1167
     }
1168 1168
 
1169 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
-    }
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
+    }
1179 1190
 
1180 1191
     /**
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 );
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 );
1189 1200
     }
1190 1201
 
1191 1202
     /**
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 );
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 );
1200 1211
     }
1201 1212
 
1202 1213
     /**
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' ) {
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' ) {
1309 1309
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1310 1310
 
1311 1311
         // Backwards compatibility.
@@ -1317,155 +1317,155 @@  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  );
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 1385
     }
1386 1386
 
1387 1387
     /**
1388
-	 * Get the initial invoice total.
1389
-	 *
1390
-	 * @since 1.0.19
1388
+     * Get the initial invoice total.
1389
+     *
1390
+     * @since 1.0.19
1391 1391
      * @param  string $context View or edit context.
1392 1392
      * @return float
1393
-	 */
1393
+     */
1394 1394
     public function get_initial_total() {
1395 1395
 
1396
-		if ( empty( $this->totals ) ) {
1397
-			$this->recalculate_total();
1398
-		}
1396
+        if ( empty( $this->totals ) ) {
1397
+            $this->recalculate_total();
1398
+        }
1399 1399
 
1400
-		$tax      = $this->totals['tax']['initial'];
1401
-		$fee      = $this->totals['fee']['initial'];
1402
-		$discount = $this->totals['discount']['initial'];
1403
-		$subtotal = $this->totals['subtotal']['initial'];
1404
-		$total    = $tax + $fee - $discount + $subtotal;
1400
+        $tax      = $this->totals['tax']['initial'];
1401
+        $fee      = $this->totals['fee']['initial'];
1402
+        $discount = $this->totals['discount']['initial'];
1403
+        $subtotal = $this->totals['subtotal']['initial'];
1404
+        $total    = $tax + $fee - $discount + $subtotal;
1405 1405
 
1406
-		if ( 0 > $total ) {
1407
-			$total = 0;
1408
-		}
1406
+        if ( 0 > $total ) {
1407
+            $total = 0;
1408
+        }
1409 1409
 
1410 1410
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1411
-	}
1411
+    }
1412 1412
 
1413
-	/**
1414
-	 * Get the recurring invoice total.
1415
-	 *
1416
-	 * @since 1.0.19
1413
+    /**
1414
+     * Get the recurring invoice total.
1415
+     *
1416
+     * @since 1.0.19
1417 1417
      * @param  string $context View or edit context.
1418 1418
      * @return float
1419
-	 */
1419
+     */
1420 1420
     public function get_recurring_total() {
1421 1421
 
1422
-		if ( empty( $this->totals ) ) {
1423
-			$this->recalculate_total();
1424
-		}
1422
+        if ( empty( $this->totals ) ) {
1423
+            $this->recalculate_total();
1424
+        }
1425 1425
 
1426
-		$tax      = $this->totals['tax']['recurring'];
1427
-		$fee      = $this->totals['fee']['recurring'];
1428
-		$discount = $this->totals['discount']['recurring'];
1429
-		$subtotal = $this->totals['subtotal']['recurring'];
1430
-		$total    = $tax + $fee - $discount + $subtotal;
1426
+        $tax      = $this->totals['tax']['recurring'];
1427
+        $fee      = $this->totals['fee']['recurring'];
1428
+        $discount = $this->totals['discount']['recurring'];
1429
+        $subtotal = $this->totals['subtotal']['recurring'];
1430
+        $total    = $tax + $fee - $discount + $subtotal;
1431 1431
 
1432
-		if ( 0 > $total ) {
1433
-			$total = 0;
1434
-		}
1432
+        if ( 0 > $total ) {
1433
+            $total = 0;
1434
+        }
1435 1435
 
1436 1436
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1437
-	}
1437
+    }
1438 1438
 
1439
-	/**
1440
-	 * Returns recurring payment details.
1441
-	 *
1442
-	 * @since 1.0.19
1439
+    /**
1440
+     * Returns recurring payment details.
1441
+     *
1442
+     * @since 1.0.19
1443 1443
      * @param  string $field Optionally provide a field to return.
1444
-	 * @param string $currency Whether to include the currency.
1444
+     * @param string $currency Whether to include the currency.
1445 1445
      * @return float
1446
-	 */
1446
+     */
1447 1447
     public function get_recurring_details( $field = '', $currency = false ) {
1448 1448
 
1449
-		// Maybe recalculate totals.
1450
-		if ( empty( $this->totals ) ) {
1451
-			$this->recalculate_total();
1452
-		}
1449
+        // Maybe recalculate totals.
1450
+        if ( empty( $this->totals ) ) {
1451
+            $this->recalculate_total();
1452
+        }
1453 1453
 
1454
-		// Prepare recurring totals.
1454
+        // Prepare recurring totals.
1455 1455
         $data = apply_filters(
1456
-			'wpinv_get_invoice_recurring_details',
1457
-			array(
1458
-				'cart_details' => $this->get_cart_details(),
1459
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1460
-				'discount'     => $this->totals['discount']['recurring'],
1461
-				'tax'          => $this->totals['tax']['recurring'],
1462
-				'fee'          => $this->totals['fee']['recurring'],
1463
-				'total'        => $this->get_recurring_total(),
1464
-			),
1465
-			$this,
1466
-			$field,
1467
-			$currency
1468
-		);
1456
+            'wpinv_get_invoice_recurring_details',
1457
+            array(
1458
+                'cart_details' => $this->get_cart_details(),
1459
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1460
+                'discount'     => $this->totals['discount']['recurring'],
1461
+                'tax'          => $this->totals['tax']['recurring'],
1462
+                'fee'          => $this->totals['fee']['recurring'],
1463
+                'total'        => $this->get_recurring_total(),
1464
+            ),
1465
+            $this,
1466
+            $field,
1467
+            $currency
1468
+        );
1469 1469
 
1470 1470
         if ( isset( $data[$field] ) ) {
1471 1471
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1475,145 +1475,145 @@  discard block
 block discarded – undo
1475 1475
     }
1476 1476
 
1477 1477
     /**
1478
-	 * Get the invoice fees.
1479
-	 *
1480
-	 * @since 1.0.19
1481
-	 * @param  string $context View or edit context.
1482
-	 * @return array
1483
-	 */
1484
-	public function get_fees( $context = 'view' ) {
1485
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1478
+     * Get the invoice fees.
1479
+     *
1480
+     * @since 1.0.19
1481
+     * @param  string $context View or edit context.
1482
+     * @return array
1483
+     */
1484
+    public function get_fees( $context = 'view' ) {
1485
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1486 1486
     }
1487 1487
 
1488 1488
     /**
1489
-	 * Get the invoice discounts.
1490
-	 *
1491
-	 * @since 1.0.19
1492
-	 * @param  string $context View or edit context.
1493
-	 * @return array
1494
-	 */
1495
-	public function get_discounts( $context = 'view' ) {
1496
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1489
+     * Get the invoice discounts.
1490
+     *
1491
+     * @since 1.0.19
1492
+     * @param  string $context View or edit context.
1493
+     * @return array
1494
+     */
1495
+    public function get_discounts( $context = 'view' ) {
1496
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1497 1497
     }
1498 1498
 
1499 1499
     /**
1500
-	 * Get the invoice taxes.
1501
-	 *
1502
-	 * @since 1.0.19
1503
-	 * @param  string $context View or edit context.
1504
-	 * @return array
1505
-	 */
1506
-	public function get_taxes( $context = 'view' ) {
1507
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1500
+     * Get the invoice taxes.
1501
+     *
1502
+     * @since 1.0.19
1503
+     * @param  string $context View or edit context.
1504
+     * @return array
1505
+     */
1506
+    public function get_taxes( $context = 'view' ) {
1507
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1508 1508
     }
1509 1509
 
1510 1510
     /**
1511
-	 * Get the invoice items.
1512
-	 *
1513
-	 * @since 1.0.19
1514
-	 * @param  string $context View or edit context.
1515
-	 * @return GetPaid_Form_Item[]
1516
-	 */
1517
-	public function get_items( $context = 'view' ) {
1511
+     * Get the invoice items.
1512
+     *
1513
+     * @since 1.0.19
1514
+     * @param  string $context View or edit context.
1515
+     * @return GetPaid_Form_Item[]
1516
+     */
1517
+    public function get_items( $context = 'view' ) {
1518 1518
         return $this->get_prop( 'items', $context );
1519 1519
     }
1520 1520
 
1521 1521
     /**
1522
-	 * Get the invoice's payment form.
1523
-	 *
1524
-	 * @since 1.0.19
1525
-	 * @param  string $context View or edit context.
1526
-	 * @return int
1527
-	 */
1528
-	public function get_payment_form( $context = 'view' ) {
1529
-		return intval( $this->get_prop( 'payment_form', $context ) );
1522
+     * Get the invoice's payment form.
1523
+     *
1524
+     * @since 1.0.19
1525
+     * @param  string $context View or edit context.
1526
+     * @return int
1527
+     */
1528
+    public function get_payment_form( $context = 'view' ) {
1529
+        return intval( $this->get_prop( 'payment_form', $context ) );
1530 1530
     }
1531 1531
 
1532 1532
     /**
1533
-	 * Get the invoice's submission id.
1534
-	 *
1535
-	 * @since 1.0.19
1536
-	 * @param  string $context View or edit context.
1537
-	 * @return string
1538
-	 */
1539
-	public function get_submission_id( $context = 'view' ) {
1540
-		return $this->get_prop( 'submission_id', $context );
1533
+     * Get the invoice's submission id.
1534
+     *
1535
+     * @since 1.0.19
1536
+     * @param  string $context View or edit context.
1537
+     * @return string
1538
+     */
1539
+    public function get_submission_id( $context = 'view' ) {
1540
+        return $this->get_prop( 'submission_id', $context );
1541 1541
     }
1542 1542
 
1543 1543
     /**
1544
-	 * Get the invoice's discount code.
1545
-	 *
1546
-	 * @since 1.0.19
1547
-	 * @param  string $context View or edit context.
1548
-	 * @return string
1549
-	 */
1550
-	public function get_discount_code( $context = 'view' ) {
1551
-		return $this->get_prop( 'discount_code', $context );
1544
+     * Get the invoice's discount code.
1545
+     *
1546
+     * @since 1.0.19
1547
+     * @param  string $context View or edit context.
1548
+     * @return string
1549
+     */
1550
+    public function get_discount_code( $context = 'view' ) {
1551
+        return $this->get_prop( 'discount_code', $context );
1552 1552
     }
1553 1553
 
1554 1554
     /**
1555
-	 * Get the invoice's gateway.
1556
-	 *
1557
-	 * @since 1.0.19
1558
-	 * @param  string $context View or edit context.
1559
-	 * @return string
1560
-	 */
1561
-	public function get_gateway( $context = 'view' ) {
1562
-		return $this->get_prop( 'gateway', $context );
1555
+     * Get the invoice's gateway.
1556
+     *
1557
+     * @since 1.0.19
1558
+     * @param  string $context View or edit context.
1559
+     * @return string
1560
+     */
1561
+    public function get_gateway( $context = 'view' ) {
1562
+        return $this->get_prop( 'gateway', $context );
1563 1563
     }
1564 1564
 
1565 1565
     /**
1566
-	 * Get the invoice's gateway display title.
1567
-	 *
1568
-	 * @since 1.0.19
1569
-	 * @return string
1570
-	 */
1566
+     * Get the invoice's gateway display title.
1567
+     *
1568
+     * @since 1.0.19
1569
+     * @return string
1570
+     */
1571 1571
     public function get_gateway_title() {
1572 1572
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1573 1573
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1574 1574
     }
1575 1575
 
1576 1576
     /**
1577
-	 * Get the invoice's transaction id.
1578
-	 *
1579
-	 * @since 1.0.19
1580
-	 * @param  string $context View or edit context.
1581
-	 * @return string
1582
-	 */
1583
-	public function get_transaction_id( $context = 'view' ) {
1584
-		return $this->get_prop( 'transaction_id', $context );
1577
+     * Get the invoice's transaction id.
1578
+     *
1579
+     * @since 1.0.19
1580
+     * @param  string $context View or edit context.
1581
+     * @return string
1582
+     */
1583
+    public function get_transaction_id( $context = 'view' ) {
1584
+        return $this->get_prop( 'transaction_id', $context );
1585 1585
     }
1586 1586
 
1587 1587
     /**
1588
-	 * Get the invoice's currency.
1589
-	 *
1590
-	 * @since 1.0.19
1591
-	 * @param  string $context View or edit context.
1592
-	 * @return string
1593
-	 */
1594
-	public function get_currency( $context = 'view' ) {
1588
+     * Get the invoice's currency.
1589
+     *
1590
+     * @since 1.0.19
1591
+     * @param  string $context View or edit context.
1592
+     * @return string
1593
+     */
1594
+    public function get_currency( $context = 'view' ) {
1595 1595
         $currency = $this->get_prop( 'currency', $context );
1596 1596
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1597 1597
     }
1598 1598
 
1599 1599
     /**
1600
-	 * Checks if we are charging taxes for this invoice.
1601
-	 *
1602
-	 * @since 1.0.19
1603
-	 * @param  string $context View or edit context.
1604
-	 * @return bool
1605
-	 */
1606
-	public function get_disable_taxes( $context = 'view' ) {
1600
+     * Checks if we are charging taxes for this invoice.
1601
+     *
1602
+     * @since 1.0.19
1603
+     * @param  string $context View or edit context.
1604
+     * @return bool
1605
+     */
1606
+    public function get_disable_taxes( $context = 'view' ) {
1607 1607
         return (bool) $this->get_prop( 'disable_taxes', $context );
1608 1608
     }
1609 1609
 
1610 1610
     /**
1611
-	 * Retrieves the remote subscription id for an invoice.
1612
-	 *
1613
-	 * @since 1.0.19
1614
-	 * @param  string $context View or edit context.
1615
-	 * @return int
1616
-	 */
1611
+     * Retrieves the remote subscription id for an invoice.
1612
+     *
1613
+     * @since 1.0.19
1614
+     * @param  string $context View or edit context.
1615
+     * @return int
1616
+     */
1617 1617
     public function get_subscription_id( $context = 'view' ) {
1618 1618
         $subscription_id = $this->get_prop( 'subscription_id', $context );
1619 1619
 
@@ -1626,12 +1626,12 @@  discard block
 block discarded – undo
1626 1626
     }
1627 1627
 
1628 1628
     /**
1629
-	 * Retrieves the payment meta for an invoice.
1630
-	 *
1631
-	 * @since 1.0.19
1632
-	 * @param  string $context View or edit context.
1633
-	 * @return array
1634
-	 */
1629
+     * Retrieves the payment meta for an invoice.
1630
+     *
1631
+     * @since 1.0.19
1632
+     * @param  string $context View or edit context.
1633
+     * @return array
1634
+     */
1635 1635
     public function get_payment_meta( $context = 'view' ) {
1636 1636
 
1637 1637
         return array(
@@ -1651,11 +1651,11 @@  discard block
 block discarded – undo
1651 1651
     }
1652 1652
 
1653 1653
     /**
1654
-	 * Retrieves the cart details for an invoice.
1655
-	 *
1656
-	 * @since 1.0.19
1657
-	 * @return array
1658
-	 */
1654
+     * Retrieves the cart details for an invoice.
1655
+     *
1656
+     * @since 1.0.19
1657
+     * @return array
1658
+     */
1659 1659
     public function get_cart_details() {
1660 1660
         $items        = $this->get_items();
1661 1661
         $cart_details = array();
@@ -1665,16 +1665,16 @@  discard block
 block discarded – undo
1665 1665
         }
1666 1666
 
1667 1667
         return $cart_details;
1668
-	}
1668
+    }
1669 1669
 
1670
-	/**
1671
-	 * Retrieves the recurring item.
1672
-	 *
1673
-	 * @return null|GetPaid_Form_Item|int
1674
-	 */
1675
-	public function get_recurring( $object = false ) {
1670
+    /**
1671
+     * Retrieves the recurring item.
1672
+     *
1673
+     * @return null|GetPaid_Form_Item|int
1674
+     */
1675
+    public function get_recurring( $object = false ) {
1676 1676
 
1677
-		// Are we returning an object?
1677
+        // Are we returning an object?
1678 1678
         if ( $object ) {
1679 1679
             return $this->get_item( $this->recurring_item );
1680 1680
         }
@@ -1682,100 +1682,100 @@  discard block
 block discarded – undo
1682 1682
         return $this->recurring_item;
1683 1683
     }
1684 1684
 
1685
-	/**
1686
-	 * Retrieves the subscription name.
1687
-	 *
1688
-	 * @since 1.0.19
1689
-	 * @return string
1690
-	 */
1691
-	public function get_subscription_name() {
1685
+    /**
1686
+     * Retrieves the subscription name.
1687
+     *
1688
+     * @since 1.0.19
1689
+     * @return string
1690
+     */
1691
+    public function get_subscription_name() {
1692 1692
 
1693
-		// Retrieve the recurring name
1693
+        // Retrieve the recurring name
1694 1694
         $item = $this->get_recurring( true );
1695 1695
 
1696
-		// Abort if it does not exist.
1696
+        // Abort if it does not exist.
1697 1697
         if ( empty( $item ) ) {
1698 1698
             return '';
1699 1699
         }
1700 1700
 
1701
-		// Return the item name.
1701
+        // Return the item name.
1702 1702
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1703
-	}
1704
-
1705
-	/**
1706
-	 * Retrieves the view url.
1707
-	 *
1708
-	 * @since 1.0.19
1709
-	 * @return string
1710
-	 */
1711
-	public function get_view_url() {
1703
+    }
1704
+
1705
+    /**
1706
+     * Retrieves the view url.
1707
+     *
1708
+     * @since 1.0.19
1709
+     * @return string
1710
+     */
1711
+    public function get_view_url() {
1712 1712
         $invoice_url = get_permalink( $this->get_id() );
1713
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1713
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1714 1714
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1715
-	}
1715
+    }
1716 1716
 
1717
-	/**
1718
-	 * Retrieves the payment url.
1719
-	 *
1720
-	 * @since 1.0.19
1721
-	 * @return string
1722
-	 */
1723
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1717
+    /**
1718
+     * Retrieves the payment url.
1719
+     *
1720
+     * @since 1.0.19
1721
+     * @return string
1722
+     */
1723
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1724 1724
 
1725
-		// Retrieve the checkout url.
1725
+        // Retrieve the checkout url.
1726 1726
         $pay_url = wpinv_get_checkout_uri();
1727 1727
 
1728
-		// Maybe force ssl.
1728
+        // Maybe force ssl.
1729 1729
         if ( is_ssl() ) {
1730 1730
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1731 1731
         }
1732 1732
 
1733
-		// Add the invoice key.
1734
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1733
+        // Add the invoice key.
1734
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1735 1735
 
1736
-		// (Maybe?) add a secret
1736
+        // (Maybe?) add a secret
1737 1737
         if ( $secret ) {
1738 1738
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1739 1739
         }
1740 1740
 
1741 1741
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1742
-	}
1742
+    }
1743 1743
 	
1744
-	/**
1745
-	 * Retrieves the receipt url.
1746
-	 *
1747
-	 * @since 1.0.19
1748
-	 * @return string
1749
-	 */
1750
-	public function get_receipt_url() {
1751
-
1752
-		// Retrieve the checkout url.
1744
+    /**
1745
+     * Retrieves the receipt url.
1746
+     *
1747
+     * @since 1.0.19
1748
+     * @return string
1749
+     */
1750
+    public function get_receipt_url() {
1751
+
1752
+        // Retrieve the checkout url.
1753 1753
         $receipt_url = wpinv_get_success_page_uri();
1754 1754
 
1755
-		// Maybe force ssl.
1755
+        // Maybe force ssl.
1756 1756
         if ( is_ssl() ) {
1757 1757
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1758 1758
         }
1759 1759
 
1760
-		// Add the invoice key.
1761
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1760
+        // Add the invoice key.
1761
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1762 1762
 
1763 1763
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1764 1764
     }
1765 1765
 
1766 1766
     /**
1767
-	 * Magic method for accessing invoice properties.
1768
-	 *
1769
-	 * @since 1.0.15
1770
-	 * @access public
1771
-	 *
1772
-	 * @param string $key Discount data to retrieve
1773
-	 * @param  string $context View or edit context.
1774
-	 * @return mixed Value of the given invoice property (if set).
1775
-	 */
1776
-	public function get( $key, $context = 'view' ) {
1767
+     * Magic method for accessing invoice properties.
1768
+     *
1769
+     * @since 1.0.15
1770
+     * @access public
1771
+     *
1772
+     * @param string $key Discount data to retrieve
1773
+     * @param  string $context View or edit context.
1774
+     * @return mixed Value of the given invoice property (if set).
1775
+     */
1776
+    public function get( $key, $context = 'view' ) {
1777 1777
         return $this->get_prop( $key, $context );
1778
-	}
1778
+    }
1779 1779
 
1780 1780
     /*
1781 1781
 	|--------------------------------------------------------------------------
@@ -1788,131 +1788,131 @@  discard block
 block discarded – undo
1788 1788
     */
1789 1789
 
1790 1790
     /**
1791
-	 * Magic method for setting invoice properties.
1792
-	 *
1793
-	 * @since 1.0.19
1794
-	 * @access public
1795
-	 *
1796
-	 * @param string $key Discount data to retrieve
1797
-	 * @param  mixed $value new value.
1798
-	 * @return mixed Value of the given invoice property (if set).
1799
-	 */
1800
-	public function set( $key, $value ) {
1791
+     * Magic method for setting invoice properties.
1792
+     *
1793
+     * @since 1.0.19
1794
+     * @access public
1795
+     *
1796
+     * @param string $key Discount data to retrieve
1797
+     * @param  mixed $value new value.
1798
+     * @return mixed Value of the given invoice property (if set).
1799
+     */
1800
+    public function set( $key, $value ) {
1801 1801
 
1802 1802
         $setter = "set_$key";
1803 1803
         if ( is_callable( array( $this, $setter ) ) ) {
1804 1804
             $this->{$setter}( $value );
1805 1805
         }
1806 1806
 
1807
-	}
1807
+    }
1808 1808
 
1809
-	/**
1810
-	 * Sets item status.
1811
-	 *
1812
-	 * @since 1.0.19
1813
-	 * @param string $new_status    New status.
1814
-	 * @param string $note          Optional note to add.
1815
-	 * @param bool   $manual_update Is this a manual status change?.
1816
-	 * @return array details of change.
1817
-	 */
1818
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1819
-		$old_status = $this->get_status();
1809
+    /**
1810
+     * Sets item status.
1811
+     *
1812
+     * @since 1.0.19
1813
+     * @param string $new_status    New status.
1814
+     * @param string $note          Optional note to add.
1815
+     * @param bool   $manual_update Is this a manual status change?.
1816
+     * @return array details of change.
1817
+     */
1818
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1819
+        $old_status = $this->get_status();
1820 1820
 
1821
-		$statuses = $this->get_all_statuses();
1821
+        $statuses = $this->get_all_statuses();
1822 1822
 
1823
-		if ( isset( $statuses[ 'draft' ] ) ) {
1824
-			unset( $statuses[ 'draft' ] );
1825
-		}
1823
+        if ( isset( $statuses[ 'draft' ] ) ) {
1824
+            unset( $statuses[ 'draft' ] );
1825
+        }
1826 1826
 
1827 1827
 
1828
-		$this->set_prop( 'status', $new_status );
1828
+        $this->set_prop( 'status', $new_status );
1829 1829
 
1830
-		// If setting the status, ensure it's set to a valid status.
1831
-		if ( true === $this->object_read ) {
1830
+        // If setting the status, ensure it's set to a valid status.
1831
+        if ( true === $this->object_read ) {
1832 1832
 
1833
-			// Only allow valid new status.
1834
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1835
-				$new_status = 'wpi-pending';
1836
-			}
1833
+            // Only allow valid new status.
1834
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1835
+                $new_status = 'wpi-pending';
1836
+            }
1837 1837
 
1838
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1839
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1840
-				$old_status = 'wpi-pending';
1841
-			}
1838
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1839
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1840
+                $old_status = 'wpi-pending';
1841
+            }
1842 1842
 
1843
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1844
-			if ( $new_status == 'wpi-renewal' && $old_status == 'publish' ) {
1845
-				$old_status = 'wpi-pending';
1846
-			}
1843
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1844
+            if ( $new_status == 'wpi-renewal' && $old_status == 'publish' ) {
1845
+                $old_status = 'wpi-pending';
1846
+            }
1847 1847
 
1848
-		}
1848
+        }
1849 1849
 
1850
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1851
-			$this->status_transition = array(
1852
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1853
-				'to'     => $new_status,
1854
-				'note'   => $note,
1855
-				'manual' => (bool) $manual_update,
1856
-			);
1850
+        if ( true === $this->object_read && $old_status !== $new_status ) {
1851
+            $this->status_transition = array(
1852
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1853
+                'to'     => $new_status,
1854
+                'note'   => $note,
1855
+                'manual' => (bool) $manual_update,
1856
+            );
1857 1857
 
1858
-			if ( $manual_update ) {
1859
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1860
-			}
1858
+            if ( $manual_update ) {
1859
+                do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1860
+            }
1861 1861
 
1862
-			$this->maybe_set_date_paid();
1862
+            $this->maybe_set_date_paid();
1863 1863
 
1864
-		}
1864
+        }
1865 1865
 
1866
-		return array(
1867
-			'from' => $old_status,
1868
-			'to'   => $new_status,
1869
-		);
1870
-	}
1866
+        return array(
1867
+            'from' => $old_status,
1868
+            'to'   => $new_status,
1869
+        );
1870
+    }
1871 1871
 
1872
-	/**
1873
-	 * Maybe set date paid.
1874
-	 *
1875
-	 * Sets the date paid variable when transitioning to the payment complete
1876
-	 * order status.
1877
-	 *
1878
-	 * @since 1.0.19
1879
-	 */
1880
-	public function maybe_set_date_paid() {
1872
+    /**
1873
+     * Maybe set date paid.
1874
+     *
1875
+     * Sets the date paid variable when transitioning to the payment complete
1876
+     * order status.
1877
+     *
1878
+     * @since 1.0.19
1879
+     */
1880
+    public function maybe_set_date_paid() {
1881 1881
 
1882
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1883
-			$this->set_date_completed( current_time( 'mysql' ) );
1884
-		}
1885
-	}
1882
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1883
+            $this->set_date_completed( current_time( 'mysql' ) );
1884
+        }
1885
+    }
1886 1886
 
1887 1887
     /**
1888
-	 * Set parent invoice ID.
1889
-	 *
1890
-	 * @since 1.0.19
1891
-	 */
1892
-	public function set_parent_id( $value ) {
1893
-		if ( $value && ( $value === $this->get_id() ) ) {
1894
-			return;
1895
-		}
1896
-		$this->set_prop( 'parent_id', absint( $value ) );
1888
+     * Set parent invoice ID.
1889
+     *
1890
+     * @since 1.0.19
1891
+     */
1892
+    public function set_parent_id( $value ) {
1893
+        if ( $value && ( $value === $this->get_id() ) ) {
1894
+            return;
1895
+        }
1896
+        $this->set_prop( 'parent_id', absint( $value ) );
1897 1897
     }
1898 1898
 
1899 1899
     /**
1900
-	 * Set plugin version when the invoice was created.
1901
-	 *
1902
-	 * @since 1.0.19
1903
-	 */
1904
-	public function set_version( $value ) {
1905
-		$this->set_prop( 'version', $value );
1900
+     * Set plugin version when the invoice was created.
1901
+     *
1902
+     * @since 1.0.19
1903
+     */
1904
+    public function set_version( $value ) {
1905
+        $this->set_prop( 'version', $value );
1906 1906
     }
1907
-
1908
-    /**
1909
-	 * Set date when the invoice was created.
1910
-	 *
1911
-	 * @since 1.0.19
1912
-	 * @param string $value Value to set.
1907
+
1908
+    /**
1909
+     * Set date when the invoice was created.
1910
+     *
1911
+     * @since 1.0.19
1912
+     * @param string $value Value to set.
1913 1913
      * @return bool Whether or not the date was set.
1914
-	 */
1915
-	public function set_date_created( $value ) {
1914
+     */
1915
+    public function set_date_created( $value ) {
1916 1916
         $date = strtotime( $value );
1917 1917
 
1918 1918
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1925,13 +1925,13 @@  discard block
 block discarded – undo
1925 1925
     }
1926 1926
 
1927 1927
     /**
1928
-	 * Set date invoice due date.
1929
-	 *
1930
-	 * @since 1.0.19
1931
-	 * @param string $value Value to set.
1928
+     * Set date invoice due date.
1929
+     *
1930
+     * @since 1.0.19
1931
+     * @param string $value Value to set.
1932 1932
      * @return bool Whether or not the date was set.
1933
-	 */
1934
-	public function set_due_date( $value ) {
1933
+     */
1934
+    public function set_due_date( $value ) {
1935 1935
         $date = strtotime( $value );
1936 1936
 
1937 1937
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1939,29 +1939,29 @@  discard block
 block discarded – undo
1939 1939
             return true;
1940 1940
         }
1941 1941
 
1942
-		$this->set_prop( 'due_date', '' );
1942
+        $this->set_prop( 'due_date', '' );
1943 1943
         return false;
1944 1944
 
1945 1945
     }
1946 1946
 
1947 1947
     /**
1948
-	 * Alias of self::set_due_date().
1949
-	 *
1950
-	 * @since 1.0.19
1951
-	 * @param  string $value New name.
1952
-	 */
1953
-	public function set_date_due( $value ) {
1954
-		$this->set_due_date( $value );
1948
+     * Alias of self::set_due_date().
1949
+     *
1950
+     * @since 1.0.19
1951
+     * @param  string $value New name.
1952
+     */
1953
+    public function set_date_due( $value ) {
1954
+        $this->set_due_date( $value );
1955 1955
     }
1956 1956
 
1957 1957
     /**
1958
-	 * Set date invoice was completed.
1959
-	 *
1960
-	 * @since 1.0.19
1961
-	 * @param string $value Value to set.
1958
+     * Set date invoice was completed.
1959
+     *
1960
+     * @since 1.0.19
1961
+     * @param string $value Value to set.
1962 1962
      * @return bool Whether or not the date was set.
1963
-	 */
1964
-	public function set_completed_date( $value ) {
1963
+     */
1964
+    public function set_completed_date( $value ) {
1965 1965
         $date = strtotime( $value );
1966 1966
 
1967 1967
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -1969,29 +1969,29 @@  discard block
 block discarded – undo
1969 1969
             return true;
1970 1970
         }
1971 1971
 
1972
-		$this->set_prop( 'completed_date', '' );
1972
+        $this->set_prop( 'completed_date', '' );
1973 1973
         return false;
1974 1974
 
1975 1975
     }
1976 1976
 
1977 1977
     /**
1978
-	 * Alias of self::set_completed_date().
1979
-	 *
1980
-	 * @since 1.0.19
1981
-	 * @param  string $value New name.
1982
-	 */
1983
-	public function set_date_completed( $value ) {
1984
-		$this->set_completed_date( $value );
1978
+     * Alias of self::set_completed_date().
1979
+     *
1980
+     * @since 1.0.19
1981
+     * @param  string $value New name.
1982
+     */
1983
+    public function set_date_completed( $value ) {
1984
+        $this->set_completed_date( $value );
1985 1985
     }
1986 1986
 
1987 1987
     /**
1988
-	 * Set date when the invoice was last modified.
1989
-	 *
1990
-	 * @since 1.0.19
1991
-	 * @param string $value Value to set.
1988
+     * Set date when the invoice was last modified.
1989
+     *
1990
+     * @since 1.0.19
1991
+     * @param string $value Value to set.
1992 1992
      * @return bool Whether or not the date was set.
1993
-	 */
1994
-	public function set_date_modified( $value ) {
1993
+     */
1994
+    public function set_date_modified( $value ) {
1995 1995
         $date = strtotime( $value );
1996 1996
 
1997 1997
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1999,706 +1999,706 @@  discard block
 block discarded – undo
1999 1999
             return true;
2000 2000
         }
2001 2001
 
2002
-		$this->set_prop( 'date_modified', '' );
2002
+        $this->set_prop( 'date_modified', '' );
2003 2003
         return false;
2004 2004
 
2005 2005
     }
2006 2006
 
2007 2007
     /**
2008
-	 * Set the invoice number.
2009
-	 *
2010
-	 * @since 1.0.19
2011
-	 * @param  string $value New number.
2012
-	 */
2013
-	public function set_number( $value ) {
2008
+     * Set the invoice number.
2009
+     *
2010
+     * @since 1.0.19
2011
+     * @param  string $value New number.
2012
+     */
2013
+    public function set_number( $value ) {
2014 2014
         $number = sanitize_text_field( $value );
2015
-		$this->set_prop( 'number', $number );
2015
+        $this->set_prop( 'number', $number );
2016 2016
     }
2017 2017
 
2018 2018
     /**
2019
-	 * Set the invoice type.
2020
-	 *
2021
-	 * @since 1.0.19
2022
-	 * @param  string $value Type.
2023
-	 */
2024
-	public function set_type( $value ) {
2019
+     * Set the invoice type.
2020
+     *
2021
+     * @since 1.0.19
2022
+     * @param  string $value Type.
2023
+     */
2024
+    public function set_type( $value ) {
2025 2025
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2026
-		$this->set_prop( 'type', $type );
2027
-	}
2026
+        $this->set_prop( 'type', $type );
2027
+    }
2028 2028
 
2029 2029
     /**
2030
-	 * Set the invoice post type.
2031
-	 *
2032
-	 * @since 1.0.19
2033
-	 * @param  string $value Post type.
2034
-	 */
2035
-	public function set_post_type( $value ) {
2030
+     * Set the invoice post type.
2031
+     *
2032
+     * @since 1.0.19
2033
+     * @param  string $value Post type.
2034
+     */
2035
+    public function set_post_type( $value ) {
2036 2036
         if ( getpaid_is_invoice_post_type( $value ) ) {
2037
-			$this->set_type( $value );
2037
+            $this->set_type( $value );
2038 2038
             $this->set_prop( 'post_type', $value );
2039 2039
         }
2040 2040
     }
2041 2041
 
2042 2042
     /**
2043
-	 * Set the invoice key.
2044
-	 *
2045
-	 * @since 1.0.19
2046
-	 * @param  string $value New key.
2047
-	 */
2048
-	public function set_key( $value ) {
2043
+     * Set the invoice key.
2044
+     *
2045
+     * @since 1.0.19
2046
+     * @param  string $value New key.
2047
+     */
2048
+    public function set_key( $value ) {
2049 2049
         $key = sanitize_text_field( $value );
2050
-		$this->set_prop( 'key', $key );
2050
+        $this->set_prop( 'key', $key );
2051 2051
     }
2052 2052
 
2053 2053
     /**
2054
-	 * Set the invoice mode.
2055
-	 *
2056
-	 * @since 1.0.19
2057
-	 * @param  string $value mode.
2058
-	 */
2059
-	public function set_mode( $value ) {
2054
+     * Set the invoice mode.
2055
+     *
2056
+     * @since 1.0.19
2057
+     * @param  string $value mode.
2058
+     */
2059
+    public function set_mode( $value ) {
2060 2060
         if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2061 2061
             $this->set_prop( 'value', $value );
2062 2062
         }
2063 2063
     }
2064 2064
 
2065 2065
     /**
2066
-	 * Set the invoice path.
2067
-	 *
2068
-	 * @since 1.0.19
2069
-	 * @param  string $value path.
2070
-	 */
2071
-	public function set_path( $value ) {
2066
+     * Set the invoice path.
2067
+     *
2068
+     * @since 1.0.19
2069
+     * @param  string $value path.
2070
+     */
2071
+    public function set_path( $value ) {
2072 2072
         $this->set_prop( 'path', $value );
2073 2073
     }
2074 2074
 
2075 2075
     /**
2076
-	 * Set the invoice name.
2077
-	 *
2078
-	 * @since 1.0.19
2079
-	 * @param  string $value New name.
2080
-	 */
2081
-	public function set_name( $value ) {
2076
+     * Set the invoice name.
2077
+     *
2078
+     * @since 1.0.19
2079
+     * @param  string $value New name.
2080
+     */
2081
+    public function set_name( $value ) {
2082 2082
         $name = sanitize_text_field( $value );
2083
-		$this->set_prop( 'name', $name );
2083
+        $this->set_prop( 'name', $name );
2084 2084
     }
2085 2085
 
2086 2086
     /**
2087
-	 * Alias of self::set_name().
2088
-	 *
2089
-	 * @since 1.0.19
2090
-	 * @param  string $value New name.
2091
-	 */
2092
-	public function set_title( $value ) {
2093
-		$this->set_name( $value );
2087
+     * Alias of self::set_name().
2088
+     *
2089
+     * @since 1.0.19
2090
+     * @param  string $value New name.
2091
+     */
2092
+    public function set_title( $value ) {
2093
+        $this->set_name( $value );
2094 2094
     }
2095 2095
 
2096 2096
     /**
2097
-	 * Set the invoice description.
2098
-	 *
2099
-	 * @since 1.0.19
2100
-	 * @param  string $value New description.
2101
-	 */
2102
-	public function set_description( $value ) {
2097
+     * Set the invoice description.
2098
+     *
2099
+     * @since 1.0.19
2100
+     * @param  string $value New description.
2101
+     */
2102
+    public function set_description( $value ) {
2103 2103
         $description = wp_kses_post( $value );
2104
-		return $this->set_prop( 'description', $description );
2104
+        return $this->set_prop( 'description', $description );
2105 2105
     }
2106 2106
 
2107 2107
     /**
2108
-	 * Alias of self::set_description().
2109
-	 *
2110
-	 * @since 1.0.19
2111
-	 * @param  string $value New description.
2112
-	 */
2113
-	public function set_excerpt( $value ) {
2114
-		$this->set_description( $value );
2108
+     * Alias of self::set_description().
2109
+     *
2110
+     * @since 1.0.19
2111
+     * @param  string $value New description.
2112
+     */
2113
+    public function set_excerpt( $value ) {
2114
+        $this->set_description( $value );
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_summary( $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_summary( $value ) {
2124
+        $this->set_description( $value );
2125 2125
     }
2126 2126
 
2127 2127
     /**
2128
-	 * Set the receiver of the invoice.
2129
-	 *
2130
-	 * @since 1.0.19
2131
-	 * @param  int $value New author.
2132
-	 */
2133
-	public function set_author( $value ) {
2134
-		$user = get_user_by( 'id', (int) $value );
2128
+     * Set the receiver of the invoice.
2129
+     *
2130
+     * @since 1.0.19
2131
+     * @param  int $value New author.
2132
+     */
2133
+    public function set_author( $value ) {
2134
+        $user = get_user_by( 'id', (int) $value );
2135 2135
 
2136
-		if ( $user && $user->ID ) {
2137
-			$this->set_prop( 'author', $user->ID );
2138
-			$this->set_prop( 'email', $user->user_email );
2139
-		}
2136
+        if ( $user && $user->ID ) {
2137
+            $this->set_prop( 'author', $user->ID );
2138
+            $this->set_prop( 'email', $user->user_email );
2139
+        }
2140 2140
 		
2141 2141
     }
2142 2142
 
2143 2143
     /**
2144
-	 * Alias of self::set_author().
2145
-	 *
2146
-	 * @since 1.0.19
2147
-	 * @param  int $value New user id.
2148
-	 */
2149
-	public function set_user_id( $value ) {
2150
-		$this->set_author( $value );
2144
+     * Alias of self::set_author().
2145
+     *
2146
+     * @since 1.0.19
2147
+     * @param  int $value New user id.
2148
+     */
2149
+    public function set_user_id( $value ) {
2150
+        $this->set_author( $value );
2151
+    }
2152
+
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_customer_id( $value ) {
2160
+        $this->set_author( $value );
2161
+    }
2162
+
2163
+    /**
2164
+     * Set the customer's ip.
2165
+     *
2166
+     * @since 1.0.19
2167
+     * @param  string $value ip address.
2168
+     */
2169
+    public function set_ip( $value ) {
2170
+        $this->set_prop( 'ip', $value );
2171
+    }
2172
+
2173
+    /**
2174
+     * Alias of self::set_ip().
2175
+     *
2176
+     * @since 1.0.19
2177
+     * @param  string $value ip address.
2178
+     */
2179
+    public function set_user_ip( $value ) {
2180
+        $this->set_ip( $value );
2151 2181
     }
2152 2182
 
2153 2183
     /**
2154
-	 * Alias of self::set_author().
2155
-	 *
2156
-	 * @since 1.0.19
2157
-	 * @param  int $value New user id.
2158
-	 */
2159
-	public function set_customer_id( $value ) {
2160
-		$this->set_author( $value );
2184
+     * Set the customer's first name.
2185
+     *
2186
+     * @since 1.0.19
2187
+     * @param  string $value first name.
2188
+     */
2189
+    public function set_first_name( $value ) {
2190
+        $this->set_prop( 'first_name', $value );
2161 2191
     }
2162 2192
 
2163 2193
     /**
2164
-	 * Set the customer's ip.
2165
-	 *
2166
-	 * @since 1.0.19
2167
-	 * @param  string $value ip address.
2168
-	 */
2169
-	public function set_ip( $value ) {
2170
-		$this->set_prop( 'ip', $value );
2194
+     * Alias of self::set_first_name().
2195
+     *
2196
+     * @since 1.0.19
2197
+     * @param  string $value first name.
2198
+     */
2199
+    public function set_user_first_name( $value ) {
2200
+        $this->set_first_name( $value );
2171 2201
     }
2172 2202
 
2173 2203
     /**
2174
-	 * Alias of self::set_ip().
2175
-	 *
2176
-	 * @since 1.0.19
2177
-	 * @param  string $value ip address.
2178
-	 */
2179
-	public function set_user_ip( $value ) {
2180
-		$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_customer_first_name( $value ) {
2210
+        $this->set_first_name( $value );
2181 2211
     }
2182 2212
 
2183 2213
     /**
2184
-	 * Set the customer's first name.
2185
-	 *
2186
-	 * @since 1.0.19
2187
-	 * @param  string $value first name.
2188
-	 */
2189
-	public function set_first_name( $value ) {
2190
-		$this->set_prop( 'first_name', $value );
2214
+     * Set the customer's last name.
2215
+     *
2216
+     * @since 1.0.19
2217
+     * @param  string $value last name.
2218
+     */
2219
+    public function set_last_name( $value ) {
2220
+        $this->set_prop( 'last_name', $value );
2191 2221
     }
2192 2222
 
2193 2223
     /**
2194
-	 * Alias of self::set_first_name().
2195
-	 *
2196
-	 * @since 1.0.19
2197
-	 * @param  string $value first name.
2198
-	 */
2199
-	public function set_user_first_name( $value ) {
2200
-		$this->set_first_name( $value );
2224
+     * Alias of self::set_last_name().
2225
+     *
2226
+     * @since 1.0.19
2227
+     * @param  string $value last name.
2228
+     */
2229
+    public function set_user_last_name( $value ) {
2230
+        $this->set_last_name( $value );
2201 2231
     }
2202 2232
 
2203 2233
     /**
2204
-	 * Alias of self::set_first_name().
2205
-	 *
2206
-	 * @since 1.0.19
2207
-	 * @param  string $value first name.
2208
-	 */
2209
-	public function set_customer_first_name( $value ) {
2210
-		$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_customer_last_name( $value ) {
2240
+        $this->set_last_name( $value );
2211 2241
     }
2212 2242
 
2213 2243
     /**
2214
-	 * Set the customer's last name.
2215
-	 *
2216
-	 * @since 1.0.19
2217
-	 * @param  string $value last name.
2218
-	 */
2219
-	public function set_last_name( $value ) {
2220
-		$this->set_prop( 'last_name', $value );
2244
+     * Set the customer's phone number.
2245
+     *
2246
+     * @since 1.0.19
2247
+     * @param  string $value phone.
2248
+     */
2249
+    public function set_phone( $value ) {
2250
+        $this->set_prop( 'phone', $value );
2221 2251
     }
2222 2252
 
2223 2253
     /**
2224
-	 * Alias of self::set_last_name().
2225
-	 *
2226
-	 * @since 1.0.19
2227
-	 * @param  string $value last name.
2228
-	 */
2229
-	public function set_user_last_name( $value ) {
2230
-		$this->set_last_name( $value );
2254
+     * Alias of self::set_phone().
2255
+     *
2256
+     * @since 1.0.19
2257
+     * @param  string $value phone.
2258
+     */
2259
+    public function set_user_phone( $value ) {
2260
+        $this->set_phone( $value );
2231 2261
     }
2232 2262
 
2233 2263
     /**
2234
-	 * Alias of self::set_last_name().
2235
-	 *
2236
-	 * @since 1.0.19
2237
-	 * @param  string $value last name.
2238
-	 */
2239
-	public function set_customer_last_name( $value ) {
2240
-		$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_customer_phone( $value ) {
2270
+        $this->set_phone( $value );
2241 2271
     }
2242 2272
 
2243 2273
     /**
2244
-	 * Set the customer's phone number.
2245
-	 *
2246
-	 * @since 1.0.19
2247
-	 * @param  string $value phone.
2248
-	 */
2249
-	public function set_phone( $value ) {
2250
-		$this->set_prop( 'phone', $value );
2274
+     * Alias of self::set_phone().
2275
+     *
2276
+     * @since 1.0.19
2277
+     * @param  string $value phone.
2278
+     */
2279
+    public function set_phone_number( $value ) {
2280
+        $this->set_phone( $value );
2251 2281
     }
2252 2282
 
2253 2283
     /**
2254
-	 * Alias of self::set_phone().
2255
-	 *
2256
-	 * @since 1.0.19
2257
-	 * @param  string $value phone.
2258
-	 */
2259
-	public function set_user_phone( $value ) {
2260
-		$this->set_phone( $value );
2284
+     * Set the customer's email address.
2285
+     *
2286
+     * @since 1.0.19
2287
+     * @param  string $value email address.
2288
+     */
2289
+    public function set_email( $value ) {
2290
+        $this->set_prop( 'email', $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_customer_phone( $value ) {
2270
-		$this->set_phone( $value );
2294
+     * Alias of self::set_email().
2295
+     *
2296
+     * @since 1.0.19
2297
+     * @param  string $value email address.
2298
+     */
2299
+    public function set_user_email( $value ) {
2300
+        $this->set_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_phone_number( $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_email_address( $value ) {
2310
+        $this->set_email( $value );
2281 2311
     }
2282 2312
 
2283 2313
     /**
2284
-	 * Set the customer's email address.
2285
-	 *
2286
-	 * @since 1.0.19
2287
-	 * @param  string $value email address.
2288
-	 */
2289
-	public function set_email( $value ) {
2290
-		$this->set_prop( 'email', $value );
2314
+     * Alias of self::set_email().
2315
+     *
2316
+     * @since 1.0.19
2317
+     * @param  string $value email address.
2318
+     */
2319
+    public function set_customer_email( $value ) {
2320
+        $this->set_email( $value );
2291 2321
     }
2292 2322
 
2293 2323
     /**
2294
-	 * Alias of self::set_email().
2295
-	 *
2296
-	 * @since 1.0.19
2297
-	 * @param  string $value email address.
2298
-	 */
2299
-	public function set_user_email( $value ) {
2300
-		$this->set_email( $value );
2324
+     * Set the customer's country.
2325
+     *
2326
+     * @since 1.0.19
2327
+     * @param  string $value country.
2328
+     */
2329
+    public function set_country( $value ) {
2330
+        $this->set_prop( 'country', $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_email_address( $value ) {
2310
-		$this->set_email( $value );
2334
+     * Alias of self::set_country().
2335
+     *
2336
+     * @since 1.0.19
2337
+     * @param  string $value country.
2338
+     */
2339
+    public function set_user_country( $value ) {
2340
+        $this->set_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_customer_email( $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_customer_country( $value ) {
2350
+        $this->set_country( $value );
2321 2351
     }
2322 2352
 
2323 2353
     /**
2324
-	 * Set the customer's country.
2325
-	 *
2326
-	 * @since 1.0.19
2327
-	 * @param  string $value country.
2328
-	 */
2329
-	public function set_country( $value ) {
2330
-		$this->set_prop( 'country', $value );
2354
+     * Set the customer's state.
2355
+     *
2356
+     * @since 1.0.19
2357
+     * @param  string $value state.
2358
+     */
2359
+    public function set_state( $value ) {
2360
+        $this->set_prop( 'state', $value );
2331 2361
     }
2332 2362
 
2333 2363
     /**
2334
-	 * Alias of self::set_country().
2335
-	 *
2336
-	 * @since 1.0.19
2337
-	 * @param  string $value country.
2338
-	 */
2339
-	public function set_user_country( $value ) {
2340
-		$this->set_country( $value );
2364
+     * Alias of self::set_state().
2365
+     *
2366
+     * @since 1.0.19
2367
+     * @param  string $value state.
2368
+     */
2369
+    public function set_user_state( $value ) {
2370
+        $this->set_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_customer_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_customer_state( $value ) {
2380
+        $this->set_state( $value );
2351 2381
     }
2352 2382
 
2353 2383
     /**
2354
-	 * Set the customer's state.
2355
-	 *
2356
-	 * @since 1.0.19
2357
-	 * @param  string $value state.
2358
-	 */
2359
-	public function set_state( $value ) {
2360
-		$this->set_prop( 'state', $value );
2384
+     * Set the customer's city.
2385
+     *
2386
+     * @since 1.0.19
2387
+     * @param  string $value city.
2388
+     */
2389
+    public function set_city( $value ) {
2390
+        $this->set_prop( 'city', $value );
2361 2391
     }
2362 2392
 
2363 2393
     /**
2364
-	 * Alias of self::set_state().
2365
-	 *
2366
-	 * @since 1.0.19
2367
-	 * @param  string $value state.
2368
-	 */
2369
-	public function set_user_state( $value ) {
2370
-		$this->set_state( $value );
2394
+     * Alias of self::set_city().
2395
+     *
2396
+     * @since 1.0.19
2397
+     * @param  string $value city.
2398
+     */
2399
+    public function set_user_city( $value ) {
2400
+        $this->set_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_customer_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_customer_city( $value ) {
2410
+        $this->set_city( $value );
2381 2411
     }
2382 2412
 
2383 2413
     /**
2384
-	 * Set the customer's city.
2385
-	 *
2386
-	 * @since 1.0.19
2387
-	 * @param  string $value city.
2388
-	 */
2389
-	public function set_city( $value ) {
2390
-		$this->set_prop( 'city', $value );
2414
+     * Set the customer's zip code.
2415
+     *
2416
+     * @since 1.0.19
2417
+     * @param  string $value zip.
2418
+     */
2419
+    public function set_zip( $value ) {
2420
+        $this->set_prop( 'zip', $value );
2391 2421
     }
2392 2422
 
2393 2423
     /**
2394
-	 * Alias of self::set_city().
2395
-	 *
2396
-	 * @since 1.0.19
2397
-	 * @param  string $value city.
2398
-	 */
2399
-	public function set_user_city( $value ) {
2400
-		$this->set_city( $value );
2424
+     * Alias of self::set_zip().
2425
+     *
2426
+     * @since 1.0.19
2427
+     * @param  string $value zip.
2428
+     */
2429
+    public function set_user_zip( $value ) {
2430
+        $this->set_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_customer_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_customer_zip( $value ) {
2440
+        $this->set_zip( $value );
2411 2441
     }
2412 2442
 
2413 2443
     /**
2414
-	 * Set the customer's zip code.
2415
-	 *
2416
-	 * @since 1.0.19
2417
-	 * @param  string $value zip.
2418
-	 */
2419
-	public function set_zip( $value ) {
2420
-		$this->set_prop( 'zip', $value );
2444
+     * Set the customer's company.
2445
+     *
2446
+     * @since 1.0.19
2447
+     * @param  string $value company.
2448
+     */
2449
+    public function set_company( $value ) {
2450
+        $this->set_prop( 'company', $value );
2421 2451
     }
2422 2452
 
2423 2453
     /**
2424
-	 * Alias of self::set_zip().
2425
-	 *
2426
-	 * @since 1.0.19
2427
-	 * @param  string $value zip.
2428
-	 */
2429
-	public function set_user_zip( $value ) {
2430
-		$this->set_zip( $value );
2454
+     * Alias of self::set_company().
2455
+     *
2456
+     * @since 1.0.19
2457
+     * @param  string $value company.
2458
+     */
2459
+    public function set_user_company( $value ) {
2460
+        $this->set_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_customer_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_customer_company( $value ) {
2470
+        $this->set_company( $value );
2441 2471
     }
2442 2472
 
2443 2473
     /**
2444
-	 * Set the customer's company.
2445
-	 *
2446
-	 * @since 1.0.19
2447
-	 * @param  string $value company.
2448
-	 */
2449
-	public function set_company( $value ) {
2450
-		$this->set_prop( 'company', $value );
2474
+     * Set the customer's var number.
2475
+     *
2476
+     * @since 1.0.19
2477
+     * @param  string $value var number.
2478
+     */
2479
+    public function set_vat_number( $value ) {
2480
+        $this->set_prop( 'vat_number', $value );
2451 2481
     }
2452 2482
 
2453 2483
     /**
2454
-	 * Alias of self::set_company().
2455
-	 *
2456
-	 * @since 1.0.19
2457
-	 * @param  string $value company.
2458
-	 */
2459
-	public function set_user_company( $value ) {
2460
-		$this->set_company( $value );
2484
+     * Alias of self::set_vat_number().
2485
+     *
2486
+     * @since 1.0.19
2487
+     * @param  string $value var number.
2488
+     */
2489
+    public function set_user_vat_number( $value ) {
2490
+        $this->set_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_customer_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_customer_vat_number( $value ) {
2500
+        $this->set_vat_number( $value );
2471 2501
     }
2472 2502
 
2473 2503
     /**
2474
-	 * Set the customer's var number.
2475
-	 *
2476
-	 * @since 1.0.19
2477
-	 * @param  string $value var number.
2478
-	 */
2479
-	public function set_vat_number( $value ) {
2480
-		$this->set_prop( 'vat_number', $value );
2504
+     * Set the customer's vat rate.
2505
+     *
2506
+     * @since 1.0.19
2507
+     * @param  string $value var rate.
2508
+     */
2509
+    public function set_vat_rate( $value ) {
2510
+        $this->set_prop( 'vat_rate', $value );
2481 2511
     }
2482 2512
 
2483 2513
     /**
2484
-	 * Alias of self::set_vat_number().
2485
-	 *
2486
-	 * @since 1.0.19
2487
-	 * @param  string $value var number.
2488
-	 */
2489
-	public function set_user_vat_number( $value ) {
2490
-		$this->set_vat_number( $value );
2514
+     * Alias of self::set_vat_rate().
2515
+     *
2516
+     * @since 1.0.19
2517
+     * @param  string $value var number.
2518
+     */
2519
+    public function set_user_vat_rate( $value ) {
2520
+        $this->set_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_customer_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_customer_vat_rate( $value ) {
2530
+        $this->set_vat_rate( $value );
2501 2531
     }
2502 2532
 
2503 2533
     /**
2504
-	 * Set the customer's vat rate.
2505
-	 *
2506
-	 * @since 1.0.19
2507
-	 * @param  string $value var rate.
2508
-	 */
2509
-	public function set_vat_rate( $value ) {
2510
-		$this->set_prop( 'vat_rate', $value );
2534
+     * Set the customer's address.
2535
+     *
2536
+     * @since 1.0.19
2537
+     * @param  string $value address.
2538
+     */
2539
+    public function set_address( $value ) {
2540
+        $this->set_prop( 'address', $value );
2511 2541
     }
2512 2542
 
2513 2543
     /**
2514
-	 * Alias of self::set_vat_rate().
2515
-	 *
2516
-	 * @since 1.0.19
2517
-	 * @param  string $value var number.
2518
-	 */
2519
-	public function set_user_vat_rate( $value ) {
2520
-		$this->set_vat_rate( $value );
2544
+     * Alias of self::set_address().
2545
+     *
2546
+     * @since 1.0.19
2547
+     * @param  string $value address.
2548
+     */
2549
+    public function set_user_address( $value ) {
2550
+        $this->set_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_customer_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_customer_address( $value ) {
2560
+        $this->set_address( $value );
2531 2561
     }
2532 2562
 
2533 2563
     /**
2534
-	 * Set the customer's address.
2535
-	 *
2536
-	 * @since 1.0.19
2537
-	 * @param  string $value address.
2538
-	 */
2539
-	public function set_address( $value ) {
2540
-		$this->set_prop( 'address', $value );
2564
+     * Set whether the customer has viewed the invoice or not.
2565
+     *
2566
+     * @since 1.0.19
2567
+     * @param  int|bool $value confirmed.
2568
+     */
2569
+    public function set_is_viewed( $value ) {
2570
+        $this->set_prop( 'is_viewed', $value );
2541 2571
     }
2542 2572
 
2543 2573
     /**
2544
-	 * Alias of self::set_address().
2545
-	 *
2546
-	 * @since 1.0.19
2547
-	 * @param  string $value address.
2548
-	 */
2549
-	public function set_user_address( $value ) {
2550
-		$this->set_address( $value );
2574
+     * Set extra email recipients.
2575
+     *
2576
+     * @since 1.0.19
2577
+     * @param  string $value email recipients.
2578
+     */
2579
+    public function set_email_cc( $value ) {
2580
+        $this->set_prop( 'email_cc', $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_customer_address( $value ) {
2560
-		$this->set_address( $value );
2584
+     * Set the invoice template.
2585
+     *
2586
+     * @since 1.0.19
2587
+     * @param  string $value email recipients.
2588
+     */
2589
+    public function set_template( $value ) {
2590
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2591
+            $this->set_prop( 'template', $value );
2592
+        }
2561 2593
     }
2562 2594
 
2563 2595
     /**
2564
-	 * Set whether the customer has viewed the invoice or not.
2565
-	 *
2566
-	 * @since 1.0.19
2567
-	 * @param  int|bool $value confirmed.
2568
-	 */
2569
-	public function set_is_viewed( $value ) {
2570
-		$this->set_prop( 'is_viewed', $value );
2571
-	}
2572
-
2573
-	/**
2574
-	 * Set extra email recipients.
2575
-	 *
2576
-	 * @since 1.0.19
2577
-	 * @param  string $value email recipients.
2578
-	 */
2579
-	public function set_email_cc( $value ) {
2580
-		$this->set_prop( 'email_cc', $value );
2581
-	}
2582
-
2583
-	/**
2584
-	 * Set the invoice template.
2585
-	 *
2586
-	 * @since 1.0.19
2587
-	 * @param  string $value email recipients.
2588
-	 */
2589
-	public function set_template( $value ) {
2590
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2591
-			$this->set_prop( 'template', $value );
2592
-		}
2593
-	}
2594
-
2595
-	/**
2596
-	 * Set the customer's address confirmed status.
2597
-	 *
2598
-	 * @since 1.0.19
2599
-	 * @param  int|bool $value confirmed.
2600
-	 */
2601
-	public function set_address_confirmed( $value ) {
2602
-		$this->set_prop( 'address_confirmed', $value );
2596
+     * Set the customer's address confirmed status.
2597
+     *
2598
+     * @since 1.0.19
2599
+     * @param  int|bool $value confirmed.
2600
+     */
2601
+    public function set_address_confirmed( $value ) {
2602
+        $this->set_prop( 'address_confirmed', $value );
2603 2603
     }
2604 2604
 
2605 2605
     /**
2606
-	 * Alias of self::set_address_confirmed().
2607
-	 *
2608
-	 * @since 1.0.19
2609
-	 * @param  int|bool $value confirmed.
2610
-	 */
2611
-	public function set_user_address_confirmed( $value ) {
2612
-		$this->set_address_confirmed( $value );
2606
+     * Alias of self::set_address_confirmed().
2607
+     *
2608
+     * @since 1.0.19
2609
+     * @param  int|bool $value confirmed.
2610
+     */
2611
+    public function set_user_address_confirmed( $value ) {
2612
+        $this->set_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_customer_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_customer_address_confirmed( $value ) {
2622
+        $this->set_address_confirmed( $value );
2623 2623
     }
2624 2624
 
2625 2625
     /**
2626
-	 * Set the invoice sub total.
2627
-	 *
2628
-	 * @since 1.0.19
2629
-	 * @param  float $value sub total.
2630
-	 */
2631
-	public function set_subtotal( $value ) {
2632
-		$this->set_prop( 'subtotal', $value );
2626
+     * Set the invoice sub total.
2627
+     *
2628
+     * @since 1.0.19
2629
+     * @param  float $value sub total.
2630
+     */
2631
+    public function set_subtotal( $value ) {
2632
+        $this->set_prop( 'subtotal', $value );
2633 2633
     }
2634 2634
 
2635 2635
     /**
2636
-	 * Set the invoice discount amount.
2637
-	 *
2638
-	 * @since 1.0.19
2639
-	 * @param  float $value discount total.
2640
-	 */
2641
-	public function set_total_discount( $value ) {
2642
-		$this->set_prop( 'total_discount', $value );
2636
+     * Set the invoice discount amount.
2637
+     *
2638
+     * @since 1.0.19
2639
+     * @param  float $value discount total.
2640
+     */
2641
+    public function set_total_discount( $value ) {
2642
+        $this->set_prop( 'total_discount', $value );
2643 2643
     }
2644 2644
 
2645 2645
     /**
2646
-	 * Alias of self::set_total_discount().
2647
-	 *
2648
-	 * @since 1.0.19
2649
-	 * @param  float $value discount total.
2650
-	 */
2651
-	public function set_discount( $value ) {
2652
-		$this->set_total_discount( $value );
2646
+     * Alias of self::set_total_discount().
2647
+     *
2648
+     * @since 1.0.19
2649
+     * @param  float $value discount total.
2650
+     */
2651
+    public function set_discount( $value ) {
2652
+        $this->set_total_discount( $value );
2653 2653
     }
2654 2654
 
2655 2655
     /**
2656
-	 * Set the invoice tax amount.
2657
-	 *
2658
-	 * @since 1.0.19
2659
-	 * @param  float $value tax total.
2660
-	 */
2661
-	public function set_total_tax( $value ) {
2662
-		$this->set_prop( 'total_tax', $value );
2656
+     * Set the invoice tax amount.
2657
+     *
2658
+     * @since 1.0.19
2659
+     * @param  float $value tax total.
2660
+     */
2661
+    public function set_total_tax( $value ) {
2662
+        $this->set_prop( 'total_tax', $value );
2663 2663
     }
2664 2664
 
2665 2665
     /**
2666
-	 * Alias of self::set_total_tax().
2667
-	 *
2668
-	 * @since 1.0.19
2669
-	 * @param  float $value tax total.
2670
-	 */
2671
-	public function set_tax_total( $value ) {
2672
-		$this->set_total_tax( $value );
2666
+     * Alias of self::set_total_tax().
2667
+     *
2668
+     * @since 1.0.19
2669
+     * @param  float $value tax total.
2670
+     */
2671
+    public function set_tax_total( $value ) {
2672
+        $this->set_total_tax( $value );
2673 2673
     }
2674 2674
 
2675 2675
     /**
2676
-	 * Set the invoice fees amount.
2677
-	 *
2678
-	 * @since 1.0.19
2679
-	 * @param  float $value fees total.
2680
-	 */
2681
-	public function set_total_fees( $value ) {
2682
-		$this->set_prop( 'total_fees', $value );
2676
+     * Set the invoice fees amount.
2677
+     *
2678
+     * @since 1.0.19
2679
+     * @param  float $value fees total.
2680
+     */
2681
+    public function set_total_fees( $value ) {
2682
+        $this->set_prop( 'total_fees', $value );
2683 2683
     }
2684 2684
 
2685 2685
     /**
2686
-	 * Alias of self::set_total_fees().
2687
-	 *
2688
-	 * @since 1.0.19
2689
-	 * @param  float $value fees total.
2690
-	 */
2691
-	public function set_fees_total( $value ) {
2692
-		$this->set_total_fees( $value );
2686
+     * Alias of self::set_total_fees().
2687
+     *
2688
+     * @since 1.0.19
2689
+     * @param  float $value fees total.
2690
+     */
2691
+    public function set_fees_total( $value ) {
2692
+        $this->set_total_fees( $value );
2693 2693
     }
2694 2694
 
2695 2695
     /**
2696
-	 * Set the invoice fees.
2697
-	 *
2698
-	 * @since 1.0.19
2699
-	 * @param  array $value fees.
2700
-	 */
2701
-	public function set_fees( $value ) {
2696
+     * Set the invoice fees.
2697
+     *
2698
+     * @since 1.0.19
2699
+     * @param  array $value fees.
2700
+     */
2701
+    public function set_fees( $value ) {
2702 2702
 
2703 2703
         $this->set_prop( 'fees', array() );
2704 2704
 
@@ -2716,23 +2716,23 @@  discard block
 block discarded – undo
2716 2716
     }
2717 2717
 
2718 2718
     /**
2719
-	 * Set the invoice taxes.
2720
-	 *
2721
-	 * @since 1.0.19
2722
-	 * @param  array $value taxes.
2723
-	 */
2724
-	public function set_taxes( $value ) {
2725
-		$this->set_prop( 'taxes', $value );
2719
+     * Set the invoice taxes.
2720
+     *
2721
+     * @since 1.0.19
2722
+     * @param  array $value taxes.
2723
+     */
2724
+    public function set_taxes( $value ) {
2725
+        $this->set_prop( 'taxes', $value );
2726 2726
     }
2727 2727
 
2728 2728
     /**
2729
-	 * Set the invoice discounts.
2730
-	 *
2731
-	 * @since 1.0.19
2732
-	 * @param  array $value discounts.
2733
-	 */
2734
-	public function set_discounts( $value ) {
2735
-		$this->set_prop( 'discounts', array() );
2729
+     * Set the invoice discounts.
2730
+     *
2731
+     * @since 1.0.19
2732
+     * @param  array $value discounts.
2733
+     */
2734
+    public function set_discounts( $value ) {
2735
+        $this->set_prop( 'discounts', array() );
2736 2736
 
2737 2737
         // Ensure that we have an array.
2738 2738
         if ( ! is_array( $value ) ) {
@@ -2747,12 +2747,12 @@  discard block
 block discarded – undo
2747 2747
     }
2748 2748
 
2749 2749
     /**
2750
-	 * Set the invoice items.
2751
-	 *
2752
-	 * @since 1.0.19
2753
-	 * @param  GetPaid_Form_Item[] $value items.
2754
-	 */
2755
-	public function set_items( $value ) {
2750
+     * Set the invoice items.
2751
+     *
2752
+     * @since 1.0.19
2753
+     * @param  GetPaid_Form_Item[] $value items.
2754
+     */
2755
+    public function set_items( $value ) {
2756 2756
 
2757 2757
         // Remove existing items.
2758 2758
         $this->set_prop( 'items', array() );
@@ -2769,85 +2769,85 @@  discard block
 block discarded – undo
2769 2769
     }
2770 2770
 
2771 2771
     /**
2772
-	 * Set the payment form.
2773
-	 *
2774
-	 * @since 1.0.19
2775
-	 * @param  int $value payment form.
2776
-	 */
2777
-	public function set_payment_form( $value ) {
2778
-		$this->set_prop( 'payment_form', $value );
2772
+     * Set the payment form.
2773
+     *
2774
+     * @since 1.0.19
2775
+     * @param  int $value payment form.
2776
+     */
2777
+    public function set_payment_form( $value ) {
2778
+        $this->set_prop( 'payment_form', $value );
2779 2779
     }
2780 2780
 
2781 2781
     /**
2782
-	 * Set the submission id.
2783
-	 *
2784
-	 * @since 1.0.19
2785
-	 * @param  string $value submission id.
2786
-	 */
2787
-	public function set_submission_id( $value ) {
2788
-		$this->set_prop( 'submission_id', $value );
2782
+     * Set the submission id.
2783
+     *
2784
+     * @since 1.0.19
2785
+     * @param  string $value submission id.
2786
+     */
2787
+    public function set_submission_id( $value ) {
2788
+        $this->set_prop( 'submission_id', $value );
2789 2789
     }
2790 2790
 
2791 2791
     /**
2792
-	 * Set the discount code.
2793
-	 *
2794
-	 * @since 1.0.19
2795
-	 * @param  string $value discount code.
2796
-	 */
2797
-	public function set_discount_code( $value ) {
2798
-		$this->set_prop( 'discount_code', $value );
2792
+     * Set the discount code.
2793
+     *
2794
+     * @since 1.0.19
2795
+     * @param  string $value discount code.
2796
+     */
2797
+    public function set_discount_code( $value ) {
2798
+        $this->set_prop( 'discount_code', $value );
2799 2799
     }
2800 2800
 
2801 2801
     /**
2802
-	 * Set the gateway.
2803
-	 *
2804
-	 * @since 1.0.19
2805
-	 * @param  string $value gateway.
2806
-	 */
2807
-	public function set_gateway( $value ) {
2808
-		$this->set_prop( 'gateway', $value );
2802
+     * Set the gateway.
2803
+     *
2804
+     * @since 1.0.19
2805
+     * @param  string $value gateway.
2806
+     */
2807
+    public function set_gateway( $value ) {
2808
+        $this->set_prop( 'gateway', $value );
2809 2809
     }
2810 2810
 
2811 2811
     /**
2812
-	 * Set the transaction id.
2813
-	 *
2814
-	 * @since 1.0.19
2815
-	 * @param  string $value transaction id.
2816
-	 */
2817
-	public function set_transaction_id( $value ) {
2818
-		if ( ! empty( $value ) ) {
2819
-			$this->set_prop( 'transaction_id', $value );
2820
-		}
2812
+     * Set the transaction id.
2813
+     *
2814
+     * @since 1.0.19
2815
+     * @param  string $value transaction id.
2816
+     */
2817
+    public function set_transaction_id( $value ) {
2818
+        if ( ! empty( $value ) ) {
2819
+            $this->set_prop( 'transaction_id', $value );
2820
+        }
2821 2821
     }
2822 2822
 
2823 2823
     /**
2824
-	 * Set the currency id.
2825
-	 *
2826
-	 * @since 1.0.19
2827
-	 * @param  string $value currency id.
2828
-	 */
2829
-	public function set_currency( $value ) {
2830
-		$this->set_prop( 'currency', $value );
2824
+     * Set the currency id.
2825
+     *
2826
+     * @since 1.0.19
2827
+     * @param  string $value currency id.
2828
+     */
2829
+    public function set_currency( $value ) {
2830
+        $this->set_prop( 'currency', $value );
2831 2831
     }
2832 2832
 
2833
-	/**
2834
-	 * Set whether to disable taxes.
2835
-	 *
2836
-	 * @since 1.0.19
2837
-	 * @param  bool $value value.
2838
-	 */
2839
-	public function set_disable_taxes( $value ) {
2840
-		$this->set_prop( 'disable_taxes', (bool) $value );
2841
-	}
2833
+    /**
2834
+     * Set whether to disable taxes.
2835
+     *
2836
+     * @since 1.0.19
2837
+     * @param  bool $value value.
2838
+     */
2839
+    public function set_disable_taxes( $value ) {
2840
+        $this->set_prop( 'disable_taxes', (bool) $value );
2841
+    }
2842 2842
 
2843 2843
     /**
2844
-	 * Set the subscription id.
2845
-	 *
2846
-	 * @since 1.0.19
2847
-	 * @param  string $value subscription id.
2848
-	 */
2849
-	public function set_subscription_id( $value ) {
2850
-		$this->set_prop( 'subscription_id', $value );
2844
+     * Set the subscription id.
2845
+     *
2846
+     * @since 1.0.19
2847
+     * @param  string $value subscription id.
2848
+     */
2849
+    public function set_subscription_id( $value ) {
2850
+        $this->set_prop( 'subscription_id', $value );
2851 2851
     }
2852 2852
 
2853 2853
     /*
@@ -2886,12 +2886,12 @@  discard block
 block discarded – undo
2886 2886
      */
2887 2887
     public function is_taxable() {
2888 2888
         return ! $this->get_disable_taxes();
2889
-	}
2889
+    }
2890 2890
 
2891
-	/**
2892
-	 * @deprecated
2893
-	 */
2894
-	public function has_vat() {
2891
+    /**
2892
+     * @deprecated
2893
+     */
2894
+    public function has_vat() {
2895 2895
         global $wpinv_euvat, $wpi_country;
2896 2896
 
2897 2897
         $requires_vat = false;
@@ -2902,17 +2902,17 @@  discard block
 block discarded – undo
2902 2902
         }
2903 2903
 
2904 2904
         return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2905
-	}
2905
+    }
2906 2906
 
2907
-	/**
2908
-	 * Checks to see if the invoice requires payment.
2909
-	 */
2910
-	public function is_free() {
2907
+    /**
2908
+     * Checks to see if the invoice requires payment.
2909
+     */
2910
+    public function is_free() {
2911 2911
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2912 2912
 
2913
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2914
-			$is_free = false;
2915
-		}
2913
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2914
+            $is_free = false;
2915
+        }
2916 2916
 
2917 2917
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2918 2918
     }
@@ -2923,46 +2923,46 @@  discard block
 block discarded – undo
2923 2923
     public function is_paid() {
2924 2924
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2925 2925
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2926
-	}
2926
+    }
2927 2927
 
2928
-	/**
2928
+    /**
2929 2929
      * Checks if the invoice needs payment.
2930 2930
      */
2931
-	public function needs_payment() {
2932
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2931
+    public function needs_payment() {
2932
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2933 2933
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2934 2934
     }
2935 2935
 
2936
-	/**
2936
+    /**
2937 2937
      * Checks if the invoice is refunded.
2938 2938
      */
2939
-	public function is_refunded() {
2939
+    public function is_refunded() {
2940 2940
         $is_refunded = $this->has_status( 'wpi-refunded' );
2941 2941
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2942
-	}
2942
+    }
2943 2943
 
2944
-	/**
2944
+    /**
2945 2945
      * Checks if the invoice is held.
2946 2946
      */
2947
-	public function is_held() {
2947
+    public function is_held() {
2948 2948
         $is_held = $this->has_status( 'wpi-onhold' );
2949 2949
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2950
-	}
2950
+    }
2951 2951
 
2952
-	/**
2952
+    /**
2953 2953
      * Checks if the invoice is due.
2954 2954
      */
2955
-	public function is_due() {
2956
-		$due_date = $this->get_due_date();
2957
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2958
-	}
2955
+    public function is_due() {
2956
+        $due_date = $this->get_due_date();
2957
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2958
+    }
2959 2959
 
2960
-	/**
2960
+    /**
2961 2961
      * Checks if the invoice is draft.
2962 2962
      */
2963
-	public function is_draft() {
2963
+    public function is_draft() {
2964 2964
         return $this->has_status( 'draft, auto-draft' );
2965
-	}
2965
+    }
2966 2966
 
2967 2967
     /**
2968 2968
      * Checks if the invoice has a given status.
@@ -2970,9 +2970,9 @@  discard block
 block discarded – undo
2970 2970
     public function has_status( $status ) {
2971 2971
         $status = wpinv_parse_list( $status );
2972 2972
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
2973
-	}
2973
+    }
2974 2974
 
2975
-	/**
2975
+    /**
2976 2976
      * Checks if the invoice is of a given type.
2977 2977
      */
2978 2978
     public function is_type( $type ) {
@@ -2995,25 +2995,25 @@  discard block
 block discarded – undo
2995 2995
      */
2996 2996
     public function has_free_trial() {
2997 2997
         return $this->is_recurring() && 0 == $this->get_initial_total();
2998
-	}
2998
+    }
2999 2999
 
3000
-	/**
3000
+    /**
3001 3001
      * @deprecated
3002 3002
      */
3003 3003
     public function is_free_trial() {
3004 3004
         $this->has_free_trial();
3005 3005
     }
3006 3006
 
3007
-	/**
3007
+    /**
3008 3008
      * Check if the initial payment if 0.
3009 3009
      *
3010 3010
      */
3011
-	public function is_initial_free() {
3011
+    public function is_initial_free() {
3012 3012
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3013 3013
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3014 3014
     }
3015 3015
 	
3016
-	/**
3016
+    /**
3017 3017
      * Check if the recurring item has a free trial.
3018 3018
      *
3019 3019
      */
@@ -3026,21 +3026,21 @@  discard block
 block discarded – undo
3026 3026
 
3027 3027
         $item = $this->get_recurring( true );
3028 3028
         return $item->has_free_trial();
3029
-	}
3029
+    }
3030 3030
 
3031
-	/**
3031
+    /**
3032 3032
      * Check if the free trial is a result of a discount.
3033 3033
      */
3034 3034
     public function is_free_trial_from_discount() {
3035
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3036
-	}
3035
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3036
+    }
3037 3037
 	
3038
-	/**
3038
+    /**
3039 3039
      * @deprecated
3040 3040
      */
3041 3041
     public function discount_first_payment_only() {
3042 3042
 
3043
-		$discount_code = $this->get_discount_code();
3043
+        $discount_code = $this->get_discount_code();
3044 3044
         if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3045 3045
             return true;
3046 3046
         }
@@ -3072,19 +3072,19 @@  discard block
 block discarded – undo
3072 3072
     public function add_item( $item ) {
3073 3073
 
3074 3074
         // Make sure that it is available for purchase.
3075
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3076
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3075
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3076
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3077 3077
         }
3078 3078
 
3079 3079
         // Do we have a recurring item?
3080
-		if ( $item->is_recurring() ) {
3080
+        if ( $item->is_recurring() ) {
3081 3081
 
3082
-			// An invoice can only contain one recurring item.
3083
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3084
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3085
-			}
3082
+            // An invoice can only contain one recurring item.
3083
+            if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3084
+                return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3085
+            }
3086 3086
 
3087
-			$this->recurring_item = $item->get_id();
3087
+            $this->recurring_item = $item->get_id();
3088 3088
         }
3089 3089
 
3090 3090
         // Invoice id.
@@ -3095,28 +3095,28 @@  discard block
 block discarded – undo
3095 3095
         $items[ (int) $item->get_id() ] = $item;
3096 3096
 
3097 3097
         $this->set_prop( 'items', $items );
3098
-		return true;
3098
+        return true;
3099 3099
     }
3100 3100
 
3101 3101
     /**
3102
-	 * Retrieves a specific item.
3103
-	 *
3104
-	 * @since 1.0.19
3105
-	 */
3106
-	public function get_item( $item_id ) {
3107
-		$items   = $this->get_items();
3108
-		$item_id = (int) $item_id;
3109
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3102
+     * Retrieves a specific item.
3103
+     *
3104
+     * @since 1.0.19
3105
+     */
3106
+    public function get_item( $item_id ) {
3107
+        $items   = $this->get_items();
3108
+        $item_id = (int) $item_id;
3109
+        return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3110 3110
     }
3111 3111
 
3112 3112
     /**
3113
-	 * Removes a specific item.
3114
-	 *
3115
-	 * @since 1.0.19
3116
-	 */
3117
-	public function remove_item( $item_id ) {
3118
-		$items   = $this->get_items();
3119
-		$item_id = (int) $item_id;
3113
+     * Removes a specific item.
3114
+     *
3115
+     * @since 1.0.19
3116
+     */
3117
+    public function remove_item( $item_id ) {
3118
+        $items   = $this->get_items();
3119
+        $item_id = (int) $item_id;
3120 3120
 
3121 3121
         if ( $item_id == $this->recurring_item ) {
3122 3122
             $this->recurring_item = null;
@@ -3143,38 +3143,38 @@  discard block
 block discarded – undo
3143 3143
         if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3144 3144
 
3145 3145
             $amount = $fees[ $fee ]['amount'] += $amount;
3146
-			$fees[ $fee ] = array(
3146
+            $fees[ $fee ] = array(
3147 3147
                 'amount'    => $amount,
3148 3148
                 'recurring' => (bool) $recurring,
3149 3149
             );
3150 3150
 
3151
-		} else {
3152
-			$fees[ $fee ] = array(
3151
+        } else {
3152
+            $fees[ $fee ] = array(
3153 3153
                 'amount'    => $amount,
3154 3154
                 'recurring' => (bool) $recurring,
3155 3155
             );
3156
-		}
3156
+        }
3157 3157
 
3158 3158
         $this->set_prop( 'fees', $fee );
3159 3159
 
3160 3160
     }
3161 3161
 
3162 3162
     /**
3163
-	 * Retrieves a specific fee.
3164
-	 *
3165
-	 * @since 1.0.19
3166
-	 */
3167
-	public function get_fee( $fee ) {
3163
+     * Retrieves a specific fee.
3164
+     *
3165
+     * @since 1.0.19
3166
+     */
3167
+    public function get_fee( $fee ) {
3168 3168
         $fees = $this->get_fees();
3169
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3169
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3170 3170
     }
3171 3171
 
3172 3172
     /**
3173
-	 * Removes a specific fee.
3174
-	 *
3175
-	 * @since 1.0.19
3176
-	 */
3177
-	public function remove_fee( $fee ) {
3173
+     * Removes a specific fee.
3174
+     *
3175
+     * @since 1.0.19
3176
+     */
3177
+    public function remove_fee( $fee ) {
3178 3178
         $fees = $this->get_fees();
3179 3179
         if ( isset( $fees[ $fee ] ) ) {
3180 3180
             unset( $fees[ $fee ] );
@@ -3197,44 +3197,44 @@  discard block
 block discarded – undo
3197 3197
         if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3198 3198
 
3199 3199
             $amount = $discounts[ $discount ]['amount'] += $amount;
3200
-			$discounts[ $discount ] = array(
3200
+            $discounts[ $discount ] = array(
3201 3201
                 'amount'    => $amount,
3202 3202
                 'recurring' => (bool) $recurring,
3203 3203
             );
3204 3204
 
3205
-		} else {
3206
-			$discounts[ $discount ] = array(
3205
+        } else {
3206
+            $discounts[ $discount ] = array(
3207 3207
                 'amount'    => $amount,
3208 3208
                 'recurring' => (bool) $recurring,
3209 3209
             );
3210
-		}
3210
+        }
3211 3211
 
3212 3212
         $this->set_prop( 'discounts', $discount );
3213 3213
 
3214 3214
     }
3215 3215
 
3216 3216
     /**
3217
-	 * Retrieves a specific discount.
3218
-	 *
3219
-	 * @since 1.0.19
3220
-	 */
3221
-	public function get_discount( $discount = false ) {
3217
+     * Retrieves a specific discount.
3218
+     *
3219
+     * @since 1.0.19
3220
+     */
3221
+    public function get_discount( $discount = false ) {
3222 3222
 
3223
-		// Backwards compatibilty.
3224
-		if ( empty( $discount ) ) {
3225
-			return $this->get_total_discount();
3226
-		}
3223
+        // Backwards compatibilty.
3224
+        if ( empty( $discount ) ) {
3225
+            return $this->get_total_discount();
3226
+        }
3227 3227
 
3228 3228
         $discounts = $this->get_discounts();
3229
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3229
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3230 3230
     }
3231 3231
 
3232 3232
     /**
3233
-	 * Removes a specific discount.
3234
-	 *
3235
-	 * @since 1.0.19
3236
-	 */
3237
-	public function remove_discount( $discount ) {
3233
+     * Removes a specific discount.
3234
+     *
3235
+     * @since 1.0.19
3236
+     */
3237
+    public function remove_discount( $discount ) {
3238 3238
         $discounts = $this->get_discounts();
3239 3239
         if ( isset( $discounts[ $discount ] ) ) {
3240 3240
             unset( $discounts[ $discount ] );
@@ -3260,44 +3260,44 @@  discard block
 block discarded – undo
3260 3260
         if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3261 3261
 
3262 3262
             $amount = $taxes[ $tax ]['amount'] += $amount;
3263
-			$taxes[ $tax ] = array(
3263
+            $taxes[ $tax ] = array(
3264 3264
                 'amount'    => $amount,
3265 3265
                 'recurring' => (bool) $recurring,
3266 3266
             );
3267 3267
 
3268
-		} else {
3269
-			$taxes[ $tax ] = array(
3268
+        } else {
3269
+            $taxes[ $tax ] = array(
3270 3270
                 'amount'    => $amount,
3271 3271
                 'recurring' => (bool) $recurring,
3272 3272
             );
3273
-		}
3273
+        }
3274 3274
 
3275 3275
         $this->set_prop( 'taxes', $tax );
3276 3276
 
3277 3277
     }
3278 3278
 
3279 3279
     /**
3280
-	 * Retrieves a specific tax.
3281
-	 *
3282
-	 * @since 1.0.19
3283
-	 */
3284
-	public function get_tax( $tax = null ) {
3280
+     * Retrieves a specific tax.
3281
+     *
3282
+     * @since 1.0.19
3283
+     */
3284
+    public function get_tax( $tax = null ) {
3285 3285
 
3286
-		// Backwards compatility.
3287
-		if ( empty( $tax ) ) {
3288
-			return $this->get_total_tax();
3289
-		}
3286
+        // Backwards compatility.
3287
+        if ( empty( $tax ) ) {
3288
+            return $this->get_total_tax();
3289
+        }
3290 3290
 
3291 3291
         $taxes = $this->get_taxes();
3292
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3292
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3293 3293
     }
3294 3294
 
3295 3295
     /**
3296
-	 * Removes a specific tax.
3297
-	 *
3298
-	 * @since 1.0.19
3299
-	 */
3300
-	public function remove_tax( $tax ) {
3296
+     * Removes a specific tax.
3297
+     *
3298
+     * @since 1.0.19
3299
+     */
3300
+    public function remove_tax( $tax ) {
3301 3301
         $taxes = $this->get_discounts();
3302 3302
         if ( isset( $taxes[ $tax ] ) ) {
3303 3303
             unset( $taxes[ $tax ] );
@@ -3306,160 +3306,160 @@  discard block
 block discarded – undo
3306 3306
     }
3307 3307
 
3308 3308
     /**
3309
-	 * Recalculates the invoice subtotal.
3310
-	 *
3311
-	 * @since 1.0.19
3312
-	 * @return float The recalculated subtotal
3313
-	 */
3314
-	public function recalculate_subtotal() {
3309
+     * Recalculates the invoice subtotal.
3310
+     *
3311
+     * @since 1.0.19
3312
+     * @return float The recalculated subtotal
3313
+     */
3314
+    public function recalculate_subtotal() {
3315 3315
         $items     = $this->get_items();
3316
-		$subtotal  = 0;
3317
-		$recurring = 0;
3316
+        $subtotal  = 0;
3317
+        $recurring = 0;
3318 3318
 
3319 3319
         foreach ( $items as $item ) {
3320
-			$subtotal  += $item->get_sub_total();
3321
-			$recurring += $item->get_recurring_sub_total();
3320
+            $subtotal  += $item->get_sub_total();
3321
+            $recurring += $item->get_recurring_sub_total();
3322 3322
         }
3323 3323
 
3324
-		if ( $this->is_renewal() ) {
3325
-			$this->set_subtotal( $recurring );
3326
-		} else {
3327
-			$this->set_subtotal( $subtotal );
3328
-		}
3324
+        if ( $this->is_renewal() ) {
3325
+            $this->set_subtotal( $recurring );
3326
+        } else {
3327
+            $this->set_subtotal( $subtotal );
3328
+        }
3329 3329
 
3330
-		$this->totals['subtotal'] = array(
3331
-			'initial'   => $subtotal,
3332
-			'recurring' => $recurring,
3333
-		);
3330
+        $this->totals['subtotal'] = array(
3331
+            'initial'   => $subtotal,
3332
+            'recurring' => $recurring,
3333
+        );
3334 3334
 
3335 3335
         return $this->is_renewal() ? $recurring : $subtotal;
3336 3336
     }
3337 3337
 
3338 3338
     /**
3339
-	 * Recalculates the invoice discount total.
3340
-	 *
3341
-	 * @since 1.0.19
3342
-	 * @return float The recalculated discount
3343
-	 */
3344
-	public function recalculate_total_discount() {
3339
+     * Recalculates the invoice discount total.
3340
+     *
3341
+     * @since 1.0.19
3342
+     * @return float The recalculated discount
3343
+     */
3344
+    public function recalculate_total_discount() {
3345 3345
         $discounts = $this->get_discounts();
3346
-		$discount  = 0;
3347
-		$recurring = 0;
3346
+        $discount  = 0;
3347
+        $recurring = 0;
3348 3348
 
3349 3349
         foreach ( $discounts as $data ) {
3350 3350
 
3351
-			if ( $data['recurring'] ) {
3352
-				$recurring += $data['amount'];
3353
-			} else {
3354
-				$discount += $data['amount'];
3355
-			}
3351
+            if ( $data['recurring'] ) {
3352
+                $recurring += $data['amount'];
3353
+            } else {
3354
+                $discount += $data['amount'];
3355
+            }
3356 3356
 
3357
-		}
3357
+        }
3358 3358
 
3359
-		if ( $this->is_renewal() ) {
3360
-			$this->set_total_discount( $recurring );
3361
-		} else {
3362
-			$this->set_total_discount( $discount );
3363
-		}
3359
+        if ( $this->is_renewal() ) {
3360
+            $this->set_total_discount( $recurring );
3361
+        } else {
3362
+            $this->set_total_discount( $discount );
3363
+        }
3364 3364
 
3365
-		$this->totals['discount'] = array(
3366
-			'initial'   => $discount,
3367
-			'recurring' => $recurring,
3368
-		);
3365
+        $this->totals['discount'] = array(
3366
+            'initial'   => $discount,
3367
+            'recurring' => $recurring,
3368
+        );
3369 3369
 
3370
-		return $this->is_renewal() ? $recurring : $discount;
3370
+        return $this->is_renewal() ? $recurring : $discount;
3371 3371
 
3372 3372
     }
3373 3373
 
3374 3374
     /**
3375
-	 * Recalculates the invoice tax total.
3376
-	 *
3377
-	 * @since 1.0.19
3378
-	 * @return float The recalculated tax
3379
-	 */
3380
-	public function recalculate_total_tax() {
3375
+     * Recalculates the invoice tax total.
3376
+     *
3377
+     * @since 1.0.19
3378
+     * @return float The recalculated tax
3379
+     */
3380
+    public function recalculate_total_tax() {
3381 3381
         $taxes     = $this->get_taxes();
3382
-		$tax       = 0;
3383
-		$recurring = 0;
3382
+        $tax       = 0;
3383
+        $recurring = 0;
3384 3384
 
3385 3385
         foreach ( $taxes as $data ) {
3386 3386
 
3387
-			if ( $data['recurring'] ) {
3388
-				$recurring += $data['amount'];
3389
-			} else {
3390
-				$tax += $data['amount'];
3391
-			}
3387
+            if ( $data['recurring'] ) {
3388
+                $recurring += $data['amount'];
3389
+            } else {
3390
+                $tax += $data['amount'];
3391
+            }
3392 3392
 
3393
-		}
3393
+        }
3394 3394
 
3395
-		if ( $this->is_renewal() ) {
3396
-			$this->set_total_tax( $recurring );
3397
-		} else {
3398
-			$this->set_total_tax( $tax );
3399
-		}
3395
+        if ( $this->is_renewal() ) {
3396
+            $this->set_total_tax( $recurring );
3397
+        } else {
3398
+            $this->set_total_tax( $tax );
3399
+        }
3400 3400
 
3401
-		$this->totals['tax'] = array(
3402
-			'initial'   => $tax,
3403
-			'recurring' => $recurring,
3404
-		);
3401
+        $this->totals['tax'] = array(
3402
+            'initial'   => $tax,
3403
+            'recurring' => $recurring,
3404
+        );
3405 3405
 
3406
-		return $this->is_renewal() ? $recurring : $tax;
3406
+        return $this->is_renewal() ? $recurring : $tax;
3407 3407
 
3408 3408
     }
3409 3409
 
3410 3410
     /**
3411
-	 * Recalculates the invoice fees total.
3412
-	 *
3413
-	 * @since 1.0.19
3414
-	 * @return float The recalculated fee
3415
-	 */
3416
-	public function recalculate_total_fees() {
3417
-		$fees      = $this->get_fees();
3418
-		$fee       = 0;
3419
-		$recurring = 0;
3411
+     * Recalculates the invoice fees total.
3412
+     *
3413
+     * @since 1.0.19
3414
+     * @return float The recalculated fee
3415
+     */
3416
+    public function recalculate_total_fees() {
3417
+        $fees      = $this->get_fees();
3418
+        $fee       = 0;
3419
+        $recurring = 0;
3420 3420
 
3421 3421
         foreach ( $fees as $data ) {
3422 3422
 
3423
-			if ( $data['recurring'] ) {
3424
-				$recurring += $data['amount'];
3425
-			} else {
3426
-				$fee += $data['amount'];
3427
-			}
3423
+            if ( $data['recurring'] ) {
3424
+                $recurring += $data['amount'];
3425
+            } else {
3426
+                $fee += $data['amount'];
3427
+            }
3428 3428
 
3429
-		}
3429
+        }
3430 3430
 
3431 3431
         if ( $this->is_renewal() ) {
3432
-			$this->set_total_fees( $recurring );
3433
-		} else {
3434
-			$this->set_total_fees( $fee );
3435
-		}
3432
+            $this->set_total_fees( $recurring );
3433
+        } else {
3434
+            $this->set_total_fees( $fee );
3435
+        }
3436 3436
 
3437
-		$this->totals['fee'] = array(
3438
-			'initial'   => $fee,
3439
-			'recurring' => $recurring,
3440
-		);
3437
+        $this->totals['fee'] = array(
3438
+            'initial'   => $fee,
3439
+            'recurring' => $recurring,
3440
+        );
3441 3441
 
3442 3442
         $this->set_total_fees( $fee );
3443 3443
         return $this->is_renewal() ? $recurring : $fee;
3444 3444
     }
3445 3445
 
3446 3446
     /**
3447
-	 * Recalculates the invoice total.
3448
-	 *
3449
-	 * @since 1.0.19
3447
+     * Recalculates the invoice total.
3448
+     *
3449
+     * @since 1.0.19
3450 3450
      * @return float The invoice total
3451
-	 */
3452
-	public function recalculate_total() {
3451
+     */
3452
+    public function recalculate_total() {
3453 3453
         $this->recalculate_subtotal();
3454 3454
         $this->recalculate_total_fees();
3455 3455
         $this->recalculate_total_discount();
3456 3456
         $this->recalculate_total_tax();
3457
-		return $this->get_total();
3458
-	}
3457
+        return $this->get_total();
3458
+    }
3459 3459
 
3460
-	/**
3461
-	 * @deprecated
3462
-	 */
3460
+    /**
3461
+     * @deprecated
3462
+     */
3463 3463
     public function recalculate_totals( $temp = false ) {
3464 3464
         $this->update_items( $temp );
3465 3465
         $this->save( true );
@@ -3523,9 +3523,9 @@  discard block
 block discarded – undo
3523 3523
         }
3524 3524
 
3525 3525
         return $note_id;
3526
-	}
3526
+    }
3527 3527
 
3528
-	/**
3528
+    /**
3529 3529
      * Generates a unique key for the invoice.
3530 3530
      */
3531 3531
     public function generate_key( $string = '' ) {
@@ -3545,106 +3545,106 @@  discard block
 block discarded – undo
3545 3545
             $number = wpinv_get_next_invoice_number( $this->post_type );
3546 3546
         }
3547 3547
 
3548
-		$number = wpinv_format_invoice_number( $number, $this->post_type );
3548
+        $number = wpinv_format_invoice_number( $number, $this->post_type );
3549 3549
 
3550
-		return $number;
3551
-	}
3550
+        return $number;
3551
+    }
3552 3552
 
3553
-	/**
3554
-	 * Handle the status transition.
3555
-	 */
3556
-	protected function status_transition() {
3557
-		$status_transition = $this->status_transition;
3553
+    /**
3554
+     * Handle the status transition.
3555
+     */
3556
+    protected function status_transition() {
3557
+        $status_transition = $this->status_transition;
3558 3558
 
3559
-		// Reset status transition variable.
3560
-		$this->status_transition = false;
3559
+        // Reset status transition variable.
3560
+        $this->status_transition = false;
3561 3561
 
3562
-		if ( $status_transition ) {
3563
-			try {
3562
+        if ( $status_transition ) {
3563
+            try {
3564 3564
 
3565
-				// Fire a hook for the status change.
3566
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3565
+                // Fire a hook for the status change.
3566
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3567 3567
 
3568
-				// @deprecated this is deprecated and will be removed in the future.
3569
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3568
+                // @deprecated this is deprecated and will be removed in the future.
3569
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3570 3570
 
3571
-				if ( ! empty( $status_transition['from'] ) ) {
3571
+                if ( ! empty( $status_transition['from'] ) ) {
3572 3572
 
3573
-					/* translators: 1: old invoice status 2: new invoice status */
3574
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3573
+                    /* translators: 1: old invoice status 2: new invoice status */
3574
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3575 3575
 
3576
-					// Fire another hook.
3577
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3578
-					do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3576
+                    // Fire another hook.
3577
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3578
+                    do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3579 3579
 
3580
-					// @deprecated this is deprecated and will be removed in the future.
3581
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3580
+                    // @deprecated this is deprecated and will be removed in the future.
3581
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3582 3582
 
3583
-					// Note the transition occurred.
3584
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3583
+                    // Note the transition occurred.
3584
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3585 3585
 
3586
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3587
-					if (
3588
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3589
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3590
-					) {
3591
-						do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3592
-					}
3593
-				} else {
3594
-					/* translators: %s: new invoice status */
3595
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3586
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3587
+                    if (
3588
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3589
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3590
+                    ) {
3591
+                        do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3592
+                    }
3593
+                } else {
3594
+                    /* translators: %s: new invoice status */
3595
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3596 3596
 
3597
-					// Note the transition occurred.
3598
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3597
+                    // Note the transition occurred.
3598
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3599 3599
 
3600
-				}
3601
-			} catch ( Exception $e ) {
3602
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3603
-			}
3604
-		}
3605
-	}
3600
+                }
3601
+            } catch ( Exception $e ) {
3602
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3603
+            }
3604
+        }
3605
+    }
3606 3606
 
3607
-	/**
3608
-	 * Updates an invoice status.
3609
-	 */
3610
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3607
+    /**
3608
+     * Updates an invoice status.
3609
+     */
3610
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3611 3611
 
3612
-		// Fires before updating a status.
3613
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3612
+        // Fires before updating a status.
3613
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3614 3614
 
3615
-		// Update the status.
3616
-		$this->set_status( $new_status, $note, $manual );
3615
+        // Update the status.
3616
+        $this->set_status( $new_status, $note, $manual );
3617 3617
 
3618
-		// Save the order.
3619
-		return $this->save();
3618
+        // Save the order.
3619
+        return $this->save();
3620 3620
 
3621
-	}
3621
+    }
3622 3622
 
3623
-	/**
3624
-	 * @deprecated
3625
-	 */
3626
-	public function refresh_item_ids() {
3623
+    /**
3624
+     * @deprecated
3625
+     */
3626
+    public function refresh_item_ids() {
3627 3627
         $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3628 3628
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3629
-	}
3629
+    }
3630 3630
 
3631
-	/**
3632
-	 * @deprecated
3633
-	 */
3634
-	public function update_items( $temp = false ) {
3631
+    /**
3632
+     * @deprecated
3633
+     */
3634
+    public function update_items( $temp = false ) {
3635 3635
 
3636
-		$this->set_items( $this->get_items() );
3636
+        $this->set_items( $this->get_items() );
3637 3637
 
3638
-		if ( ! $temp ) {
3639
-			$this->save();
3640
-		}
3638
+        if ( ! $temp ) {
3639
+            $this->save();
3640
+        }
3641 3641
 
3642 3642
         return $this;
3643
-	}
3643
+    }
3644 3644
 
3645
-	/**
3646
-	 * @deprecated
3647
-	 */
3645
+    /**
3646
+     * @deprecated
3647
+     */
3648 3648
     public function validate_discount() {
3649 3649
 
3650 3650
         $discount_code = $this->get_discount_code();
@@ -3660,86 +3660,86 @@  discard block
 block discarded – undo
3660 3660
 
3661 3661
     }
3662 3662
 
3663
-	/**
3664
-	 * Refunds an invoice.
3665
-	 */
3663
+    /**
3664
+     * Refunds an invoice.
3665
+     */
3666 3666
     public function refund() {
3667
-		$this->set_status( 'wpi-refunded' );
3667
+        $this->set_status( 'wpi-refunded' );
3668 3668
         $this->save();
3669
-	}
3669
+    }
3670 3670
 
3671
-	/**
3672
-	 * Marks an invoice as paid.
3673
-	 * 
3674
-	 * @param string $transaction_id
3675
-	 */
3671
+    /**
3672
+     * Marks an invoice as paid.
3673
+     * 
3674
+     * @param string $transaction_id
3675
+     */
3676 3676
     public function mark_paid( $transaction_id = null, $note = '' ) {
3677 3677
 
3678
-		// Set the transaction id.
3679
-		if ( empty( $transaction_id ) ) {
3680
-			$transaction_id = $this->generate_key('trans_');
3681
-		}
3678
+        // Set the transaction id.
3679
+        if ( empty( $transaction_id ) ) {
3680
+            $transaction_id = $this->generate_key('trans_');
3681
+        }
3682 3682
 
3683
-		if ( ! $this->get_transaction_id() ) {
3684
-			$this->set_transaction_id( $transaction_id );
3685
-		}
3683
+        if ( ! $this->get_transaction_id() ) {
3684
+            $this->set_transaction_id( $transaction_id );
3685
+        }
3686 3686
 
3687
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3688
-			return $this->save();
3689
-		}
3687
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3688
+            return $this->save();
3689
+        }
3690 3690
 
3691
-		// Set the completed date.
3692
-		$this->set_date_completed( current_time( 'mysql' ) );
3691
+        // Set the completed date.
3692
+        $this->set_date_completed( current_time( 'mysql' ) );
3693 3693
 
3694
-		// Set the new status.
3695
-		if ( $this->is_renewal() ) {
3694
+        // Set the new status.
3695
+        if ( $this->is_renewal() ) {
3696 3696
 
3697
-			$_note = sprintf(
3698
-				__( 'Renewed via %s', 'invoicing' ),
3699
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3700
-			);
3697
+            $_note = sprintf(
3698
+                __( 'Renewed via %s', 'invoicing' ),
3699
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3700
+            );
3701 3701
 
3702
-			if ( 'none' == $this->get_gateway() ) {
3703
-				$_note = $note;
3704
-			}
3702
+            if ( 'none' == $this->get_gateway() ) {
3703
+                $_note = $note;
3704
+            }
3705 3705
 
3706
-			$this->set_status( 'wpi-renewal', $_note );
3706
+            $this->set_status( 'wpi-renewal', $_note );
3707 3707
 
3708
-		} else {
3708
+        } else {
3709 3709
 
3710
-			$_note = sprintf(
3711
-				__( 'Paid via %s', 'invoicing' ),
3712
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3713
-			);
3710
+            $_note = sprintf(
3711
+                __( 'Paid via %s', 'invoicing' ),
3712
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3713
+            );
3714 3714
 
3715
-			if ( 'none' == $this->get_gateway() ) {
3716
-				$_note = $note;
3717
-			}
3715
+            if ( 'none' == $this->get_gateway() ) {
3716
+                $_note = $note;
3717
+            }
3718 3718
 
3719
-			$this->set_status( 'publish',$_note );
3719
+            $this->set_status( 'publish',$_note );
3720 3720
 
3721
-		}
3721
+        }
3722 3722
 
3723
-		// Set checkout mode.
3724
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3725
-		$this->set_mode( $mode );
3723
+        // Set checkout mode.
3724
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3725
+        $this->set_mode( $mode );
3726 3726
 
3727
-		// Save the invoice.
3727
+        // Save the invoice.
3728 3728
         $this->save();
3729
-	}
3730
-
3731
-
3732
-	/**
3733
-	 * Save data to the database.
3734
-	 *
3735
-	 * @since 1.0.19
3736
-	 * @return int invoice ID
3737
-	 */
3738
-	public function save() {
3739
-		$this->maybe_set_date_paid();
3740
-		parent::save();
3741
-		$this->status_transition();
3742
-		return $this->get_id();
3743
-	}
3729
+    }
3730
+
3731
+
3732
+    /**
3733
+     * Save data to the database.
3734
+     *
3735
+     * @since 1.0.19
3736
+     * @return int invoice ID
3737
+     */
3738
+    public function save() {
3739
+        $this->maybe_set_date_paid();
3740
+        parent::save();
3741
+        $this->status_transition();
3742
+        return $this->get_id();
3743
+    }
3744 3744
 
3745 3745
 }
Please login to merge, or discard this patch.
Spacing   +747 added lines, -747 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
     /**
@@ -1393,7 +1393,7 @@  discard block
 block discarded – undo
1393 1393
 	 */
1394 1394
     public function get_initial_total() {
1395 1395
 
1396
-		if ( empty( $this->totals ) ) {
1396
+		if (empty($this->totals)) {
1397 1397
 			$this->recalculate_total();
1398 1398
 		}
1399 1399
 
@@ -1403,11 +1403,11 @@  discard block
 block discarded – undo
1403 1403
 		$subtotal = $this->totals['subtotal']['initial'];
1404 1404
 		$total    = $tax + $fee - $discount + $subtotal;
1405 1405
 
1406
-		if ( 0 > $total ) {
1406
+		if (0 > $total) {
1407 1407
 			$total = 0;
1408 1408
 		}
1409 1409
 
1410
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1410
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1411 1411
 	}
1412 1412
 
1413 1413
 	/**
@@ -1419,7 +1419,7 @@  discard block
 block discarded – undo
1419 1419
 	 */
1420 1420
     public function get_recurring_total() {
1421 1421
 
1422
-		if ( empty( $this->totals ) ) {
1422
+		if (empty($this->totals)) {
1423 1423
 			$this->recalculate_total();
1424 1424
 		}
1425 1425
 
@@ -1429,11 +1429,11 @@  discard block
 block discarded – undo
1429 1429
 		$subtotal = $this->totals['subtotal']['recurring'];
1430 1430
 		$total    = $tax + $fee - $discount + $subtotal;
1431 1431
 
1432
-		if ( 0 > $total ) {
1432
+		if (0 > $total) {
1433 1433
 			$total = 0;
1434 1434
 		}
1435 1435
 
1436
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1436
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1437 1437
 	}
1438 1438
 
1439 1439
 	/**
@@ -1444,10 +1444,10 @@  discard block
 block discarded – undo
1444 1444
 	 * @param string $currency Whether to include the currency.
1445 1445
      * @return float
1446 1446
 	 */
1447
-    public function get_recurring_details( $field = '', $currency = false ) {
1447
+    public function get_recurring_details($field = '', $currency = false) {
1448 1448
 
1449 1449
 		// Maybe recalculate totals.
1450
-		if ( empty( $this->totals ) ) {
1450
+		if (empty($this->totals)) {
1451 1451
 			$this->recalculate_total();
1452 1452
 		}
1453 1453
 
@@ -1467,8 +1467,8 @@  discard block
 block discarded – undo
1467 1467
 			$currency
1468 1468
 		);
1469 1469
 
1470
-        if ( isset( $data[$field] ) ) {
1471
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1470
+        if (isset($data[$field])) {
1471
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1472 1472
         }
1473 1473
 
1474 1474
         return $data;
@@ -1481,8 +1481,8 @@  discard block
 block discarded – undo
1481 1481
 	 * @param  string $context View or edit context.
1482 1482
 	 * @return array
1483 1483
 	 */
1484
-	public function get_fees( $context = 'view' ) {
1485
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1484
+	public function get_fees($context = 'view') {
1485
+		return wpinv_parse_list($this->get_prop('fees', $context));
1486 1486
     }
1487 1487
 
1488 1488
     /**
@@ -1492,8 +1492,8 @@  discard block
 block discarded – undo
1492 1492
 	 * @param  string $context View or edit context.
1493 1493
 	 * @return array
1494 1494
 	 */
1495
-	public function get_discounts( $context = 'view' ) {
1496
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1495
+	public function get_discounts($context = 'view') {
1496
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1497 1497
     }
1498 1498
 
1499 1499
     /**
@@ -1503,8 +1503,8 @@  discard block
 block discarded – undo
1503 1503
 	 * @param  string $context View or edit context.
1504 1504
 	 * @return array
1505 1505
 	 */
1506
-	public function get_taxes( $context = 'view' ) {
1507
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1506
+	public function get_taxes($context = 'view') {
1507
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1508 1508
     }
1509 1509
 
1510 1510
     /**
@@ -1514,8 +1514,8 @@  discard block
 block discarded – undo
1514 1514
 	 * @param  string $context View or edit context.
1515 1515
 	 * @return GetPaid_Form_Item[]
1516 1516
 	 */
1517
-	public function get_items( $context = 'view' ) {
1518
-        return $this->get_prop( 'items', $context );
1517
+	public function get_items($context = 'view') {
1518
+        return $this->get_prop('items', $context);
1519 1519
     }
1520 1520
 
1521 1521
     /**
@@ -1525,8 +1525,8 @@  discard block
 block discarded – undo
1525 1525
 	 * @param  string $context View or edit context.
1526 1526
 	 * @return int
1527 1527
 	 */
1528
-	public function get_payment_form( $context = 'view' ) {
1529
-		return intval( $this->get_prop( 'payment_form', $context ) );
1528
+	public function get_payment_form($context = 'view') {
1529
+		return intval($this->get_prop('payment_form', $context));
1530 1530
     }
1531 1531
 
1532 1532
     /**
@@ -1536,8 +1536,8 @@  discard block
 block discarded – undo
1536 1536
 	 * @param  string $context View or edit context.
1537 1537
 	 * @return string
1538 1538
 	 */
1539
-	public function get_submission_id( $context = 'view' ) {
1540
-		return $this->get_prop( 'submission_id', $context );
1539
+	public function get_submission_id($context = 'view') {
1540
+		return $this->get_prop('submission_id', $context);
1541 1541
     }
1542 1542
 
1543 1543
     /**
@@ -1547,8 +1547,8 @@  discard block
 block discarded – undo
1547 1547
 	 * @param  string $context View or edit context.
1548 1548
 	 * @return string
1549 1549
 	 */
1550
-	public function get_discount_code( $context = 'view' ) {
1551
-		return $this->get_prop( 'discount_code', $context );
1550
+	public function get_discount_code($context = 'view') {
1551
+		return $this->get_prop('discount_code', $context);
1552 1552
     }
1553 1553
 
1554 1554
     /**
@@ -1558,8 +1558,8 @@  discard block
 block discarded – undo
1558 1558
 	 * @param  string $context View or edit context.
1559 1559
 	 * @return string
1560 1560
 	 */
1561
-	public function get_gateway( $context = 'view' ) {
1562
-		return $this->get_prop( 'gateway', $context );
1561
+	public function get_gateway($context = 'view') {
1562
+		return $this->get_prop('gateway', $context);
1563 1563
     }
1564 1564
 
1565 1565
     /**
@@ -1569,8 +1569,8 @@  discard block
 block discarded – undo
1569 1569
 	 * @return string
1570 1570
 	 */
1571 1571
     public function get_gateway_title() {
1572
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1573
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1572
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1573
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1574 1574
     }
1575 1575
 
1576 1576
     /**
@@ -1580,8 +1580,8 @@  discard block
 block discarded – undo
1580 1580
 	 * @param  string $context View or edit context.
1581 1581
 	 * @return string
1582 1582
 	 */
1583
-	public function get_transaction_id( $context = 'view' ) {
1584
-		return $this->get_prop( 'transaction_id', $context );
1583
+	public function get_transaction_id($context = 'view') {
1584
+		return $this->get_prop('transaction_id', $context);
1585 1585
     }
1586 1586
 
1587 1587
     /**
@@ -1591,9 +1591,9 @@  discard block
 block discarded – undo
1591 1591
 	 * @param  string $context View or edit context.
1592 1592
 	 * @return string
1593 1593
 	 */
1594
-	public function get_currency( $context = 'view' ) {
1595
-        $currency = $this->get_prop( 'currency', $context );
1596
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1594
+	public function get_currency($context = 'view') {
1595
+        $currency = $this->get_prop('currency', $context);
1596
+        return empty($currency) ? wpinv_get_currency() : $currency;
1597 1597
     }
1598 1598
 
1599 1599
     /**
@@ -1603,8 +1603,8 @@  discard block
 block discarded – undo
1603 1603
 	 * @param  string $context View or edit context.
1604 1604
 	 * @return bool
1605 1605
 	 */
1606
-	public function get_disable_taxes( $context = 'view' ) {
1607
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1606
+	public function get_disable_taxes($context = 'view') {
1607
+        return (bool) $this->get_prop('disable_taxes', $context);
1608 1608
     }
1609 1609
 
1610 1610
     /**
@@ -1614,12 +1614,12 @@  discard block
 block discarded – undo
1614 1614
 	 * @param  string $context View or edit context.
1615 1615
 	 * @return int
1616 1616
 	 */
1617
-    public function get_subscription_id( $context = 'view' ) {
1618
-        $subscription_id = $this->get_prop( 'subscription_id', $context );
1617
+    public function get_subscription_id($context = 'view') {
1618
+        $subscription_id = $this->get_prop('subscription_id', $context);
1619 1619
 
1620
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1620
+        if (empty($subscription_id) && $this->is_renewal()) {
1621 1621
             $parent = $this->get_parent();
1622
-            return $parent->get_subscription_id( $context );
1622
+            return $parent->get_subscription_id($context);
1623 1623
         }
1624 1624
 
1625 1625
         return $subscription_id;
@@ -1632,20 +1632,20 @@  discard block
 block discarded – undo
1632 1632
 	 * @param  string $context View or edit context.
1633 1633
 	 * @return array
1634 1634
 	 */
1635
-    public function get_payment_meta( $context = 'view' ) {
1635
+    public function get_payment_meta($context = 'view') {
1636 1636
 
1637 1637
         return array(
1638
-            'price'        => $this->get_total( $context ),
1639
-            'date'         => $this->get_date_created( $context ),
1640
-            'user_email'   => $this->get_email( $context ),
1641
-            'invoice_key'  => $this->get_key( $context ),
1642
-            'currency'     => $this->get_currency( $context ),
1643
-            'items'        => $this->get_items( $context ),
1644
-            'user_info'    => $this->get_user_info( $context ),
1638
+            'price'        => $this->get_total($context),
1639
+            'date'         => $this->get_date_created($context),
1640
+            'user_email'   => $this->get_email($context),
1641
+            'invoice_key'  => $this->get_key($context),
1642
+            'currency'     => $this->get_currency($context),
1643
+            'items'        => $this->get_items($context),
1644
+            'user_info'    => $this->get_user_info($context),
1645 1645
             'cart_details' => $this->get_cart_details(),
1646
-            'status'       => $this->get_status( $context ),
1647
-            'fees'         => $this->get_fees( $context ),
1648
-            'taxes'        => $this->get_taxes( $context ),
1646
+            'status'       => $this->get_status($context),
1647
+            'fees'         => $this->get_fees($context),
1648
+            'taxes'        => $this->get_taxes($context),
1649 1649
         );
1650 1650
 
1651 1651
     }
@@ -1660,7 +1660,7 @@  discard block
 block discarded – undo
1660 1660
         $items        = $this->get_items();
1661 1661
         $cart_details = array();
1662 1662
 
1663
-        foreach ( $items as $item_id => $item ) {
1663
+        foreach ($items as $item_id => $item) {
1664 1664
             $cart_details[] = $item->prepare_data_for_saving();
1665 1665
         }
1666 1666
 
@@ -1672,11 +1672,11 @@  discard block
 block discarded – undo
1672 1672
 	 *
1673 1673
 	 * @return null|GetPaid_Form_Item|int
1674 1674
 	 */
1675
-	public function get_recurring( $object = false ) {
1675
+	public function get_recurring($object = false) {
1676 1676
 
1677 1677
 		// Are we returning an object?
1678
-        if ( $object ) {
1679
-            return $this->get_item( $this->recurring_item );
1678
+        if ($object) {
1679
+            return $this->get_item($this->recurring_item);
1680 1680
         }
1681 1681
 
1682 1682
         return $this->recurring_item;
@@ -1691,15 +1691,15 @@  discard block
 block discarded – undo
1691 1691
 	public function get_subscription_name() {
1692 1692
 
1693 1693
 		// Retrieve the recurring name
1694
-        $item = $this->get_recurring( true );
1694
+        $item = $this->get_recurring(true);
1695 1695
 
1696 1696
 		// Abort if it does not exist.
1697
-        if ( empty( $item ) ) {
1697
+        if (empty($item)) {
1698 1698
             return '';
1699 1699
         }
1700 1700
 
1701 1701
 		// Return the item name.
1702
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1702
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1703 1703
 	}
1704 1704
 
1705 1705
 	/**
@@ -1709,9 +1709,9 @@  discard block
 block discarded – undo
1709 1709
 	 * @return string
1710 1710
 	 */
1711 1711
 	public function get_view_url() {
1712
-        $invoice_url = get_permalink( $this->get_id() );
1713
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1714
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1712
+        $invoice_url = get_permalink($this->get_id());
1713
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1714
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1715 1715
 	}
1716 1716
 
1717 1717
 	/**
@@ -1720,25 +1720,25 @@  discard block
 block discarded – undo
1720 1720
 	 * @since 1.0.19
1721 1721
 	 * @return string
1722 1722
 	 */
1723
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1723
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1724 1724
 
1725 1725
 		// Retrieve the checkout url.
1726 1726
         $pay_url = wpinv_get_checkout_uri();
1727 1727
 
1728 1728
 		// Maybe force ssl.
1729
-        if ( is_ssl() ) {
1730
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1729
+        if (is_ssl()) {
1730
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1731 1731
         }
1732 1732
 
1733 1733
 		// Add the invoice key.
1734
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1734
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1735 1735
 
1736 1736
 		// (Maybe?) add a secret
1737
-        if ( $secret ) {
1738
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1737
+        if ($secret) {
1738
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1739 1739
         }
1740 1740
 
1741
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1741
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1742 1742
 	}
1743 1743
 	
1744 1744
 	/**
@@ -1753,14 +1753,14 @@  discard block
 block discarded – undo
1753 1753
         $receipt_url = wpinv_get_success_page_uri();
1754 1754
 
1755 1755
 		// Maybe force ssl.
1756
-        if ( is_ssl() ) {
1757
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1756
+        if (is_ssl()) {
1757
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1758 1758
         }
1759 1759
 
1760 1760
 		// Add the invoice key.
1761
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1761
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1762 1762
 
1763
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1763
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1764 1764
     }
1765 1765
 
1766 1766
     /**
@@ -1773,8 +1773,8 @@  discard block
 block discarded – undo
1773 1773
 	 * @param  string $context View or edit context.
1774 1774
 	 * @return mixed Value of the given invoice property (if set).
1775 1775
 	 */
1776
-	public function get( $key, $context = 'view' ) {
1777
-        return $this->get_prop( $key, $context );
1776
+	public function get($key, $context = 'view') {
1777
+        return $this->get_prop($key, $context);
1778 1778
 	}
1779 1779
 
1780 1780
     /*
@@ -1797,11 +1797,11 @@  discard block
 block discarded – undo
1797 1797
 	 * @param  mixed $value new value.
1798 1798
 	 * @return mixed Value of the given invoice property (if set).
1799 1799
 	 */
1800
-	public function set( $key, $value ) {
1800
+	public function set($key, $value) {
1801 1801
 
1802 1802
         $setter = "set_$key";
1803
-        if ( is_callable( array( $this, $setter ) ) ) {
1804
-            $this->{$setter}( $value );
1803
+        if (is_callable(array($this, $setter))) {
1804
+            $this->{$setter}($value);
1805 1805
         }
1806 1806
 
1807 1807
 	}
@@ -1815,48 +1815,48 @@  discard block
 block discarded – undo
1815 1815
 	 * @param bool   $manual_update Is this a manual status change?.
1816 1816
 	 * @return array details of change.
1817 1817
 	 */
1818
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1818
+	public function set_status($new_status, $note = '', $manual_update = false) {
1819 1819
 		$old_status = $this->get_status();
1820 1820
 
1821 1821
 		$statuses = $this->get_all_statuses();
1822 1822
 
1823
-		if ( isset( $statuses[ 'draft' ] ) ) {
1824
-			unset( $statuses[ 'draft' ] );
1823
+		if (isset($statuses['draft'])) {
1824
+			unset($statuses['draft']);
1825 1825
 		}
1826 1826
 
1827 1827
 
1828
-		$this->set_prop( 'status', $new_status );
1828
+		$this->set_prop('status', $new_status);
1829 1829
 
1830 1830
 		// If setting the status, ensure it's set to a valid status.
1831
-		if ( true === $this->object_read ) {
1831
+		if (true === $this->object_read) {
1832 1832
 
1833 1833
 			// Only allow valid new status.
1834
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1834
+			if (!array_key_exists($new_status, $statuses)) {
1835 1835
 				$new_status = 'wpi-pending';
1836 1836
 			}
1837 1837
 
1838 1838
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1839
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1839
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1840 1840
 				$old_status = 'wpi-pending';
1841 1841
 			}
1842 1842
 
1843 1843
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1844
-			if ( $new_status == 'wpi-renewal' && $old_status == 'publish' ) {
1844
+			if ($new_status == 'wpi-renewal' && $old_status == 'publish') {
1845 1845
 				$old_status = 'wpi-pending';
1846 1846
 			}
1847 1847
 
1848 1848
 		}
1849 1849
 
1850
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1850
+		if (true === $this->object_read && $old_status !== $new_status) {
1851 1851
 			$this->status_transition = array(
1852
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1852
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1853 1853
 				'to'     => $new_status,
1854 1854
 				'note'   => $note,
1855 1855
 				'manual' => (bool) $manual_update,
1856 1856
 			);
1857 1857
 
1858
-			if ( $manual_update ) {
1859
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1858
+			if ($manual_update) {
1859
+				do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1860 1860
 			}
1861 1861
 
1862 1862
 			$this->maybe_set_date_paid();
@@ -1879,8 +1879,8 @@  discard block
 block discarded – undo
1879 1879
 	 */
1880 1880
 	public function maybe_set_date_paid() {
1881 1881
 
1882
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1883
-			$this->set_date_completed( current_time( 'mysql' ) );
1882
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
1883
+			$this->set_date_completed(current_time('mysql'));
1884 1884
 		}
1885 1885
 	}
1886 1886
 
@@ -1889,11 +1889,11 @@  discard block
 block discarded – undo
1889 1889
 	 *
1890 1890
 	 * @since 1.0.19
1891 1891
 	 */
1892
-	public function set_parent_id( $value ) {
1893
-		if ( $value && ( $value === $this->get_id() ) ) {
1892
+	public function set_parent_id($value) {
1893
+		if ($value && ($value === $this->get_id())) {
1894 1894
 			return;
1895 1895
 		}
1896
-		$this->set_prop( 'parent_id', absint( $value ) );
1896
+		$this->set_prop('parent_id', absint($value));
1897 1897
     }
1898 1898
 
1899 1899
     /**
@@ -1901,8 +1901,8 @@  discard block
 block discarded – undo
1901 1901
 	 *
1902 1902
 	 * @since 1.0.19
1903 1903
 	 */
1904
-	public function set_version( $value ) {
1905
-		$this->set_prop( 'version', $value );
1904
+	public function set_version($value) {
1905
+		$this->set_prop('version', $value);
1906 1906
     }
1907 1907
 
1908 1908
     /**
@@ -1912,15 +1912,15 @@  discard block
 block discarded – undo
1912 1912
 	 * @param string $value Value to set.
1913 1913
      * @return bool Whether or not the date was set.
1914 1914
 	 */
1915
-	public function set_date_created( $value ) {
1916
-        $date = strtotime( $value );
1915
+	public function set_date_created($value) {
1916
+        $date = strtotime($value);
1917 1917
 
1918
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1919
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
1918
+        if ($date && $value !== '0000-00-00 00:00:00') {
1919
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
1920 1920
             return true;
1921 1921
         }
1922 1922
 
1923
-        return $this->set_prop( 'date_created', '' );
1923
+        return $this->set_prop('date_created', '');
1924 1924
 
1925 1925
     }
1926 1926
 
@@ -1931,15 +1931,15 @@  discard block
 block discarded – undo
1931 1931
 	 * @param string $value Value to set.
1932 1932
      * @return bool Whether or not the date was set.
1933 1933
 	 */
1934
-	public function set_due_date( $value ) {
1935
-        $date = strtotime( $value );
1934
+	public function set_due_date($value) {
1935
+        $date = strtotime($value);
1936 1936
 
1937
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1938
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
1937
+        if ($date && $value !== '0000-00-00 00:00:00') {
1938
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
1939 1939
             return true;
1940 1940
         }
1941 1941
 
1942
-		$this->set_prop( 'due_date', '' );
1942
+		$this->set_prop('due_date', '');
1943 1943
         return false;
1944 1944
 
1945 1945
     }
@@ -1950,8 +1950,8 @@  discard block
 block discarded – undo
1950 1950
 	 * @since 1.0.19
1951 1951
 	 * @param  string $value New name.
1952 1952
 	 */
1953
-	public function set_date_due( $value ) {
1954
-		$this->set_due_date( $value );
1953
+	public function set_date_due($value) {
1954
+		$this->set_due_date($value);
1955 1955
     }
1956 1956
 
1957 1957
     /**
@@ -1961,15 +1961,15 @@  discard block
 block discarded – undo
1961 1961
 	 * @param string $value Value to set.
1962 1962
      * @return bool Whether or not the date was set.
1963 1963
 	 */
1964
-	public function set_completed_date( $value ) {
1965
-        $date = strtotime( $value );
1964
+	public function set_completed_date($value) {
1965
+        $date = strtotime($value);
1966 1966
 
1967
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
1968
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
1967
+        if ($date && $value !== '0000-00-00 00:00:00') {
1968
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
1969 1969
             return true;
1970 1970
         }
1971 1971
 
1972
-		$this->set_prop( 'completed_date', '' );
1972
+		$this->set_prop('completed_date', '');
1973 1973
         return false;
1974 1974
 
1975 1975
     }
@@ -1980,8 +1980,8 @@  discard block
 block discarded – undo
1980 1980
 	 * @since 1.0.19
1981 1981
 	 * @param  string $value New name.
1982 1982
 	 */
1983
-	public function set_date_completed( $value ) {
1984
-		$this->set_completed_date( $value );
1983
+	public function set_date_completed($value) {
1984
+		$this->set_completed_date($value);
1985 1985
     }
1986 1986
 
1987 1987
     /**
@@ -1991,15 +1991,15 @@  discard block
 block discarded – undo
1991 1991
 	 * @param string $value Value to set.
1992 1992
      * @return bool Whether or not the date was set.
1993 1993
 	 */
1994
-	public function set_date_modified( $value ) {
1995
-        $date = strtotime( $value );
1994
+	public function set_date_modified($value) {
1995
+        $date = strtotime($value);
1996 1996
 
1997
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1998
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
1997
+        if ($date && $value !== '0000-00-00 00:00:00') {
1998
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
1999 1999
             return true;
2000 2000
         }
2001 2001
 
2002
-		$this->set_prop( 'date_modified', '' );
2002
+		$this->set_prop('date_modified', '');
2003 2003
         return false;
2004 2004
 
2005 2005
     }
@@ -2010,9 +2010,9 @@  discard block
 block discarded – undo
2010 2010
 	 * @since 1.0.19
2011 2011
 	 * @param  string $value New number.
2012 2012
 	 */
2013
-	public function set_number( $value ) {
2014
-        $number = sanitize_text_field( $value );
2015
-		$this->set_prop( 'number', $number );
2013
+	public function set_number($value) {
2014
+        $number = sanitize_text_field($value);
2015
+		$this->set_prop('number', $number);
2016 2016
     }
2017 2017
 
2018 2018
     /**
@@ -2021,9 +2021,9 @@  discard block
 block discarded – undo
2021 2021
 	 * @since 1.0.19
2022 2022
 	 * @param  string $value Type.
2023 2023
 	 */
2024
-	public function set_type( $value ) {
2025
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2026
-		$this->set_prop( 'type', $type );
2024
+	public function set_type($value) {
2025
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2026
+		$this->set_prop('type', $type);
2027 2027
 	}
2028 2028
 
2029 2029
     /**
@@ -2032,10 +2032,10 @@  discard block
 block discarded – undo
2032 2032
 	 * @since 1.0.19
2033 2033
 	 * @param  string $value Post type.
2034 2034
 	 */
2035
-	public function set_post_type( $value ) {
2036
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2037
-			$this->set_type( $value );
2038
-            $this->set_prop( 'post_type', $value );
2035
+	public function set_post_type($value) {
2036
+        if (getpaid_is_invoice_post_type($value)) {
2037
+			$this->set_type($value);
2038
+            $this->set_prop('post_type', $value);
2039 2039
         }
2040 2040
     }
2041 2041
 
@@ -2045,9 +2045,9 @@  discard block
 block discarded – undo
2045 2045
 	 * @since 1.0.19
2046 2046
 	 * @param  string $value New key.
2047 2047
 	 */
2048
-	public function set_key( $value ) {
2049
-        $key = sanitize_text_field( $value );
2050
-		$this->set_prop( 'key', $key );
2048
+	public function set_key($value) {
2049
+        $key = sanitize_text_field($value);
2050
+		$this->set_prop('key', $key);
2051 2051
     }
2052 2052
 
2053 2053
     /**
@@ -2056,9 +2056,9 @@  discard block
 block discarded – undo
2056 2056
 	 * @since 1.0.19
2057 2057
 	 * @param  string $value mode.
2058 2058
 	 */
2059
-	public function set_mode( $value ) {
2060
-        if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2061
-            $this->set_prop( 'value', $value );
2059
+	public function set_mode($value) {
2060
+        if (!in_array($value, array('live', 'test'))) {
2061
+            $this->set_prop('value', $value);
2062 2062
         }
2063 2063
     }
2064 2064
 
@@ -2068,8 +2068,8 @@  discard block
 block discarded – undo
2068 2068
 	 * @since 1.0.19
2069 2069
 	 * @param  string $value path.
2070 2070
 	 */
2071
-	public function set_path( $value ) {
2072
-        $this->set_prop( 'path', $value );
2071
+	public function set_path($value) {
2072
+        $this->set_prop('path', $value);
2073 2073
     }
2074 2074
 
2075 2075
     /**
@@ -2078,9 +2078,9 @@  discard block
 block discarded – undo
2078 2078
 	 * @since 1.0.19
2079 2079
 	 * @param  string $value New name.
2080 2080
 	 */
2081
-	public function set_name( $value ) {
2082
-        $name = sanitize_text_field( $value );
2083
-		$this->set_prop( 'name', $name );
2081
+	public function set_name($value) {
2082
+        $name = sanitize_text_field($value);
2083
+		$this->set_prop('name', $name);
2084 2084
     }
2085 2085
 
2086 2086
     /**
@@ -2089,8 +2089,8 @@  discard block
 block discarded – undo
2089 2089
 	 * @since 1.0.19
2090 2090
 	 * @param  string $value New name.
2091 2091
 	 */
2092
-	public function set_title( $value ) {
2093
-		$this->set_name( $value );
2092
+	public function set_title($value) {
2093
+		$this->set_name($value);
2094 2094
     }
2095 2095
 
2096 2096
     /**
@@ -2099,9 +2099,9 @@  discard block
 block discarded – undo
2099 2099
 	 * @since 1.0.19
2100 2100
 	 * @param  string $value New description.
2101 2101
 	 */
2102
-	public function set_description( $value ) {
2103
-        $description = wp_kses_post( $value );
2104
-		return $this->set_prop( 'description', $description );
2102
+	public function set_description($value) {
2103
+        $description = wp_kses_post($value);
2104
+		return $this->set_prop('description', $description);
2105 2105
     }
2106 2106
 
2107 2107
     /**
@@ -2110,8 +2110,8 @@  discard block
 block discarded – undo
2110 2110
 	 * @since 1.0.19
2111 2111
 	 * @param  string $value New description.
2112 2112
 	 */
2113
-	public function set_excerpt( $value ) {
2114
-		$this->set_description( $value );
2113
+	public function set_excerpt($value) {
2114
+		$this->set_description($value);
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_summary( $value ) {
2124
-		$this->set_description( $value );
2123
+	public function set_summary($value) {
2124
+		$this->set_description($value);
2125 2125
     }
2126 2126
 
2127 2127
     /**
@@ -2130,12 +2130,12 @@  discard block
 block discarded – undo
2130 2130
 	 * @since 1.0.19
2131 2131
 	 * @param  int $value New author.
2132 2132
 	 */
2133
-	public function set_author( $value ) {
2134
-		$user = get_user_by( 'id', (int) $value );
2133
+	public function set_author($value) {
2134
+		$user = get_user_by('id', (int) $value);
2135 2135
 
2136
-		if ( $user && $user->ID ) {
2137
-			$this->set_prop( 'author', $user->ID );
2138
-			$this->set_prop( 'email', $user->user_email );
2136
+		if ($user && $user->ID) {
2137
+			$this->set_prop('author', $user->ID);
2138
+			$this->set_prop('email', $user->user_email);
2139 2139
 		}
2140 2140
 		
2141 2141
     }
@@ -2146,8 +2146,8 @@  discard block
 block discarded – undo
2146 2146
 	 * @since 1.0.19
2147 2147
 	 * @param  int $value New user id.
2148 2148
 	 */
2149
-	public function set_user_id( $value ) {
2150
-		$this->set_author( $value );
2149
+	public function set_user_id($value) {
2150
+		$this->set_author($value);
2151 2151
     }
2152 2152
 
2153 2153
     /**
@@ -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_customer_id( $value ) {
2160
-		$this->set_author( $value );
2159
+	public function set_customer_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  string $value ip address.
2168 2168
 	 */
2169
-	public function set_ip( $value ) {
2170
-		$this->set_prop( 'ip', $value );
2169
+	public function set_ip($value) {
2170
+		$this->set_prop('ip', $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_user_ip( $value ) {
2180
-		$this->set_ip( $value );
2179
+	public function set_user_ip($value) {
2180
+		$this->set_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 first name.
2188 2188
 	 */
2189
-	public function set_first_name( $value ) {
2190
-		$this->set_prop( 'first_name', $value );
2189
+	public function set_first_name($value) {
2190
+		$this->set_prop('first_name', $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_user_first_name( $value ) {
2200
-		$this->set_first_name( $value );
2199
+	public function set_user_first_name($value) {
2200
+		$this->set_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_customer_first_name( $value ) {
2210
-		$this->set_first_name( $value );
2209
+	public function set_customer_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 last name.
2218 2218
 	 */
2219
-	public function set_last_name( $value ) {
2220
-		$this->set_prop( 'last_name', $value );
2219
+	public function set_last_name($value) {
2220
+		$this->set_prop('last_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_user_last_name( $value ) {
2230
-		$this->set_last_name( $value );
2229
+	public function set_user_last_name($value) {
2230
+		$this->set_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_customer_last_name( $value ) {
2240
-		$this->set_last_name( $value );
2239
+	public function set_customer_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 phone.
2248 2248
 	 */
2249
-	public function set_phone( $value ) {
2250
-		$this->set_prop( 'phone', $value );
2249
+	public function set_phone($value) {
2250
+		$this->set_prop('phone', $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_user_phone( $value ) {
2260
-		$this->set_phone( $value );
2259
+	public function set_user_phone($value) {
2260
+		$this->set_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_customer_phone( $value ) {
2270
-		$this->set_phone( $value );
2269
+	public function set_customer_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_phone_number( $value ) {
2280
-		$this->set_phone( $value );
2279
+	public function set_phone_number($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 email address.
2288 2288
 	 */
2289
-	public function set_email( $value ) {
2290
-		$this->set_prop( 'email', $value );
2289
+	public function set_email($value) {
2290
+		$this->set_prop('email', $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_user_email( $value ) {
2300
-		$this->set_email( $value );
2299
+	public function set_user_email($value) {
2300
+		$this->set_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_email_address( $value ) {
2310
-		$this->set_email( $value );
2309
+	public function set_email_address($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_customer_email( $value ) {
2320
-		$this->set_email( $value );
2319
+	public function set_customer_email($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 country.
2328 2328
 	 */
2329
-	public function set_country( $value ) {
2330
-		$this->set_prop( 'country', $value );
2329
+	public function set_country($value) {
2330
+		$this->set_prop('country', $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_user_country( $value ) {
2340
-		$this->set_country( $value );
2339
+	public function set_user_country($value) {
2340
+		$this->set_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_customer_country( $value ) {
2350
-		$this->set_country( $value );
2349
+	public function set_customer_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 state.
2358 2358
 	 */
2359
-	public function set_state( $value ) {
2360
-		$this->set_prop( 'state', $value );
2359
+	public function set_state($value) {
2360
+		$this->set_prop('state', $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_user_state( $value ) {
2370
-		$this->set_state( $value );
2369
+	public function set_user_state($value) {
2370
+		$this->set_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_customer_state( $value ) {
2380
-		$this->set_state( $value );
2379
+	public function set_customer_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 city.
2388 2388
 	 */
2389
-	public function set_city( $value ) {
2390
-		$this->set_prop( 'city', $value );
2389
+	public function set_city($value) {
2390
+		$this->set_prop('city', $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_user_city( $value ) {
2400
-		$this->set_city( $value );
2399
+	public function set_user_city($value) {
2400
+		$this->set_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_customer_city( $value ) {
2410
-		$this->set_city( $value );
2409
+	public function set_customer_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 zip.
2418 2418
 	 */
2419
-	public function set_zip( $value ) {
2420
-		$this->set_prop( 'zip', $value );
2419
+	public function set_zip($value) {
2420
+		$this->set_prop('zip', $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_user_zip( $value ) {
2430
-		$this->set_zip( $value );
2429
+	public function set_user_zip($value) {
2430
+		$this->set_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_customer_zip( $value ) {
2440
-		$this->set_zip( $value );
2439
+	public function set_customer_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 company.
2448 2448
 	 */
2449
-	public function set_company( $value ) {
2450
-		$this->set_prop( 'company', $value );
2449
+	public function set_company($value) {
2450
+		$this->set_prop('company', $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_user_company( $value ) {
2460
-		$this->set_company( $value );
2459
+	public function set_user_company($value) {
2460
+		$this->set_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_customer_company( $value ) {
2470
-		$this->set_company( $value );
2469
+	public function set_customer_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 var number.
2478 2478
 	 */
2479
-	public function set_vat_number( $value ) {
2480
-		$this->set_prop( 'vat_number', $value );
2479
+	public function set_vat_number($value) {
2480
+		$this->set_prop('vat_number', $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_user_vat_number( $value ) {
2490
-		$this->set_vat_number( $value );
2489
+	public function set_user_vat_number($value) {
2490
+		$this->set_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_customer_vat_number( $value ) {
2500
-		$this->set_vat_number( $value );
2499
+	public function set_customer_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 rate.
2508 2508
 	 */
2509
-	public function set_vat_rate( $value ) {
2510
-		$this->set_prop( 'vat_rate', $value );
2509
+	public function set_vat_rate($value) {
2510
+		$this->set_prop('vat_rate', $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 number.
2518 2518
 	 */
2519
-	public function set_user_vat_rate( $value ) {
2520
-		$this->set_vat_rate( $value );
2519
+	public function set_user_vat_rate($value) {
2520
+		$this->set_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_customer_vat_rate( $value ) {
2530
-		$this->set_vat_rate( $value );
2529
+	public function set_customer_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 address.
2538 2538
 	 */
2539
-	public function set_address( $value ) {
2540
-		$this->set_prop( 'address', $value );
2539
+	public function set_address($value) {
2540
+		$this->set_prop('address', $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_user_address( $value ) {
2550
-		$this->set_address( $value );
2549
+	public function set_user_address($value) {
2550
+		$this->set_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_customer_address( $value ) {
2560
-		$this->set_address( $value );
2559
+	public function set_customer_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  int|bool $value confirmed.
2568 2568
 	 */
2569
-	public function set_is_viewed( $value ) {
2570
-		$this->set_prop( 'is_viewed', $value );
2569
+	public function set_is_viewed($value) {
2570
+		$this->set_prop('is_viewed', $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  string $value email recipients.
2578 2578
 	 */
2579
-	public function set_email_cc( $value ) {
2580
-		$this->set_prop( 'email_cc', $value );
2579
+	public function set_email_cc($value) {
2580
+		$this->set_prop('email_cc', $value);
2581 2581
 	}
2582 2582
 
2583 2583
 	/**
@@ -2586,9 +2586,9 @@  discard block
 block discarded – undo
2586 2586
 	 * @since 1.0.19
2587 2587
 	 * @param  string $value email recipients.
2588 2588
 	 */
2589
-	public function set_template( $value ) {
2590
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2591
-			$this->set_prop( 'template', $value );
2589
+	public function set_template($value) {
2590
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2591
+			$this->set_prop('template', $value);
2592 2592
 		}
2593 2593
 	}
2594 2594
 
@@ -2598,8 +2598,8 @@  discard block
 block discarded – undo
2598 2598
 	 * @since 1.0.19
2599 2599
 	 * @param  int|bool $value confirmed.
2600 2600
 	 */
2601
-	public function set_address_confirmed( $value ) {
2602
-		$this->set_prop( 'address_confirmed', $value );
2601
+	public function set_address_confirmed($value) {
2602
+		$this->set_prop('address_confirmed', $value);
2603 2603
     }
2604 2604
 
2605 2605
     /**
@@ -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_user_address_confirmed( $value ) {
2612
-		$this->set_address_confirmed( $value );
2611
+	public function set_user_address_confirmed($value) {
2612
+		$this->set_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_customer_address_confirmed( $value ) {
2622
-		$this->set_address_confirmed( $value );
2621
+	public function set_customer_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  float $value sub total.
2630 2630
 	 */
2631
-	public function set_subtotal( $value ) {
2632
-		$this->set_prop( 'subtotal', $value );
2631
+	public function set_subtotal($value) {
2632
+		$this->set_prop('subtotal', $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 discount total.
2640 2640
 	 */
2641
-	public function set_total_discount( $value ) {
2642
-		$this->set_prop( 'total_discount', $value );
2641
+	public function set_total_discount($value) {
2642
+		$this->set_prop('total_discount', $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_discount( $value ) {
2652
-		$this->set_total_discount( $value );
2651
+	public function set_discount($value) {
2652
+		$this->set_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 tax total.
2660 2660
 	 */
2661
-	public function set_total_tax( $value ) {
2662
-		$this->set_prop( 'total_tax', $value );
2661
+	public function set_total_tax($value) {
2662
+		$this->set_prop('total_tax', $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_tax_total( $value ) {
2672
-		$this->set_total_tax( $value );
2671
+	public function set_tax_total($value) {
2672
+		$this->set_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 fees total.
2680 2680
 	 */
2681
-	public function set_total_fees( $value ) {
2682
-		$this->set_prop( 'total_fees', $value );
2681
+	public function set_total_fees($value) {
2682
+		$this->set_prop('total_fees', $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_fees_total( $value ) {
2692
-		$this->set_total_fees( $value );
2691
+	public function set_fees_total($value) {
2692
+		$this->set_total_fees($value);
2693 2693
     }
2694 2694
 
2695 2695
     /**
@@ -2698,18 +2698,18 @@  discard block
 block discarded – undo
2698 2698
 	 * @since 1.0.19
2699 2699
 	 * @param  array $value fees.
2700 2700
 	 */
2701
-	public function set_fees( $value ) {
2701
+	public function set_fees($value) {
2702 2702
 
2703
-        $this->set_prop( 'fees', array() );
2703
+        $this->set_prop('fees', array());
2704 2704
 
2705 2705
         // Ensure that we have an array.
2706
-        if ( ! is_array( $value ) ) {
2706
+        if (!is_array($value)) {
2707 2707
             return;
2708 2708
         }
2709 2709
 
2710
-        foreach ( $value as $name => $data ) {
2711
-            if ( isset( $data['amount'] ) ) {
2712
-                $this->add_fee( $name, $data['amount'], $data['recurring'] );
2710
+        foreach ($value as $name => $data) {
2711
+            if (isset($data['amount'])) {
2712
+                $this->add_fee($name, $data['amount'], $data['recurring']);
2713 2713
             }
2714 2714
         }
2715 2715
 
@@ -2721,8 +2721,8 @@  discard block
 block discarded – undo
2721 2721
 	 * @since 1.0.19
2722 2722
 	 * @param  array $value taxes.
2723 2723
 	 */
2724
-	public function set_taxes( $value ) {
2725
-		$this->set_prop( 'taxes', $value );
2724
+	public function set_taxes($value) {
2725
+		$this->set_prop('taxes', $value);
2726 2726
     }
2727 2727
 
2728 2728
     /**
@@ -2731,17 +2731,17 @@  discard block
 block discarded – undo
2731 2731
 	 * @since 1.0.19
2732 2732
 	 * @param  array $value discounts.
2733 2733
 	 */
2734
-	public function set_discounts( $value ) {
2735
-		$this->set_prop( 'discounts', array() );
2734
+	public function set_discounts($value) {
2735
+		$this->set_prop('discounts', array());
2736 2736
 
2737 2737
         // Ensure that we have an array.
2738
-        if ( ! is_array( $value ) ) {
2738
+        if (!is_array($value)) {
2739 2739
             return;
2740 2740
         }
2741 2741
 
2742
-        foreach ( $value as $name => $data ) {
2743
-            if ( isset( $data['amount'] ) ) {
2744
-                $this->add_discount( $name, $data['amount'], $data['recurring'] );
2742
+        foreach ($value as $name => $data) {
2743
+            if (isset($data['amount'])) {
2744
+                $this->add_discount($name, $data['amount'], $data['recurring']);
2745 2745
             }
2746 2746
         }
2747 2747
     }
@@ -2752,18 +2752,18 @@  discard block
 block discarded – undo
2752 2752
 	 * @since 1.0.19
2753 2753
 	 * @param  GetPaid_Form_Item[] $value items.
2754 2754
 	 */
2755
-	public function set_items( $value ) {
2755
+	public function set_items($value) {
2756 2756
 
2757 2757
         // Remove existing items.
2758
-        $this->set_prop( 'items', array() );
2758
+        $this->set_prop('items', array());
2759 2759
 
2760 2760
         // Ensure that we have an array.
2761
-        if ( ! is_array( $value ) ) {
2761
+        if (!is_array($value)) {
2762 2762
             return;
2763 2763
         }
2764 2764
 
2765
-        foreach ( $value as $item ) {
2766
-            $this->add_item( $item );
2765
+        foreach ($value as $item) {
2766
+            $this->add_item($item);
2767 2767
         }
2768 2768
 
2769 2769
     }
@@ -2774,8 +2774,8 @@  discard block
 block discarded – undo
2774 2774
 	 * @since 1.0.19
2775 2775
 	 * @param  int $value payment form.
2776 2776
 	 */
2777
-	public function set_payment_form( $value ) {
2778
-		$this->set_prop( 'payment_form', $value );
2777
+	public function set_payment_form($value) {
2778
+		$this->set_prop('payment_form', $value);
2779 2779
     }
2780 2780
 
2781 2781
     /**
@@ -2784,8 +2784,8 @@  discard block
 block discarded – undo
2784 2784
 	 * @since 1.0.19
2785 2785
 	 * @param  string $value submission id.
2786 2786
 	 */
2787
-	public function set_submission_id( $value ) {
2788
-		$this->set_prop( 'submission_id', $value );
2787
+	public function set_submission_id($value) {
2788
+		$this->set_prop('submission_id', $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 discount code.
2796 2796
 	 */
2797
-	public function set_discount_code( $value ) {
2798
-		$this->set_prop( 'discount_code', $value );
2797
+	public function set_discount_code($value) {
2798
+		$this->set_prop('discount_code', $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 gateway.
2806 2806
 	 */
2807
-	public function set_gateway( $value ) {
2808
-		$this->set_prop( 'gateway', $value );
2807
+	public function set_gateway($value) {
2808
+		$this->set_prop('gateway', $value);
2809 2809
     }
2810 2810
 
2811 2811
     /**
@@ -2814,9 +2814,9 @@  discard block
 block discarded – undo
2814 2814
 	 * @since 1.0.19
2815 2815
 	 * @param  string $value transaction id.
2816 2816
 	 */
2817
-	public function set_transaction_id( $value ) {
2818
-		if ( ! empty( $value ) ) {
2819
-			$this->set_prop( 'transaction_id', $value );
2817
+	public function set_transaction_id($value) {
2818
+		if (!empty($value)) {
2819
+			$this->set_prop('transaction_id', $value);
2820 2820
 		}
2821 2821
     }
2822 2822
 
@@ -2826,8 +2826,8 @@  discard block
 block discarded – undo
2826 2826
 	 * @since 1.0.19
2827 2827
 	 * @param  string $value currency id.
2828 2828
 	 */
2829
-	public function set_currency( $value ) {
2830
-		$this->set_prop( 'currency', $value );
2829
+	public function set_currency($value) {
2830
+		$this->set_prop('currency', $value);
2831 2831
     }
2832 2832
 
2833 2833
 	/**
@@ -2836,8 +2836,8 @@  discard block
 block discarded – undo
2836 2836
 	 * @since 1.0.19
2837 2837
 	 * @param  bool $value value.
2838 2838
 	 */
2839
-	public function set_disable_taxes( $value ) {
2840
-		$this->set_prop( 'disable_taxes', (bool) $value );
2839
+	public function set_disable_taxes($value) {
2840
+		$this->set_prop('disable_taxes', (bool) $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  string $value subscription id.
2848 2848
 	 */
2849
-	public function set_subscription_id( $value ) {
2850
-		$this->set_prop( 'subscription_id', $value );
2849
+	public function set_subscription_id($value) {
2850
+		$this->set_prop('subscription_id', $value);
2851 2851
     }
2852 2852
 
2853 2853
     /*
@@ -2864,28 +2864,28 @@  discard block
 block discarded – undo
2864 2864
      */
2865 2865
     public function is_parent() {
2866 2866
         $parent = $this->get_parent_id();
2867
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
2867
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
2868 2868
     }
2869 2869
 
2870 2870
     /**
2871 2871
      * Checks if this is a renewal invoice.
2872 2872
      */
2873 2873
     public function is_renewal() {
2874
-        return ! $this->is_parent();
2874
+        return !$this->is_parent();
2875 2875
     }
2876 2876
 
2877 2877
     /**
2878 2878
      * Checks if this is a recurring invoice.
2879 2879
      */
2880 2880
     public function is_recurring() {
2881
-        return $this->is_renewal() || ! empty( $this->recurring_item );
2881
+        return $this->is_renewal() || !empty($this->recurring_item);
2882 2882
     }
2883 2883
 
2884 2884
     /**
2885 2885
      * Checks if this is a taxable invoice.
2886 2886
      */
2887 2887
     public function is_taxable() {
2888
-        return ! $this->get_disable_taxes();
2888
+        return !$this->get_disable_taxes();
2889 2889
 	}
2890 2890
 
2891 2891
 	/**
@@ -2896,57 +2896,57 @@  discard block
 block discarded – undo
2896 2896
 
2897 2897
         $requires_vat = false;
2898 2898
 
2899
-        if ( $this->country ) {
2899
+        if ($this->country) {
2900 2900
             $wpi_country        = $this->country;
2901
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2901
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2902 2902
         }
2903 2903
 
2904
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2904
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2905 2905
 	}
2906 2906
 
2907 2907
 	/**
2908 2908
 	 * Checks to see if the invoice requires payment.
2909 2909
 	 */
2910 2910
 	public function is_free() {
2911
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2911
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
2912 2912
 
2913
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2913
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
2914 2914
 			$is_free = false;
2915 2915
 		}
2916 2916
 
2917
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2917
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2918 2918
     }
2919 2919
 
2920 2920
     /**
2921 2921
      * Checks if the invoice is paid.
2922 2922
      */
2923 2923
     public function is_paid() {
2924
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2925
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2924
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2925
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2926 2926
 	}
2927 2927
 
2928 2928
 	/**
2929 2929
      * Checks if the invoice needs payment.
2930 2930
      */
2931 2931
 	public function needs_payment() {
2932
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2933
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2932
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
2933
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
2934 2934
     }
2935 2935
 
2936 2936
 	/**
2937 2937
      * Checks if the invoice is refunded.
2938 2938
      */
2939 2939
 	public function is_refunded() {
2940
-        $is_refunded = $this->has_status( 'wpi-refunded' );
2941
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2940
+        $is_refunded = $this->has_status('wpi-refunded');
2941
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
2942 2942
 	}
2943 2943
 
2944 2944
 	/**
2945 2945
      * Checks if the invoice is held.
2946 2946
      */
2947 2947
 	public function is_held() {
2948
-        $is_held = $this->has_status( 'wpi-onhold' );
2949
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2948
+        $is_held = $this->has_status('wpi-onhold');
2949
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
2950 2950
 	}
2951 2951
 
2952 2952
 	/**
@@ -2954,30 +2954,30 @@  discard block
 block discarded – undo
2954 2954
      */
2955 2955
 	public function is_due() {
2956 2956
 		$due_date = $this->get_due_date();
2957
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2957
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
2958 2958
 	}
2959 2959
 
2960 2960
 	/**
2961 2961
      * Checks if the invoice is draft.
2962 2962
      */
2963 2963
 	public function is_draft() {
2964
-        return $this->has_status( 'draft, auto-draft' );
2964
+        return $this->has_status('draft, auto-draft');
2965 2965
 	}
2966 2966
 
2967 2967
     /**
2968 2968
      * Checks if the invoice has a given status.
2969 2969
      */
2970
-    public function has_status( $status ) {
2971
-        $status = wpinv_parse_list( $status );
2972
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
2970
+    public function has_status($status) {
2971
+        $status = wpinv_parse_list($status);
2972
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
2973 2973
 	}
2974 2974
 
2975 2975
 	/**
2976 2976
      * Checks if the invoice is of a given type.
2977 2977
      */
2978
-    public function is_type( $type ) {
2979
-        $type = wpinv_parse_list( $type );
2980
-        return in_array( $this->get_type(), $type );
2978
+    public function is_type($type) {
2979
+        $type = wpinv_parse_list($type);
2980
+        return in_array($this->get_type(), $type);
2981 2981
     }
2982 2982
 
2983 2983
     /**
@@ -3009,8 +3009,8 @@  discard block
 block discarded – undo
3009 3009
      *
3010 3010
      */
3011 3011
 	public function is_initial_free() {
3012
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3013
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3012
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3013
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3014 3014
     }
3015 3015
 	
3016 3016
 	/**
@@ -3020,11 +3020,11 @@  discard block
 block discarded – undo
3020 3020
     public function item_has_free_trial() {
3021 3021
 
3022 3022
         // Ensure we have a recurring item.
3023
-        if ( ! $this->is_recurring() ) {
3023
+        if (!$this->is_recurring()) {
3024 3024
             return false;
3025 3025
         }
3026 3026
 
3027
-        $item = $this->get_recurring( true );
3027
+        $item = $this->get_recurring(true);
3028 3028
         return $item->has_free_trial();
3029 3029
 	}
3030 3030
 
@@ -3032,7 +3032,7 @@  discard block
 block discarded – undo
3032 3032
      * Check if the free trial is a result of a discount.
3033 3033
      */
3034 3034
     public function is_free_trial_from_discount() {
3035
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3035
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3036 3036
 	}
3037 3037
 	
3038 3038
 	/**
@@ -3041,17 +3041,17 @@  discard block
 block discarded – undo
3041 3041
     public function discount_first_payment_only() {
3042 3042
 
3043 3043
 		$discount_code = $this->get_discount_code();
3044
-        if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3044
+        if (empty($this->discount_code) || !$this->is_recurring()) {
3045 3045
             return true;
3046 3046
         }
3047 3047
 
3048
-        $discount = wpinv_get_discount_obj( $discount_code );
3048
+        $discount = wpinv_get_discount_obj($discount_code);
3049 3049
 
3050
-        if ( ! $discount || ! $discount->exists() ) {
3050
+        if (!$discount || !$discount->exists()) {
3051 3051
             return true;
3052 3052
         }
3053 3053
 
3054
-        return ! $discount->get_is_recurring();
3054
+        return !$discount->get_is_recurring();
3055 3055
     }
3056 3056
 
3057 3057
     /*
@@ -3069,19 +3069,19 @@  discard block
 block discarded – undo
3069 3069
      * @param GetPaid_Form_Item $item
3070 3070
      * @return WP_Error|Bool
3071 3071
      */
3072
-    public function add_item( $item ) {
3072
+    public function add_item($item) {
3073 3073
 
3074 3074
         // Make sure that it is available for purchase.
3075
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3076
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3075
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3076
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3077 3077
         }
3078 3078
 
3079 3079
         // Do we have a recurring item?
3080
-		if ( $item->is_recurring() ) {
3080
+		if ($item->is_recurring()) {
3081 3081
 
3082 3082
 			// An invoice can only contain one recurring item.
3083
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3084
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3083
+			if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) {
3084
+				return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing'));
3085 3085
 			}
3086 3086
 
3087 3087
 			$this->recurring_item = $item->get_id();
@@ -3092,9 +3092,9 @@  discard block
 block discarded – undo
3092 3092
 
3093 3093
         // Retrieve all items.
3094 3094
         $items = $this->get_items();
3095
-        $items[ (int) $item->get_id() ] = $item;
3095
+        $items[(int) $item->get_id()] = $item;
3096 3096
 
3097
-        $this->set_prop( 'items', $items );
3097
+        $this->set_prop('items', $items);
3098 3098
 		return true;
3099 3099
     }
3100 3100
 
@@ -3103,10 +3103,10 @@  discard block
 block discarded – undo
3103 3103
 	 *
3104 3104
 	 * @since 1.0.19
3105 3105
 	 */
3106
-	public function get_item( $item_id ) {
3106
+	public function get_item($item_id) {
3107 3107
 		$items   = $this->get_items();
3108 3108
 		$item_id = (int) $item_id;
3109
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3109
+		return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null;
3110 3110
     }
3111 3111
 
3112 3112
     /**
@@ -3114,17 +3114,17 @@  discard block
 block discarded – undo
3114 3114
 	 *
3115 3115
 	 * @since 1.0.19
3116 3116
 	 */
3117
-	public function remove_item( $item_id ) {
3117
+	public function remove_item($item_id) {
3118 3118
 		$items   = $this->get_items();
3119 3119
 		$item_id = (int) $item_id;
3120 3120
 
3121
-        if ( $item_id == $this->recurring_item ) {
3121
+        if ($item_id == $this->recurring_item) {
3122 3122
             $this->recurring_item = null;
3123 3123
         }
3124 3124
 
3125
-        if ( isset( $items[ $item_id ] ) ) {
3126
-            unset( $items[ $item_id ] );
3127
-            $this->set_prop( 'items', $items );
3125
+        if (isset($items[$item_id])) {
3126
+            unset($items[$item_id]);
3127
+            $this->set_prop('items', $items);
3128 3128
         }
3129 3129
     }
3130 3130
 
@@ -3135,27 +3135,27 @@  discard block
 block discarded – undo
3135 3135
      * @param float $value
3136 3136
      * @return WP_Error|Bool
3137 3137
      */
3138
-    public function add_fee( $fee, $value, $recurring = false ) {
3138
+    public function add_fee($fee, $value, $recurring = false) {
3139 3139
 
3140
-        $amount = wpinv_sanitize_amount( $value );
3140
+        $amount = wpinv_sanitize_amount($value);
3141 3141
         $fees   = $this->get_fees();
3142 3142
 
3143
-        if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3143
+        if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) {
3144 3144
 
3145
-            $amount = $fees[ $fee ]['amount'] += $amount;
3146
-			$fees[ $fee ] = array(
3145
+            $amount = $fees[$fee]['amount'] += $amount;
3146
+			$fees[$fee] = array(
3147 3147
                 'amount'    => $amount,
3148 3148
                 'recurring' => (bool) $recurring,
3149 3149
             );
3150 3150
 
3151 3151
 		} else {
3152
-			$fees[ $fee ] = array(
3152
+			$fees[$fee] = array(
3153 3153
                 'amount'    => $amount,
3154 3154
                 'recurring' => (bool) $recurring,
3155 3155
             );
3156 3156
 		}
3157 3157
 
3158
-        $this->set_prop( 'fees', $fee );
3158
+        $this->set_prop('fees', $fee);
3159 3159
 
3160 3160
     }
3161 3161
 
@@ -3164,9 +3164,9 @@  discard block
 block discarded – undo
3164 3164
 	 *
3165 3165
 	 * @since 1.0.19
3166 3166
 	 */
3167
-	public function get_fee( $fee ) {
3167
+	public function get_fee($fee) {
3168 3168
         $fees = $this->get_fees();
3169
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3169
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3170 3170
     }
3171 3171
 
3172 3172
     /**
@@ -3174,11 +3174,11 @@  discard block
 block discarded – undo
3174 3174
 	 *
3175 3175
 	 * @since 1.0.19
3176 3176
 	 */
3177
-	public function remove_fee( $fee ) {
3177
+	public function remove_fee($fee) {
3178 3178
         $fees = $this->get_fees();
3179
-        if ( isset( $fees[ $fee ] ) ) {
3180
-            unset( $fees[ $fee ] );
3181
-            $this->set_prop( 'fees', $fees );
3179
+        if (isset($fees[$fee])) {
3180
+            unset($fees[$fee]);
3181
+            $this->set_prop('fees', $fees);
3182 3182
         }
3183 3183
     }
3184 3184
 
@@ -3189,27 +3189,27 @@  discard block
 block discarded – undo
3189 3189
      * @param float $value
3190 3190
      * @return WP_Error|Bool
3191 3191
      */
3192
-    public function add_discount( $discount, $value, $recurring = false ) {
3192
+    public function add_discount($discount, $value, $recurring = false) {
3193 3193
 
3194
-        $amount    = wpinv_sanitize_amount( $value );
3194
+        $amount    = wpinv_sanitize_amount($value);
3195 3195
         $discounts = $this->get_discounts();
3196 3196
 
3197
-        if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3197
+        if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) {
3198 3198
 
3199
-            $amount = $discounts[ $discount ]['amount'] += $amount;
3200
-			$discounts[ $discount ] = array(
3199
+            $amount = $discounts[$discount]['amount'] += $amount;
3200
+			$discounts[$discount] = array(
3201 3201
                 'amount'    => $amount,
3202 3202
                 'recurring' => (bool) $recurring,
3203 3203
             );
3204 3204
 
3205 3205
 		} else {
3206
-			$discounts[ $discount ] = array(
3206
+			$discounts[$discount] = array(
3207 3207
                 'amount'    => $amount,
3208 3208
                 'recurring' => (bool) $recurring,
3209 3209
             );
3210 3210
 		}
3211 3211
 
3212
-        $this->set_prop( 'discounts', $discount );
3212
+        $this->set_prop('discounts', $discount);
3213 3213
 
3214 3214
     }
3215 3215
 
@@ -3218,15 +3218,15 @@  discard block
 block discarded – undo
3218 3218
 	 *
3219 3219
 	 * @since 1.0.19
3220 3220
 	 */
3221
-	public function get_discount( $discount = false ) {
3221
+	public function get_discount($discount = false) {
3222 3222
 
3223 3223
 		// Backwards compatibilty.
3224
-		if ( empty( $discount ) ) {
3224
+		if (empty($discount)) {
3225 3225
 			return $this->get_total_discount();
3226 3226
 		}
3227 3227
 
3228 3228
         $discounts = $this->get_discounts();
3229
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3229
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3230 3230
     }
3231 3231
 
3232 3232
     /**
@@ -3234,11 +3234,11 @@  discard block
 block discarded – undo
3234 3234
 	 *
3235 3235
 	 * @since 1.0.19
3236 3236
 	 */
3237
-	public function remove_discount( $discount ) {
3237
+	public function remove_discount($discount) {
3238 3238
         $discounts = $this->get_discounts();
3239
-        if ( isset( $discounts[ $discount ] ) ) {
3240
-            unset( $discounts[ $discount ] );
3241
-            $this->set_prop( 'discounts', $discounts );
3239
+        if (isset($discounts[$discount])) {
3240
+            unset($discounts[$discount]);
3241
+            $this->set_prop('discounts', $discounts);
3242 3242
         }
3243 3243
     }
3244 3244
 
@@ -3248,31 +3248,31 @@  discard block
 block discarded – undo
3248 3248
      * @param string $tax
3249 3249
      * @param float $value
3250 3250
      */
3251
-    public function add_tax( $tax, $value, $recurring = true ) {
3251
+    public function add_tax($tax, $value, $recurring = true) {
3252 3252
 
3253
-        if ( ! $this->is_taxable() ) {
3253
+        if (!$this->is_taxable()) {
3254 3254
             return;
3255 3255
         }
3256 3256
 
3257
-        $amount    = wpinv_sanitize_amount( $value );
3257
+        $amount    = wpinv_sanitize_amount($value);
3258 3258
         $taxes     = $this->get_taxes();
3259 3259
 
3260
-        if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3260
+        if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) {
3261 3261
 
3262
-            $amount = $taxes[ $tax ]['amount'] += $amount;
3263
-			$taxes[ $tax ] = array(
3262
+            $amount = $taxes[$tax]['amount'] += $amount;
3263
+			$taxes[$tax] = array(
3264 3264
                 'amount'    => $amount,
3265 3265
                 'recurring' => (bool) $recurring,
3266 3266
             );
3267 3267
 
3268 3268
 		} else {
3269
-			$taxes[ $tax ] = array(
3269
+			$taxes[$tax] = array(
3270 3270
                 'amount'    => $amount,
3271 3271
                 'recurring' => (bool) $recurring,
3272 3272
             );
3273 3273
 		}
3274 3274
 
3275
-        $this->set_prop( 'taxes', $tax );
3275
+        $this->set_prop('taxes', $tax);
3276 3276
 
3277 3277
     }
3278 3278
 
@@ -3281,15 +3281,15 @@  discard block
 block discarded – undo
3281 3281
 	 *
3282 3282
 	 * @since 1.0.19
3283 3283
 	 */
3284
-	public function get_tax( $tax = null ) {
3284
+	public function get_tax($tax = null) {
3285 3285
 
3286 3286
 		// Backwards compatility.
3287
-		if ( empty( $tax ) ) {
3287
+		if (empty($tax)) {
3288 3288
 			return $this->get_total_tax();
3289 3289
 		}
3290 3290
 
3291 3291
         $taxes = $this->get_taxes();
3292
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3292
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3293 3293
     }
3294 3294
 
3295 3295
     /**
@@ -3297,11 +3297,11 @@  discard block
 block discarded – undo
3297 3297
 	 *
3298 3298
 	 * @since 1.0.19
3299 3299
 	 */
3300
-	public function remove_tax( $tax ) {
3300
+	public function remove_tax($tax) {
3301 3301
         $taxes = $this->get_discounts();
3302
-        if ( isset( $taxes[ $tax ] ) ) {
3303
-            unset( $taxes[ $tax ] );
3304
-            $this->set_prop( 'taxes', $taxes );
3302
+        if (isset($taxes[$tax])) {
3303
+            unset($taxes[$tax]);
3304
+            $this->set_prop('taxes', $taxes);
3305 3305
         }
3306 3306
     }
3307 3307
 
@@ -3312,19 +3312,19 @@  discard block
 block discarded – undo
3312 3312
 	 * @return float The recalculated subtotal
3313 3313
 	 */
3314 3314
 	public function recalculate_subtotal() {
3315
-        $items     = $this->get_items();
3315
+        $items = $this->get_items();
3316 3316
 		$subtotal  = 0;
3317 3317
 		$recurring = 0;
3318 3318
 
3319
-        foreach ( $items as $item ) {
3319
+        foreach ($items as $item) {
3320 3320
 			$subtotal  += $item->get_sub_total();
3321 3321
 			$recurring += $item->get_recurring_sub_total();
3322 3322
         }
3323 3323
 
3324
-		if ( $this->is_renewal() ) {
3325
-			$this->set_subtotal( $recurring );
3324
+		if ($this->is_renewal()) {
3325
+			$this->set_subtotal($recurring);
3326 3326
 		} else {
3327
-			$this->set_subtotal( $subtotal );
3327
+			$this->set_subtotal($subtotal);
3328 3328
 		}
3329 3329
 
3330 3330
 		$this->totals['subtotal'] = array(
@@ -3346,9 +3346,9 @@  discard block
 block discarded – undo
3346 3346
 		$discount  = 0;
3347 3347
 		$recurring = 0;
3348 3348
 
3349
-        foreach ( $discounts as $data ) {
3349
+        foreach ($discounts as $data) {
3350 3350
 
3351
-			if ( $data['recurring'] ) {
3351
+			if ($data['recurring']) {
3352 3352
 				$recurring += $data['amount'];
3353 3353
 			} else {
3354 3354
 				$discount += $data['amount'];
@@ -3356,10 +3356,10 @@  discard block
 block discarded – undo
3356 3356
 
3357 3357
 		}
3358 3358
 
3359
-		if ( $this->is_renewal() ) {
3360
-			$this->set_total_discount( $recurring );
3359
+		if ($this->is_renewal()) {
3360
+			$this->set_total_discount($recurring);
3361 3361
 		} else {
3362
-			$this->set_total_discount( $discount );
3362
+			$this->set_total_discount($discount);
3363 3363
 		}
3364 3364
 
3365 3365
 		$this->totals['discount'] = array(
@@ -3378,13 +3378,13 @@  discard block
 block discarded – undo
3378 3378
 	 * @return float The recalculated tax
3379 3379
 	 */
3380 3380
 	public function recalculate_total_tax() {
3381
-        $taxes     = $this->get_taxes();
3381
+        $taxes = $this->get_taxes();
3382 3382
 		$tax       = 0;
3383 3383
 		$recurring = 0;
3384 3384
 
3385
-        foreach ( $taxes as $data ) {
3385
+        foreach ($taxes as $data) {
3386 3386
 
3387
-			if ( $data['recurring'] ) {
3387
+			if ($data['recurring']) {
3388 3388
 				$recurring += $data['amount'];
3389 3389
 			} else {
3390 3390
 				$tax += $data['amount'];
@@ -3392,10 +3392,10 @@  discard block
 block discarded – undo
3392 3392
 
3393 3393
 		}
3394 3394
 
3395
-		if ( $this->is_renewal() ) {
3396
-			$this->set_total_tax( $recurring );
3395
+		if ($this->is_renewal()) {
3396
+			$this->set_total_tax($recurring);
3397 3397
 		} else {
3398
-			$this->set_total_tax( $tax );
3398
+			$this->set_total_tax($tax);
3399 3399
 		}
3400 3400
 
3401 3401
 		$this->totals['tax'] = array(
@@ -3418,9 +3418,9 @@  discard block
 block discarded – undo
3418 3418
 		$fee       = 0;
3419 3419
 		$recurring = 0;
3420 3420
 
3421
-        foreach ( $fees as $data ) {
3421
+        foreach ($fees as $data) {
3422 3422
 
3423
-			if ( $data['recurring'] ) {
3423
+			if ($data['recurring']) {
3424 3424
 				$recurring += $data['amount'];
3425 3425
 			} else {
3426 3426
 				$fee += $data['amount'];
@@ -3428,10 +3428,10 @@  discard block
 block discarded – undo
3428 3428
 
3429 3429
 		}
3430 3430
 
3431
-        if ( $this->is_renewal() ) {
3432
-			$this->set_total_fees( $recurring );
3431
+        if ($this->is_renewal()) {
3432
+			$this->set_total_fees($recurring);
3433 3433
 		} else {
3434
-			$this->set_total_fees( $fee );
3434
+			$this->set_total_fees($fee);
3435 3435
 		}
3436 3436
 
3437 3437
 		$this->totals['fee'] = array(
@@ -3439,7 +3439,7 @@  discard block
 block discarded – undo
3439 3439
 			'recurring' => $recurring,
3440 3440
 		);
3441 3441
 
3442
-        $this->set_total_fees( $fee );
3442
+        $this->set_total_fees($fee);
3443 3443
         return $this->is_renewal() ? $recurring : $fee;
3444 3444
     }
3445 3445
 
@@ -3460,9 +3460,9 @@  discard block
 block discarded – undo
3460 3460
 	/**
3461 3461
 	 * @deprecated
3462 3462
 	 */
3463
-    public function recalculate_totals( $temp = false ) {
3464
-        $this->update_items( $temp );
3465
-        $this->save( true );
3463
+    public function recalculate_totals($temp = false) {
3464
+        $this->update_items($temp);
3465
+        $this->save(true);
3466 3466
         return $this;
3467 3467
     }
3468 3468
 
@@ -3479,33 +3479,33 @@  discard block
 block discarded – undo
3479 3479
      * @param string $note The note being added.
3480 3480
      *
3481 3481
      */
3482
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3482
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3483 3483
 
3484 3484
         // Bail if no note specified or this invoice is not yet saved.
3485
-        if ( ! $note || $this->get_id() == 0 ) {
3485
+        if (!$note || $this->get_id() == 0) {
3486 3486
             return false;
3487 3487
         }
3488 3488
 
3489
-        if ( ( ( is_user_logged_in() && wpinv_current_user_can_manage_invoicing() ) || $added_by_user ) && !$system ) {
3490
-            $user                 = get_user_by( 'id', get_current_user_id() );
3489
+        if (((is_user_logged_in() && wpinv_current_user_can_manage_invoicing()) || $added_by_user) && !$system) {
3490
+            $user                 = get_user_by('id', get_current_user_id());
3491 3491
             $comment_author       = $user->display_name;
3492 3492
             $comment_author_email = $user->user_email;
3493 3493
         } else {
3494 3494
             $comment_author       = 'System';
3495 3495
             $comment_author_email = 'system@';
3496
-            $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) : 'noreply.com';
3497
-            $comment_author_email = sanitize_email( $comment_author_email );
3496
+            $comment_author_email .= isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : 'noreply.com';
3497
+            $comment_author_email = sanitize_email($comment_author_email);
3498 3498
         }
3499 3499
 
3500
-        do_action( 'wpinv_pre_insert_invoice_note', $this->get_id(), $note, $customer_type );
3500
+        do_action('wpinv_pre_insert_invoice_note', $this->get_id(), $note, $customer_type);
3501 3501
 
3502
-        $note_id = wp_insert_comment( wp_filter_comment( array(
3502
+        $note_id = wp_insert_comment(wp_filter_comment(array(
3503 3503
             'comment_post_ID'      => $this->get_id(),
3504 3504
             'comment_content'      => $note,
3505 3505
             'comment_agent'        => 'GetPaid',
3506 3506
             'user_id'              => is_admin() ? get_current_user_id() : 0,
3507
-            'comment_date'         => current_time( 'mysql' ),
3508
-            'comment_date_gmt'     => current_time( 'mysql', 1 ),
3507
+            'comment_date'         => current_time('mysql'),
3508
+            'comment_date_gmt'     => current_time('mysql', 1),
3509 3509
             'comment_approved'     => 1,
3510 3510
             'comment_parent'       => 0,
3511 3511
             'comment_author'       => $comment_author,
@@ -3513,13 +3513,13 @@  discard block
 block discarded – undo
3513 3513
             'comment_author_url'   => '',
3514 3514
             'comment_author_email' => $comment_author_email,
3515 3515
             'comment_type'         => 'wpinv_note'
3516
-        ) ) );
3516
+        )));
3517 3517
 
3518
-        do_action( 'wpinv_insert_payment_note', $note_id, $this->get_id(), $note );
3518
+        do_action('wpinv_insert_payment_note', $note_id, $this->get_id(), $note);
3519 3519
 
3520
-        if ( $customer_type ) {
3521
-            add_comment_meta( $note_id, '_wpi_customer_note', 1 );
3522
-            do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $this->get_id(), 'user_note' => $note ) );
3520
+        if ($customer_type) {
3521
+            add_comment_meta($note_id, '_wpi_customer_note', 1);
3522
+            do_action('wpinv_new_customer_note', array('invoice_id' => $this->get_id(), 'user_note' => $note));
3523 3523
         }
3524 3524
 
3525 3525
         return $note_id;
@@ -3528,10 +3528,10 @@  discard block
 block discarded – undo
3528 3528
 	/**
3529 3529
      * Generates a unique key for the invoice.
3530 3530
      */
3531
-    public function generate_key( $string = '' ) {
3532
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3531
+    public function generate_key($string = '') {
3532
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3533 3533
         return strtolower(
3534
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3534
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3535 3535
         );
3536 3536
     }
3537 3537
 
@@ -3541,11 +3541,11 @@  discard block
 block discarded – undo
3541 3541
     public function generate_number() {
3542 3542
         $number = $this->get_id();
3543 3543
 
3544
-        if ( $this->has_status( 'auto-draft' ) && wpinv_sequential_number_active( $this->post_type ) ) {
3545
-            $number = wpinv_get_next_invoice_number( $this->post_type );
3544
+        if ($this->has_status('auto-draft') && wpinv_sequential_number_active($this->post_type)) {
3545
+            $number = wpinv_get_next_invoice_number($this->post_type);
3546 3546
         }
3547 3547
 
3548
-		$number = wpinv_format_invoice_number( $number, $this->post_type );
3548
+		$number = wpinv_format_invoice_number($number, $this->post_type);
3549 3549
 
3550 3550
 		return $number;
3551 3551
 	}
@@ -3559,47 +3559,47 @@  discard block
 block discarded – undo
3559 3559
 		// Reset status transition variable.
3560 3560
 		$this->status_transition = false;
3561 3561
 
3562
-		if ( $status_transition ) {
3562
+		if ($status_transition) {
3563 3563
 			try {
3564 3564
 
3565 3565
 				// Fire a hook for the status change.
3566
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3566
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition);
3567 3567
 
3568 3568
 				// @deprecated this is deprecated and will be removed in the future.
3569
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3569
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3570 3570
 
3571
-				if ( ! empty( $status_transition['from'] ) ) {
3571
+				if (!empty($status_transition['from'])) {
3572 3572
 
3573 3573
 					/* translators: 1: old invoice status 2: new invoice status */
3574
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3574
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to']));
3575 3575
 
3576 3576
 					// Fire another hook.
3577
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3578
-					do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3577
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this);
3578
+					do_action('getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this);
3579 3579
 
3580 3580
 					// @deprecated this is deprecated and will be removed in the future.
3581
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3581
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3582 3582
 
3583 3583
 					// Note the transition occurred.
3584
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3584
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3585 3585
 
3586 3586
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3587 3587
 					if (
3588
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3589
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3588
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded'), true)
3589
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3590 3590
 					) {
3591
-						do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3591
+						do_action('getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition);
3592 3592
 					}
3593 3593
 				} else {
3594 3594
 					/* translators: %s: new invoice status */
3595
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3595
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to']));
3596 3596
 
3597 3597
 					// Note the transition occurred.
3598
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3598
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3599 3599
 
3600 3600
 				}
3601
-			} catch ( Exception $e ) {
3602
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3601
+			} catch (Exception $e) {
3602
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3603 3603
 			}
3604 3604
 		}
3605 3605
 	}
@@ -3607,13 +3607,13 @@  discard block
 block discarded – undo
3607 3607
 	/**
3608 3608
 	 * Updates an invoice status.
3609 3609
 	 */
3610
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3610
+	public function update_status($new_status = false, $note = '', $manual = false) {
3611 3611
 
3612 3612
 		// Fires before updating a status.
3613
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3613
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3614 3614
 
3615 3615
 		// Update the status.
3616
-		$this->set_status( $new_status, $note, $manual );
3616
+		$this->set_status($new_status, $note, $manual);
3617 3617
 
3618 3618
 		// Save the order.
3619 3619
 		return $this->save();
@@ -3624,18 +3624,18 @@  discard block
 block discarded – undo
3624 3624
 	 * @deprecated
3625 3625
 	 */
3626 3626
 	public function refresh_item_ids() {
3627
-        $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3628
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3627
+        $item_ids = implode(',', array_unique(array_keys($this->get_items())));
3628
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3629 3629
 	}
3630 3630
 
3631 3631
 	/**
3632 3632
 	 * @deprecated
3633 3633
 	 */
3634
-	public function update_items( $temp = false ) {
3634
+	public function update_items($temp = false) {
3635 3635
 
3636
-		$this->set_items( $this->get_items() );
3636
+		$this->set_items($this->get_items());
3637 3637
 
3638
-		if ( ! $temp ) {
3638
+		if (!$temp) {
3639 3639
 			$this->save();
3640 3640
 		}
3641 3641
 
@@ -3649,11 +3649,11 @@  discard block
 block discarded – undo
3649 3649
 
3650 3650
         $discount_code = $this->get_discount_code();
3651 3651
 
3652
-        if ( empty( $discount_code ) ) {
3652
+        if (empty($discount_code)) {
3653 3653
             return false;
3654 3654
         }
3655 3655
 
3656
-        $discount = wpinv_get_discount_obj( $discount_code );
3656
+        $discount = wpinv_get_discount_obj($discount_code);
3657 3657
 
3658 3658
         // Ensure it is active.
3659 3659
         return $discount->exists();
@@ -3664,7 +3664,7 @@  discard block
 block discarded – undo
3664 3664
 	 * Refunds an invoice.
3665 3665
 	 */
3666 3666
     public function refund() {
3667
-		$this->set_status( 'wpi-refunded' );
3667
+		$this->set_status('wpi-refunded');
3668 3668
         $this->save();
3669 3669
 	}
3670 3670
 
@@ -3673,56 +3673,56 @@  discard block
 block discarded – undo
3673 3673
 	 * 
3674 3674
 	 * @param string $transaction_id
3675 3675
 	 */
3676
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3676
+    public function mark_paid($transaction_id = null, $note = '') {
3677 3677
 
3678 3678
 		// Set the transaction id.
3679
-		if ( empty( $transaction_id ) ) {
3679
+		if (empty($transaction_id)) {
3680 3680
 			$transaction_id = $this->generate_key('trans_');
3681 3681
 		}
3682 3682
 
3683
-		if ( ! $this->get_transaction_id() ) {
3684
-			$this->set_transaction_id( $transaction_id );
3683
+		if (!$this->get_transaction_id()) {
3684
+			$this->set_transaction_id($transaction_id);
3685 3685
 		}
3686 3686
 
3687
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3687
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3688 3688
 			return $this->save();
3689 3689
 		}
3690 3690
 
3691 3691
 		// Set the completed date.
3692
-		$this->set_date_completed( current_time( 'mysql' ) );
3692
+		$this->set_date_completed(current_time('mysql'));
3693 3693
 
3694 3694
 		// Set the new status.
3695
-		if ( $this->is_renewal() ) {
3695
+		if ($this->is_renewal()) {
3696 3696
 
3697 3697
 			$_note = sprintf(
3698
-				__( 'Renewed via %s', 'invoicing' ),
3699
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3698
+				__('Renewed via %s', 'invoicing'),
3699
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3700 3700
 			);
3701 3701
 
3702
-			if ( 'none' == $this->get_gateway() ) {
3702
+			if ('none' == $this->get_gateway()) {
3703 3703
 				$_note = $note;
3704 3704
 			}
3705 3705
 
3706
-			$this->set_status( 'wpi-renewal', $_note );
3706
+			$this->set_status('wpi-renewal', $_note);
3707 3707
 
3708 3708
 		} else {
3709 3709
 
3710 3710
 			$_note = sprintf(
3711
-				__( 'Paid via %s', 'invoicing' ),
3712
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3711
+				__('Paid via %s', 'invoicing'),
3712
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3713 3713
 			);
3714 3714
 
3715
-			if ( 'none' == $this->get_gateway() ) {
3715
+			if ('none' == $this->get_gateway()) {
3716 3716
 				$_note = $note;
3717 3717
 			}
3718 3718
 
3719
-			$this->set_status( 'publish',$_note );
3719
+			$this->set_status('publish', $_note);
3720 3720
 
3721 3721
 		}
3722 3722
 
3723 3723
 		// Set checkout mode.
3724
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3725
-		$this->set_mode( $mode );
3724
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3725
+		$this->set_mode($mode);
3726 3726
 
3727 3727
 		// Save the invoice.
3728 3728
         $this->save();
Please login to merge, or discard this patch.
includes/error-functions.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -100,13 +100,13 @@
 block discarded – undo
100 100
  */
101 101
 function getpaid_doing_it_wrong( $function, $message, $version ) {
102 102
 
103
-	$message .= ' Backtrace: ' . wp_debug_backtrace_summary();
104
-
105
-	if ( is_ajax() || defined( 'REST_REQUEST' ) ) {
106
-		do_action( 'doing_it_wrong_run', $function, $message, $version );
107
-		error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." );
108
-	} else {
109
-		_doing_it_wrong( $function, $message, $version );
110
-	}
103
+    $message .= ' Backtrace: ' . wp_debug_backtrace_summary();
104
+
105
+    if ( is_ajax() || defined( 'REST_REQUEST' ) ) {
106
+        do_action( 'doing_it_wrong_run', $function, $message, $version );
107
+        error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." );
108
+    } else {
109
+        _doing_it_wrong( $function, $message, $version );
110
+    }
111 111
 
112 112
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 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
  * Returns the errors as html
@@ -14,16 +14,16 @@  discard block
 block discarded – undo
14 14
  * @param clear whether or not to clear the errors.
15 15
  * @since  1.0.19
16 16
  */
17
-function getpaid_get_errors_html( $clear = true ) {
17
+function getpaid_get_errors_html($clear = true) {
18 18
 
19 19
     $errors = '';
20
-    foreach ( wpinv_get_errors() as $error_id => $error ) {
21
-        $error_id = esc_attr( $error_id );
22
-        $error    = '<strong>' . __( 'Error', 'invoicing' ) . '</strong>: ' . wp_kses_post( $error ); 
20
+    foreach (wpinv_get_errors() as $error_id => $error) {
21
+        $error_id = esc_attr($error_id);
22
+        $error    = '<strong>' . __('Error', 'invoicing') . '</strong>: ' . wp_kses_post($error); 
23 23
         $errors  .= "<p class='p-0' id='getpaid-error-$error_id'>$error</p>";
24 24
     }
25 25
 
26
-    if ( $clear ){
26
+    if ($clear) {
27 27
         wpinv_clear_errors();
28 28
     }
29 29
 
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
  * @return array
45 45
  */
46 46
 function wpinv_get_errors() {
47
-    $errors = getpaid()->session->get( 'wpinv_errors' );
48
-    return is_array( $errors ) ? $errors : array();
47
+    $errors = getpaid()->session->get('wpinv_errors');
48
+    return is_array($errors) ? $errors : array();
49 49
 }
50 50
 
51 51
 /**
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
  * @param string $error_id The error id.
55 55
  * @param string $error_message The error message.
56 56
  */
57
-function wpinv_set_error( $error_id, $error_message ) {
57
+function wpinv_set_error($error_id, $error_message) {
58 58
     $errors              = wpinv_get_errors();
59
-    $errors[ $error_id ] = $error_message;
60
-    getpaid()->session->set( 'wpinv_errors', $errors );
59
+    $errors[$error_id] = $error_message;
60
+    getpaid()->session->set('wpinv_errors', $errors);
61 61
 }
62 62
 
63 63
 /**
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
  * 
66 66
  */
67 67
 function wpinv_has_errors() {
68
-    return count( wpinv_get_errors() ) > 0;
68
+    return count(wpinv_get_errors()) > 0;
69 69
 }
70 70
 
71 71
 /**
@@ -73,21 +73,21 @@  discard block
 block discarded – undo
73 73
  * 
74 74
  */
75 75
 function wpinv_clear_errors() {
76
-    getpaid()->session->set( 'wpinv_errors', null );
76
+    getpaid()->session->set('wpinv_errors', null);
77 77
 }
78 78
 
79 79
 /**
80 80
  * Clears a single error.
81 81
  * 
82 82
  */
83
-function wpinv_unset_error( $error_id ) {
83
+function wpinv_unset_error($error_id) {
84 84
     $errors = wpinv_get_errors();
85 85
 
86
-    if ( isset( $errors[ $error_id ] ) ) {
87
-        unset( $errors[ $error_id ] );
86
+    if (isset($errors[$error_id])) {
87
+        unset($errors[$error_id]);
88 88
     }
89 89
 
90
-    getpaid()->session->set( 'wpinv_errors', $errors );
90
+    getpaid()->session->set('wpinv_errors', $errors);
91 91
 }
92 92
 
93 93
 /**
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
  * @param string $message Message to log.
99 99
  * @param string $version Version the message was added in.
100 100
  */
101
-function getpaid_doing_it_wrong( $function, $message, $version ) {
101
+function getpaid_doing_it_wrong($function, $message, $version) {
102 102
 
103 103
 	$message .= ' Backtrace: ' . wp_debug_backtrace_summary();
104 104
 
105
-	if ( is_ajax() || defined( 'REST_REQUEST' ) ) {
106
-		do_action( 'doing_it_wrong_run', $function, $message, $version );
107
-		error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." );
105
+	if (is_ajax() || defined('REST_REQUEST')) {
106
+		do_action('doing_it_wrong_run', $function, $message, $version);
107
+		error_log("{$function} was called incorrectly. {$message}. This message was added in version {$version}.");
108 108
 	} else {
109
-		_doing_it_wrong( $function, $message, $version );
109
+		_doing_it_wrong($function, $message, $version);
110 110
 	}
111 111
 
112 112
 }
Please login to merge, or discard this patch.
includes/deprecated-functions.php 1 patch
Spacing   +81 added lines, -81 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
  * @deprecated
@@ -19,48 +19,48 @@  discard block
 block discarded – undo
19 19
  * @deprecated
20 20
  */
21 21
 function wpinv_get_invoice_cart() {
22
-    return wpinv_get_invoice( getpaid_get_current_invoice_id() );
22
+    return wpinv_get_invoice(getpaid_get_current_invoice_id());
23 23
 }
24 24
 
25 25
 /**
26 26
  * @deprecated
27 27
  */
28
-function wpinv_get_invoice_description( $invoice ) {
29
-    $invoice = new WPInv_Invoice( $invoice );
28
+function wpinv_get_invoice_description($invoice) {
29
+    $invoice = new WPInv_Invoice($invoice);
30 30
     return $invoice->get_description();
31 31
 }
32 32
 
33 33
 /**
34 34
  * @deprecated
35 35
  */
36
-function wpinv_get_invoice_currency_code( $invoice ) {
37
-    $invoice = new WPInv_Invoice( $invoice );
36
+function wpinv_get_invoice_currency_code($invoice) {
37
+    $invoice = new WPInv_Invoice($invoice);
38 38
     return $invoice->get_currency();
39 39
 }
40 40
 
41 41
 /**
42 42
  * @deprecated
43 43
  */
44
-function wpinv_get_payment_user_email( $invoice ) {
45
-    $invoice = new WPInv_Invoice( $invoice );
44
+function wpinv_get_payment_user_email($invoice) {
45
+    $invoice = new WPInv_Invoice($invoice);
46 46
     return $invoice->get_email();
47 47
 }
48 48
 
49 49
 /**
50 50
  * @deprecated
51 51
  */
52
-function wpinv_get_user_id( $invoice ) {
53
-    $invoice = new WPInv_Invoice( $invoice );
52
+function wpinv_get_user_id($invoice) {
53
+    $invoice = new WPInv_Invoice($invoice);
54 54
     return $invoice->get_user_id();
55 55
 }
56 56
 
57 57
 /**
58 58
  * @deprecated
59 59
  */
60
-function wpinv_get_invoice_status( $invoice, $return_label = false ) {
61
-    $invoice = new WPInv_Invoice( $invoice );
60
+function wpinv_get_invoice_status($invoice, $return_label = false) {
61
+    $invoice = new WPInv_Invoice($invoice);
62 62
     
63
-    if ( $return_label ) {
63
+    if ($return_label) {
64 64
         return $invoice->get_status_nicename();
65 65
     }
66 66
 
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
 /**
71 71
  * @deprecated
72 72
  */
73
-function wpinv_get_payment_gateway( $invoice, $return_label = false ) {
74
-    $invoice = new WPInv_Invoice( $invoice );
73
+function wpinv_get_payment_gateway($invoice, $return_label = false) {
74
+    $invoice = new WPInv_Invoice($invoice);
75 75
 
76
-    if ( $return_label ) {
76
+    if ($return_label) {
77 77
         return $invoice->get_gateway_title();
78 78
     }
79 79
 
@@ -83,75 +83,75 @@  discard block
 block discarded – undo
83 83
 /**
84 84
  * @deprecated
85 85
  */
86
-function wpinv_get_payment_gateway_name( $invoice ) {
87
-    return wpinv_get_payment_gateway( $invoice, true );
86
+function wpinv_get_payment_gateway_name($invoice) {
87
+    return wpinv_get_payment_gateway($invoice, true);
88 88
 }
89 89
 
90 90
 /**
91 91
  * @deprecated
92 92
  */
93
-function wpinv_get_payment_transaction_id( $invoice ) {
94
-    $invoice = new WPInv_Invoice( $invoice );
93
+function wpinv_get_payment_transaction_id($invoice) {
94
+    $invoice = new WPInv_Invoice($invoice);
95 95
     return $invoice->get_transaction_id();
96 96
 }
97 97
 
98 98
 /**
99 99
  * @deprecated
100 100
  */
101
-function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) {
102
-    $invoice = new WPInv_Invoice( $invoice_id );
103
-    return $invoice->get_meta( $meta_key, $single );
101
+function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) {
102
+    $invoice = new WPInv_Invoice($invoice_id);
103
+    return $invoice->get_meta($meta_key, $single);
104 104
 }
105 105
 
106 106
 /**
107 107
  * @deprecated
108 108
  */
109
-function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '' ) {
110
-    $invoice = new WPInv_Invoice( $invoice_id );
111
-    return $invoice->update_meta_data( $meta_key, $meta_value );
109
+function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '') {
110
+    $invoice = new WPInv_Invoice($invoice_id);
111
+    return $invoice->update_meta_data($meta_key, $meta_value);
112 112
 }
113 113
 
114 114
 /**
115 115
  * @deprecated
116 116
  */
117
-function wpinv_get_items( $invoice = 0 ) {
118
-    $invoice = new WPInv_Invoice( $invoice );
117
+function wpinv_get_items($invoice = 0) {
118
+    $invoice = new WPInv_Invoice($invoice);
119 119
     return $invoice->get_items();
120 120
 }
121 121
 
122 122
 /**
123 123
  * @deprecated
124 124
  */
125
-function wpinv_get_fees( $invoice = 0 ) {
126
-    $invoice = new WPInv_Invoice( $invoice );
125
+function wpinv_get_fees($invoice = 0) {
126
+    $invoice = new WPInv_Invoice($invoice);
127 127
     return $invoice->get_fees();
128 128
 }
129 129
 
130 130
 /**
131 131
  * @deprecated
132 132
  */
133
-function wpinv_get_invoice_ip( $invoice ) {
134
-    $invoice = new WPInv_Invoice( $invoice );
133
+function wpinv_get_invoice_ip($invoice) {
134
+    $invoice = new WPInv_Invoice($invoice);
135 135
     return $invoice->get_ip();
136 136
 }
137 137
 
138 138
 /**
139 139
  * @deprecated
140 140
  */
141
-function wpinv_get_invoice_user_info( $invoice ) {
142
-    $invoice = new WPInv_Invoice( $invoice );
141
+function wpinv_get_invoice_user_info($invoice) {
142
+    $invoice = new WPInv_Invoice($invoice);
143 143
     return $invoice->get_user_info();
144 144
 }
145 145
 
146 146
 /**
147 147
  * @deprecated
148 148
  */
149
-function wpinv_subtotal( $invoice = 0, $currency = false ) {
150
-    $invoice  = new WPInv_Invoice( $invoice );
149
+function wpinv_subtotal($invoice = 0, $currency = false) {
150
+    $invoice  = new WPInv_Invoice($invoice);
151 151
     $subtotal = $invoice->get_subtotal();
152 152
 
153
-    if ( $currency ) {
154
-        return wpinv_price( wpinv_format_amount( $subtotal ), $invoice->get_currency() );
153
+    if ($currency) {
154
+        return wpinv_price(wpinv_format_amount($subtotal), $invoice->get_currency());
155 155
     }
156 156
 
157 157
     return $subtotal;
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
 /**
161 161
  * @deprecated
162 162
  */
163
-function wpinv_tax( $invoice = 0, $currency = false ) {
164
-    $invoice  = new WPInv_Invoice( $invoice );
163
+function wpinv_tax($invoice = 0, $currency = false) {
164
+    $invoice  = new WPInv_Invoice($invoice);
165 165
     $tax      = $invoice->get_total_tax();
166 166
 
167
-    if ( $currency ) {
168
-        return wpinv_price( wpinv_format_amount( $tax ), $invoice->get_currency() );
167
+    if ($currency) {
168
+        return wpinv_price(wpinv_format_amount($tax), $invoice->get_currency());
169 169
     }
170 170
 
171 171
     return $tax;
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
 /**
175 175
  * @deprecated
176 176
  */
177
-function wpinv_discount( $invoice = 0, $currency = false, $deprecated ) {
178
-    $invoice  = new WPInv_Invoice( $invoice );
177
+function wpinv_discount($invoice = 0, $currency = false, $deprecated) {
178
+    $invoice  = new WPInv_Invoice($invoice);
179 179
     $discount = $invoice->get_total_discount();
180 180
 
181
-    if ( $currency ) {
182
-        return wpinv_price( wpinv_format_amount( $discount ), $invoice->get_currency() );
181
+    if ($currency) {
182
+        return wpinv_price(wpinv_format_amount($discount), $invoice->get_currency());
183 183
     }
184 184
 
185 185
     return $discount;
@@ -188,20 +188,20 @@  discard block
 block discarded – undo
188 188
 /**
189 189
  * @deprecated
190 190
  */
191
-function wpinv_discount_code( $invoice = 0 ) {
192
-    $invoice = new WPInv_Invoice( $invoice );
191
+function wpinv_discount_code($invoice = 0) {
192
+    $invoice = new WPInv_Invoice($invoice);
193 193
     return $invoice->get_discount_code();
194 194
 }
195 195
 
196 196
 /**
197 197
  * @deprecated
198 198
  */
199
-function wpinv_payment_total( $invoice = 0, $currency = false ) {
200
-    $invoice  = new WPInv_Invoice( $invoice );
199
+function wpinv_payment_total($invoice = 0, $currency = false) {
200
+    $invoice = new WPInv_Invoice($invoice);
201 201
     $total = $invoice->get_total();
202 202
 
203
-    if ( $currency ) {
204
-        return wpinv_price( wpinv_format_amount( $total ), $invoice->get_currency() );
203
+    if ($currency) {
204
+        return wpinv_price(wpinv_format_amount($total), $invoice->get_currency());
205 205
     }
206 206
 
207 207
     return $total;
@@ -210,51 +210,51 @@  discard block
 block discarded – undo
210 210
 /**
211 211
  * @deprecated
212 212
  */
213
-function wpinv_get_date_created( $invoice = 0, $format = '' ) {
214
-    $invoice = new WPInv_Invoice( $invoice );
213
+function wpinv_get_date_created($invoice = 0, $format = '') {
214
+    $invoice = new WPInv_Invoice($invoice);
215 215
 
216
-    $format         = ! empty( $format ) ? $format : get_option( 'date_format' );
216
+    $format         = !empty($format) ? $format : get_option('date_format');
217 217
     $date_created   = $invoice->get_created_date();
218 218
 
219
-    return empty( $date_created ) ? date_i18n( $format, strtotime( $date_created ) ) : '';
219
+    return empty($date_created) ? date_i18n($format, strtotime($date_created)) : '';
220 220
 }
221 221
 
222 222
 /**
223 223
  * @deprecated
224 224
  */
225
-function wpinv_get_invoice_date( $invoice = 0, $format = '' ) {
226
-    wpinv_get_date_created( $invoice, $format );
225
+function wpinv_get_invoice_date($invoice = 0, $format = '') {
226
+    wpinv_get_date_created($invoice, $format);
227 227
 }
228 228
 
229 229
 /**
230 230
  * @deprecated
231 231
  */
232
-function wpinv_get_invoice_vat_number( $invoice = 0 ) {
233
-    $invoice = new WPInv_Invoice( $invoice );
232
+function wpinv_get_invoice_vat_number($invoice = 0) {
233
+    $invoice = new WPInv_Invoice($invoice);
234 234
     return $invoice->get_vat_number();
235 235
 }
236 236
 
237 237
 /**
238 238
  * @deprecated
239 239
  */
240
-function wpinv_insert_payment_note( $invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false ) {
241
-    $invoice = new WPInv_Invoice( $invoice );
242
-    return $invoice->add_note( $note, $user_type, $added_by_user, $system );
240
+function wpinv_insert_payment_note($invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false) {
241
+    $invoice = new WPInv_Invoice($invoice);
242
+    return $invoice->add_note($note, $user_type, $added_by_user, $system);
243 243
 }
244 244
 
245 245
 /**
246 246
  * @deprecated
247 247
  */
248
-function wpinv_get_payment_key( $invoice = 0 ) {
249
-	$invoice = new WPInv_Invoice( $invoice );
248
+function wpinv_get_payment_key($invoice = 0) {
249
+	$invoice = new WPInv_Invoice($invoice);
250 250
     return $invoice->get_key();
251 251
 }
252 252
 
253 253
 /**
254 254
  * @deprecated
255 255
  */
256
-function wpinv_get_invoice_number( $invoice = 0 ) {
257
-    $invoice = new WPInv_Invoice( $invoice );
256
+function wpinv_get_invoice_number($invoice = 0) {
257
+    $invoice = new WPInv_Invoice($invoice);
258 258
     return $invoice->get_number();
259 259
 }
260 260
 
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
 /**
402 402
  * @deprecated
403 403
  */
404
-function wpinv_update_payment_status( $invoice, $new_status = 'publish' ) {    
405
-    $invoice = new WPInv_Invoice( $invoice );
406
-    return $invoice->update_status( $new_status );
404
+function wpinv_update_payment_status($invoice, $new_status = 'publish') {    
405
+    $invoice = new WPInv_Invoice($invoice);
406
+    return $invoice->update_status($new_status);
407 407
 }
408 408
 
409 409
 /**
@@ -456,22 +456,22 @@  discard block
 block discarded – undo
456 456
 /**
457 457
  * @deprecated
458 458
  */
459
-function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) {
459
+function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') {
460 460
 
461 461
     // Fetch the invoice.
462
-    $invoice = new WPInv_Invoice( $invoice_id );
462
+    $invoice = new WPInv_Invoice($invoice_id);
463 463
 
464
-    if ( 0 ==  $invoice->get_id() ) {
464
+    if (0 == $invoice->get_id()) {
465 465
         return false;
466 466
     }
467 467
 
468 468
     // Prepare the transaction id.
469
-    if ( empty( $transaction_id ) ) {
469
+    if (empty($transaction_id)) {
470 470
         $transaction_id = $invoice_id;
471 471
     }
472 472
 
473 473
     // Set the transaction id;
474
-    $invoice->set_transaction_id( apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice ) );
474
+    $invoice->set_transaction_id(apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice));
475 475
 
476 476
     // Save the invoice.
477 477
     return $invoice->save();
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 /**
481 481
  * @deprecated
482 482
  */
483
-function wpinv_send_to_gateway( $gateway, $payment_data ) {
484
-    do_action( 'wpinv_gateway_' . $gateway, $payment_data );
483
+function wpinv_send_to_gateway($gateway, $payment_data) {
484
+    do_action('wpinv_gateway_' . $gateway, $payment_data);
485 485
 }
486 486
 
487 487
 /**
@@ -494,8 +494,8 @@  discard block
 block discarded – undo
494 494
 /**
495 495
  * @deprecated
496 496
  */
497
-function wpinv_die( $message = '', $title = '', $status = 400 ) {
498
-    add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 );
499
-    add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 );
500
-    wp_die( $message, $title, array( 'response' => $status ));
497
+function wpinv_die($message = '', $title = '', $status = 400) {
498
+    add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3);
499
+    add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3);
500
+    wp_die($message, $title, array('response' => $status));
501 501
 }
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
@@ -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
  * Returns an array of payment gateways.
@@ -12,141 +12,141 @@  discard block
 block discarded – undo
12 12
  * @return array
13 13
  */
14 14
 function wpinv_get_payment_gateways() {
15
-    return apply_filters( 'wpinv_payment_gateways', array() );
15
+    return apply_filters('wpinv_payment_gateways', array());
16 16
 }
17 17
 
18
-function wpinv_payment_gateway_titles( $all_gateways ) {
18
+function wpinv_payment_gateway_titles($all_gateways) {
19 19
     global $wpinv_options;
20 20
 
21 21
     $gateways = array();
22
-    foreach ( $all_gateways as $key => $gateway ) {
23
-        if ( !empty( $wpinv_options[$key . '_title'] ) ) {
24
-            $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' );
22
+    foreach ($all_gateways as $key => $gateway) {
23
+        if (!empty($wpinv_options[$key . '_title'])) {
24
+            $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing');
25 25
         }
26 26
 
27
-        $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' );
27
+        $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : '');
28 28
     }
29 29
 
30
-    asort( $gateways );
30
+    asort($gateways);
31 31
 
32
-    foreach ( $gateways as $gateway => $key ) {
32
+    foreach ($gateways as $gateway => $key) {
33 33
         $gateways[$gateway] = $all_gateways[$gateway];
34 34
     }
35 35
 
36 36
     return $gateways;
37 37
 }
38
-add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 );
38
+add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1);
39 39
 
40
-function wpinv_get_enabled_payment_gateways( $sort = false ) {
40
+function wpinv_get_enabled_payment_gateways($sort = false) {
41 41
     $gateways = wpinv_get_payment_gateways();
42
-    $enabled  = wpinv_get_option( 'gateways', false );
42
+    $enabled  = wpinv_get_option('gateways', false);
43 43
 
44 44
     $gateway_list = array();
45 45
 
46
-    foreach ( $gateways as $key => $gateway ) {
47
-        if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
48
-            $gateway_list[ $key ] = $gateway;
46
+    foreach ($gateways as $key => $gateway) {
47
+        if (isset($enabled[$key]) && $enabled[$key] == 1) {
48
+            $gateway_list[$key] = $gateway;
49 49
         }
50 50
     }
51 51
 
52
-    if ( true === $sort ) {
53
-        uasort( $gateway_list, 'wpinv_sort_gateway_order' );
52
+    if (true === $sort) {
53
+        uasort($gateway_list, 'wpinv_sort_gateway_order');
54 54
         
55 55
         // Reorder our gateways so the default is first
56 56
         $default_gateway_id = wpinv_get_default_gateway();
57 57
 
58
-        if ( wpinv_is_gateway_active( $default_gateway_id ) ) {
59
-            $default_gateway    = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] );
60
-            unset( $gateway_list[ $default_gateway_id ] );
58
+        if (wpinv_is_gateway_active($default_gateway_id)) {
59
+            $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]);
60
+            unset($gateway_list[$default_gateway_id]);
61 61
 
62
-            $gateway_list = array_merge( $default_gateway, $gateway_list );
62
+            $gateway_list = array_merge($default_gateway, $gateway_list);
63 63
         }
64 64
     }
65 65
 
66
-    return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list );
66
+    return apply_filters('wpinv_enabled_payment_gateways', $gateway_list);
67 67
 }
68 68
 
69
-function wpinv_sort_gateway_order( $a, $b ) {
69
+function wpinv_sort_gateway_order($a, $b) {
70 70
     return $a['ordering'] - $b['ordering'];
71 71
 }
72 72
 
73
-function wpinv_is_gateway_active( $gateway ) {
73
+function wpinv_is_gateway_active($gateway) {
74 74
     $gateways = wpinv_get_enabled_payment_gateways();
75 75
 
76
-    $ret = is_array($gateways) && $gateway ?  array_key_exists( $gateway, $gateways ) : false;
76
+    $ret = is_array($gateways) && $gateway ?  array_key_exists($gateway, $gateways) : false;
77 77
 
78
-    return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways );
78
+    return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways);
79 79
 }
80 80
 
81 81
 function wpinv_get_default_gateway() {
82
-    $default = wpinv_get_option( 'default_gateway', 'paypal' );
82
+    $default = wpinv_get_option('default_gateway', 'paypal');
83 83
 
84
-    if ( !wpinv_is_gateway_active( $default ) ) {
84
+    if (!wpinv_is_gateway_active($default)) {
85 85
         $gateways = wpinv_get_enabled_payment_gateways();
86
-        $gateways = array_keys( $gateways );
87
-        $default  = reset( $gateways );
86
+        $gateways = array_keys($gateways);
87
+        $default  = reset($gateways);
88 88
     }
89 89
 
90
-    return apply_filters( 'wpinv_default_gateway', $default );
90
+    return apply_filters('wpinv_default_gateway', $default);
91 91
 }
92 92
 
93
-function wpinv_get_gateway_admin_label( $gateway ) {
93
+function wpinv_get_gateway_admin_label($gateway) {
94 94
     $gateways = wpinv_get_payment_gateways();
95
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
96
-    $payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
95
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
96
+    $payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
97 97
 
98
-    if( $gateway == 'manual' && $payment ) {
99
-        if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) {
100
-            $label = __( 'Free Purchase', 'invoicing' );
98
+    if ($gateway == 'manual' && $payment) {
99
+        if (!((float) wpinv_payment_total($payment) > 0)) {
100
+            $label = __('Free Purchase', 'invoicing');
101 101
         }
102 102
     }
103 103
 
104
-    return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway );
104
+    return apply_filters('wpinv_gateway_admin_label', $label, $gateway);
105 105
 }
106 106
 
107
-function wpinv_get_gateway_description( $gateway ) {
107
+function wpinv_get_gateway_description($gateway) {
108 108
     global $wpinv_options;
109 109
 
110
-    $description = ! empty( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : '';
110
+    $description = !empty($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : '';
111 111
 
112
-    return apply_filters( 'wpinv_gateway_description', $description, $gateway );
112
+    return apply_filters('wpinv_gateway_description', $description, $gateway);
113 113
 }
114 114
 
115
-function wpinv_get_gateway_button_label( $gateway ) {
116
-    return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' );
115
+function wpinv_get_gateway_button_label($gateway) {
116
+    return apply_filters('wpinv_gateway_' . $gateway . '_button_label', '');
117 117
 }
118 118
 
119
-function wpinv_get_gateway_checkout_label( $gateway ) {
119
+function wpinv_get_gateway_checkout_label($gateway) {
120 120
     $gateways = wpinv_get_payment_gateways();
121
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
121
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
122 122
 
123
-    if ( $gateway == 'none' ) {
124
-        $label = __( 'None', 'invoicing' );
123
+    if ($gateway == 'none') {
124
+        $label = __('None', 'invoicing');
125 125
     }
126 126
 
127
-    return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway );
127
+    return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway);
128 128
 }
129 129
 
130
-function wpinv_settings_sections_gateways( $settings ) {
130
+function wpinv_settings_sections_gateways($settings) {
131 131
     $gateways = wpinv_get_payment_gateways();
132 132
     
133 133
     if (!empty($gateways)) {
134
-        foreach  ($gateways as $key => $gateway) {
134
+        foreach ($gateways as $key => $gateway) {
135 135
             $settings[$key] = $gateway['admin_label'];
136 136
         }
137 137
     }
138 138
     
139 139
     return $settings;    
140 140
 }
141
-add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 );
141
+add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1);
142 142
 
143 143
 /**
144 144
  * Adds GateWay settings.
145 145
  */
146
-function wpinv_settings_gateways( $settings ) {
146
+function wpinv_settings_gateways($settings) {
147 147
 
148 148
     // Loop through each gateway.
149
-    foreach  ( wpinv_get_payment_gateways() as $key => $gateway ) {
149
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
150 150
 
151 151
         $gateway_settings = array(
152 152
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             "{$key}_header" => array(
155 155
 
156 156
                 'id'     => "{$key}_gateway_header",
157
-                'name'   => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>',
157
+                'name'   => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>',
158 158
                 'custom' => $key,
159 159
                 'type'   => 'gateway_header',
160 160
 
@@ -163,56 +163,56 @@  discard block
 block discarded – undo
163 163
             // Activate/Deactivate a gateway.
164 164
             "{$key}_active" => array(
165 165
                 'id'   => $key . '_active',
166
-                'name' => __( 'Activate', 'invoicing' ),
167
-                'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ),
166
+                'name' => __('Activate', 'invoicing'),
167
+                'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']),
168 168
                 'type' => 'checkbox',
169 169
             ),
170 170
 
171 171
             // Activate/Deactivate sandbox.
172 172
             "{$key}_sandbox" => array(
173 173
                 'id'   => $key . '_sandbox',
174
-                'name' => __( 'Sandbox', 'invoicing' ),
175
-                'desc' => __( 'Enable sandbox to test payments', 'invoicing' ),
174
+                'name' => __('Sandbox', 'invoicing'),
175
+                'desc' => __('Enable sandbox to test payments', 'invoicing'),
176 176
                 'type' => 'checkbox',
177 177
             ),
178 178
 
179 179
             // Checkout title.
180 180
             "{$key}_title" => array(
181 181
                 'id'   => $key . '_title',
182
-                'name' => __( 'Checkout Title', 'invoicing' ),
183
-                'std'  => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '',
182
+                'name' => __('Checkout Title', 'invoicing'),
183
+                'std'  => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '',
184 184
                 'type' => 'text',
185 185
             ),
186 186
 
187 187
             // Checkout description.
188 188
             "{$key}_desc" => array(
189 189
                 'id'   => $key . '_desc',
190
-                'name' => __( 'Checkout Description', 'invoicing' ),
191
-                'std'  => apply_filters( "getpaid_default_{$key}_checkout_description", '' ),
190
+                'name' => __('Checkout Description', 'invoicing'),
191
+                'std'  => apply_filters("getpaid_default_{$key}_checkout_description", ''),
192 192
                 'type' => 'text',
193 193
             ),
194 194
 
195 195
             // Checkout order.
196 196
             "{$key}_ordering" => array(
197 197
                 'id'   => $key . '_ordering',
198
-                'name' => __( 'Priority', 'invoicing' ),
199
-                'std'  => apply_filters( "getpaid_default_{$key}_checkout_description", '' ),
198
+                'name' => __('Priority', 'invoicing'),
199
+                'std'  => apply_filters("getpaid_default_{$key}_checkout_description", ''),
200 200
                 'type' => 'number',
201 201
                 'step' => '1',
202 202
                 'min'  => '-100000',
203 203
                 'max'  => '100000',
204
-                'std'  => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10',
204
+                'std'  => isset($gateway['ordering']) ? $gateway['ordering'] : '10',
205 205
             ),
206 206
 
207 207
         );
208 208
 
209 209
         // Maybe remove the sandbox.
210
-        if ( ! apply_filters( "wpinv_{$key}_supports_sandbox", false ) ) {
211
-            unset( $gateway_settings["{$key}_sandbox"] );
210
+        if (!apply_filters("wpinv_{$key}_supports_sandbox", false)) {
211
+            unset($gateway_settings["{$key}_sandbox"]);
212 212
         }
213 213
   
214
-        $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway );
215
-        $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway );
214
+        $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway);
215
+        $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway);
216 216
         
217 217
         $settings[$key] = $gateway_settings;
218 218
     }
@@ -220,38 +220,38 @@  discard block
 block discarded – undo
220 220
     return $settings;
221 221
 
222 222
 }
223
-add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 );
223
+add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1);
224 224
 
225
-function wpinv_gateway_header_callback( $args ) {
226
-    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />';
225
+function wpinv_gateway_header_callback($args) {
226
+    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />';
227 227
 }
228 228
 
229
-function wpinv_get_gateway_supports( $gateway ) {
229
+function wpinv_get_gateway_supports($gateway) {
230 230
     $gateways = wpinv_get_enabled_payment_gateways();
231
-    $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
232
-    return apply_filters( 'wpinv_gateway_supports', $supports, $gateway );
231
+    $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
232
+    return apply_filters('wpinv_gateway_supports', $supports, $gateway);
233 233
 }
234 234
 
235
-function wpinv_gateway_supports_buy_now( $gateway ) {
236
-    $supports = wpinv_get_gateway_supports( $gateway );
237
-    $ret = in_array( 'buy_now', $supports );
238
-    return apply_filters( 'wpinv_gateway_supports_buy_now', $ret, $gateway );
235
+function wpinv_gateway_supports_buy_now($gateway) {
236
+    $supports = wpinv_get_gateway_supports($gateway);
237
+    $ret = in_array('buy_now', $supports);
238
+    return apply_filters('wpinv_gateway_supports_buy_now', $ret, $gateway);
239 239
 }
240 240
 
241 241
 function wpinv_shop_supports_buy_now() {
242 242
     $gateways = wpinv_get_enabled_payment_gateways();
243 243
     $ret      = false;
244 244
 
245
-    if ( !wpinv_use_taxes()  && $gateways ) {
246
-        foreach ( $gateways as $gateway_id => $gateway ) {
247
-            if ( wpinv_gateway_supports_buy_now( $gateway_id ) ) {
245
+    if (!wpinv_use_taxes() && $gateways) {
246
+        foreach ($gateways as $gateway_id => $gateway) {
247
+            if (wpinv_gateway_supports_buy_now($gateway_id)) {
248 248
                 $ret = true;
249 249
                 break;
250 250
             }
251 251
         }
252 252
     }
253 253
 
254
-    return apply_filters( 'wpinv_shop_supports_buy_now', $ret );
254
+    return apply_filters('wpinv_shop_supports_buy_now', $ret);
255 255
 }
256 256
 
257 257
 
@@ -259,61 +259,61 @@  discard block
 block discarded – undo
259 259
     $gateways = wpinv_get_enabled_payment_gateways();
260 260
     $show_gateways = false;
261 261
 
262
-    $chosen_gateway = isset( $_GET['payment-mode'] ) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode'] ) : false;
262
+    $chosen_gateway = isset($_GET['payment-mode']) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode']) : false;
263 263
 
264
-    if ( count( $gateways ) > 1 && empty( $chosen_gateway ) ) {
264
+    if (count($gateways) > 1 && empty($chosen_gateway)) {
265 265
         $show_gateways = true;
266
-        if ( wpinv_get_cart_total() <= 0 ) {
266
+        if (wpinv_get_cart_total() <= 0) {
267 267
             $show_gateways = false;
268 268
         }
269 269
     }
270 270
     
271
-    if ( !$show_gateways && wpinv_cart_has_recurring_item() ) {
271
+    if (!$show_gateways && wpinv_cart_has_recurring_item()) {
272 272
         $show_gateways = true;
273 273
     }
274 274
 
275
-    return apply_filters( 'wpinv_show_gateways', $show_gateways );
275
+    return apply_filters('wpinv_show_gateways', $show_gateways);
276 276
 }
277 277
 
278
-function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
279
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
278
+function wpinv_get_chosen_gateway($invoice_id = 0) {
279
+	$gateways = array_keys(wpinv_get_enabled_payment_gateways());
280 280
 
281 281
     $chosen = false;
282
-    if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
282
+    if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) {
283 283
         $chosen = $invoice->get_gateway();
284 284
     }
285 285
 
286
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
286
+	$chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen;
287 287
 
288
-	if ( false !== $chosen ) {
289
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
288
+	if (false !== $chosen) {
289
+		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen);
290 290
 	}
291 291
 
292
-	if ( ! empty ( $chosen ) ) {
293
-		$enabled_gateway = urldecode( $chosen );
294
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
292
+	if (!empty ($chosen)) {
293
+		$enabled_gateway = urldecode($chosen);
294
+	} else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) {
295 295
 		$enabled_gateway = 'manual';
296 296
 	} else {
297 297
 		$enabled_gateway = wpinv_get_default_gateway();
298 298
 	}
299 299
     
300
-    if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
301
-        if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
300
+    if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) {
301
+        if (wpinv_is_gateway_active(wpinv_get_default_gateway())) {
302 302
             $enabled_gateway = wpinv_get_default_gateway();
303
-        }else{
303
+        } else {
304 304
             $enabled_gateway = $gateways[0];
305 305
         }
306 306
 
307 307
     }
308 308
 
309
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
309
+	return apply_filters('wpinv_chosen_gateway', $enabled_gateway);
310 310
 }
311 311
 
312
-function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
313
-    return wpinv_error_log( $message, $title );
312
+function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) {
313
+    return wpinv_error_log($message, $title);
314 314
 }
315 315
 
316
-function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
316
+function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
317 317
 	$ret  = 0;
318 318
 	$args = array(
319 319
 		'meta_key'    => '_wpinv_gateway',
@@ -324,48 +324,48 @@  discard block
 block discarded – undo
324 324
 		'fields'      => 'ids'
325 325
 	);
326 326
 
327
-	$payments = new WP_Query( $args );
327
+	$payments = new WP_Query($args);
328 328
 
329
-	if( $payments )
329
+	if ($payments)
330 330
 		$ret = $payments->post_count;
331 331
 	return $ret;
332 332
 }
333 333
 
334
-function wpinv_settings_update_gateways( $input ) {
334
+function wpinv_settings_update_gateways($input) {
335 335
     global $wpinv_options;
336 336
     
337
-    if ( !empty( $input['save_gateway'] ) ) {
338
-        $gateways = wpinv_get_option( 'gateways', false );
337
+    if (!empty($input['save_gateway'])) {
338
+        $gateways = wpinv_get_option('gateways', false);
339 339
         $gateways = !empty($gateways) ? $gateways : array();
340 340
         $gateway = $input['save_gateway'];
341 341
         
342
-        if ( !empty( $input[$gateway . '_active'] ) ) {
342
+        if (!empty($input[$gateway . '_active'])) {
343 343
             $gateways[$gateway] = 1;
344 344
         } else {
345
-            if ( isset( $gateways[$gateway] ) ) {
346
-                unset( $gateways[$gateway] );
345
+            if (isset($gateways[$gateway])) {
346
+                unset($gateways[$gateway]);
347 347
             }
348 348
         }
349 349
         
350 350
         $input['gateways'] = $gateways;
351 351
     }
352 352
     
353
-    if ( !empty( $input['default_gateway'] ) ) {
353
+    if (!empty($input['default_gateway'])) {
354 354
         $gateways = wpinv_get_payment_gateways();
355 355
         
356
-        foreach ( $gateways as $key => $gateway ) {
357
-            $active   = 0;
358
-            if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) {
356
+        foreach ($gateways as $key => $gateway) {
357
+            $active = 0;
358
+            if (!empty($input['gateways']) && !empty($input['gateways'][$key])) {
359 359
                 $active = 1;
360 360
             }
361 361
             
362 362
             $input[$key . '_active'] = $active;
363 363
             
364
-            if ( empty( $wpinv_options[$key . '_title'] ) ) {
364
+            if (empty($wpinv_options[$key . '_title'])) {
365 365
                 $input[$key . '_title'] = $gateway['checkout_label'];
366 366
             }
367 367
             
368
-            if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) {
368
+            if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) {
369 369
                 $input[$key . '_ordering'] = $gateway['ordering'];
370 370
             }
371 371
         }
@@ -373,27 +373,27 @@  discard block
 block discarded – undo
373 373
     
374 374
     return $input;
375 375
 }
376
-add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 );
376
+add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1);
377 377
 
378 378
 // PayPal Standard settings
379
-function wpinv_gateway_settings_paypal( $setting ) {    
380
-    $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' );
381
-    $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
379
+function wpinv_gateway_settings_paypal($setting) {    
380
+    $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');
381
+    $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
382 382
     
383 383
     $setting['paypal_sandbox'] = array(
384 384
             'type' => 'checkbox',
385 385
             'id'   => 'paypal_sandbox',
386
-            'name' => __( 'PayPal Sandbox', 'invoicing' ),
387
-            'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ),
386
+            'name' => __('PayPal Sandbox', 'invoicing'),
387
+            'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'),
388 388
             'std'  => 1
389 389
         );
390 390
         
391 391
     $setting['paypal_email'] = array(
392 392
             'type' => 'text',
393 393
             'id'   => 'paypal_email',
394
-            'name' => __( 'PayPal Email', 'invoicing' ),
395
-            'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ),
396
-            'std' => __( '[email protected]', 'invoicing' ),
394
+            'name' => __('PayPal Email', 'invoicing'),
395
+            'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'),
396
+            'std' => __('[email protected]', 'invoicing'),
397 397
         );
398 398
     /*
399 399
     $setting['paypal_ipn_url'] = array(
@@ -407,18 +407,18 @@  discard block
 block discarded – undo
407 407
         
408 408
     return $setting;
409 409
 }
410
-add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 );
410
+add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1);
411 411
 
412 412
 /**
413 413
  * Displays the ipn url field.
414 414
  */
415
-function wpinv_ipn_url_callback( $args ) {
416
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
415
+function wpinv_ipn_url_callback($args) {
416
+    $sanitize_id = wpinv_sanitize_key($args['id']);
417 417
     
418 418
     $attrs = $args['readonly'] ? ' readonly' : '';
419 419
 
420
-    $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()">';
421
-    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">'  . $args['desc'] . '</label>';
420
+    $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()">';
421
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>';
422 422
 
423 423
     echo $html;
424 424
 }
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
  * 
431 431
  * @return bool
432 432
  */
433
-function wpinv_is_test_mode( $gateway = '' ) {
434
-    $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", false );
435
-    return apply_filters( 'wpinv_is_test_mode', $sandbox, $gateway );
433
+function wpinv_is_test_mode($gateway = '') {
434
+    $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", false);
435
+    return apply_filters('wpinv_is_test_mode', $sandbox, $gateway);
436 436
 }
437 437
 
438 438
 /**
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
  * 
444 444
  * @return string
445 445
  */
446
-function wpinv_get_ipn_url( $gateway = false, $args = array() ) {
446
+function wpinv_get_ipn_url($gateway = false, $args = array()) {
447 447
     $args = wp_parse_args(
448 448
         array(
449 449
             'wpi-listener' => 'IPN',
@@ -452,24 +452,24 @@  discard block
 block discarded – undo
452 452
         $args
453 453
     );
454 454
 
455
-    return apply_filters( 'wpinv_ipn_url', add_query_arg( $args,  home_url( 'index.php' ) ), $gateway, $args );
455
+    return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args);
456 456
 
457 457
 }
458 458
 
459
-function wpinv_get_post_data( $method = 'request' ) {
459
+function wpinv_get_post_data($method = 'request') {
460 460
     $data       = array();
461 461
     $request    = $_REQUEST;
462 462
     
463
-    if ( $method == 'post' ) {
464
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
463
+    if ($method == 'post') {
464
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
465 465
             return $data;
466 466
         }
467 467
         
468 468
         $request = $_POST;
469 469
     }
470 470
     
471
-    if ( $method == 'get' ) {
472
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'GET' ) {
471
+    if ($method == 'get') {
472
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') {
473 473
             return $data;
474 474
         }
475 475
         
@@ -480,11 +480,11 @@  discard block
 block discarded – undo
480 480
     $post_data = '';
481 481
     
482 482
     // Fallback just in case post_max_size is lower than needed
483
-    if ( ini_get( 'allow_url_fopen' ) ) {
484
-        $post_data = file_get_contents( 'php://input' );
483
+    if (ini_get('allow_url_fopen')) {
484
+        $post_data = file_get_contents('php://input');
485 485
     } else {
486 486
         // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
487
-        ini_set( 'post_max_size', '12M' );
487
+        ini_set('post_max_size', '12M');
488 488
     }
489 489
     // Start the encoded data collection with notification command
490 490
     $encoded_data = 'cmd=_notify-validate';
@@ -493,33 +493,33 @@  discard block
 block discarded – undo
493 493
     $arg_separator = wpinv_get_php_arg_separator_output();
494 494
 
495 495
     // Verify there is a post_data
496
-    if ( $post_data || strlen( $post_data ) > 0 ) {
496
+    if ($post_data || strlen($post_data) > 0) {
497 497
         // Append the data
498 498
         $encoded_data .= $arg_separator . $post_data;
499 499
     } else {
500 500
         // Check if POST is empty
501
-        if ( empty( $request ) ) {
501
+        if (empty($request)) {
502 502
             // Nothing to do
503 503
             return;
504 504
         } else {
505 505
             // Loop through each POST
506
-            foreach ( $request as $key => $value ) {
506
+            foreach ($request as $key => $value) {
507 507
                 // Encode the value and append the data
508
-                $encoded_data .= $arg_separator . "$key=" . urlencode( $value );
508
+                $encoded_data .= $arg_separator . "$key=" . urlencode($value);
509 509
             }
510 510
         }
511 511
     }
512 512
 
513 513
     // Convert collected post data to an array
514
-    wp_parse_str( $encoded_data, $data );
514
+    wp_parse_str($encoded_data, $data);
515 515
 
516
-    foreach ( $data as $key => $value ) {
517
-        if ( false !== strpos( $key, 'amp;' ) ) {
518
-            $new_key = str_replace( '&amp;', '&', $key );
519
-            $new_key = str_replace( 'amp;', '&' , $new_key );
516
+    foreach ($data as $key => $value) {
517
+        if (false !== strpos($key, 'amp;')) {
518
+            $new_key = str_replace('&amp;', '&', $key);
519
+            $new_key = str_replace('amp;', '&', $new_key);
520 520
 
521
-            unset( $data[ $key ] );
522
-            $data[ $new_key ] = sanitize_text_field( $value );
521
+            unset($data[$key]);
522
+            $data[$new_key] = sanitize_text_field($value);
523 523
         }
524 524
     }
525 525
     
@@ -529,12 +529,12 @@  discard block
 block discarded – undo
529 529
 /**
530 530
  * Checks if a given gateway supports subscription payments.
531 531
  */
532
-function wpinv_gateway_support_subscription( $gateway ) {
532
+function wpinv_gateway_support_subscription($gateway) {
533 533
     $supports = false;
534 534
 
535
-    if ( wpinv_is_gateway_active( $gateway ) ) {
536
-        $supports = apply_filters( 'wpinv_' . $gateway . '_support_subscription', $supports );
537
-        $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $gateway );
535
+    if (wpinv_is_gateway_active($gateway)) {
536
+        $supports = apply_filters('wpinv_' . $gateway . '_support_subscription', $supports);
537
+        $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $gateway);
538 538
     }
539 539
 
540 540
     return $supports;
@@ -546,14 +546,14 @@  discard block
 block discarded – undo
546 546
  * @param array $gateways an array of gateways.
547 547
  * @param GetPaid_Payment_Form $form payment form.
548 548
  */
549
-function wpinv_payment_gateways_on_cart( $gateways, $form ) {
549
+function wpinv_payment_gateways_on_cart($gateways, $form) {
550 550
 
551
-    if ( $form->is_recurring() ) {
551
+    if ($form->is_recurring()) {
552 552
 
553
-        foreach ( array_keys( $gateways ) as $gateway ) {
553
+        foreach (array_keys($gateways) as $gateway) {
554 554
 
555
-            if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
556
-                unset( $gateways[$gateway] );
555
+            if (!wpinv_gateway_support_subscription($gateway)) {
556
+                unset($gateways[$gateway]);
557 557
             }
558 558
 
559 559
         }
@@ -562,24 +562,24 @@  discard block
 block discarded – undo
562 562
 
563 563
     return $gateways;
564 564
 }
565
-add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 );
565
+add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2);
566 566
 
567 567
 /**
568 568
  * Validates checkout fields.
569 569
  *
570 570
  * @param GetPaid_Payment_Form_Submission $submission
571 571
  */
572
-function wpinv_checkout_validate_gateway( $submission ) {
572
+function wpinv_checkout_validate_gateway($submission) {
573 573
 
574 574
     $data = $submission->get_data();
575 575
 
576 576
     // Non-recurring gateways should not be allowed to process recurring invoices.
577
-    if ( $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
578
-        wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway does not support subscription payment.', 'invoicing' ) );
577
+    if ($submission->has_recurring && !wpinv_gateway_support_subscription($data['wpi-gateway'])) {
578
+        wpinv_set_error('invalid_gateway', __('The selected payment gateway does not support subscription payment.', 'invoicing'));
579 579
     }
580 580
 
581
-    if ( ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
582
-        wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
581
+    if (!wpinv_is_gateway_active($data['wpi-gateway'])) {
582
+        wpinv_set_error('invalid_gateway', __('The selected payment gateway is not active', 'invoicing'));
583 583
     }
584 584
 
585 585
 }
@@ -587,84 +587,84 @@  discard block
 block discarded – undo
587 587
 /**
588 588
  * Validates a zip code.
589 589
  */
590
-function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) {
590
+function wpinv_checkout_validate_cc_zip($zip = 0, $country_code = '') {
591 591
 
592
-    if ( empty( $zip ) || empty( $country_code ) ){
592
+    if (empty($zip) || empty($country_code)) {
593 593
         return false;
594 594
     }
595 595
 
596 596
     // Prepare the country code.
597
-    $country_code = strtoupper( trim( $country_code ) );
597
+    $country_code = strtoupper(trim($country_code));
598 598
 
599 599
     // Fetch the regexes.
600
-    $zip_regex = wpinv_get_data( 'zip-regexes' );
600
+    $zip_regex = wpinv_get_data('zip-regexes');
601 601
 
602 602
     // Check if it is valid.
603
-    $is_valid = ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip );
603
+    $is_valid = !isset ($zip_regex[$country_code]) || preg_match("/" . $zip_regex[$country_code] . "/i", $zip);
604 604
 
605
-    return apply_filters( 'wpinv_is_zip_valid', $is_valid, $zip, $country_code );
605
+    return apply_filters('wpinv_is_zip_valid', $is_valid, $zip, $country_code);
606 606
 }
607 607
 
608 608
 function wpinv_checkout_validate_agree_to_terms() {
609 609
     // Validate agree to terms
610
-    if ( ! isset( $_POST['wpi_agree_to_terms'] ) || $_POST['wpi_agree_to_terms'] != 1 ) {
610
+    if (!isset($_POST['wpi_agree_to_terms']) || $_POST['wpi_agree_to_terms'] != 1) {
611 611
         // User did not agree
612
-        wpinv_set_error( 'agree_to_terms', apply_filters( 'wpinv_agree_to_terms_text', __( 'You must agree to the terms of use', 'invoicing' ) ) );
612
+        wpinv_set_error('agree_to_terms', apply_filters('wpinv_agree_to_terms_text', __('You must agree to the terms of use', 'invoicing')));
613 613
     }
614 614
 }
615 615
 
616 616
 function wpinv_checkout_validate_invoice_user() {
617 617
     global $wpi_cart, $user_ID;
618 618
 
619
-    if(empty($wpi_cart)){
619
+    if (empty($wpi_cart)) {
620 620
         $wpi_cart = wpinv_get_invoice_cart();
621 621
     }
622 622
 
623
-    $invoice_user = (int)$wpi_cart->get_user_id();
623
+    $invoice_user = (int) $wpi_cart->get_user_id();
624 624
     $valid_user_data = array(
625 625
         'user_id' => $invoice_user
626 626
     );
627 627
 
628 628
     // If guest checkout allowed
629
-    if ( !wpinv_require_login_to_checkout() ) {
629
+    if (!wpinv_require_login_to_checkout()) {
630 630
         return $valid_user_data;
631 631
     }
632 632
     
633 633
     // Verify there is a user_ID
634
-    if ( $user_ID == $invoice_user ) {
634
+    if ($user_ID == $invoice_user) {
635 635
         // Get the logged in user data
636
-        $user_data = get_userdata( $user_ID );
637
-        $required_fields  = wpinv_checkout_required_fields();
636
+        $user_data = get_userdata($user_ID);
637
+        $required_fields = wpinv_checkout_required_fields();
638 638
 
639 639
         // Loop through required fields and show error messages
640
-         if ( !empty( $required_fields ) ) {
641
-            foreach ( $required_fields as $field_name => $value ) {
642
-                if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) {
643
-                    wpinv_set_error( $value['error_id'], $value['error_message'] );
640
+         if (!empty($required_fields)) {
641
+            foreach ($required_fields as $field_name => $value) {
642
+                if (in_array($value, $required_fields) && empty($_POST['wpinv_' . $field_name])) {
643
+                    wpinv_set_error($value['error_id'], $value['error_message']);
644 644
                 }
645 645
             }
646 646
         }
647 647
 
648 648
         // Verify data
649
-        if ( $user_data ) {
649
+        if ($user_data) {
650 650
             // Collected logged in user data
651 651
             $valid_user_data = array(
652 652
                 'user_id'     => $user_ID,
653
-                'email'       => isset( $_POST['wpinv_email'] ) ? sanitize_email( $_POST['wpinv_email'] ) : $user_data->user_email,
654
-                'first_name'  => isset( $_POST['wpinv_first_name'] ) && ! empty( $_POST['wpinv_first_name'] ) ? sanitize_text_field( $_POST['wpinv_first_name'] ) : $user_data->first_name,
655
-                'last_name'   => isset( $_POST['wpinv_last_name'] ) && ! empty( $_POST['wpinv_last_name']  ) ? sanitize_text_field( $_POST['wpinv_last_name']  ) : $user_data->last_name,
653
+                'email'       => isset($_POST['wpinv_email']) ? sanitize_email($_POST['wpinv_email']) : $user_data->user_email,
654
+                'first_name'  => isset($_POST['wpinv_first_name']) && !empty($_POST['wpinv_first_name']) ? sanitize_text_field($_POST['wpinv_first_name']) : $user_data->first_name,
655
+                'last_name'   => isset($_POST['wpinv_last_name']) && !empty($_POST['wpinv_last_name']) ? sanitize_text_field($_POST['wpinv_last_name']) : $user_data->last_name,
656 656
             );
657 657
 
658
-            if ( !empty( $_POST[ 'wpinv_email' ] ) && !is_email( $_POST[ 'wpinv_email' ] ) ) {
659
-                wpinv_set_error( 'invalid_email', __( 'Please enter a valid email address', 'invoicing' ) );
658
+            if (!empty($_POST['wpinv_email']) && !is_email($_POST['wpinv_email'])) {
659
+                wpinv_set_error('invalid_email', __('Please enter a valid email address', 'invoicing'));
660 660
             }
661 661
         } else {
662 662
             // Set invalid user error
663
-            wpinv_set_error( 'invalid_user', __( 'The user billing information is invalid', 'invoicing' ) );
663
+            wpinv_set_error('invalid_user', __('The user billing information is invalid', 'invoicing'));
664 664
         }
665 665
     } else {
666 666
         // Set invalid user error
667
-        wpinv_set_error( 'invalid_user_id', __( 'The invalid invoice user id', 'invoicing' ) );
667
+        wpinv_set_error('invalid_user_id', __('The invalid invoice user id', 'invoicing'));
668 668
     }
669 669
 
670 670
     // Return user data
@@ -676,18 +676,18 @@  discard block
 block discarded – undo
676 676
 
677 677
     $data = array();
678 678
     
679
-    if ( is_user_logged_in() ) {
680
-        if ( !wpinv_require_login_to_checkout() || ( wpinv_require_login_to_checkout() && (int)$wpi_cart->get_user_id() === (int)get_current_user_id() ) ) {
681
-            $data['user_id'] = (int)get_current_user_id();
679
+    if (is_user_logged_in()) {
680
+        if (!wpinv_require_login_to_checkout() || (wpinv_require_login_to_checkout() && (int) $wpi_cart->get_user_id() === (int) get_current_user_id())) {
681
+            $data['user_id'] = (int) get_current_user_id();
682 682
         } else {
683
-            wpinv_set_error( 'logged_in_only', __( 'You are not allowed to pay for this invoice', 'invoicing' ) );
683
+            wpinv_set_error('logged_in_only', __('You are not allowed to pay for this invoice', 'invoicing'));
684 684
         }
685 685
     } else {
686 686
         // If guest checkout allowed
687
-        if ( !wpinv_require_login_to_checkout() ) {
687
+        if (!wpinv_require_login_to_checkout()) {
688 688
             $data['user_id'] = 0;
689 689
         } else {
690
-            wpinv_set_error( 'logged_in_only', __( 'You must be logged in to pay for this invoice', 'invoicing' ) );
690
+            wpinv_set_error('logged_in_only', __('You must be logged in to pay for this invoice', 'invoicing'));
691 691
         }
692 692
     }
693 693
 
@@ -701,41 +701,41 @@  discard block
 block discarded – undo
701 701
  * @param WPInv_Invoice $invoice
702 702
  * @param GetPaid_Payment_Form_Submission $submission
703 703
  */
704
-function wpinv_process_checkout( $invoice, $submission ) {
704
+function wpinv_process_checkout($invoice, $submission) {
705 705
 
706 706
     // No need to send free invoices to the gateway.
707
-    if ( $invoice->is_free() ) {
708
-        $invoice->set_gateway( 'none' );
709
-        $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
707
+    if ($invoice->is_free()) {
708
+        $invoice->set_gateway('none');
709
+        $invoice->add_note(__("This is a free invoice and won't be sent to the payment gateway", 'invoicing'), false, false, true);
710 710
         $invoice->mark_paid();
711
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
711
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
712 712
     }
713 713
 
714 714
     // Clear an checkout errors.
715 715
     wpinv_clear_errors();
716 716
 
717 717
     // Fires before sending to the gateway.
718
-    do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
718
+    do_action('getpaid_checkout_before_gateway', $invoice, $submission);
719 719
 
720 720
     // Allow the sumission data to be modified before it is sent to the gateway.
721 721
     $submission_data    = $submission->get_data();
722
-    $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $submission_data['wpi-gateway'], $submission, $invoice );
723
-    $submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
722
+    $submission_gateway = apply_filters('getpaid_gateway_submission_gateway', $submission_data['wpi-gateway'], $submission, $invoice);
723
+    $submission_data    = apply_filters('getpaid_gateway_submission_data', $submission_data, $submission, $invoice);
724 724
 
725 725
     // Validate the currency.
726
-    if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
727
-        wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support the invoice currency', 'invoicing' ) );
726
+    if (!apply_filters("getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency())) {
727
+        wpinv_set_error('invalid_currency', __('The chosen payment gateway does not support the invoice currency', 'invoicing'));
728 728
     }
729 729
 
730 730
     // Check to see if we have any errors.
731
-    if ( wpinv_get_errors() ) {
731
+    if (wpinv_get_errors()) {
732 732
         wpinv_send_back_to_checkout();
733 733
     }
734 734
 
735 735
     // Send info to the gateway for payment processing
736
-    do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
736
+    do_action("getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission);
737 737
 
738 738
     // Backwards compatibility.
739
-    do_action( "wpinv_gateway_$submission_gateway", null, $invoice, $submission_data, $submission );
739
+    do_action("wpinv_gateway_$submission_gateway", null, $invoice, $submission_data, $submission);
740 740
 
741 741
 }
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -13,53 +13,53 @@  discard block
 block discarded – undo
13 13
 class WPInv_Plugin {
14 14
 
15 15
     /**
16
-	 * GetPaid version.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * GetPaid version.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $version;
21 21
 
22 22
     /**
23
-	 * Session instance.
24
-	 *
25
-	 * @var WPInv_Session|WPInv_Session_Handler
26
-	 */
23
+     * Session instance.
24
+     *
25
+     * @var WPInv_Session|WPInv_Session_Handler
26
+     */
27 27
     public $session;
28 28
     
29 29
     /**
30
-	 * Notes instance.
31
-	 *
32
-	 * @var WPInv_Notes
33
-	 */
30
+     * Notes instance.
31
+     *
32
+     * @var WPInv_Notes
33
+     */
34 34
     public $notes;
35 35
     
36 36
     /**
37
-	 * Reports instance.
38
-	 *
39
-	 * @var WPInv_Reports
40
-	 */
37
+     * Reports instance.
38
+     *
39
+     * @var WPInv_Reports
40
+     */
41 41
     public $reports;
42 42
     
43 43
     /**
44
-	 * API instance.
45
-	 *
46
-	 * @var WPInv_API
47
-	 */
44
+     * API instance.
45
+     *
46
+     * @var WPInv_API
47
+     */
48 48
     public $api;
49 49
     
50 50
     /**
51
-	 * Form elements instance.
52
-	 *
53
-	 * @var WPInv_Payment_Form_Elements
54
-	 */
51
+     * Form elements instance.
52
+     *
53
+     * @var WPInv_Payment_Form_Elements
54
+     */
55 55
     public $form_elements;
56 56
     
57 57
     /**
58
-	 * Tax instance.
59
-	 *
60
-	 * @var WPInv_EUVat
61
-	 */
62
-	public $tax;
58
+     * Tax instance.
59
+     *
60
+     * @var WPInv_EUVat
61
+     */
62
+    public $tax;
63 63
 
64 64
     /**
65 65
      * @param array An array of payment gateways.
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
     public $options;
73 73
 
74 74
     /**
75
-	 * Class constructor.
76
-	 */
75
+     * Class constructor.
76
+     */
77 77
     public function __construct() {
78 78
         $this->define_constants();
79 79
         $this->includes();
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
     }
83 83
 
84 84
     /**
85
-	 * Define class properties.
86
-	 */
85
+     * Define class properties.
86
+     */
87 87
     public function set_properties() {
88 88
 
89 89
         $this->session       = new WPInv_Session_Handler();
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 
99 99
     }
100 100
 
101
-     /**
102
-	 * Define plugin constants.
103
-	 */
101
+        /**
102
+         * Define plugin constants.
103
+         */
104 104
     public function define_constants() {
105 105
         define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
106 106
         define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
     }
109 109
 
110 110
     /**
111
-	 * Hook into actions and filters.
112
-	 *
113
-	 * @since 1.0.19
114
-	 */
111
+     * Hook into actions and filters.
112
+     *
113
+     * @since 1.0.19
114
+     */
115 115
     protected function init_hooks() {
116 116
         /* Internationalize the text strings used. */
117 117
         add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
     }
210 210
 
211 211
     /**
212
-	 * Include required core files used in admin and on the frontend.
213
-	 */
212
+     * Include required core files used in admin and on the frontend.
213
+     */
214 214
     public function includes() {
215 215
 
216 216
         // Start with the settings.
@@ -240,10 +240,10 @@  discard block
 block discarded – undo
240 240
         require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
241 241
 
242 242
         // Register autoloader.
243
-		try {
244
-			spl_autoload_register( array( $this, 'autoload' ), true );
245
-		} catch ( Exception $e ) {
246
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
243
+        try {
244
+            spl_autoload_register( array( $this, 'autoload' ), true );
245
+        } catch ( Exception $e ) {
246
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
247 247
         }
248 248
 
249 249
         require_once( WPINV_PLUGIN_DIR . 'includes/class-getpaid-post-types.php' );
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
269 269
         require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
270 270
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
271
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
272
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
273
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
274
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
275
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
271
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
272
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
273
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
274
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
275
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
276 276
         require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
277 277
         require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
278 278
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
@@ -334,48 +334,48 @@  discard block
 block discarded – undo
334 334
     }
335 335
 
336 336
     /**
337
-	 * Class autoloader
338
-	 *
339
-	 * @param       string $class_name The name of the class to load.
340
-	 * @access      public
341
-	 * @since       1.0.19
342
-	 * @return      void
343
-	 */
344
-	public function autoload( $class_name ) {
345
-
346
-		// Normalize the class name...
347
-		$class_name  = strtolower( $class_name );
348
-
349
-		// ... and make sure it is our class.
350
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
351
-			return;
352
-		}
353
-
354
-		// Next, prepare the file name from the class.
355
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
337
+     * Class autoloader
338
+     *
339
+     * @param       string $class_name The name of the class to load.
340
+     * @access      public
341
+     * @since       1.0.19
342
+     * @return      void
343
+     */
344
+    public function autoload( $class_name ) {
345
+
346
+        // Normalize the class name...
347
+        $class_name  = strtolower( $class_name );
348
+
349
+        // ... and make sure it is our class.
350
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
351
+            return;
352
+        }
353
+
354
+        // Next, prepare the file name from the class.
355
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
356 356
 
357 357
         // Base path of the classes.
358 358
         $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
359 359
 
360
-		// And an array of possible locations in order of importance.
361
-		$locations = array(
360
+        // And an array of possible locations in order of importance.
361
+        $locations = array(
362 362
             "$plugin_path/includes",
363 363
             "$plugin_path/includes/data-stores",
364 364
             "$plugin_path/includes/gateways",
365 365
             "$plugin_path/includes/admin",
366 366
             "$plugin_path/includes/admin/meta-boxes",
367
-		);
367
+        );
368 368
 
369
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
369
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
370 370
 
371
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
372
-				include trailingslashit( $location ) . $file_name;
373
-				break;
374
-			}
371
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
372
+                include trailingslashit( $location ) . $file_name;
373
+                break;
374
+            }
375 375
 
376
-		}
376
+        }
377 377
 
378
-	}
378
+    }
379 379
 
380 380
     /**
381 381
      * Inits hooks etc.
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
             wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
513 513
             wp_enqueue_style( 'jquery-ui-css' );
514 514
             wp_deregister_style( 'yoast-seo-select2' );
515
-	        wp_deregister_style( 'yoast-seo-monorepo' );
515
+            wp_deregister_style( 'yoast-seo-monorepo' );
516 516
         }
517 517
 
518 518
         wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
         if ( $page == 'wpinv-subscriptions' ) {
527 527
             wp_enqueue_script( 'jquery-ui-datepicker' );
528 528
             wp_deregister_style( 'yoast-seo-select2' );
529
-	        wp_deregister_style( 'yoast-seo-monorepo' );
529
+            wp_deregister_style( 'yoast-seo-monorepo' );
530 530
         }
531 531
         
532 532
         if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
@@ -695,19 +695,19 @@  discard block
 block discarded – undo
695 695
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
696 696
     }
697 697
 
698
-	/**
699
-	 * Register widgets
700
-	 *
701
-	 */
702
-	public function register_widgets() {
703
-		register_widget( "WPInv_Checkout_Widget" );
704
-		register_widget( "WPInv_History_Widget" );
705
-		register_widget( "WPInv_Receipt_Widget" );
706
-		register_widget( "WPInv_Subscriptions_Widget" );
707
-		register_widget( "WPInv_Buy_Item_Widget" );
698
+    /**
699
+     * Register widgets
700
+     *
701
+     */
702
+    public function register_widgets() {
703
+        register_widget( "WPInv_Checkout_Widget" );
704
+        register_widget( "WPInv_History_Widget" );
705
+        register_widget( "WPInv_Receipt_Widget" );
706
+        register_widget( "WPInv_Subscriptions_Widget" );
707
+        register_widget( "WPInv_Buy_Item_Widget" );
708 708
         register_widget( "WPInv_Messages_Widget" );
709 709
         register_widget( 'WPInv_GetPaid_Widget' );
710
-	}
710
+    }
711 711
     
712 712
     /**
713 713
      * Remove our pages from yoast sitemaps.
Please login to merge, or discard this patch.
Spacing   +277 added lines, -277 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
  * Manual Payment Gateway class.
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	 * Define plugin constants.
103 103
 	 */
104 104
     public function define_constants() {
105
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
106
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
105
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
106
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
107 107
         $this->version = WPINV_VERSION;
108 108
     }
109 109
 
@@ -114,32 +114,32 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
     protected function init_hooks() {
116 116
         /* Internationalize the text strings used. */
117
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
117
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
118 118
         
119 119
         /* Perform actions on admin initialization. */
120
-        add_action( 'admin_init', array( &$this, 'admin_init') );
120
+        add_action('admin_init', array(&$this, 'admin_init'));
121 121
 
122 122
         // Init the plugin after WordPress inits.
123
-        add_action( 'init', array( $this, 'init' ), 1 );
124
-        add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 );
125
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
123
+        add_action('init', array($this, 'init'), 1);
124
+        add_action('getpaid_init', array($this, 'maybe_process_ipn'), 5);
125
+        add_action('init', array(&$this, 'wpinv_actions'));
126 126
         
127
-        if ( class_exists( 'BuddyPress' ) ) {
128
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
127
+        if (class_exists('BuddyPress')) {
128
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
129 129
         }
130 130
 
131
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
132
-        add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
133
-        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
134
-        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
131
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
132
+        add_action('wp_footer', array(&$this, 'wp_footer'));
133
+        add_action('widgets_init', array(&$this, 'register_widgets'));
134
+        add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
135 135
 
136
-        if ( is_admin() ) {
137
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
138
-            add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) );
139
-            add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) );
136
+        if (is_admin()) {
137
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
138
+            add_filter('admin_body_class', array(&$this, 'admin_body_class'));
139
+            add_action('admin_init', array(&$this, 'init_ayecode_connect_helper'));
140 140
 
141 141
         } else {
142
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
142
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
143 143
         }
144 144
         
145 145
         /**
@@ -149,28 +149,28 @@  discard block
 block discarded – undo
149 149
          *
150 150
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
151 151
          */
152
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
152
+        do_action_ref_array('wpinv_actions', array(&$this));
153 153
 
154
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
154
+        add_action('admin_init', array(&$this, 'activation_redirect'));
155 155
     }
156 156
 
157 157
     /**
158 158
      * Maybe show the AyeCode Connect Notice.
159 159
      */
160
-    public function init_ayecode_connect_helper(){
160
+    public function init_ayecode_connect_helper() {
161 161
         // AyeCode Connect notice
162
-        if ( is_admin() ){
162
+        if (is_admin()) {
163 163
             // set the strings so they can be translated
164 164
             $strings = array(
165
-                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
166
-                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
167
-                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
168
-                'connect_button'    => __("Connect Site","invoicing"),
169
-                'connecting_button'    => __("Connecting...","invoicing"),
170
-                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
171
-                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
165
+                'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
166
+                'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
167
+                'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
168
+                'connect_button'    => __("Connect Site", "invoicing"),
169
+                'connecting_button'    => __("Connecting...", "invoicing"),
170
+                'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
171
+                'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
172 172
             );
173
-            new AyeCode_Connect_Helper($strings,array('wpi-addons'));
173
+            new AyeCode_Connect_Helper($strings, array('wpi-addons'));
174 174
         }
175 175
     }
176 176
     
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
         /* Internationalize the text strings used. */
179 179
         $this->load_textdomain();
180 180
 
181
-        do_action( 'wpinv_loaded' );
181
+        do_action('wpinv_loaded');
182 182
 
183 183
         // Fix oxygen page builder conflict
184
-        if ( function_exists( 'ct_css_output' ) ) {
184
+        if (function_exists('ct_css_output')) {
185 185
             wpinv_oxygen_fix_conflict();
186 186
         }
187 187
     }
@@ -191,21 +191,21 @@  discard block
 block discarded – undo
191 191
      *
192 192
      * @since 1.0
193 193
      */
194
-    public function load_textdomain( $locale = NULL ) {
195
-        if ( empty( $locale ) ) {
196
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
194
+    public function load_textdomain($locale = NULL) {
195
+        if (empty($locale)) {
196
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
197 197
         }
198 198
 
199
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
199
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
200 200
         
201
-        unload_textdomain( 'invoicing' );
202
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
203
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
201
+        unload_textdomain('invoicing');
202
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
203
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
204 204
         
205 205
         /**
206 206
          * Define language constants.
207 207
          */
208
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
208
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
209 209
     }
210 210
 
211 211
     /**
@@ -214,123 +214,123 @@  discard block
 block discarded – undo
214 214
     public function includes() {
215 215
 
216 216
         // Start with the settings.
217
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
217
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
218 218
         $this->options = wpinv_get_settings();
219 219
         $GLOBALS['wpinv_options'] = $this->options; // Backwards compatibility.
220 220
 
221 221
         // Packages/libraries.
222
-        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
223
-        require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
224
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
222
+        require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
223
+        require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php');
224
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php');
225 225
 
226 226
         // Load functions.
227
-        require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
228
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
229
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
230
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
231
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
232
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
233
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
234
-        require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
235
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
236
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
237
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
238
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
239
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
240
-        require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
227
+        require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php');
228
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
229
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
230
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
231
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
232
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
233
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
234
+        require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php');
235
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
236
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
237
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
238
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
239
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
240
+        require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php');
241 241
 
242 242
         // Register autoloader.
243 243
 		try {
244
-			spl_autoload_register( array( $this, 'autoload' ), true );
245
-		} catch ( Exception $e ) {
246
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
247
-        }
248
-
249
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-getpaid-post-types.php' );
250
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
251
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
252
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' );
253
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
254
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
255
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
256
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
257
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
258
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
259
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
260
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
261
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
262
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
263
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
264
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
265
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
266
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
267
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
268
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
269
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
270
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
271
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
272
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
273
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
274
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
275
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
276
-        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
277
-        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
278
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
244
+			spl_autoload_register(array($this, 'autoload'), true);
245
+		} catch (Exception $e) {
246
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
247
+        }
248
+
249
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-getpaid-post-types.php');
250
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
251
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
252
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php');
253
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
254
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
255
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
256
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
257
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
258
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
259
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
260
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
261
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
262
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
263
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
264
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
265
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
266
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
267
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
268
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
269
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
270
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
271
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
272
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
273
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
274
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
275
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
276
+        require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
277
+        require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php');
278
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php');
279 279
 
280 280
         /**
281 281
          * Load the tax class.
282 282
          */
283
-        if ( ! class_exists( 'WPInv_EUVat' ) ) {
284
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
283
+        if (!class_exists('WPInv_EUVat')) {
284
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
285 285
         }
286 286
 
287
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
288
-        if ( !empty( $gateways ) ) {
289
-            foreach ( $gateways as $gateway ) {
290
-                if ( $gateway == 'manual' ) {
287
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
288
+        if (!empty($gateways)) {
289
+            foreach ($gateways as $gateway) {
290
+                if ($gateway == 'manual') {
291 291
                     continue;
292 292
                 }
293 293
                 
294 294
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
295 295
                 
296
-                if ( file_exists( $gateway_file ) ) {
297
-                    require_once( $gateway_file );
296
+                if (file_exists($gateway_file)) {
297
+                    require_once($gateway_file);
298 298
                 }
299 299
             }
300 300
         }
301 301
         
302
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
302
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
303 303
             GetPaid_Post_Types_Admin::init();
304 304
 
305
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
306
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
305
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
306
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
307 307
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
308
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
309
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
310
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
311
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
312
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
313
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
308
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
309
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
310
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
311
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
312
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
313
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php');
314 314
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
315 315
             // load the user class only on the users.php page
316 316
             global $pagenow;
317
-            if($pagenow=='users.php'){
317
+            if ($pagenow == 'users.php') {
318 318
                 new WPInv_Admin_Users();
319 319
             }
320 320
         }
321 321
 
322 322
         // Register cli commands
323
-        if ( defined( 'WP_CLI' ) && WP_CLI ) {
324
-            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
325
-            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
323
+        if (defined('WP_CLI') && WP_CLI) {
324
+            require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
325
+            WP_CLI::add_command('invoicing', 'WPInv_CLI');
326 326
         }
327 327
         
328 328
         // include css inliner
329
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
330
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
329
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
330
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
331 331
         }
332 332
         
333
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
333
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
334 334
     }
335 335
 
336 336
     /**
@@ -341,21 +341,21 @@  discard block
 block discarded – undo
341 341
 	 * @since       1.0.19
342 342
 	 * @return      void
343 343
 	 */
344
-	public function autoload( $class_name ) {
344
+	public function autoload($class_name) {
345 345
 
346 346
 		// Normalize the class name...
347
-		$class_name  = strtolower( $class_name );
347
+		$class_name = strtolower($class_name);
348 348
 
349 349
 		// ... and make sure it is our class.
350
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
350
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
351 351
 			return;
352 352
 		}
353 353
 
354 354
 		// Next, prepare the file name from the class.
355
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
355
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
356 356
 
357 357
         // Base path of the classes.
358
-        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
358
+        $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
359 359
 
360 360
 		// And an array of possible locations in order of importance.
361 361
 		$locations = array(
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
             "$plugin_path/includes/admin/meta-boxes",
367 367
 		);
368 368
 
369
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
369
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
370 370
 
371
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
372
-				include trailingslashit( $location ) . $file_name;
371
+			if (file_exists(trailingslashit($location) . $file_name)) {
372
+				include trailingslashit($location) . $file_name;
373 373
 				break;
374 374
 			}
375 375
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
     public function init() {
384 384
 
385 385
         // Fires before getpaid inits.
386
-        do_action( 'before_getpaid_init', $this );
386
+        do_action('before_getpaid_init', $this);
387 387
 
388 388
         // Load default gateways.
389 389
         $gateways = apply_filters(
@@ -397,12 +397,12 @@  discard block
 block discarded – undo
397 397
             )
398 398
         );
399 399
 
400
-        foreach ( $gateways as $id => $class ) {
401
-            $this->gateways[ $id ] = new $class();
400
+        foreach ($gateways as $id => $class) {
401
+            $this->gateways[$id] = new $class();
402 402
         }
403 403
 
404 404
         // Fires after getpaid inits.
405
-        do_action( 'getpaid_init', $this );
405
+        do_action('getpaid_init', $this);
406 406
         
407 407
     }
408 408
 
@@ -412,131 +412,131 @@  discard block
 block discarded – undo
412 412
     public function maybe_process_ipn() {
413 413
 
414 414
         // Ensure that this is an IPN request.
415
-        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
415
+        if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
416 416
             return;
417 417
         }
418 418
 
419
-        $gateway = wpinv_clean( $_GET['wpi-gateway'] );
419
+        $gateway = wpinv_clean($_GET['wpi-gateway']);
420 420
 
421
-        do_action( 'wpinv_verify_payment_ipn', $gateway );
422
-        do_action( "wpinv_verify_{$gateway}_ipn" );
421
+        do_action('wpinv_verify_payment_ipn', $gateway);
422
+        do_action("wpinv_verify_{$gateway}_ipn");
423 423
         exit;
424 424
 
425 425
     }
426 426
 
427 427
     public function admin_init() {
428 428
         $this->default_payment_form = wpinv_get_default_payment_form();
429
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
429
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
430 430
     }
431 431
 
432 432
     public function activation_redirect() {
433 433
         // Bail if no activation redirect
434
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
434
+        if (!get_transient('_wpinv_activation_redirect')) {
435 435
             return;
436 436
         }
437 437
 
438 438
         // Delete the redirect transient
439
-        delete_transient( '_wpinv_activation_redirect' );
439
+        delete_transient('_wpinv_activation_redirect');
440 440
 
441 441
         // Bail if activating from network, or bulk
442
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
442
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
443 443
             return;
444 444
         }
445 445
 
446
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
446
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
447 447
         exit;
448 448
     }
449 449
     
450 450
     public function enqueue_scripts() {
451
-        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
451
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
452 452
         
453
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
454
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
455
-        wp_enqueue_style( 'wpinv_front_style' );
453
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css');
454
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version);
455
+        wp_enqueue_style('wpinv_front_style');
456 456
                
457 457
         // Register scripts
458
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
459
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
458
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
459
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js'));
460 460
 
461 461
         $localize                         = array();
462
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
463
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
462
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
463
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
464 464
         $localize['currency_symbol']      = wpinv_currency_symbol();
465 465
         $localize['currency_pos']         = wpinv_currency_position();
466 466
         $localize['thousand_sep']         = wpinv_thousands_separator();
467 467
         $localize['decimal_sep']          = wpinv_decimal_separator();
468 468
         $localize['decimals']             = wpinv_decimals();
469
-        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
469
+        $localize['txtComplete']          = __('Continue', 'invoicing');
470 470
         $localize['UseTaxes']             = wpinv_use_taxes();
471
-        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
472
-        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
473
-        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
471
+        $localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
472
+        $localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
473
+        $localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
474 474
 
475
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
475
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
476 476
         
477
-        wp_enqueue_script( 'jquery-blockui' );
477
+        wp_enqueue_script('jquery-blockui');
478 478
         $autofill_api = wpinv_get_option('address_autofill_api');
479 479
         $autofill_active = wpinv_get_option('address_autofill_active');
480
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
481
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
482
-                wp_dequeue_script( 'google-maps-api' );
480
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
481
+            if (wp_script_is('google-maps-api', 'enqueued')) {
482
+                wp_dequeue_script('google-maps-api');
483 483
             }
484
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
485
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
484
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
485
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
486 486
         }
487 487
 
488
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
489
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
488
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
489
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
490 490
 
491
-        wp_enqueue_script( 'wpinv-front-script' );
492
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
491
+        wp_enqueue_script('wpinv-front-script');
492
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
493 493
 
494
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
495
-        wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
494
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
495
+        wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true);
496 496
     }
497 497
 
498
-    public function admin_enqueue_scripts( $hook ) {
498
+    public function admin_enqueue_scripts($hook) {
499 499
         global $post, $pagenow;
500 500
         
501 501
         $post_type  = wpinv_admin_post_type();
502
-        $suffix     = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
503
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
502
+        $suffix     = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
503
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
504 504
 
505 505
         $jquery_ui_css = false;
506
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
506
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
507 507
             $jquery_ui_css = true;
508
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
508
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
509 509
             $jquery_ui_css = true;
510 510
         }
511
-        if ( $jquery_ui_css ) {
512
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
513
-            wp_enqueue_style( 'jquery-ui-css' );
514
-            wp_deregister_style( 'yoast-seo-select2' );
515
-	        wp_deregister_style( 'yoast-seo-monorepo' );
511
+        if ($jquery_ui_css) {
512
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
513
+            wp_enqueue_style('jquery-ui-css');
514
+            wp_deregister_style('yoast-seo-select2');
515
+	        wp_deregister_style('yoast-seo-monorepo');
516 516
         }
517 517
 
518
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
519
-        wp_enqueue_style( 'wpinv_meta_box_style' );
518
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
519
+        wp_enqueue_style('wpinv_meta_box_style');
520 520
         
521
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
522
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version );
523
-        wp_enqueue_style( 'wpinv_admin_style' );
521
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
522
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version);
523
+        wp_enqueue_style('wpinv_admin_style');
524 524
 
525
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
526
-        if ( $page == 'wpinv-subscriptions' ) {
527
-            wp_enqueue_script( 'jquery-ui-datepicker' );
528
-            wp_deregister_style( 'yoast-seo-select2' );
529
-	        wp_deregister_style( 'yoast-seo-monorepo' );
525
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
526
+        if ($page == 'wpinv-subscriptions') {
527
+            wp_enqueue_script('jquery-ui-datepicker');
528
+            wp_deregister_style('yoast-seo-select2');
529
+	        wp_deregister_style('yoast-seo-monorepo');
530 530
         }
531 531
         
532
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
533
-            wp_enqueue_script( 'jquery-ui-datepicker' );
532
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
533
+            wp_enqueue_script('jquery-ui-datepicker');
534 534
         }
535 535
 
536
-        wp_enqueue_style( 'wp-color-picker' );
537
-        wp_enqueue_script( 'wp-color-picker' );
536
+        wp_enqueue_style('wp-color-picker');
537
+        wp_enqueue_script('wp-color-picker');
538 538
         
539
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
539
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
540 540
 
541 541
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
542 542
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -547,21 +547,21 @@  discard block
 block discarded – undo
547 547
             }
548 548
         }
549 549
 
550
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
551
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
550
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
551
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
552 552
 
553
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
554
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  $version );
555
-        wp_enqueue_script( 'wpinv-admin-script' );
553
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
554
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), $version);
555
+        wp_enqueue_script('wpinv-admin-script');
556 556
         
557 557
         $localize                               = array();
558
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
559
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
560
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
561
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
562
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
563
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
564
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
558
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
559
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
560
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
561
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
562
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
563
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
564
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
565 565
         $localize['tax']                        = wpinv_tax_amount();
566 566
         $localize['discount']                   = wpinv_discount_amount();
567 567
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -569,104 +569,104 @@  discard block
 block discarded – undo
569 569
         $localize['thousand_sep']               = wpinv_thousands_separator();
570 570
         $localize['decimal_sep']                = wpinv_decimal_separator();
571 571
         $localize['decimals']                   = wpinv_decimals();
572
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
573
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
574
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
575
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
576
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
577
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
578
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
579
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
580
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
581
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
582
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
583
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
584
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
585
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
586
-        $localize['item_description']           = __( 'Item Description', 'invoicing' );
587
-        $localize['discount_description']       = __( 'Discount Description', 'invoicing' );
588
-        $localize['invoice_description']        = __( 'Invoice Description', 'invoicing' );
589
-        $localize['searching']                  = __( 'Searching', 'invoicing' );
590
-
591
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
592
-
593
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
572
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
573
+        $localize['status_publish']             = wpinv_status_nicename('publish');
574
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
575
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
576
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
577
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
578
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
579
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
580
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
581
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
582
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
583
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
584
+        $localize['action_edit']                = __('Edit', 'invoicing');
585
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
586
+        $localize['item_description']           = __('Item Description', 'invoicing');
587
+        $localize['discount_description']       = __('Discount Description', 'invoicing');
588
+        $localize['invoice_description']        = __('Invoice Description', 'invoicing');
589
+        $localize['searching']                  = __('Searching', 'invoicing');
590
+
591
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
592
+
593
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
594 594
 
595 595
         // Load payment form scripts on our admin pages only.
596
-        if ( ( $hook == 'post-new.php' || $hook == 'post.php' ) && 'wpi_payment_form' === $post->post_type ) {
596
+        if (($hook == 'post-new.php' || $hook == 'post.php') && 'wpi_payment_form' === $post->post_type) {
597 597
 
598
-            wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
599
-            wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
600
-            wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
598
+            wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
599
+            wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
600
+            wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
601 601
 
602
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
603
-            wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
602
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
603
+            wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
604 604
         
605
-            wp_localize_script( 'wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
605
+            wp_localize_script('wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
606 606
                 'elements'      => $this->form_elements->get_elements(),
607
-                'form_elements' => $this->form_elements->get_form_elements( $post->ID ),
607
+                'form_elements' => $this->form_elements->get_form_elements($post->ID),
608 608
                 'all_items'     => $this->form_elements->get_published_items(),
609 609
                 'currency'      => wpinv_currency_symbol(),
610 610
                 'position'      => wpinv_currency_position(),
611 611
                 'decimals'      => (int) wpinv_decimals(),
612 612
                 'thousands_sep' => wpinv_thousands_separator(),
613 613
                 'decimals_sep'  => wpinv_decimal_separator(),
614
-                'form_items'    => $this->form_elements->get_form_items( $post->ID ),
614
+                'form_items'    => $this->form_elements->get_form_items($post->ID),
615 615
                 'is_default'    => $post->ID == $this->default_payment_form,
616
-            ) );
616
+            ));
617 617
 
618
-            wp_enqueue_script( 'wpinv-admin-payment-form-script' );
618
+            wp_enqueue_script('wpinv-admin-payment-form-script');
619 619
         }
620 620
 
621
-        if ( $page == 'wpinv-subscriptions' ) {
622
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
623
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
621
+        if ($page == 'wpinv-subscriptions') {
622
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
623
+            wp_enqueue_script('wpinv-sub-admin-script');
624 624
         }
625 625
 
626
-        if ( $page == 'wpinv-reports' ) {
627
-            wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
626
+        if ($page == 'wpinv-reports') {
627
+            wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7');
628 628
         }
629 629
 
630 630
     }
631 631
 
632
-    public function admin_body_class( $classes ) {
632
+    public function admin_body_class($classes) {
633 633
         global $pagenow, $post, $current_screen;
634 634
         
635
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote' ) ) {
635
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote')) {
636 636
             $classes .= ' wpinv-cpt';
637 637
         }
638 638
         
639
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
639
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
640 640
 
641
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
642
-        if ( $add_class ) {
643
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
641
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
642
+        if ($add_class) {
643
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
644 644
         }
645 645
         
646 646
         $settings_class = array();
647
-        if ( $page == 'wpinv-settings' ) {
648
-            if ( !empty( $_REQUEST['tab'] ) ) {
649
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
647
+        if ($page == 'wpinv-settings') {
648
+            if (!empty($_REQUEST['tab'])) {
649
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
650 650
             }
651 651
             
652
-            if ( !empty( $_REQUEST['section'] ) ) {
653
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
652
+            if (!empty($_REQUEST['section'])) {
653
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
654 654
             }
655 655
             
656
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
656
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
657 657
         }
658 658
         
659
-        if ( !empty( $settings_class ) ) {
660
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
659
+        if (!empty($settings_class)) {
660
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
661 661
         }
662 662
         
663 663
         $post_type = wpinv_admin_post_type();
664 664
 
665
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
665
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
666 666
             return $classes .= ' wpinv';
667 667
         }
668 668
         
669
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
669
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
670 670
             $classes .= ' wpi-editable-n';
671 671
         }
672 672
 
@@ -678,21 +678,21 @@  discard block
 block discarded – undo
678 678
     }
679 679
     
680 680
     public function wpinv_actions() {
681
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
682
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
681
+        if (isset($_REQUEST['wpi_action'])) {
682
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
683 683
         }
684 684
     }
685 685
     
686
-    public function pre_get_posts( $wp_query ) {
687
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
688
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
686
+    public function pre_get_posts($wp_query) {
687
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
688
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
689 689
         }
690 690
         
691 691
         return $wp_query;
692 692
     }
693 693
     
694 694
     public function bp_invoicing_init() {
695
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
695
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
696 696
     }
697 697
 
698 698
 	/**
@@ -700,13 +700,13 @@  discard block
 block discarded – undo
700 700
 	 *
701 701
 	 */
702 702
 	public function register_widgets() {
703
-		register_widget( "WPInv_Checkout_Widget" );
704
-		register_widget( "WPInv_History_Widget" );
705
-		register_widget( "WPInv_Receipt_Widget" );
706
-		register_widget( "WPInv_Subscriptions_Widget" );
707
-		register_widget( "WPInv_Buy_Item_Widget" );
708
-        register_widget( "WPInv_Messages_Widget" );
709
-        register_widget( 'WPInv_GetPaid_Widget' );
703
+		register_widget("WPInv_Checkout_Widget");
704
+		register_widget("WPInv_History_Widget");
705
+		register_widget("WPInv_Receipt_Widget");
706
+		register_widget("WPInv_Subscriptions_Widget");
707
+		register_widget("WPInv_Buy_Item_Widget");
708
+        register_widget("WPInv_Messages_Widget");
709
+        register_widget('WPInv_GetPaid_Widget');
710 710
 	}
711 711
     
712 712
     /**
@@ -715,10 +715,10 @@  discard block
 block discarded – undo
715 715
      * @since 1.0.19
716 716
      * @param int[] $excluded_posts_ids
717 717
      */
718
-    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
718
+    public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
719 719
 
720 720
         // Ensure that we have an array.
721
-        if ( ! is_array( $excluded_posts_ids ) ) {
721
+        if (!is_array($excluded_posts_ids)) {
722 722
             $excluded_posts_ids = array();
723 723
         }
724 724
 
@@ -726,24 +726,24 @@  discard block
 block discarded – undo
726 726
         $our_pages = array();
727 727
     
728 728
         // Checkout page.
729
-        $our_pages[] = wpinv_get_option( 'checkout_page', false );
729
+        $our_pages[] = wpinv_get_option('checkout_page', false);
730 730
 
731 731
         // Success page.
732
-        $our_pages[] = wpinv_get_option( 'success_page', false );
732
+        $our_pages[] = wpinv_get_option('success_page', false);
733 733
 
734 734
         // Failure page.
735
-        $our_pages[] = wpinv_get_option( 'failure_page', false );
735
+        $our_pages[] = wpinv_get_option('failure_page', false);
736 736
 
737 737
         // History page.
738
-        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
738
+        $our_pages[] = wpinv_get_option('invoice_history_page', false);
739 739
 
740 740
         // Subscriptions page.
741
-        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
741
+        $our_pages[] = wpinv_get_option('invoice_subscription_page', false);
742 742
 
743
-        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
743
+        $our_pages   = array_map('intval', array_filter($our_pages));
744 744
 
745 745
         $excluded_posts_ids = $excluded_posts_ids + $our_pages;
746
-        return array_unique( $excluded_posts_ids );
746
+        return array_unique($excluded_posts_ids);
747 747
 
748 748
     }
749 749
 
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +581 added lines, -581 removed lines patch added patch discarded remove patch
@@ -4,99 +4,99 @@  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
  * Displays an invoice.
11 11
  * 
12 12
  * @param WPInv_Invoice $invoice.
13 13
  */
14
-function getpaid_invoice( $invoice ) {
15
-    if ( ! empty( $invoice ) ) {
16
-        wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) );
14
+function getpaid_invoice($invoice) {
15
+    if (!empty($invoice)) {
16
+        wpinv_get_template('invoice/invoice.php', compact('invoice'));
17 17
     }
18 18
 }
19
-add_action( 'getpaid_invoice', 'getpaid_invoice', 10 );
19
+add_action('getpaid_invoice', 'getpaid_invoice', 10);
20 20
 
21 21
 /**
22 22
  * Displays the invoice footer.
23 23
  */
24
-function getpaid_invoice_footer( $invoice ) {
25
-    if ( ! empty( $invoice ) ) {
26
-        wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) );
24
+function getpaid_invoice_footer($invoice) {
25
+    if (!empty($invoice)) {
26
+        wpinv_get_template('invoice/footer.php', compact('invoice'));
27 27
     }
28 28
 }
29
-add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 );
29
+add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10);
30 30
 
31 31
 /**
32 32
  * Displays the invoice top bar.
33 33
  */
34
-function getpaid_invoice_header( $invoice ) {
35
-    if ( ! empty( $invoice ) ) {
36
-        wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) );
34
+function getpaid_invoice_header($invoice) {
35
+    if (!empty($invoice)) {
36
+        wpinv_get_template('invoice/header.php', compact('invoice'));
37 37
     }
38 38
 }
39
-add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 );
39
+add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10);
40 40
 
41 41
 /**
42 42
  * Displays actions on the left side of the header.
43 43
  */
44
-function getpaid_invoice_header_left_actions( $invoice ) {
45
-    if ( ! empty( $invoice ) ) {
46
-        wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) );
44
+function getpaid_invoice_header_left_actions($invoice) {
45
+    if (!empty($invoice)) {
46
+        wpinv_get_template('invoice/header-left-actions.php', compact('invoice'));
47 47
     }
48 48
 }
49
-add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 );
49
+add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10);
50 50
 
51 51
 /**
52 52
  * Displays actions on the right side of the invoice top bar.
53 53
  */
54
-function getpaid_invoice_header_right_actions( $invoice ) {
55
-    if ( ! empty( $invoice ) ) {
56
-        wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) );
54
+function getpaid_invoice_header_right_actions($invoice) {
55
+    if (!empty($invoice)) {
56
+        wpinv_get_template('invoice/header-right-actions.php', compact('invoice'));
57 57
     }
58 58
 }
59
-add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 );
59
+add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10);
60 60
 
61 61
 /**
62 62
  * Displays the invoice title, watermark, logo etc.
63 63
  */
64
-function getpaid_invoice_details_top( $invoice ) {
65
-    if ( ! empty( $invoice ) ) {
66
-        wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) );
64
+function getpaid_invoice_details_top($invoice) {
65
+    if (!empty($invoice)) {
66
+        wpinv_get_template('invoice/details-top.php', compact('invoice'));
67 67
     }
68 68
 }
69
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 );
69
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10);
70 70
 
71 71
 /**
72 72
  * Displays the company logo.
73 73
  */
74
-function getpaid_invoice_logo( $invoice ) {
75
-    if ( ! empty( $invoice ) ) {
76
-        wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) );
74
+function getpaid_invoice_logo($invoice) {
75
+    if (!empty($invoice)) {
76
+        wpinv_get_template('invoice/invoice-logo.php', compact('invoice'));
77 77
     }
78 78
 }
79
-add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' );
79
+add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo');
80 80
 
81 81
 /**
82 82
  * Displays the type of invoice.
83 83
  */
84
-function getpaid_invoice_type( $invoice ) {
85
-    if ( ! empty( $invoice ) ) {
86
-        wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) );
84
+function getpaid_invoice_type($invoice) {
85
+    if (!empty($invoice)) {
86
+        wpinv_get_template('invoice/invoice-type.php', compact('invoice'));
87 87
     }
88 88
 }
89
-add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' );
89
+add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type');
90 90
 
91 91
 /**
92 92
  * Displays the invoice details.
93 93
  */
94
-function getpaid_invoice_details_main( $invoice ) {
95
-    if ( ! empty( $invoice ) ) {
96
-        wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) );
94
+function getpaid_invoice_details_main($invoice) {
95
+    if (!empty($invoice)) {
96
+        wpinv_get_template('invoice/details.php', compact('invoice'));
97 97
     }
98 98
 }
99
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 );
99
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50);
100 100
 
101 101
 /**
102 102
  * Returns a path to the templates directory.
@@ -125,30 +125,30 @@  discard block
 block discarded – undo
125 125
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
126 126
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
127 127
  */
128
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
128
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
129 129
 
130 130
     // Make variables available to the template.
131
-    if ( ! empty( $args ) && is_array( $args ) ) {
132
-		extract( $args );
131
+    if (!empty($args) && is_array($args)) {
132
+		extract($args);
133 133
 	}
134 134
 
135 135
     // Locate the template.
136
-	$located = wpinv_locate_template( $template_name, $template_path, $default_path );
136
+	$located = wpinv_locate_template($template_name, $template_path, $default_path);
137 137
 
138 138
     // Abort if the file does not exist.
139
-	if ( ! file_exists( $located ) ) {
140
-        _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
139
+	if (!file_exists($located)) {
140
+        _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1');
141 141
 		return;
142 142
 	}
143 143
 
144 144
     // Fires before loading a template.
145
-	do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
145
+	do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args);
146 146
 
147 147
     // Load the template.
148
-	include( $located );
148
+	include($located);
149 149
 
150 150
     // Fires after loading a template.
151
-	do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
151
+	do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args);
152 152
 }
153 153
 
154 154
 /**
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
161 161
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
162 162
  */
163
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
163
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
164 164
 	ob_start();
165
-	wpinv_get_template( $template_name, $args, $template_path, $default_path );
165
+	wpinv_get_template($template_name, $args, $template_path, $default_path);
166 166
 	return ob_get_clean();
167 167
 }
168 168
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
  * @return string
173 173
  */
174 174
 function wpinv_template_path() {
175
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
175
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
176 176
 }
177 177
 
178 178
 /**
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
  * @return string
182 182
  */
183 183
 function wpinv_get_theme_template_dir_name() {
184
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
184
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
185 185
 }
186 186
 
187 187
 /**
@@ -193,72 +193,72 @@  discard block
 block discarded – undo
193 193
  * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
194 194
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
195 195
  */
196
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
196
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
197 197
 
198 198
     // Load the defaults for the template path and default path.
199
-    $template_path = empty( $template_path ) ? wpinv_template_path() : $template_path;
200
-    $default_path  = empty( $default_path ) ? WPINV_PLUGIN_DIR . 'templates/' : $default_path;
199
+    $template_path = empty($template_path) ? wpinv_template_path() : $template_path;
200
+    $default_path  = empty($default_path) ? WPINV_PLUGIN_DIR . 'templates/' : $default_path;
201 201
 
202 202
     // Check if the template was overidden.
203 203
     $template = locate_template(
204
-        array( trailingslashit( $template_path ) . $template_name )
204
+        array(trailingslashit($template_path) . $template_name)
205 205
     );
206 206
 
207 207
     // Maybe replace it with a default path.
208
-    if ( empty( $template ) && ! empty( $default_path ) ) {
209
-        $template = trailingslashit( $default_path ) . $template_name;
208
+    if (empty($template) && !empty($default_path)) {
209
+        $template = trailingslashit($default_path) . $template_name;
210 210
     }
211 211
 
212 212
     // Return what we found.
213
-    return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path, $default_path );
213
+    return apply_filters('wpinv_locate_template', $template, $template_name, $template_path, $default_path);
214 214
 }
215 215
 
216
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
217
-	do_action( 'get_template_part_' . $slug, $slug, $name );
216
+function wpinv_get_template_part($slug, $name = null, $load = true) {
217
+	do_action('get_template_part_' . $slug, $slug, $name);
218 218
 
219 219
 	// Setup possible parts
220 220
 	$templates = array();
221
-	if ( isset( $name ) )
221
+	if (isset($name))
222 222
 		$templates[] = $slug . '-' . $name . '.php';
223 223
 	$templates[] = $slug . '.php';
224 224
 
225 225
 	// Allow template parts to be filtered
226
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
226
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
227 227
 
228 228
 	// Return the part that is found
229
-	return wpinv_locate_tmpl( $templates, $load, false );
229
+	return wpinv_locate_tmpl($templates, $load, false);
230 230
 }
231 231
 
232
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
232
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
233 233
 	// No file found yet
234 234
 	$located = false;
235 235
 
236 236
 	// Try to find a template file
237
-	foreach ( (array)$template_names as $template_name ) {
237
+	foreach ((array) $template_names as $template_name) {
238 238
 
239 239
 		// Continue if template is empty
240
-		if ( empty( $template_name ) )
240
+		if (empty($template_name))
241 241
 			continue;
242 242
 
243 243
 		// Trim off any slashes from the template name
244
-		$template_name = ltrim( $template_name, '/' );
244
+		$template_name = ltrim($template_name, '/');
245 245
 
246 246
 		// try locating this template file by looping through the template paths
247
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
247
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
248 248
 
249
-			if( file_exists( $template_path . $template_name ) ) {
249
+			if (file_exists($template_path . $template_name)) {
250 250
 				$located = $template_path . $template_name;
251 251
 				break;
252 252
 			}
253 253
 		}
254 254
 
255
-		if( !empty( $located ) ) {
255
+		if (!empty($located)) {
256 256
 			break;
257 257
 		}
258 258
 	}
259 259
 
260
-	if ( ( true == $load ) && ! empty( $located ) )
261
-		load_template( $located, $require_once );
260
+	if ((true == $load) && !empty($located))
261
+		load_template($located, $require_once);
262 262
 
263 263
 	return $located;
264 264
 }
@@ -267,155 +267,155 @@  discard block
 block discarded – undo
267 267
 	$template_dir = wpinv_get_theme_template_dir_name();
268 268
 
269 269
 	$file_paths = array(
270
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
271
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
270
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
271
+		10 => trailingslashit(get_template_directory()) . $template_dir,
272 272
 		100 => wpinv_get_templates_dir()
273 273
 	);
274 274
 
275
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
275
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
276 276
 
277 277
 	// sort the file paths based on priority
278
-	ksort( $file_paths, SORT_NUMERIC );
278
+	ksort($file_paths, SORT_NUMERIC);
279 279
 
280
-	return array_map( 'trailingslashit', $file_paths );
280
+	return array_map('trailingslashit', $file_paths);
281 281
 }
282 282
 
283 283
 function wpinv_checkout_meta_tags() {
284 284
 
285 285
 	$pages   = array();
286
-	$pages[] = wpinv_get_option( 'success_page' );
287
-	$pages[] = wpinv_get_option( 'failure_page' );
288
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
289
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
286
+	$pages[] = wpinv_get_option('success_page');
287
+	$pages[] = wpinv_get_option('failure_page');
288
+	$pages[] = wpinv_get_option('invoice_history_page');
289
+	$pages[] = wpinv_get_option('invoice_subscription_page');
290 290
 
291
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
291
+	if (!wpinv_is_checkout() && !is_page($pages)) {
292 292
 		return;
293 293
 	}
294 294
 
295 295
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
296 296
 }
297
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
297
+add_action('wp_head', 'wpinv_checkout_meta_tags');
298 298
 
299
-function wpinv_add_body_classes( $class ) {
300
-	$classes = (array)$class;
299
+function wpinv_add_body_classes($class) {
300
+	$classes = (array) $class;
301 301
 
302
-	if( wpinv_is_checkout() ) {
302
+	if (wpinv_is_checkout()) {
303 303
 		$classes[] = 'wpinv-checkout';
304 304
 		$classes[] = 'wpinv-page';
305 305
 	}
306 306
 
307
-	if( wpinv_is_success_page() ) {
307
+	if (wpinv_is_success_page()) {
308 308
 		$classes[] = 'wpinv-success';
309 309
 		$classes[] = 'wpinv-page';
310 310
 	}
311 311
 
312
-	if( wpinv_is_failed_transaction_page() ) {
312
+	if (wpinv_is_failed_transaction_page()) {
313 313
 		$classes[] = 'wpinv-failed-transaction';
314 314
 		$classes[] = 'wpinv-page';
315 315
 	}
316 316
 
317
-	if( wpinv_is_invoice_history_page() ) {
317
+	if (wpinv_is_invoice_history_page()) {
318 318
 		$classes[] = 'wpinv-history';
319 319
 		$classes[] = 'wpinv-page';
320 320
 	}
321 321
 
322
-	if( wpinv_is_subscriptions_history_page() ) {
322
+	if (wpinv_is_subscriptions_history_page()) {
323 323
 		$classes[] = 'wpinv-subscription';
324 324
 		$classes[] = 'wpinv-page';
325 325
 	}
326 326
 
327
-	if( wpinv_is_test_mode() ) {
327
+	if (wpinv_is_test_mode()) {
328 328
 		$classes[] = 'wpinv-test-mode';
329 329
 		$classes[] = 'wpinv-page';
330 330
 	}
331 331
 
332
-	return array_unique( $classes );
332
+	return array_unique($classes);
333 333
 }
334
-add_filter( 'body_class', 'wpinv_add_body_classes' );
334
+add_filter('body_class', 'wpinv_add_body_classes');
335 335
 
336
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
337
-    $args = array( 'nopaging' => true );
336
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
337
+    $args = array('nopaging' => true);
338 338
 
339
-    if ( ! empty( $status ) )
339
+    if (!empty($status))
340 340
         $args['post_status'] = $status;
341 341
 
342
-    $discounts = wpinv_get_discounts( $args );
342
+    $discounts = wpinv_get_discounts($args);
343 343
     $options   = array();
344 344
 
345
-    if ( $discounts ) {
346
-        foreach ( $discounts as $discount ) {
347
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
345
+    if ($discounts) {
346
+        foreach ($discounts as $discount) {
347
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
348 348
         }
349 349
     } else {
350
-        $options[0] = __( 'No discounts found', 'invoicing' );
350
+        $options[0] = __('No discounts found', 'invoicing');
351 351
     }
352 352
 
353
-    $output = wpinv_html_select( array(
353
+    $output = wpinv_html_select(array(
354 354
         'name'             => $name,
355 355
         'selected'         => $selected,
356 356
         'options'          => $options,
357 357
         'show_option_all'  => false,
358 358
         'show_option_none' => false,
359
-    ) );
359
+    ));
360 360
 
361 361
     return $output;
362 362
 }
363 363
 
364
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
365
-    $current     = date( 'Y' );
366
-    $start_year  = $current - absint( $years_before );
367
-    $end_year    = $current + absint( $years_after );
368
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
364
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
365
+    $current     = date('Y');
366
+    $start_year  = $current - absint($years_before);
367
+    $end_year    = $current + absint($years_after);
368
+    $selected    = empty($selected) ? date('Y') : $selected;
369 369
     $options     = array();
370 370
 
371
-    while ( $start_year <= $end_year ) {
372
-        $options[ absint( $start_year ) ] = $start_year;
371
+    while ($start_year <= $end_year) {
372
+        $options[absint($start_year)] = $start_year;
373 373
         $start_year++;
374 374
     }
375 375
 
376
-    $output = wpinv_html_select( array(
376
+    $output = wpinv_html_select(array(
377 377
         'name'             => $name,
378 378
         'selected'         => $selected,
379 379
         'options'          => $options,
380 380
         'show_option_all'  => false,
381 381
         'show_option_none' => false
382
-    ) );
382
+    ));
383 383
 
384 384
     return $output;
385 385
 }
386 386
 
387
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
387
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
388 388
 
389 389
     $options = array(
390
-        '1'  => __( 'January', 'invoicing' ),
391
-        '2'  => __( 'February', 'invoicing' ),
392
-        '3'  => __( 'March', 'invoicing' ),
393
-        '4'  => __( 'April', 'invoicing' ),
394
-        '5'  => __( 'May', 'invoicing' ),
395
-        '6'  => __( 'June', 'invoicing' ),
396
-        '7'  => __( 'July', 'invoicing' ),
397
-        '8'  => __( 'August', 'invoicing' ),
398
-        '9'  => __( 'September', 'invoicing' ),
399
-        '10' => __( 'October', 'invoicing' ),
400
-        '11' => __( 'November', 'invoicing' ),
401
-        '12' => __( 'December', 'invoicing' ),
390
+        '1'  => __('January', 'invoicing'),
391
+        '2'  => __('February', 'invoicing'),
392
+        '3'  => __('March', 'invoicing'),
393
+        '4'  => __('April', 'invoicing'),
394
+        '5'  => __('May', 'invoicing'),
395
+        '6'  => __('June', 'invoicing'),
396
+        '7'  => __('July', 'invoicing'),
397
+        '8'  => __('August', 'invoicing'),
398
+        '9'  => __('September', 'invoicing'),
399
+        '10' => __('October', 'invoicing'),
400
+        '11' => __('November', 'invoicing'),
401
+        '12' => __('December', 'invoicing'),
402 402
     );
403 403
 
404 404
     // If no month is selected, default to the current month
405
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
405
+    $selected = empty($selected) ? date('n') : $selected;
406 406
 
407
-    $output = wpinv_html_select( array(
407
+    $output = wpinv_html_select(array(
408 408
         'name'             => $name,
409 409
         'selected'         => $selected,
410 410
         'options'          => $options,
411 411
         'show_option_all'  => false,
412 412
         'show_option_none' => false
413
-    ) );
413
+    ));
414 414
 
415 415
     return $output;
416 416
 }
417 417
 
418
-function wpinv_html_select( $args = array() ) {
418
+function wpinv_html_select($args = array()) {
419 419
     $defaults = array(
420 420
         'options'          => array(),
421 421
         'name'             => null,
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
         'selected'         => 0,
425 425
         'placeholder'      => null,
426 426
         'multiple'         => false,
427
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
428
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
427
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
428
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
429 429
         'data'             => array(),
430 430
         'onchange'         => null,
431 431
         'required'         => false,
@@ -433,74 +433,74 @@  discard block
 block discarded – undo
433 433
         'readonly'         => false,
434 434
     );
435 435
 
436
-    $args = wp_parse_args( $args, $defaults );
436
+    $args = wp_parse_args($args, $defaults);
437 437
 
438 438
     $data_elements = '';
439
-    foreach ( $args['data'] as $key => $value ) {
440
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
439
+    foreach ($args['data'] as $key => $value) {
440
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
441 441
     }
442 442
 
443
-    if( $args['multiple'] ) {
443
+    if ($args['multiple']) {
444 444
         $multiple = ' MULTIPLE';
445 445
     } else {
446 446
         $multiple = '';
447 447
     }
448 448
 
449
-    if( $args['placeholder'] ) {
449
+    if ($args['placeholder']) {
450 450
         $placeholder = $args['placeholder'];
451 451
     } else {
452 452
         $placeholder = '';
453 453
     }
454 454
     
455 455
     $options = '';
456
-    if( !empty( $args['onchange'] ) ) {
457
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
456
+    if (!empty($args['onchange'])) {
457
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
458 458
     }
459 459
     
460
-    if( !empty( $args['required'] ) ) {
460
+    if (!empty($args['required'])) {
461 461
         $options .= ' required="required"';
462 462
     }
463 463
     
464
-    if( !empty( $args['disabled'] ) ) {
464
+    if (!empty($args['disabled'])) {
465 465
         $options .= ' disabled';
466 466
     }
467 467
     
468
-    if( !empty( $args['readonly'] ) ) {
468
+    if (!empty($args['readonly'])) {
469 469
         $options .= ' readonly';
470 470
     }
471 471
 
472
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
473
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
472
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
473
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
474 474
 
475
-    if ( $args['show_option_all'] ) {
476
-        if( $args['multiple'] ) {
477
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
475
+    if ($args['show_option_all']) {
476
+        if ($args['multiple']) {
477
+            $selected = selected(true, in_array(0, $args['selected']), false);
478 478
         } else {
479
-            $selected = selected( $args['selected'], 0, false );
479
+            $selected = selected($args['selected'], 0, false);
480 480
         }
481
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
481
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
482 482
     }
483 483
 
484
-    if ( !empty( $args['options'] ) ) {
484
+    if (!empty($args['options'])) {
485 485
 
486
-        if ( $args['show_option_none'] ) {
487
-            if( $args['multiple'] ) {
488
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
486
+        if ($args['show_option_none']) {
487
+            if ($args['multiple']) {
488
+                $selected = selected(true, in_array("", $args['selected']), false);
489 489
             } else {
490
-                $selected = selected( $args['selected'] === "", true, false );
490
+                $selected = selected($args['selected'] === "", true, false);
491 491
             }
492
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
492
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
493 493
         }
494 494
 
495
-        foreach( $args['options'] as $key => $option ) {
495
+        foreach ($args['options'] as $key => $option) {
496 496
 
497
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
498
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
497
+            if ($args['multiple'] && is_array($args['selected'])) {
498
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
499 499
             } else {
500
-                $selected = selected( $args['selected'], $key, false );
500
+                $selected = selected($args['selected'], $key, false);
501 501
             }
502 502
 
503
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
503
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
504 504
         }
505 505
     }
506 506
 
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
     return $output;
510 510
 }
511 511
 
512
-function wpinv_item_dropdown( $args = array() ) {
512
+function wpinv_item_dropdown($args = array()) {
513 513
     $defaults = array(
514 514
         'name'              => 'wpi_item',
515 515
         'id'                => 'wpi_item',
@@ -517,14 +517,14 @@  discard block
 block discarded – undo
517 517
         'multiple'          => false,
518 518
         'selected'          => 0,
519 519
         'number'            => 100,
520
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
521
-        'data'              => array( 'search-type' => 'item' ),
520
+        'placeholder'       => __('Choose a item', 'invoicing'),
521
+        'data'              => array('search-type' => 'item'),
522 522
         'show_option_all'   => false,
523 523
         'show_option_none'  => false,
524 524
         'show_recurring'    => false,
525 525
     );
526 526
 
527
-    $args = wp_parse_args( $args, $defaults );
527
+    $args = wp_parse_args($args, $defaults);
528 528
 
529 529
     $item_args = array(
530 530
         'post_type'      => 'wpi_item',
@@ -533,44 +533,44 @@  discard block
 block discarded – undo
533 533
         'posts_per_page' => $args['number']
534 534
     );
535 535
 
536
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
536
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
537 537
 
538
-    $items      = get_posts( $item_args );
538
+    $items      = get_posts($item_args);
539 539
     $options    = array();
540
-    if ( $items ) {
541
-        foreach ( $items as $item ) {
542
-            $title = esc_html( $item->post_title );
540
+    if ($items) {
541
+        foreach ($items as $item) {
542
+            $title = esc_html($item->post_title);
543 543
             
544
-            if ( !empty( $args['show_recurring'] ) ) {
545
-                $title .= wpinv_get_item_suffix( $item->ID, false );
544
+            if (!empty($args['show_recurring'])) {
545
+                $title .= wpinv_get_item_suffix($item->ID, false);
546 546
             }
547 547
             
548
-            $options[ absint( $item->ID ) ] = $title;
548
+            $options[absint($item->ID)] = $title;
549 549
         }
550 550
     }
551 551
 
552 552
     // This ensures that any selected items are included in the drop down
553
-    if( is_array( $args['selected'] ) ) {
554
-        foreach( $args['selected'] as $item ) {
555
-            if( ! in_array( $item, $options ) ) {
556
-                $title = get_the_title( $item );
557
-                if ( !empty( $args['show_recurring'] ) ) {
558
-                    $title .= wpinv_get_item_suffix( $item, false );
553
+    if (is_array($args['selected'])) {
554
+        foreach ($args['selected'] as $item) {
555
+            if (!in_array($item, $options)) {
556
+                $title = get_the_title($item);
557
+                if (!empty($args['show_recurring'])) {
558
+                    $title .= wpinv_get_item_suffix($item, false);
559 559
                 }
560 560
                 $options[$item] = $title;
561 561
             }
562 562
         }
563
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
564
-        if ( ! in_array( $args['selected'], $options ) ) {
565
-            $title = get_the_title( $args['selected'] );
566
-            if ( !empty( $args['show_recurring'] ) ) {
567
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
563
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
564
+        if (!in_array($args['selected'], $options)) {
565
+            $title = get_the_title($args['selected']);
566
+            if (!empty($args['show_recurring'])) {
567
+                $title .= wpinv_get_item_suffix($args['selected'], false);
568 568
             }
569
-            $options[$args['selected']] = get_the_title( $args['selected'] );
569
+            $options[$args['selected']] = get_the_title($args['selected']);
570 570
         }
571 571
     }
572 572
 
573
-    $output = wpinv_html_select( array(
573
+    $output = wpinv_html_select(array(
574 574
         'name'             => $args['name'],
575 575
         'selected'         => $args['selected'],
576 576
         'id'               => $args['id'],
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
         'show_option_all'  => $args['show_option_all'],
582 582
         'show_option_none' => $args['show_option_none'],
583 583
         'data'             => $args['data'],
584
-    ) );
584
+    ));
585 585
 
586 586
     return $output;
587 587
 }
@@ -601,16 +601,16 @@  discard block
 block discarded – undo
601 601
     );
602 602
 
603 603
     $options = array();
604
-    if ( $items ) {
605
-        foreach ( $items as $item ) {
606
-            $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false );
604
+    if ($items) {
605
+        foreach ($items as $item) {
606
+            $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false);
607 607
         }
608 608
     }
609 609
 
610 610
     return $options;
611 611
 }
612 612
 
613
-function wpinv_html_checkbox( $args = array() ) {
613
+function wpinv_html_checkbox($args = array()) {
614 614
     $defaults = array(
615 615
         'name'     => null,
616 616
         'current'  => null,
@@ -621,17 +621,17 @@  discard block
 block discarded – undo
621 621
         )
622 622
     );
623 623
 
624
-    $args = wp_parse_args( $args, $defaults );
624
+    $args = wp_parse_args($args, $defaults);
625 625
 
626
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
626
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
627 627
     $options = '';
628
-    if ( ! empty( $args['options']['disabled'] ) ) {
628
+    if (!empty($args['options']['disabled'])) {
629 629
         $options .= ' disabled="disabled"';
630
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
630
+    } elseif (!empty($args['options']['readonly'])) {
631 631
         $options .= ' readonly';
632 632
     }
633 633
 
634
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
634
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
635 635
 
636 636
     return $output;
637 637
 }
@@ -639,30 +639,30 @@  discard block
 block discarded – undo
639 639
 /**
640 640
  * Displays a hidden field.
641 641
  */
642
-function getpaid_hidden_field( $name, $value ) {
643
-    $name  = sanitize_text_field( $name );
644
-    $value = esc_attr( $value );
642
+function getpaid_hidden_field($name, $value) {
643
+    $name  = sanitize_text_field($name);
644
+    $value = esc_attr($value);
645 645
 
646 646
     echo "<input type='hidden' name='$name' value='$value' />";
647 647
 }
648 648
 
649
-function wpinv_html_text( $args = array() ) {
649
+function wpinv_html_text($args = array()) {
650 650
     // Backwards compatibility
651
-    if ( func_num_args() > 1 ) {
651
+    if (func_num_args() > 1) {
652 652
         $args = func_get_args();
653 653
 
654 654
         $name  = $args[0];
655
-        $value = isset( $args[1] ) ? $args[1] : '';
656
-        $label = isset( $args[2] ) ? $args[2] : '';
657
-        $desc  = isset( $args[3] ) ? $args[3] : '';
655
+        $value = isset($args[1]) ? $args[1] : '';
656
+        $label = isset($args[2]) ? $args[2] : '';
657
+        $desc  = isset($args[3]) ? $args[3] : '';
658 658
     }
659 659
 
660 660
     $defaults = array(
661 661
         'id'           => '',
662
-        'name'         => isset( $name )  ? $name  : 'text',
663
-        'value'        => isset( $value ) ? $value : null,
664
-        'label'        => isset( $label ) ? $label : null,
665
-        'desc'         => isset( $desc )  ? $desc  : null,
662
+        'name'         => isset($name) ? $name : 'text',
663
+        'value'        => isset($value) ? $value : null,
664
+        'label'        => isset($label) ? $label : null,
665
+        'desc'         => isset($desc) ? $desc : null,
666 666
         'placeholder'  => '',
667 667
         'class'        => 'regular-text',
668 668
         'disabled'     => false,
@@ -672,51 +672,51 @@  discard block
 block discarded – undo
672 672
         'data'         => false
673 673
     );
674 674
 
675
-    $args = wp_parse_args( $args, $defaults );
675
+    $args = wp_parse_args($args, $defaults);
676 676
 
677
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
677
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
678 678
     $options = '';
679
-    if( $args['required'] ) {
679
+    if ($args['required']) {
680 680
         $options .= ' required="required"';
681 681
     }
682
-    if( $args['readonly'] ) {
682
+    if ($args['readonly']) {
683 683
         $options .= ' readonly';
684 684
     }
685
-    if( $args['readonly'] ) {
685
+    if ($args['readonly']) {
686 686
         $options .= ' readonly';
687 687
     }
688 688
 
689 689
     $data = '';
690
-    if ( !empty( $args['data'] ) ) {
691
-        foreach ( $args['data'] as $key => $value ) {
692
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
690
+    if (!empty($args['data'])) {
691
+        foreach ($args['data'] as $key => $value) {
692
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
693 693
         }
694 694
     }
695 695
 
696
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
697
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
698
-    if ( ! empty( $args['desc'] ) ) {
699
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
696
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
697
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
698
+    if (!empty($args['desc'])) {
699
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
700 700
     }
701 701
 
702
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] )  . '" autocomplete="' . esc_attr( $args['autocomplete'] )  . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
702
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
703 703
 
704 704
     $output .= '</span>';
705 705
 
706 706
     return $output;
707 707
 }
708 708
 
709
-function wpinv_html_date_field( $args = array() ) {
710
-    if( empty( $args['class'] ) ) {
709
+function wpinv_html_date_field($args = array()) {
710
+    if (empty($args['class'])) {
711 711
         $args['class'] = 'wpiDatepicker';
712
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
712
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
713 713
         $args['class'] .= ' wpiDatepicker';
714 714
     }
715 715
 
716
-    return wpinv_html_text( $args );
716
+    return wpinv_html_text($args);
717 717
 }
718 718
 
719
-function wpinv_html_textarea( $args = array() ) {
719
+function wpinv_html_textarea($args = array()) {
720 720
     $defaults = array(
721 721
         'name'        => 'textarea',
722 722
         'value'       => null,
@@ -727,31 +727,31 @@  discard block
 block discarded – undo
727 727
         'placeholder' => '',
728 728
     );
729 729
 
730
-    $args = wp_parse_args( $args, $defaults );
730
+    $args = wp_parse_args($args, $defaults);
731 731
 
732
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
732
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
733 733
     $disabled = '';
734
-    if( $args['disabled'] ) {
734
+    if ($args['disabled']) {
735 735
         $disabled = ' disabled="disabled"';
736 736
     }
737 737
 
738
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
739
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
740
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
738
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
739
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
740
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
741 741
 
742
-    if ( ! empty( $args['desc'] ) ) {
743
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
742
+    if (!empty($args['desc'])) {
743
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
744 744
     }
745 745
     $output .= '</span>';
746 746
 
747 747
     return $output;
748 748
 }
749 749
 
750
-function wpinv_html_ajax_user_search( $args = array() ) {
750
+function wpinv_html_ajax_user_search($args = array()) {
751 751
     $defaults = array(
752 752
         'name'        => 'user_id',
753 753
         'value'       => null,
754
-        'placeholder' => __( 'Enter username', 'invoicing' ),
754
+        'placeholder' => __('Enter username', 'invoicing'),
755 755
         'label'       => null,
756 756
         'desc'        => null,
757 757
         'class'       => '',
@@ -760,13 +760,13 @@  discard block
 block discarded – undo
760 760
         'data'        => false
761 761
     );
762 762
 
763
-    $args = wp_parse_args( $args, $defaults );
763
+    $args = wp_parse_args($args, $defaults);
764 764
 
765 765
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
766 766
 
767 767
     $output  = '<span class="wpinv_user_search_wrap">';
768
-        $output .= wpinv_html_text( $args );
769
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
768
+        $output .= wpinv_html_text($args);
769
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
770 770
     $output .= '</span>';
771 771
 
772 772
     return $output;
@@ -782,20 +782,20 @@  discard block
 block discarded – undo
782 782
  * 
783 783
  * @param string $template the template that is currently being used.
784 784
  */
785
-function wpinv_template( $template ) {
785
+function wpinv_template($template) {
786 786
     global $post;
787 787
 
788
-    if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) {
788
+    if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) {
789 789
 
790 790
         // If the user can view this invoice, display it.
791
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
791
+        if (wpinv_user_can_view_invoice($post->ID)) {
792 792
 
793
-            return wpinv_get_template_part( 'wpinv-invoice-print', false, false );
793
+            return wpinv_get_template_part('wpinv-invoice-print', false, false);
794 794
 
795 795
         // Else display an error message.
796 796
         } else {
797 797
 
798
-            return wpinv_get_template_part( 'wpinv-invalid-access', false, false );
798
+            return wpinv_get_template_part('wpinv-invalid-access', false, false);
799 799
 
800 800
         }
801 801
 
@@ -803,46 +803,46 @@  discard block
 block discarded – undo
803 803
 
804 804
     return $template;
805 805
 }
806
-add_filter( 'template_include', 'wpinv_template', 10, 1 );
806
+add_filter('template_include', 'wpinv_template', 10, 1);
807 807
 
808 808
 function wpinv_get_business_address() {
809 809
     $business_address   = wpinv_store_address();
810
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
810
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
811 811
     
812 812
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
813 813
     
814
-    return apply_filters( 'wpinv_get_business_address', $business_address );
814
+    return apply_filters('wpinv_get_business_address', $business_address);
815 815
 }
816 816
 
817 817
 /**
818 818
  * Displays the company address.
819 819
  */
820 820
 function wpinv_display_from_address() {
821
-    wpinv_get_template( 'invoice/company-address.php' );
821
+    wpinv_get_template('invoice/company-address.php');
822 822
 }
823
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 );
823
+add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10);
824 824
 
825
-function wpinv_watermark( $id = 0 ) {
826
-    $output = wpinv_get_watermark( $id );
827
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
825
+function wpinv_watermark($id = 0) {
826
+    $output = wpinv_get_watermark($id);
827
+    return apply_filters('wpinv_get_watermark', $output, $id);
828 828
 }
829 829
 
830
-function wpinv_get_watermark( $id ) {
831
-    if ( !$id > 0 ) {
830
+function wpinv_get_watermark($id) {
831
+    if (!$id > 0) {
832 832
         return NULL;
833 833
     }
834 834
 
835
-    $invoice = wpinv_get_invoice( $id );
835
+    $invoice = wpinv_get_invoice($id);
836 836
     
837
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
838
-        if ( $invoice->is_paid() ) {
839
-            return __( 'Paid', 'invoicing' );
837
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
838
+        if ($invoice->is_paid()) {
839
+            return __('Paid', 'invoicing');
840 840
         }
841
-        if ( $invoice->is_refunded() ) {
842
-            return __( 'Refunded', 'invoicing' );
841
+        if ($invoice->is_refunded()) {
842
+            return __('Refunded', 'invoicing');
843 843
         }
844
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
845
-            return __( 'Cancelled', 'invoicing' );
844
+        if ($invoice->has_status(array('wpi-cancelled'))) {
845
+            return __('Cancelled', 'invoicing');
846 846
         }
847 847
     }
848 848
     
@@ -852,140 +852,140 @@  discard block
 block discarded – undo
852 852
 /**
853 853
  * @deprecated
854 854
  */
855
-function wpinv_display_invoice_details( $invoice ) {
856
-    return getpaid_invoice_meta( $invoice );
855
+function wpinv_display_invoice_details($invoice) {
856
+    return getpaid_invoice_meta($invoice);
857 857
 }
858 858
 
859 859
 /**
860 860
  * Displays invoice meta.
861 861
  */
862
-function getpaid_invoice_meta( $invoice ) {
862
+function getpaid_invoice_meta($invoice) {
863 863
 
864
-    $invoice = new WPInv_Invoice( $invoice );
864
+    $invoice = new WPInv_Invoice($invoice);
865 865
 
866 866
     // Ensure that we have an invoice.
867
-    if ( 0 == $invoice->get_id() ) {
867
+    if (0 == $invoice->get_id()) {
868 868
         return;
869 869
     }
870 870
 
871 871
     // Load the invoice meta.
872
-    $meta    = array(
872
+    $meta = array(
873 873
 
874 874
         'number' => array(
875 875
             'label' => sprintf(
876
-                __( '%s Number', 'invoicing' ),
877
-                ucfirst( $invoice->get_type() )
876
+                __('%s Number', 'invoicing'),
877
+                ucfirst($invoice->get_type())
878 878
             ),
879
-            'value' => sanitize_text_field( $invoice->get_number() ),
879
+            'value' => sanitize_text_field($invoice->get_number()),
880 880
         ),
881 881
 
882 882
         'status' => array(
883 883
             'label' => sprintf(
884
-                __( '%s Status', 'invoicing' ),
885
-                ucfirst( $invoice->get_type() )
884
+                __('%s Status', 'invoicing'),
885
+                ucfirst($invoice->get_type())
886 886
             ),
887
-            'value' => sanitize_text_field( $invoice->get_status_nicename() ),
887
+            'value' => sanitize_text_field($invoice->get_status_nicename()),
888 888
         ),
889 889
 
890 890
         'date' => array(
891 891
             'label' => sprintf(
892
-                __( '%s Date', 'invoicing' ),
893
-                ucfirst( $invoice->get_type() )
892
+                __('%s Date', 'invoicing'),
893
+                ucfirst($invoice->get_type())
894 894
             ),
895
-            'value' => getpaid_format_date( $invoice->get_created_date() ),
895
+            'value' => getpaid_format_date($invoice->get_created_date()),
896 896
         ),
897 897
 
898 898
         'date_paid' => array(
899
-            'label' => __( 'Paid On', 'invoicing' ),
900
-            'value' => getpaid_format_date( $invoice->get_completed_date() ),
899
+            'label' => __('Paid On', 'invoicing'),
900
+            'value' => getpaid_format_date($invoice->get_completed_date()),
901 901
         ),
902 902
 
903 903
         'gateway'   => array(
904
-            'label' => __( 'Payment Method', 'invoicing' ),
905
-            'value' => sanitize_text_field( $invoice->get_gateway_title() ),
904
+            'label' => __('Payment Method', 'invoicing'),
905
+            'value' => sanitize_text_field($invoice->get_gateway_title()),
906 906
         ),
907 907
 
908 908
         'transaction_id' => array(
909
-            'label' => __( 'Transaction ID', 'invoicing' ),
910
-            'value' => sanitize_text_field( $invoice->get_transaction_id() ),
909
+            'label' => __('Transaction ID', 'invoicing'),
910
+            'value' => sanitize_text_field($invoice->get_transaction_id()),
911 911
         ),
912 912
 
913 913
         'due_date'  => array(
914
-            'label' => __( 'Due Date', 'invoicing' ),
915
-            'value' => getpaid_format_date( $invoice->get_due_date() ),
914
+            'label' => __('Due Date', 'invoicing'),
915
+            'value' => getpaid_format_date($invoice->get_due_date()),
916 916
         ),
917 917
 
918 918
         'vat_number' => array(
919 919
             'label' => sprintf(
920
-                __( '%s Number', 'invoicing' ),
920
+                __('%s Number', 'invoicing'),
921 921
                 getpaid_tax()->get_vat_name()
922 922
             ),
923
-            'value' => sanitize_text_field( $invoice->get_vat_number() ),
923
+            'value' => sanitize_text_field($invoice->get_vat_number()),
924 924
         ),
925 925
 
926 926
     );
927 927
 
928 928
     // If it is not paid, remove the date of payment.
929
-    if ( ! $invoice->is_paid() ) {
930
-        unset( $meta[ 'date_paid' ] );
931
-        unset( $meta[ 'transaction_id' ] );
929
+    if (!$invoice->is_paid()) {
930
+        unset($meta['date_paid']);
931
+        unset($meta['transaction_id']);
932 932
     }
933 933
 
934
-    if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) {
935
-        unset( $meta[ 'gateway' ] );
934
+    if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) {
935
+        unset($meta['gateway']);
936 936
     }
937 937
 
938 938
     // Only display the due date if due dates are enabled.
939
-    if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) {
940
-        unset( $meta[ 'due_date' ] );
939
+    if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) {
940
+        unset($meta['due_date']);
941 941
     }
942 942
 
943 943
     // Only display the vat number if taxes are enabled.
944
-    if ( ! wpinv_use_taxes() ) {
945
-        unset( $meta[ 'vat_number' ] );
944
+    if (!wpinv_use_taxes()) {
945
+        unset($meta['vat_number']);
946 946
     }
947 947
 
948
-    if ( $invoice->is_recurring() ) {
948
+    if ($invoice->is_recurring()) {
949 949
 
950 950
         // Link to the parent invoice.
951
-        if ( $invoice->is_renewal() ) {
951
+        if ($invoice->is_renewal()) {
952 952
 
953
-            $meta[ 'parent' ] = array(
953
+            $meta['parent'] = array(
954 954
 
955 955
                 'label' => sprintf(
956
-                    __( 'Parent %s', 'invoicing' ),
957
-                    ucfirst( $invoice->get_type() )
956
+                    __('Parent %s', 'invoicing'),
957
+                    ucfirst($invoice->get_type())
958 958
                 ),
959 959
 
960
-                'value' => wpinv_invoice_link( $invoice->get_parent_id() ),
960
+                'value' => wpinv_invoice_link($invoice->get_parent_id()),
961 961
 
962 962
             );
963 963
 
964 964
         }
965 965
 
966
-        $subscription = wpinv_get_subscription( $invoice );
966
+        $subscription = wpinv_get_subscription($invoice);
967 967
 
968
-        if ( ! empty ( $subscription ) ) {
968
+        if (!empty ($subscription)) {
969 969
 
970 970
             // Display the renewal date.
971
-            if ( $subscription->is_active() && 'cancelled' != $subscription->status ) {
971
+            if ($subscription->is_active() && 'cancelled' != $subscription->status) {
972 972
 
973
-                $meta[ 'renewal_date' ] = array(
973
+                $meta['renewal_date'] = array(
974 974
 
975
-                    'label' => __( 'Renews On', 'invoicing' ),
976
-                    'value' => getpaid_format_date( $subscription->expiration ),
975
+                    'label' => __('Renews On', 'invoicing'),
976
+                    'value' => getpaid_format_date($subscription->expiration),
977 977
         
978 978
                 );
979 979
 
980 980
             }
981 981
 
982
-            if ( $invoice->is_parent() ) {
982
+            if ($invoice->is_parent()) {
983 983
 
984 984
                 // Display the recurring amount.
985
-                $meta[ 'recurring_total' ] = array(
985
+                $meta['recurring_total'] = array(
986 986
 
987
-                    'label' => __( 'Recurring Amount', 'invoicing' ),
988
-                    'value' => wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), $invoice->get_currency() ),
987
+                    'label' => __('Recurring Amount', 'invoicing'),
988
+                    'value' => wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()),
989 989
         
990 990
                 );
991 991
 
@@ -995,20 +995,20 @@  discard block
 block discarded – undo
995 995
     }
996 996
 
997 997
     // Add the invoice total to the meta.
998
-    $meta[ 'invoice_total' ] = array(
998
+    $meta['invoice_total'] = array(
999 999
 
1000
-        'label' => __( 'Total Amount', 'invoicing' ),
1001
-        'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ),
1000
+        'label' => __('Total Amount', 'invoicing'),
1001
+        'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()),
1002 1002
 
1003 1003
     );
1004 1004
 
1005 1005
     // Provide a way for third party plugins to filter the meta.
1006
-    $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice );
1006
+    $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice);
1007 1007
 
1008
-    wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) );
1008
+    wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta'));
1009 1009
 
1010 1010
 }
1011
-add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 );
1011
+add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10);
1012 1012
 
1013 1013
 /**
1014 1014
  * Retrieves the address markup to use on Invoices.
@@ -1020,29 +1020,29 @@  discard block
 block discarded – undo
1020 1020
  * @param  string $separator How to separate address lines.
1021 1021
  * @return string
1022 1022
  */
1023
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
1023
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
1024 1024
 
1025 1025
     // Retrieve the address markup...
1026
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
1027
-    $format = wpinv_get_full_address_format( $country );
1026
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
1027
+    $format = wpinv_get_full_address_format($country);
1028 1028
 
1029 1029
     // ... and the replacements.
1030
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
1030
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
1031 1031
 
1032
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
1032
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
1033 1033
     
1034 1034
 	// Remove unavailable tags.
1035
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
1035
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
1036 1036
 
1037 1037
     // Clean up white space.
1038
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
1039
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
1038
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
1039
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
1040 1040
     
1041 1041
     // Break newlines apart and remove empty lines/trim commas and white space.
1042
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
1042
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
1043 1043
 
1044 1044
     // Add html breaks.
1045
-	$formatted_address = implode( $separator, $formatted_address );
1045
+	$formatted_address = implode($separator, $formatted_address);
1046 1046
 
1047 1047
 	// We're done!
1048 1048
 	return $formatted_address;
@@ -1054,88 +1054,88 @@  discard block
 block discarded – undo
1054 1054
  * 
1055 1055
  * @param WPInv_Invoice $invoice
1056 1056
  */
1057
-function wpinv_display_to_address( $invoice = 0 ) {
1058
-    if ( ! empty( $invoice ) ) {
1059
-        wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) );
1057
+function wpinv_display_to_address($invoice = 0) {
1058
+    if (!empty($invoice)) {
1059
+        wpinv_get_template('invoice/billing-address.php', compact('invoice'));
1060 1060
     }
1061 1061
 }
1062
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 );
1062
+add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40);
1063 1063
 
1064 1064
 
1065 1065
 /**
1066 1066
  * Displays invoice line items.
1067 1067
  */
1068
-function wpinv_display_line_items( $invoice_id = 0 ) {
1068
+function wpinv_display_line_items($invoice_id = 0) {
1069 1069
 
1070 1070
     // Prepare the invoice.
1071
-    $invoice = new WPInv_Invoice( $invoice_id );
1071
+    $invoice = new WPInv_Invoice($invoice_id);
1072 1072
 
1073 1073
     // Abort if there is no invoice.
1074
-    if ( 0 == $invoice->get_id() ) {
1074
+    if (0 == $invoice->get_id()) {
1075 1075
         return;
1076 1076
     }
1077 1077
 
1078 1078
     // Line item columns.
1079
-    $columns = getpaid_invoice_item_columns( $invoice );
1080
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
1079
+    $columns = getpaid_invoice_item_columns($invoice);
1080
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
1081 1081
 
1082
-    wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) );
1082
+    wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns'));
1083 1083
 }
1084
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 );
1084
+add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10);
1085 1085
 
1086 1086
 /**
1087 1087
  * Displays invoice notices on invoices.
1088 1088
  */
1089 1089
 function wpinv_display_invoice_notice() {
1090 1090
 
1091
-    $label  = wpinv_get_option( 'vat_invoice_notice_label' );
1092
-    $notice = wpinv_get_option( 'vat_invoice_notice' );
1091
+    $label  = wpinv_get_option('vat_invoice_notice_label');
1092
+    $notice = wpinv_get_option('vat_invoice_notice');
1093 1093
 
1094
-    if ( empty( $label ) && empty( $notice ) ) {
1094
+    if (empty($label) && empty($notice)) {
1095 1095
         return;
1096 1096
     }
1097 1097
 
1098 1098
     echo '<div class="mt-4 mb-4 wpinv-vat-notice">';
1099 1099
 
1100
-    if ( ! empty( $label ) ) {
1101
-        $label = sanitize_text_field( $label );
1100
+    if (!empty($label)) {
1101
+        $label = sanitize_text_field($label);
1102 1102
         echo "<h5>$label</h5>";
1103 1103
     }
1104 1104
 
1105
-    if ( ! empty( $notice ) ) {
1106
-        echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>';
1105
+    if (!empty($notice)) {
1106
+        echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>';
1107 1107
     }
1108 1108
 
1109 1109
     echo '</div>';
1110 1110
 }
1111
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 );
1111
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100);
1112 1112
 
1113 1113
 /**
1114 1114
  * @param WPInv_Invoice $invoice
1115 1115
  */
1116
-function wpinv_display_invoice_notes( $invoice ) {
1116
+function wpinv_display_invoice_notes($invoice) {
1117 1117
 
1118 1118
     // Retrieve the notes.
1119
-    $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' );
1119
+    $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer');
1120 1120
 
1121 1121
     // Abort if we have non.
1122
-    if ( empty( $notes ) ) {
1122
+    if (empty($notes)) {
1123 1123
         return;
1124 1124
     }
1125 1125
 
1126 1126
     // Echo the note.
1127 1127
     echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">';
1128
-    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>';
1128
+    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>';
1129 1129
     echo '<ul class="getpaid-invoice-notes mt-4 p-0">';
1130 1130
 
1131
-    foreach( $notes as $note ) {
1132
-        wpinv_get_invoice_note_line_item( $note );
1131
+    foreach ($notes as $note) {
1132
+        wpinv_get_invoice_note_line_item($note);
1133 1133
     }
1134 1134
 
1135 1135
     echo '</ul>';
1136 1136
     echo '</div>';
1137 1137
 }
1138
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 );
1138
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60);
1139 1139
 
1140 1140
 /**
1141 1141
  * Loads scripts on our invoice templates.
@@ -1143,32 +1143,32 @@  discard block
 block discarded – undo
1143 1143
 function wpinv_display_style() {
1144 1144
 
1145 1145
     // Make sure that all scripts have been loaded.
1146
-    if ( ! did_action( 'wp_enqueue_scripts' ) ) {
1147
-        do_action( 'wp_enqueue_scripts' );
1146
+    if (!did_action('wp_enqueue_scripts')) {
1147
+        do_action('wp_enqueue_scripts');
1148 1148
     }
1149 1149
 
1150 1150
     // Register the invoices style.
1151
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) );
1151
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css'));
1152 1152
 
1153 1153
     // Load required styles
1154
-    wp_print_styles( 'open-sans' );
1155
-    wp_print_styles( 'wpinv-single-style' );
1156
-    wp_print_styles( 'ayecode-ui' );
1154
+    wp_print_styles('open-sans');
1155
+    wp_print_styles('wpinv-single-style');
1156
+    wp_print_styles('ayecode-ui');
1157 1157
 
1158 1158
     // Maybe load custom css.
1159
-    $custom_css = wpinv_get_option( 'template_custom_css' );
1159
+    $custom_css = wpinv_get_option('template_custom_css');
1160 1160
 
1161
-    if ( isset( $custom_css ) && ! empty( $custom_css ) ) {
1162
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
1163
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
1161
+    if (isset($custom_css) && !empty($custom_css)) {
1162
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
1163
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
1164 1164
         echo '<style type="text/css">';
1165 1165
         echo $custom_css;
1166 1166
         echo '</style>';
1167 1167
     }
1168 1168
 
1169 1169
 }
1170
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
1171
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
1170
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
1171
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1172 1172
 
1173 1173
 
1174 1174
 /**
@@ -1180,41 +1180,41 @@  discard block
 block discarded – undo
1180 1180
     // Retrieve the current invoice.
1181 1181
     $invoice_id = getpaid_get_current_invoice_id();
1182 1182
 
1183
-    if ( empty( $invoice_id ) ) {
1183
+    if (empty($invoice_id)) {
1184 1184
 
1185 1185
         return aui()->alert(
1186 1186
             array(
1187 1187
                 'type'    => 'warning',
1188
-                'content' => __( 'Invalid invoice', 'invoicing' ),
1188
+                'content' => __('Invalid invoice', 'invoicing'),
1189 1189
             )
1190 1190
         );
1191 1191
 
1192 1192
     }
1193 1193
 
1194 1194
     // Can the user view this invoice?
1195
-    if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) {
1195
+    if (!wpinv_user_can_view_invoice($invoice_id)) {
1196 1196
 
1197 1197
         return aui()->alert(
1198 1198
             array(
1199 1199
                 'type'    => 'warning',
1200
-                'content' => __( 'You are not allowed to view this invoice', 'invoicing' ),
1200
+                'content' => __('You are not allowed to view this invoice', 'invoicing'),
1201 1201
             )
1202 1202
         );
1203 1203
 
1204 1204
     }
1205 1205
 
1206 1206
     // Ensure that it is not yet paid for.
1207
-    $invoice = new WPInv_Invoice( $invoice_id );
1207
+    $invoice = new WPInv_Invoice($invoice_id);
1208 1208
 
1209 1209
     // Maybe mark it as viewed.
1210
-    getpaid_maybe_mark_invoice_as_viewed( $invoice );
1210
+    getpaid_maybe_mark_invoice_as_viewed($invoice);
1211 1211
 
1212
-    if ( $invoice->is_paid() ) {
1212
+    if ($invoice->is_paid()) {
1213 1213
 
1214 1214
         return aui()->alert(
1215 1215
             array(
1216 1216
                 'type'    => 'success',
1217
-                'content' => __( 'This invoice has already been paid.', 'invoicing' ),
1217
+                'content' => __('This invoice has already been paid.', 'invoicing'),
1218 1218
             )
1219 1219
         );
1220 1220
 
@@ -1224,14 +1224,14 @@  discard block
 block discarded – undo
1224 1224
     $wpi_checkout_id = $invoice_id;
1225 1225
 
1226 1226
     // We'll display this invoice via the default form.
1227
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1227
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1228 1228
 
1229
-    if ( 0 == $form->get_id() ) {
1229
+    if (0 == $form->get_id()) {
1230 1230
 
1231 1231
         return aui()->alert(
1232 1232
             array(
1233 1233
                 'type'    => 'warning',
1234
-                'content' => __( 'Error loading the payment form', 'invoicing' ),
1234
+                'content' => __('Error loading the payment form', 'invoicing'),
1235 1235
             )
1236 1236
         );
1237 1237
 
@@ -1239,37 +1239,37 @@  discard block
 block discarded – undo
1239 1239
 
1240 1240
     // Set the invoice.
1241 1241
     $form->invoice = $invoice;
1242
-    $form->set_items( $invoice->get_items() );
1242
+    $form->set_items($invoice->get_items());
1243 1243
 
1244 1244
     // Generate the html.
1245 1245
     return $form->get_html();
1246 1246
 
1247 1247
 }
1248 1248
 
1249
-function wpinv_checkout_cart( $cart_details = array(), $echo = true ) {
1249
+function wpinv_checkout_cart($cart_details = array(), $echo = true) {
1250 1250
     global $ajax_cart_details;
1251 1251
     $ajax_cart_details = $cart_details;
1252 1252
 
1253 1253
     ob_start();
1254
-    do_action( 'wpinv_before_checkout_cart' );
1254
+    do_action('wpinv_before_checkout_cart');
1255 1255
     echo '<div id="wpinv_checkout_cart_form" method="post">';
1256 1256
         echo '<div id="wpinv_checkout_cart_wrap">';
1257
-            wpinv_get_template_part( 'wpinv-checkout-cart' );
1257
+            wpinv_get_template_part('wpinv-checkout-cart');
1258 1258
         echo '</div>';
1259 1259
     echo '</div>';
1260
-    do_action( 'wpinv_after_checkout_cart' );
1260
+    do_action('wpinv_after_checkout_cart');
1261 1261
     $content = ob_get_clean();
1262 1262
 
1263
-    if ( $echo ) {
1263
+    if ($echo) {
1264 1264
         echo $content;
1265 1265
     } else {
1266 1266
         return $content;
1267 1267
     }
1268 1268
 }
1269
-add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1269
+add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10);
1270 1270
 
1271 1271
 function wpinv_empty_cart_message() {
1272
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1272
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1273 1273
 }
1274 1274
 
1275 1275
 /**
@@ -1286,51 +1286,51 @@  discard block
 block discarded – undo
1286 1286
         )
1287 1287
     );
1288 1288
 }
1289
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1289
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1290 1290
 
1291 1291
 function wpinv_checkout_cart_columns() {
1292 1292
     $default = 3;
1293
-    if ( wpinv_item_quantities_enabled() ) {
1293
+    if (wpinv_item_quantities_enabled()) {
1294 1294
         $default++;
1295 1295
     }
1296 1296
 
1297
-    if ( wpinv_use_taxes() ) {
1297
+    if (wpinv_use_taxes()) {
1298 1298
         $default++;
1299 1299
     }
1300 1300
 
1301
-    return apply_filters( 'wpinv_checkout_cart_columns', $default );
1301
+    return apply_filters('wpinv_checkout_cart_columns', $default);
1302 1302
 }
1303 1303
 
1304
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1305
-    $invoice = wpinv_get_invoice( $invoice_id );
1304
+function wpinv_receipt_billing_address($invoice_id = 0) {
1305
+    $invoice = wpinv_get_invoice($invoice_id);
1306 1306
 
1307
-    if ( empty( $invoice ) ) {
1307
+    if (empty($invoice)) {
1308 1308
         return NULL;
1309 1309
     }
1310 1310
 
1311 1311
     $billing_details = $invoice->get_user_info();
1312
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1312
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1313 1313
 
1314 1314
     ob_start();
1315 1315
     ?>
1316 1316
     <table class="table table-bordered table-sm wpi-billing-details">
1317 1317
         <tbody>
1318 1318
             <tr class="wpi-receipt-name">
1319
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1320
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1319
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1320
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1321 1321
             </tr>
1322 1322
             <tr class="wpi-receipt-email">
1323
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1324
-                <td><?php echo $billing_details['email'] ;?></td>
1323
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1324
+                <td><?php echo $billing_details['email']; ?></td>
1325 1325
             </tr>
1326 1326
             <tr class="wpi-receipt-address">
1327
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1328
-                <td><?php echo $address_row ;?></td>
1327
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1328
+                <td><?php echo $address_row; ?></td>
1329 1329
             </tr>
1330
-            <?php if ( $billing_details['phone'] ) { ?>
1330
+            <?php if ($billing_details['phone']) { ?>
1331 1331
             <tr class="wpi-receipt-phone">
1332
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1333
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1332
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1333
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1334 1334
             </tr>
1335 1335
             <?php } ?>
1336 1336
         </tbody>
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
     <?php
1339 1339
     $output = ob_get_clean();
1340 1340
     
1341
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1341
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1342 1342
 
1343 1343
     echo $output;
1344 1344
 }
@@ -1346,56 +1346,56 @@  discard block
 block discarded – undo
1346 1346
 /**
1347 1347
  * Filters the receipt page.
1348 1348
  */
1349
-function wpinv_filter_success_page_content( $content ) {
1349
+function wpinv_filter_success_page_content($content) {
1350 1350
 
1351 1351
     // Ensure this is our page.
1352
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1352
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1353 1353
 
1354
-        $gateway = sanitize_text_field( $_GET['payment-confirm'] );
1355
-        return apply_filters( "wpinv_payment_confirm_$gateway", $content );
1354
+        $gateway = sanitize_text_field($_GET['payment-confirm']);
1355
+        return apply_filters("wpinv_payment_confirm_$gateway", $content);
1356 1356
 
1357 1357
     }
1358 1358
 
1359 1359
     return $content;
1360 1360
 }
1361
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1361
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1362 1362
 
1363
-function wpinv_invoice_link( $invoice_id ) {
1364
-    $invoice = wpinv_get_invoice( $invoice_id );
1363
+function wpinv_invoice_link($invoice_id) {
1364
+    $invoice = wpinv_get_invoice($invoice_id);
1365 1365
 
1366
-    if ( empty( $invoice ) ) {
1366
+    if (empty($invoice)) {
1367 1367
         return NULL;
1368 1368
     }
1369 1369
 
1370
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1370
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1371 1371
 
1372
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1372
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1373 1373
 }
1374 1374
 
1375
-function wpinv_invoice_subscription_details( $invoice ) {
1376
-    if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) {
1377
-        $subscription = wpinv_get_subscription( $invoice, true );
1375
+function wpinv_invoice_subscription_details($invoice) {
1376
+    if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) {
1377
+        $subscription = wpinv_get_subscription($invoice, true);
1378 1378
 
1379
-        if ( empty( $subscription ) ) {
1379
+        if (empty($subscription)) {
1380 1380
             return;
1381 1381
         }
1382 1382
 
1383 1383
         $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency);
1384
-        $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency() ) . ' / ' . $frequency;
1385
-        $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), $invoice->get_currency() );
1384
+        $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()) . ' / ' . $frequency;
1385
+        $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), $invoice->get_currency());
1386 1386
 
1387 1387
         $payments = $subscription->get_child_payments();
1388 1388
         ?>
1389 1389
         <div class="wpinv-subscriptions-details">
1390
-            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3>
1390
+            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3>
1391 1391
             <table class="table">
1392 1392
                 <thead>
1393 1393
                     <tr>
1394
-                        <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th>
1395
-                        <th><?php _e( 'Start Date', 'invoicing' ) ;?></th>
1396
-                        <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th>
1397
-                        <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th>
1398
-                        <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th>
1394
+                        <th><?php _e('Billing Cycle', 'invoicing'); ?></th>
1395
+                        <th><?php _e('Start Date', 'invoicing'); ?></th>
1396
+                        <th><?php _e('Expiration Date', 'invoicing'); ?></th>
1397
+                        <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th>
1398
+                        <th class="text-center"><?php _e('Status', 'invoicing'); ?></th>
1399 1399
                     </tr>
1400 1400
                 </thead>
1401 1401
                 <tbody>
@@ -1403,35 +1403,35 @@  discard block
 block discarded – undo
1403 1403
                         <td><?php printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); ?></td>
1404 1404
                         <td><?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?></td>
1405 1405
                         <td><?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?></td>
1406
-                        <td class="text-center"><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? __( 'Until Cancelled', 'invoicing' ) : $subscription->bill_times); ?></td>
1406
+                        <td class="text-center"><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? __('Until Cancelled', 'invoicing') : $subscription->bill_times); ?></td>
1407 1407
                         <td class="text-center wpi-sub-status"><?php echo $subscription->get_status_label(); ?></td>
1408 1408
                     </tr>
1409 1409
                 </tbody>
1410 1410
             </table>
1411 1411
         </div>
1412
-        <?php if ( !empty( $payments ) ) { ?>
1412
+        <?php if (!empty($payments)) { ?>
1413 1413
         <div class="wpinv-renewal-payments">
1414
-            <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3>
1414
+            <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3>
1415 1415
             <table class="table">
1416 1416
                 <thead>
1417 1417
                     <tr>
1418 1418
                         <th>#</th>
1419
-                        <th><?php _e( 'Invoice', 'invoicing' ) ;?></th>
1420
-                        <th><?php _e( 'Date', 'invoicing' ) ;?></th>
1421
-                        <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th>
1419
+                        <th><?php _e('Invoice', 'invoicing'); ?></th>
1420
+                        <th><?php _e('Date', 'invoicing'); ?></th>
1421
+                        <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th>
1422 1422
                     </tr>
1423 1423
                 </thead>
1424 1424
                 <tbody>
1425 1425
                     <?php
1426 1426
                         $i = 1;
1427
-                        foreach ( $payments as $payment ) {
1427
+                        foreach ($payments as $payment) {
1428 1428
                             $invoice_id = $payment->ID;
1429 1429
                     ?>
1430 1430
                     <tr>
1431
-                        <th scope="row"><?php echo $i;?></th>
1432
-                        <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td>
1431
+                        <th scope="row"><?php echo $i; ?></th>
1432
+                        <td><?php echo wpinv_invoice_link($invoice_id); ?></td>
1433 1433
                         <td><?php echo$invoice->get_date_created(); ?></td>
1434
-                        <td class="text-right"><?php echo wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); ?></td>
1434
+                        <td class="text-right"><?php echo wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); ?></td>
1435 1435
                     </tr>
1436 1436
                     <?php $i++; } ?>
1437 1437
                 </tbody>
@@ -1441,64 +1441,64 @@  discard block
 block discarded – undo
1441 1441
         <?php
1442 1442
     }
1443 1443
 }
1444
-add_action( 'getpaid_invoice_line_items', 'wpinv_invoice_subscription_details', 20 );
1444
+add_action('getpaid_invoice_line_items', 'wpinv_invoice_subscription_details', 20);
1445 1445
 
1446
-function wpinv_cart_total_label( $label, $invoice ) {
1447
-    if ( empty( $invoice ) ) {
1446
+function wpinv_cart_total_label($label, $invoice) {
1447
+    if (empty($invoice)) {
1448 1448
         return $label;
1449 1449
     }
1450 1450
 
1451 1451
     $prefix_label = '';
1452
-    if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) {
1453
-        $prefix_label   = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice );
1454
-    } else if ( $invoice->is_renewal() ) {
1455
-        $prefix_label   = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> ';        
1452
+    if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) {
1453
+        $prefix_label   = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice);
1454
+    } else if ($invoice->is_renewal()) {
1455
+        $prefix_label   = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> ';        
1456 1456
     }
1457 1457
 
1458
-    if ( $prefix_label != '' ) {
1459
-        $label  = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
1458
+    if ($prefix_label != '') {
1459
+        $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
1460 1460
     }
1461 1461
 
1462 1462
     return $label;
1463 1463
 }
1464
-add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1465
-add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1466
-add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1464
+add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1465
+add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1466
+add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1467 1467
 
1468
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
1469
-    if ( empty( $note ) ) {
1468
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
1469
+    if (empty($note)) {
1470 1470
         return NULL;
1471 1471
     }
1472 1472
 
1473
-    if ( is_int( $note ) ) {
1474
-        $note = get_comment( $note );
1473
+    if (is_int($note)) {
1474
+        $note = get_comment($note);
1475 1475
     }
1476 1476
 
1477
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
1477
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
1478 1478
         return NULL;
1479 1479
     }
1480 1480
 
1481
-    $note_classes   = array( 'note' );
1482
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
1481
+    $note_classes   = array('note');
1482
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
1483 1483
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
1484
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
1485
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
1484
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
1485
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
1486 1486
 
1487 1487
     ob_start();
1488 1488
     ?>
1489
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3">
1489
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3">
1490 1490
         <div class="note_content bg-light border position-relative p-4">
1491 1491
 
1492
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
1492
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
1493 1493
 
1494
-            <?php if ( ! is_admin() ) : ?>
1494
+            <?php if (!is_admin()) : ?>
1495 1495
                 <em class="meta position-absolute form-text">
1496 1496
                     <?php
1497 1497
                         printf(
1498
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1498
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1499 1499
                             $note->comment_author,
1500
-                            date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ),
1501
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1500
+                            date_i18n(get_option('date_format'), strtotime($note->comment_date)),
1501
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1502 1502
                         );
1503 1503
                     ?>
1504 1504
                 </em>
@@ -1506,12 +1506,12 @@  discard block
 block discarded – undo
1506 1506
 
1507 1507
         </div>
1508 1508
 
1509
-        <?php if ( is_admin() ) : ?>
1509
+        <?php if (is_admin()) : ?>
1510 1510
 
1511 1511
             <p class="meta px-4 py-2">
1512
-                <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr>&nbsp;&nbsp;
1513
-                <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?>
1514
-                    <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
1512
+                <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr>&nbsp;&nbsp;
1513
+                <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?>
1514
+                    <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
1515 1515
                 <?php } ?>
1516 1516
             </p>
1517 1517
 
@@ -1520,9 +1520,9 @@  discard block
 block discarded – undo
1520 1520
     </li>
1521 1521
     <?php
1522 1522
     $note_content = ob_get_clean();
1523
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
1523
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
1524 1524
 
1525
-    if ( $echo ) {
1525
+    if ($echo) {
1526 1526
         echo $note_content;
1527 1527
     } else {
1528 1528
         return $note_content;
@@ -1532,36 +1532,36 @@  discard block
 block discarded – undo
1532 1532
 function wpinv_invalid_invoice_content() {
1533 1533
     global $post;
1534 1534
 
1535
-    $invoice = wpinv_get_invoice( $post->ID );
1535
+    $invoice = wpinv_get_invoice($post->ID);
1536 1536
 
1537
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
1538
-    if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
1539
-        if ( is_user_logged_in() ) {
1540
-            if ( wpinv_require_login_to_checkout() ) {
1541
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1542
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
1537
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
1538
+    if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
1539
+        if (is_user_logged_in()) {
1540
+            if (wpinv_require_login_to_checkout()) {
1541
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1542
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
1543 1543
                 }
1544 1544
             }
1545 1545
         } else {
1546
-            if ( wpinv_require_login_to_checkout() ) {
1547
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1548
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
1546
+            if (wpinv_require_login_to_checkout()) {
1547
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1548
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
1549 1549
                 }
1550 1550
             }
1551 1551
         }
1552 1552
     } else {
1553
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
1553
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
1554 1554
     }
1555 1555
     ?>
1556 1556
     <div class="row wpinv-row-invalid">
1557 1557
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
1558
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
1558
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
1559 1559
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
1560 1560
         </div>
1561 1561
     </div>
1562 1562
     <?php
1563 1563
 }
1564
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
1564
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
1565 1565
 
1566 1566
 /**
1567 1567
  * Function to get privacy policy text.
@@ -1570,21 +1570,21 @@  discard block
 block discarded – undo
1570 1570
  * @return string
1571 1571
  */
1572 1572
 function wpinv_get_policy_text() {
1573
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
1573
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
1574 1574
 
1575
-    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ));
1575
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
1576 1576
 
1577
-    if(!$privacy_page_id){
1578
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
1577
+    if (!$privacy_page_id) {
1578
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
1579 1579
     }
1580 1580
 
1581
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
1581
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
1582 1582
 
1583 1583
     $find_replace = array(
1584 1584
         '[wpinv_privacy_policy]' => $privacy_link,
1585 1585
     );
1586 1586
 
1587
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
1587
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
1588 1588
 
1589 1589
     return wp_kses_post(wpautop($privacy_text));
1590 1590
 }
@@ -1593,25 +1593,25 @@  discard block
 block discarded – undo
1593 1593
 /**
1594 1594
  * Allows the user to set their own price for an invoice item
1595 1595
  */
1596
-function wpinv_checkout_cart_item_name_your_price( $cart_item, $key ) {
1596
+function wpinv_checkout_cart_item_name_your_price($cart_item, $key) {
1597 1597
     
1598 1598
     //Ensure we have an item id
1599
-    if(! is_array( $cart_item ) || empty( $cart_item['id'] ) ) {
1599
+    if (!is_array($cart_item) || empty($cart_item['id'])) {
1600 1600
         return;
1601 1601
     }
1602 1602
 
1603 1603
     //Fetch the item
1604 1604
     $item_id = $cart_item['id'];
1605
-    $item    = new WPInv_Item( $item_id );
1605
+    $item    = new WPInv_Item($item_id);
1606 1606
     
1607
-    if(! $item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing() ) {
1607
+    if (!$item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing()) {
1608 1608
         return;
1609 1609
     }
1610 1610
 
1611 1611
     //Fetch the dynamic pricing "strings"
1612
-    $suggested_price_text = esc_html( wpinv_get_option( 'suggested_price_text', __( 'Suggested Price:', 'invoicing' ) ) );
1613
-    $minimum_price_text   = esc_html( wpinv_get_option( 'minimum_price_text', __( 'Minimum Price:', 'invoicing' ) ) );
1614
-    $name_your_price_text = esc_html( wpinv_get_option( 'name_your_price_text', __( 'Name Your Price', 'invoicing' ) ) );
1612
+    $suggested_price_text = esc_html(wpinv_get_option('suggested_price_text', __('Suggested Price:', 'invoicing')));
1613
+    $minimum_price_text   = esc_html(wpinv_get_option('minimum_price_text', __('Minimum Price:', 'invoicing')));
1614
+    $name_your_price_text = esc_html(wpinv_get_option('name_your_price_text', __('Name Your Price', 'invoicing')));
1615 1615
 
1616 1616
     //Display a "name_your_price" button
1617 1617
     echo " &mdash; <a href='#' class='wpinv-name-your-price-frontend small'>$name_your_price_text</a></div>";
@@ -1620,7 +1620,7 @@  discard block
 block discarded – undo
1620 1620
     echo '<div class="name-your-price-miniform">';
1621 1621
     
1622 1622
     //Maybe display the recommended price
1623
-    if( $item->get_price() > 0 && !empty( $suggested_price_text ) ) {
1623
+    if ($item->get_price() > 0 && !empty($suggested_price_text)) {
1624 1624
         $suggested_price = $item->get_the_price();
1625 1625
         echo "<div>$suggested_price_text &mdash; $suggested_price</div>";
1626 1626
     }
@@ -1628,52 +1628,52 @@  discard block
 block discarded – undo
1628 1628
     //Display the update price form
1629 1629
     $symbol         = wpinv_currency_symbol();
1630 1630
     $position       = wpinv_currency_position();
1631
-    $minimum        = esc_attr( $item->get_minimum_price() );
1632
-    $price          = esc_attr( $cart_item['item_price'] );
1633
-    $update         = esc_attr__( "Update", 'invoicing' );
1631
+    $minimum        = esc_attr($item->get_minimum_price());
1632
+    $price          = esc_attr($cart_item['item_price']);
1633
+    $update         = esc_attr__("Update", 'invoicing');
1634 1634
 
1635 1635
     //Ensure it supports dynamic prici
1636
-    if( $price < $minimum ) {
1636
+    if ($price < $minimum) {
1637 1637
         $price = $minimum;
1638 1638
     }
1639 1639
 
1640 1640
     echo '<label>';
1641 1641
     echo $position != 'right' ? $symbol . '&nbsp;' : '';
1642 1642
     echo "<input type='number' min='$minimum' placeholder='$price' value='$price' class='wpi-field-price' />";
1643
-    echo $position == 'right' ? '&nbsp;' . $symbol : '' ;
1643
+    echo $position == 'right' ? '&nbsp;' . $symbol : '';
1644 1644
     echo "</label>";
1645 1645
     echo "<input type='hidden' value='$item_id' class='wpi-field-item' />";
1646 1646
     echo "<a class='btn btn-success wpinv-submit wpinv-update-dynamic-price-frontend'>$update</a>";
1647 1647
 
1648 1648
     //Maybe display the minimum price
1649
-    if( $item->get_minimum_price() > 0 && !empty( $minimum_price_text ) ) {
1650
-        $minimum_price = wpinv_price( wpinv_format_amount( $item->get_minimum_price() ) );
1649
+    if ($item->get_minimum_price() > 0 && !empty($minimum_price_text)) {
1650
+        $minimum_price = wpinv_price(wpinv_format_amount($item->get_minimum_price()));
1651 1651
         echo "<div>$minimum_price_text &mdash; $minimum_price</div>";
1652 1652
     }
1653 1653
 
1654 1654
     echo "</div>";
1655 1655
 
1656 1656
 }
1657
-add_action( 'wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2 );
1657
+add_action('wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2);
1658 1658
 
1659 1659
 function wpinv_oxygen_fix_conflict() {
1660 1660
     global $ct_ignore_post_types;
1661 1661
 
1662
-    if ( ! is_array( $ct_ignore_post_types ) ) {
1662
+    if (!is_array($ct_ignore_post_types)) {
1663 1663
         $ct_ignore_post_types = array();
1664 1664
     }
1665 1665
 
1666
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
1666
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
1667 1667
 
1668
-    foreach ( $post_types as $post_type ) {
1668
+    foreach ($post_types as $post_type) {
1669 1669
         $ct_ignore_post_types[] = $post_type;
1670 1670
 
1671 1671
         // Ignore post type
1672
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
1672
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
1673 1673
     }
1674 1674
 
1675
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
1676
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
1675
+    remove_filter('template_include', 'wpinv_template', 10, 1);
1676
+    add_filter('template_include', 'wpinv_template', 999, 1);
1677 1677
 }
1678 1678
 
1679 1679
 /**
@@ -1681,10 +1681,10 @@  discard block
 block discarded – undo
1681 1681
  * 
1682 1682
  * @param GetPaid_Payment_Form $form
1683 1683
  */
1684
-function getpaid_display_payment_form( $form ) {
1684
+function getpaid_display_payment_form($form) {
1685 1685
 
1686
-    if ( is_numeric( $form ) ) {
1687
-        $form = new GetPaid_Payment_Form( $form );
1686
+    if (is_numeric($form)) {
1687
+        $form = new GetPaid_Payment_Form($form);
1688 1688
     }
1689 1689
 
1690 1690
     $form->display();
@@ -1694,124 +1694,124 @@  discard block
 block discarded – undo
1694 1694
 /**
1695 1695
  * Helper function to display a item payment form on the frontend.
1696 1696
  */
1697
-function getpaid_display_item_payment_form( $items ) {
1697
+function getpaid_display_item_payment_form($items) {
1698 1698
     global $invoicing;
1699 1699
 
1700
-    foreach ( array_keys( $items ) as $id ) {
1701
-	    if ( 'publish' != get_post_status( $id ) ) {
1702
-		    unset( $items[ $id ] );
1700
+    foreach (array_keys($items) as $id) {
1701
+	    if ('publish' != get_post_status($id)) {
1702
+		    unset($items[$id]);
1703 1703
 	    }
1704 1704
     }
1705 1705
 
1706
-    if ( empty( $items ) ) {
1706
+    if (empty($items)) {
1707 1707
 		return aui()->alert(
1708 1708
 			array(
1709 1709
 				'type'    => 'warning',
1710
-				'content' => __( 'No published items found', 'invoicing' ),
1710
+				'content' => __('No published items found', 'invoicing'),
1711 1711
 			)
1712 1712
 		);
1713 1713
     }
1714 1714
 
1715
-    $item_key = getpaid_convert_items_to_string( $items );
1715
+    $item_key = getpaid_convert_items_to_string($items);
1716 1716
 
1717 1717
     // Get the form elements and items.
1718 1718
     $form     = wpinv_get_default_payment_form();
1719
-	$elements = $invoicing->form_elements->get_form_elements( $form );
1720
-	$items    = $invoicing->form_elements->convert_normal_items( $items );
1719
+	$elements = $invoicing->form_elements->get_form_elements($form);
1720
+	$items    = $invoicing->form_elements->convert_normal_items($items);
1721 1721
 
1722 1722
 	ob_start();
1723 1723
 	echo "<form class='wpinv_payment_form'>";
1724
-	do_action( 'wpinv_payment_form_top' );
1724
+	do_action('wpinv_payment_form_top');
1725 1725
     echo "<input type='hidden' name='form_id' value='$form'/>";
1726 1726
     echo "<input type='hidden' name='form_items' value='$item_key'/>";
1727
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
1728
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
1727
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
1728
+	wp_nonce_field('vat_validation', '_wpi_nonce');
1729 1729
 
1730
-	foreach ( $elements as $element ) {
1731
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
1732
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
1730
+	foreach ($elements as $element) {
1731
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
1732
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
1733 1733
 	}
1734 1734
 
1735 1735
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
1736
-	do_action( 'wpinv_payment_form_bottom' );
1736
+	do_action('wpinv_payment_form_bottom');
1737 1737
 	echo '</form>';
1738 1738
 
1739 1739
 	$content = ob_get_clean();
1740
-	return str_replace( 'sr-only', '', $content );
1740
+	return str_replace('sr-only', '', $content);
1741 1741
 }
1742 1742
 
1743 1743
 /**
1744 1744
  * Helper function to display an invoice payment form on the frontend.
1745 1745
  */
1746
-function getpaid_display_invoice_payment_form( $invoice_id ) {
1746
+function getpaid_display_invoice_payment_form($invoice_id) {
1747 1747
     global $invoicing;
1748 1748
 
1749
-    $invoice = wpinv_get_invoice( $invoice_id );
1749
+    $invoice = wpinv_get_invoice($invoice_id);
1750 1750
 
1751
-    if ( empty( $invoice ) ) {
1751
+    if (empty($invoice)) {
1752 1752
 		return aui()->alert(
1753 1753
 			array(
1754 1754
 				'type'    => 'warning',
1755
-				'content' => __( 'Invoice not found', 'invoicing' ),
1755
+				'content' => __('Invoice not found', 'invoicing'),
1756 1756
 			)
1757 1757
 		);
1758 1758
     }
1759 1759
 
1760
-    if ( $invoice->is_paid() ) {
1760
+    if ($invoice->is_paid()) {
1761 1761
 		return aui()->alert(
1762 1762
 			array(
1763 1763
 				'type'    => 'warning',
1764
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1764
+				'content' => __('Invoice has already been paid', 'invoicing'),
1765 1765
 			)
1766 1766
 		);
1767 1767
     }
1768 1768
 
1769 1769
     // Get the form elements and items.
1770
-    $form     = wpinv_get_default_payment_form();
1771
-	$elements = $invoicing->form_elements->get_form_elements( $form );
1772
-	$items    = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice );
1770
+    $form = wpinv_get_default_payment_form();
1771
+	$elements = $invoicing->form_elements->get_form_elements($form);
1772
+	$items    = $invoicing->form_elements->convert_checkout_items($invoice->cart_details, $invoice);
1773 1773
 
1774 1774
 	ob_start();
1775 1775
 	echo "<form class='wpinv_payment_form'>";
1776
-	do_action( 'wpinv_payment_form_top' );
1776
+	do_action('wpinv_payment_form_top');
1777 1777
     echo "<input type='hidden' name='form_id' value='$form'/>";
1778 1778
     echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>";
1779
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
1780
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
1779
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
1780
+	wp_nonce_field('vat_validation', '_wpi_nonce');
1781 1781
 
1782
-	foreach ( $elements as $element ) {
1783
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
1784
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
1782
+	foreach ($elements as $element) {
1783
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
1784
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
1785 1785
 	}
1786 1786
 
1787 1787
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
1788
-	do_action( 'wpinv_payment_form_bottom' );
1788
+	do_action('wpinv_payment_form_bottom');
1789 1789
 	echo '</form>';
1790 1790
 
1791 1791
 	$content = ob_get_clean();
1792
-	return str_replace( 'sr-only', '', $content );
1792
+	return str_replace('sr-only', '', $content);
1793 1793
 }
1794 1794
 
1795 1795
 /**
1796 1796
  * Helper function to convert item string to array.
1797 1797
  */
1798
-function getpaid_convert_items_to_array( $items ) {
1799
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
1798
+function getpaid_convert_items_to_array($items) {
1799
+    $items    = array_filter(array_map('trim', explode(',', $items)));
1800 1800
     $prepared = array();
1801 1801
 
1802
-    foreach ( $items as $item ) {
1803
-        $data = array_map( 'trim', explode( '|', $item ) );
1802
+    foreach ($items as $item) {
1803
+        $data = array_map('trim', explode('|', $item));
1804 1804
 
1805
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
1805
+        if (empty($data[0]) || !is_numeric($data[0])) {
1806 1806
             continue;
1807 1807
         }
1808 1808
 
1809 1809
         $quantity = 1;
1810
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
1810
+        if (isset($data[1]) && is_numeric($data[1])) {
1811 1811
             $quantity = $data[1];
1812 1812
         }
1813 1813
 
1814
-        $prepared[ $data[0] ] = $quantity;
1814
+        $prepared[$data[0]] = $quantity;
1815 1815
 
1816 1816
     }
1817 1817
 
@@ -1821,13 +1821,13 @@  discard block
 block discarded – undo
1821 1821
 /**
1822 1822
  * Helper function to convert item array to string.
1823 1823
  */
1824
-function getpaid_convert_items_to_string( $items ) {
1824
+function getpaid_convert_items_to_string($items) {
1825 1825
     $prepared = array();
1826 1826
 
1827
-    foreach ( $items as $item => $quantity ) {
1827
+    foreach ($items as $item => $quantity) {
1828 1828
         $prepared[] = "$item|$quantity";
1829 1829
     }
1830
-    return implode( ',', $prepared );
1830
+    return implode(',', $prepared);
1831 1831
 }
1832 1832
 
1833 1833
 /**
@@ -1835,22 +1835,22 @@  discard block
 block discarded – undo
1835 1835
  * 
1836 1836
  * Provide a label and one of $form, $items or $invoice.
1837 1837
  */
1838
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
1839
-    $label = sanitize_text_field( $label );
1838
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
1839
+    $label = sanitize_text_field($label);
1840 1840
     $nonce = wp_create_nonce('getpaid_ajax_form');
1841 1841
 
1842
-    if ( ! empty( $form ) ) {
1843
-        $form  = esc_attr( $form );
1842
+    if (!empty($form)) {
1843
+        $form = esc_attr($form);
1844 1844
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; 
1845 1845
     }
1846 1846
 	
1847
-	if ( ! empty( $items ) ) {
1848
-        $items  = esc_attr( $items );
1847
+	if (!empty($items)) {
1848
+        $items = esc_attr($items);
1849 1849
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; 
1850 1850
     }
1851 1851
     
1852
-    if ( ! empty( $invoice ) ) {
1853
-        $invoice  = esc_attr( $invoice );
1852
+    if (!empty($invoice)) {
1853
+        $invoice = esc_attr($invoice);
1854 1854
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-invoice='$invoice'>$label</button>"; 
1855 1855
     }
1856 1856
 
@@ -1861,17 +1861,17 @@  discard block
 block discarded – undo
1861 1861
  *
1862 1862
  * @param WPInv_Invoice $invoice
1863 1863
  */
1864
-function getpaid_the_invoice_description( $invoice ) {
1864
+function getpaid_the_invoice_description($invoice) {
1865 1865
     $description = $invoice->get_description();
1866 1866
 
1867
-    if ( empty( $description ) ) {
1867
+    if (empty($description)) {
1868 1868
         return;
1869 1869
     }
1870 1870
 
1871
-    $description = wp_kses_post( $description );
1871
+    $description = wp_kses_post($description);
1872 1872
     echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>";
1873 1873
 }
1874
-add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 );
1874
+add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100);
1875 1875
 
1876 1876
 /**
1877 1877
  * Render element on a form.
@@ -1879,41 +1879,41 @@  discard block
 block discarded – undo
1879 1879
  * @param array $element
1880 1880
  * @param GetPaid_Payment_Form $form
1881 1881
  */
1882
-function getpaid_payment_form_element( $element, $form ) {
1882
+function getpaid_payment_form_element($element, $form) {
1883 1883
 
1884 1884
     // Set up the args.
1885
-    $element_type    = trim( $element['type'] );
1885
+    $element_type    = trim($element['type']);
1886 1886
     $element['form'] = $form;
1887
-    extract( $element );
1887
+    extract($element);
1888 1888
 
1889 1889
     // Try to locate the appropriate template.
1890
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
1890
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
1891 1891
     
1892 1892
     // Abort if this is not our element.
1893
-    if ( empty( $located ) || ! file_exists( $located ) ) {
1893
+    if (empty($located) || !file_exists($located)) {
1894 1894
         return;
1895 1895
     }
1896 1896
 
1897 1897
     // Generate the class and id of the element.
1898
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
1899
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
1898
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
1899
+    $id            = isset($id) ? $id : uniqid('gp');
1900 1900
 
1901 1901
     // Echo the opening wrapper.
1902 1902
     echo "<div class='getpaid-payment-form-element $wrapper_class'>";
1903 1903
 
1904 1904
     // Fires before displaying a given element type's content.
1905
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
1905
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
1906 1906
 
1907 1907
     // Include the template for the element.
1908 1908
     include $located;
1909 1909
 
1910 1910
     // Fires after displaying a given element type's content.
1911
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
1911
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
1912 1912
 
1913 1913
     // Echo the closing wrapper.
1914 1914
     echo '</div>';
1915 1915
 }
1916
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
1916
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
1917 1917
 
1918 1918
 /**
1919 1919
  * Shows a list of gateways that support recurring payments.
@@ -1921,16 +1921,16 @@  discard block
 block discarded – undo
1921 1921
 function wpinv_get_recurring_gateways_text() {
1922 1922
     $gateways = array();
1923 1923
 
1924
-    foreach ( wpinv_get_payment_gateways() as $key => $gateway ) {
1925
-        if ( wpinv_gateway_support_subscription( $key ) ) {
1926
-            $gateways[] = sanitize_text_field( $gateway['admin_label'] );
1924
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
1925
+        if (wpinv_gateway_support_subscription($key)) {
1926
+            $gateways[] = sanitize_text_field($gateway['admin_label']);
1927 1927
         }
1928 1928
     }
1929 1929
 
1930
-    if ( empty( $gateways ) ) {
1931
-        return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>";
1930
+    if (empty($gateways)) {
1931
+        return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>";
1932 1932
     }
1933 1933
 
1934
-    return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>";
1934
+    return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>";
1935 1935
 
1936 1936
 }
Please login to merge, or discard this patch.