Passed
Push — master ( a15c21...706a80 )
by Stiofan
04:34
created
templates/emails/fee-item.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -10,68 +10,68 @@  discard block
 block discarded – undo
10 10
  * @var array $columns
11 11
  */
12 12
 
13
-defined( 'ABSPATH' ) || exit;
13
+defined('ABSPATH') || exit;
14 14
 
15 15
 ?>
16 16
 
17
-<?php do_action( 'getpaid_before_email_fee_item', $invoice, $fee ); ?>
17
+<?php do_action('getpaid_before_email_fee_item', $invoice, $fee); ?>
18 18
 
19 19
 <tr class="wpinv_cart_item item-fee">
20 20
 
21
-    <?php foreach ( array_keys( $columns ) as $column ): ?>
21
+    <?php foreach (array_keys($columns) as $column): ?>
22 22
 
23
-        <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>">
23
+        <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>">
24 24
             
25 25
             <?php
26 26
 
27 27
                 // Fires before printing a fee item column.
28
-                do_action( "getpaid_email_fee_item_before_$column", $fee, $invoice );
28
+                do_action("getpaid_email_fee_item_before_$column", $fee, $invoice);
29 29
 
30 30
                 // Item name.
31
-                if ( 'name' == $column ) {
31
+                if ('name' == $column) {
32 32
 
33 33
                     // Display the name.
34
-                    echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $fee['name'] ) . '</div>';
34
+                    echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($fee['name']) . '</div>';
35 35
 
36 36
                     // And an optional description.
37
-                    $description = empty( $fee['description'] ) ? esc_html__( 'Fee', 'invoicing' ) : esc_html( $fee['description'] );
37
+                    $description = empty($fee['description']) ? esc_html__('Fee', 'invoicing') : esc_html($fee['description']);
38 38
                     echo "<p class='small'>$description</p>";
39 39
 
40 40
                 }
41 41
 
42 42
                 // Item price.
43
-                if ( 'price' == $column ) {
43
+                if ('price' == $column) {
44 44
 
45 45
                     // Display the item price (or recurring price if this is a renewal invoice)
46
-                    if ( $invoice->is_recurring() && $invoice->is_renewal() ) {
47
-                        echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() );
46
+                    if ($invoice->is_recurring() && $invoice->is_renewal()) {
47
+                        echo wpinv_price($fee['recurring_fee'], $invoice->get_currency());
48 48
                     } else {
49
-                        echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() );
49
+                        echo wpinv_price($fee['initial_fee'], $invoice->get_currency());
50 50
                     }
51 51
 
52 52
                 }
53 53
 
54 54
                 // Item quantity.
55
-                if ( 'quantity' == $column ) {
55
+                if ('quantity' == $column) {
56 56
                     echo "&mdash;";
57 57
                 }
58 58
 
59 59
                 // Item tax.
60
-                if ( 'tax_rate' == $column ) {
60
+                if ('tax_rate' == $column) {
61 61
                     echo "&mdash;";
62 62
                 }
63 63
 
64 64
                 // Item sub total.
65
-                if ( 'subtotal' == $column ) {
66
-                    if ( $invoice->is_recurring() && $invoice->is_renewal() ) {
67
-                        echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() );
65
+                if ('subtotal' == $column) {
66
+                    if ($invoice->is_recurring() && $invoice->is_renewal()) {
67
+                        echo wpinv_price($fee['recurring_fee'], $invoice->get_currency());
68 68
                     } else {
69
-                        echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() );
69
+                        echo wpinv_price($fee['initial_fee'], $invoice->get_currency());
70 70
                     }
71 71
                 }
72 72
 
73 73
                 // Fires when printing a line item column.
74
-                do_action( "getpaid_email_fee_item_$column", $fee, $invoice );
74
+                do_action("getpaid_email_fee_item_$column", $fee, $invoice);
75 75
 
76 76
             ?>
77 77
 
@@ -81,4 +81,4 @@  discard block
 block discarded – undo
81 81
 
82 82
 </tr>
83 83
 
84
-<?php do_action( 'getpaid_after_email_fee_item', $invoice, $fee ); ?>
84
+<?php do_action('getpaid_after_email_fee_item', $invoice, $fee); ?>
Please login to merge, or discard this patch.
includes/class-getpaid-daily-maintenance.php 2 patches
Spacing   +35 added lines, -35 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
  * Daily maintenance class.
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * Class constructor.
17 17
 	 */
18
-	public function __construct(){
18
+	public function __construct() {
19 19
 
20 20
 		// Clear deprecated events.
21
-		add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) );
21
+		add_action('wp', array($this, 'maybe_clear_deprecated_events'));
22 22
 
23 23
 		// (Maybe) schedule a cron that runs daily.
24
-		add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) );
24
+		add_action('wp', array($this, 'maybe_create_scheduled_event'));
25 25
 
26 26
 		// Fired everyday at 7 a.m (this might vary for sites with few visitors)
27
-		add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) );
28
-		add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) );
29
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) );
30
-		add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) );
31
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) );
27
+		add_action('getpaid_daily_maintenance', array($this, 'log_cron_run'));
28
+		add_action('getpaid_daily_maintenance', array($this, 'backwards_compat'));
29
+		add_action('getpaid_daily_maintenance', array($this, 'maybe_expire_subscriptions'));
30
+		add_action('getpaid_daily_maintenance', array($this, 'check_renewing_subscriptions'));
31
+		add_action('getpaid_daily_maintenance', array($this, 'maybe_update_geoip_databases'));
32 32
 
33 33
 	}
34 34
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	public function maybe_create_scheduled_event() {
40 40
 
41
-		if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) {
42
-			$timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) );
43
-			wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' );
41
+		if (!wp_next_scheduled('getpaid_daily_maintenance')) {
42
+			$timestamp = strtotime('tomorrow 07:00:00', current_time('timestamp'));
43
+			wp_schedule_event($timestamp, 'daily', 'getpaid_daily_maintenance');
44 44
 		}
45 45
 
46 46
 	}
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function maybe_clear_deprecated_events() {
53 53
 
54
-		if ( ! get_option( 'wpinv_cleared_old_events' ) ) {
55
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
56
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
57
-			update_option( 'wpinv_cleared_old_events', 1 );
54
+		if (!get_option('wpinv_cleared_old_events')) {
55
+			wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily');
56
+			wp_clear_scheduled_hook('wpinv_register_schedule_event_daily');
57
+			update_option('wpinv_cleared_old_events', 1);
58 58
 		}
59 59
 
60 60
 	}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 */
66 66
 	public function backwards_compat() {
67
-		do_action( 'wpinv_register_schedule_event_daily' );
67
+		do_action('wpinv_register_schedule_event_daily');
68 68
 	}
69 69
 
70 70
 	/**
@@ -74,29 +74,29 @@  discard block
 block discarded – undo
74 74
 	public function check_renewing_subscriptions() {
75 75
 
76 76
 		// Fetch subscriptions that expire today.
77
-		$args  = array(
77
+		$args = array(
78 78
 			'number'             => -1,
79 79
 			'count_total'        => false,
80 80
 			'status'             => 'trialling active',
81 81
 			'date_expires_query' => array(
82 82
 				array(
83
-					'year'          => date( 'Y', current_time( 'timestamp' ) ),
84
-					'month'         => date( 'n', current_time( 'timestamp' ) ),
85
-					'day'           => date( 'j', current_time( 'timestamp' ) ),
83
+					'year'          => date('Y', current_time('timestamp')),
84
+					'month'         => date('n', current_time('timestamp')),
85
+					'day'           => date('j', current_time('timestamp')),
86 86
 					'compare'       => '=',
87 87
 				),
88 88
 			),
89 89
 		);
90 90
 
91
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
91
+		$subscriptions = new GetPaid_Subscriptions_Query($args);
92 92
 
93
-		foreach ( $subscriptions->get_results() as $subscription ) {
93
+		foreach ($subscriptions->get_results() as $subscription) {
94 94
 
95 95
 			/** @var WPInv_Subscription $subscription */
96
-			if ( $subscription->is_last_renewal() ) {
96
+			if ($subscription->is_last_renewal()) {
97 97
 				$subscription->complete();
98 98
 			} else {
99
-				do_action( 'getpaid_should_renew_subscription', $subscription );
99
+				do_action('getpaid_should_renew_subscription', $subscription);
100 100
 			}
101 101
 
102 102
 		}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	public function maybe_expire_subscriptions() {
111 111
 
112 112
 		// Fetch expired subscriptions (skips those that expire today).
113
-		$args  = array(
113
+		$args = array(
114 114
 			'number'             => -1,
115 115
 			'count_total'        => false,
116 116
 			'status'             => 'trialling active failing cancelled',
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 			),
121 121
 		);
122 122
 
123
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
123
+		$subscriptions = new GetPaid_Subscriptions_Query($args);
124 124
 
125
-		foreach ( $subscriptions->get_results() as $subscription ) {
126
-			if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', true, $subscription ) ) {
127
-				$subscription->set_status( 'expired' );
125
+		foreach ($subscriptions->get_results() as $subscription) {
126
+			if (apply_filters('getpaid_daily_maintenance_should_expire_subscription', true, $subscription)) {
127
+				$subscription->set_status('expired');
128 128
 				$subscription->save();
129 129
 			}
130 130
 		}
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 */
138 138
 	public function log_cron_run() {
139
-		wpinv_error_log( 'GetPaid Daily Cron', false );
139
+		wpinv_error_log('GetPaid Daily Cron', false);
140 140
 	}
141 141
 
142 142
 	/**
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 	 *
145 145
 	 */
146 146
 	public function maybe_update_geoip_databases() {
147
-		$updated = get_transient( 'getpaid_updated_geoip_databases' );
147
+		$updated = get_transient('getpaid_updated_geoip_databases');
148 148
 
149
-		if ( false === $updated ) {
150
-			set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS );
151
-			do_action( 'getpaid_update_geoip_databases' );
149
+		if (false === $updated) {
150
+			set_transient('getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS);
151
+			do_action('getpaid_update_geoip_databases');
152 152
 		}
153 153
 
154 154
 	}
Please login to merge, or discard this patch.
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -12,145 +12,145 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Daily_Maintenance {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 */
18
-	public function __construct(){
19
-
20
-		// Clear deprecated events.
21
-		add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) );
22
-
23
-		// (Maybe) schedule a cron that runs daily.
24
-		add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) );
25
-
26
-		// Fired everyday at 7 a.m (this might vary for sites with few visitors)
27
-		add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) );
28
-		add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) );
29
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) );
30
-		add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) );
31
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) );
32
-
33
-	}
34
-
35
-	/**
36
-	 * Schedules a cron to run every day at 7 a.m
37
-	 *
38
-	 */
39
-	public function maybe_create_scheduled_event() {
40
-
41
-		if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) {
42
-			$timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) );
43
-			wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' );
44
-		}
45
-
46
-	}
47
-
48
-	/**
49
-	 * Clears deprecated events.
50
-	 *
51
-	 */
52
-	public function maybe_clear_deprecated_events() {
53
-
54
-		if ( ! get_option( 'wpinv_cleared_old_events' ) ) {
55
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
56
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
57
-			update_option( 'wpinv_cleared_old_events', 1 );
58
-		}
59
-
60
-	}
61
-
62
-	/**
63
-	 * Fires the old hook for backwards compatibility.
64
-	 *
65
-	 */
66
-	public function backwards_compat() {
67
-		do_action( 'wpinv_register_schedule_event_daily' );
68
-	}
69
-
70
-	/**
71
-	 * Checks for subscriptions that are scheduled to renew.
72
-	 *
73
-	 */
74
-	public function check_renewing_subscriptions() {
75
-
76
-		// Fetch subscriptions that expire today.
77
-		$args  = array(
78
-			'number'             => -1,
79
-			'count_total'        => false,
80
-			'status'             => 'trialling active',
81
-			'date_expires_query' => array(
82
-				array(
83
-					'year'          => date( 'Y', current_time( 'timestamp' ) ),
84
-					'month'         => date( 'n', current_time( 'timestamp' ) ),
85
-					'day'           => date( 'j', current_time( 'timestamp' ) ),
86
-					'compare'       => '=',
87
-				),
88
-			),
89
-		);
90
-
91
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
92
-
93
-		foreach ( $subscriptions->get_results() as $subscription ) {
94
-
95
-			/** @var WPInv_Subscription $subscription */
96
-			if ( $subscription->is_last_renewal() ) {
97
-				$subscription->complete();
98
-			} else {
99
-				do_action( 'getpaid_should_renew_subscription', $subscription );
100
-			}
101
-
102
-		}
103
-
104
-	}
105
-
106
-	/**
107
-	 * Expires expired subscriptions.
108
-	 *
109
-	 */
110
-	public function maybe_expire_subscriptions() {
111
-
112
-		// Fetch expired subscriptions (skips those that expire today).
113
-		$args  = array(
114
-			'number'             => -1,
115
-			'count_total'        => false,
116
-			'status'             => 'trialling active failing cancelled',
117
-			'date_expires_query' => array(
118
-				'before'    => 'yesterday',
119
-				'inclusive' => false,
120
-			),
121
-		);
122
-
123
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
124
-
125
-		foreach ( $subscriptions->get_results() as $subscription ) {
126
-			if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', true, $subscription ) ) {
127
-				$subscription->set_status( 'expired' );
128
-				$subscription->save();
129
-			}
130
-		}
131
-
132
-	}
133
-
134
-	/**
135
-	 * Logs cron runs.
136
-	 *
137
-	 */
138
-	public function log_cron_run() {
139
-		wpinv_error_log( 'GetPaid Daily Cron', false );
140
-	}
141
-
142
-	/**
143
-	 * Updates GeoIP databases.
144
-	 *
145
-	 */
146
-	public function maybe_update_geoip_databases() {
147
-		$updated = get_transient( 'getpaid_updated_geoip_databases' );
148
-
149
-		if ( false === $updated ) {
150
-			set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS );
151
-			do_action( 'getpaid_update_geoip_databases' );
152
-		}
153
-
154
-	}
15
+    /**
16
+     * Class constructor.
17
+     */
18
+    public function __construct(){
19
+
20
+        // Clear deprecated events.
21
+        add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) );
22
+
23
+        // (Maybe) schedule a cron that runs daily.
24
+        add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) );
25
+
26
+        // Fired everyday at 7 a.m (this might vary for sites with few visitors)
27
+        add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) );
28
+        add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) );
29
+        add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) );
30
+        add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) );
31
+        add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) );
32
+
33
+    }
34
+
35
+    /**
36
+     * Schedules a cron to run every day at 7 a.m
37
+     *
38
+     */
39
+    public function maybe_create_scheduled_event() {
40
+
41
+        if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) {
42
+            $timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) );
43
+            wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' );
44
+        }
45
+
46
+    }
47
+
48
+    /**
49
+     * Clears deprecated events.
50
+     *
51
+     */
52
+    public function maybe_clear_deprecated_events() {
53
+
54
+        if ( ! get_option( 'wpinv_cleared_old_events' ) ) {
55
+            wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
56
+            wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
57
+            update_option( 'wpinv_cleared_old_events', 1 );
58
+        }
59
+
60
+    }
61
+
62
+    /**
63
+     * Fires the old hook for backwards compatibility.
64
+     *
65
+     */
66
+    public function backwards_compat() {
67
+        do_action( 'wpinv_register_schedule_event_daily' );
68
+    }
69
+
70
+    /**
71
+     * Checks for subscriptions that are scheduled to renew.
72
+     *
73
+     */
74
+    public function check_renewing_subscriptions() {
75
+
76
+        // Fetch subscriptions that expire today.
77
+        $args  = array(
78
+            'number'             => -1,
79
+            'count_total'        => false,
80
+            'status'             => 'trialling active',
81
+            'date_expires_query' => array(
82
+                array(
83
+                    'year'          => date( 'Y', current_time( 'timestamp' ) ),
84
+                    'month'         => date( 'n', current_time( 'timestamp' ) ),
85
+                    'day'           => date( 'j', current_time( 'timestamp' ) ),
86
+                    'compare'       => '=',
87
+                ),
88
+            ),
89
+        );
90
+
91
+        $subscriptions = new GetPaid_Subscriptions_Query( $args );
92
+
93
+        foreach ( $subscriptions->get_results() as $subscription ) {
94
+
95
+            /** @var WPInv_Subscription $subscription */
96
+            if ( $subscription->is_last_renewal() ) {
97
+                $subscription->complete();
98
+            } else {
99
+                do_action( 'getpaid_should_renew_subscription', $subscription );
100
+            }
101
+
102
+        }
103
+
104
+    }
105
+
106
+    /**
107
+     * Expires expired subscriptions.
108
+     *
109
+     */
110
+    public function maybe_expire_subscriptions() {
111
+
112
+        // Fetch expired subscriptions (skips those that expire today).
113
+        $args  = array(
114
+            'number'             => -1,
115
+            'count_total'        => false,
116
+            'status'             => 'trialling active failing cancelled',
117
+            'date_expires_query' => array(
118
+                'before'    => 'yesterday',
119
+                'inclusive' => false,
120
+            ),
121
+        );
122
+
123
+        $subscriptions = new GetPaid_Subscriptions_Query( $args );
124
+
125
+        foreach ( $subscriptions->get_results() as $subscription ) {
126
+            if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', true, $subscription ) ) {
127
+                $subscription->set_status( 'expired' );
128
+                $subscription->save();
129
+            }
130
+        }
131
+
132
+    }
133
+
134
+    /**
135
+     * Logs cron runs.
136
+     *
137
+     */
138
+    public function log_cron_run() {
139
+        wpinv_error_log( 'GetPaid Daily Cron', false );
140
+    }
141
+
142
+    /**
143
+     * Updates GeoIP databases.
144
+     *
145
+     */
146
+    public function maybe_update_geoip_databases() {
147
+        $updated = get_transient( 'getpaid_updated_geoip_databases' );
148
+
149
+        if ( false === $updated ) {
150
+            set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS );
151
+            do_action( 'getpaid_update_geoip_databases' );
152
+        }
153
+
154
+    }
155 155
 
156 156
 }
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-authorize-net-gateway.php 2 patches
Indentation   +232 added lines, -232 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_Authorize_Net_Legacy_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', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
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'] );
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
     }
176 176
 
177 177
     /**
178
-	 * Retrieves a customer profile.
179
-	 *
180
-	 *
181
-	 * @param string $profile_id profile id.
182
-	 * @return string|WP_Error Profile id.
178
+     * Retrieves a customer profile.
179
+     *
180
+     *
181
+     * @param string $profile_id profile id.
182
+     * @return string|WP_Error Profile id.
183 183
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile
184
-	 */
185
-	public function get_customer_profile( $profile_id ) {
184
+     */
185
+    public function get_customer_profile( $profile_id ) {
186 186
 
187 187
         // Generate args.
188 188
         $args = array(
@@ -197,17 +197,17 @@  discard block
 block discarded – undo
197 197
     }
198 198
 
199 199
     /**
200
-	 * Creates a customer profile.
201
-	 *
202
-	 *
200
+     * Creates a customer profile.
201
+     *
202
+     *
203 203
      * @param string $profile_id profile id.
204
-	 * @param WPInv_Invoice $invoice Invoice.
204
+     * @param WPInv_Invoice $invoice Invoice.
205 205
      * @param array $submission_data Posted checkout fields.
206 206
      * @param bool $save Whether or not to save the payment as a token.
207 207
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
208
-	 * @return string|WP_Error Profile id.
209
-	 */
210
-	public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
208
+     * @return string|WP_Error Profile id.
209
+     */
210
+    public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
211 211
 
212 212
         // Remove non-digits from the number
213 213
         $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] );
@@ -282,13 +282,13 @@  discard block
 block discarded – undo
282 282
     }
283 283
 
284 284
     /**
285
-	 * Retrieves payment details from cache.
286
-	 *
287
-	 *
285
+     * Retrieves payment details from cache.
286
+     *
287
+     *
288 288
      * @param array $payment_details.
289
-	 * @return array|false Profile id.
290
-	 */
291
-	public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) {
289
+     * @return array|false Profile id.
290
+     */
291
+    public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) {
292 292
 
293 293
         $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
294 294
         $payment_details    = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY );
@@ -313,13 +313,13 @@  discard block
 block discarded – undo
313 313
     }
314 314
 
315 315
     /**
316
-	 * Securely adds payment details to cache.
317
-	 *
318
-	 *
316
+     * Securely adds payment details to cache.
317
+     *
318
+     *
319 319
      * @param array $payment_details.
320 320
      * @param string $payment_profile_id.
321
-	 */
322
-	public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) {
321
+     */
322
+    public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) {
323 323
 
324 324
         $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
325 325
         $cached_information = is_array( $cached_information ) ? $cached_information : array();
@@ -331,15 +331,15 @@  discard block
 block discarded – undo
331 331
     }
332 332
 
333 333
     /**
334
-	 * Retrieves a customer payment profile.
335
-	 *
336
-	 *
337
-	 * @param string $customer_profile_id customer profile id.
334
+     * Retrieves a customer payment profile.
335
+     *
336
+     *
337
+     * @param string $customer_profile_id customer profile id.
338 338
      * @param string $payment_profile_id payment profile id.
339
-	 * @return string|WP_Error Profile id.
339
+     * @return string|WP_Error Profile id.
340 340
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile
341
-	 */
342
-	public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
341
+     */
342
+    public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
343 343
 
344 344
         // Generate args.
345 345
         $args = array(
@@ -355,15 +355,15 @@  discard block
 block discarded – undo
355 355
     }
356 356
 
357 357
     /**
358
-	 * Charges a customer payment profile.
359
-	 *
358
+     * Charges a customer payment profile.
359
+     *
360 360
      * @param string $customer_profile_id customer profile id.
361 361
      * @param string $payment_profile_id payment profile id.
362
-	 * @param WPInv_Invoice $invoice Invoice.
362
+     * @param WPInv_Invoice $invoice Invoice.
363 363
      * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile
364
-	 * @return WP_Error|object
365
-	 */
366
-	public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
364
+     * @return WP_Error|object
365
+     */
366
+    public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
367 367
 
368 368
         // Generate args.
369 369
         $args = array(
@@ -409,41 +409,41 @@  discard block
 block discarded – undo
409 409
     }
410 410
 
411 411
     /**
412
-	 * Processes a customer charge.
413
-	 *
412
+     * Processes a customer charge.
413
+     *
414 414
      * @param stdClass $result Api response.
415
-	 * @param WPInv_Invoice $invoice Invoice.
416
-	 */
417
-	public function process_charge_response( $result, $invoice ) {
415
+     * @param WPInv_Invoice $invoice Invoice.
416
+     */
417
+    public function process_charge_response( $result, $invoice ) {
418 418
 
419 419
         wpinv_clear_errors();
420
-		$response_code = (int) $result->transactionResponse->responseCode;
420
+        $response_code = (int) $result->transactionResponse->responseCode;
421 421
 
422
-		// Succeeded.
423
-		if ( 1 == $response_code || 4 == $response_code ) {
422
+        // Succeeded.
423
+        if ( 1 == $response_code || 4 == $response_code ) {
424 424
 
425
-			// Maybe set a transaction id.
426
-			if ( ! empty( $result->transactionResponse->transId ) ) {
427
-				$invoice->set_transaction_id( $result->transactionResponse->transId );
428
-			}
425
+            // Maybe set a transaction id.
426
+            if ( ! empty( $result->transactionResponse->transId ) ) {
427
+                $invoice->set_transaction_id( $result->transactionResponse->transId );
428
+            }
429 429
 
430
-			$invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true );
430
+            $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true );
431 431
 
432
-			if ( 1 == $response_code ) {
433
-				return $invoice->mark_paid();
434
-			}
432
+            if ( 1 == $response_code ) {
433
+                return $invoice->mark_paid();
434
+            }
435 435
 
436
-			$invoice->set_status( 'wpi-onhold' );
437
-        	$invoice->add_note(
436
+            $invoice->set_status( 'wpi-onhold' );
437
+            $invoice->add_note(
438 438
                 sprintf(
439 439
                     __( 'Held for review: %s', 'invoicing' ),
440 440
                     $result->transactionResponse->messages->message[0]->description
441 441
                 )
442
-			);
442
+            );
443 443
 
444
-			return $invoice->save();
444
+            return $invoice->save();
445 445
 
446
-		}
446
+        }
447 447
 
448 448
         wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) );
449 449
 
@@ -455,13 +455,13 @@  discard block
 block discarded – undo
455 455
     }
456 456
 
457 457
     /**
458
-	 * Returns payment information.
459
-	 *
460
-	 *
461
-	 * @param array $card Card details.
462
-	 * @return array
463
-	 */
464
-	public function get_payment_information( $card ) {
458
+     * Returns payment information.
459
+     *
460
+     *
461
+     * @param array $card Card details.
462
+     * @return array
463
+     */
464
+    public function get_payment_information( $card ) {
465 465
         return array(
466 466
 
467 467
             'creditCard'         => array (
@@ -474,25 +474,25 @@  discard block
 block discarded – undo
474 474
     }
475 475
 
476 476
     /**
477
-	 * Returns the customer profile meta name.
478
-	 *
479
-	 *
480
-	 * @param WPInv_Invoice $invoice Invoice.
481
-	 * @return string
482
-	 */
483
-	public function get_customer_profile_meta_name( $invoice ) {
477
+     * Returns the customer profile meta name.
478
+     *
479
+     *
480
+     * @param WPInv_Invoice $invoice Invoice.
481
+     * @return string
482
+     */
483
+    public function get_customer_profile_meta_name( $invoice ) {
484 484
         return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
485 485
     }
486 486
 
487 487
     /**
488
-	 * Validates the submitted data.
489
-	 *
490
-	 *
491
-	 * @param array $submission_data Posted checkout fields.
488
+     * Validates the submitted data.
489
+     *
490
+     *
491
+     * @param array $submission_data Posted checkout fields.
492 492
      * @param WPInv_Invoice $invoice
493
-	 * @return WP_Error|string The payment profile id
494
-	 */
495
-	public function validate_submission_data( $submission_data, $invoice ) {
493
+     * @return WP_Error|string The payment profile id
494
+     */
495
+    public function validate_submission_data( $submission_data, $invoice ) {
496 496
 
497 497
         // Validate authentication details.
498 498
         $auth = $this->get_auth_params();
@@ -524,13 +524,13 @@  discard block
 block discarded – undo
524 524
     }
525 525
 
526 526
     /**
527
-	 * Returns invoice line items.
528
-	 *
529
-	 *
530
-	 * @param WPInv_Invoice $invoice Invoice.
531
-	 * @return array
532
-	 */
533
-	public function get_line_items( $invoice ) {
527
+     * Returns invoice line items.
528
+     *
529
+     *
530
+     * @param WPInv_Invoice $invoice Invoice.
531
+     * @return array
532
+     */
533
+    public function get_line_items( $invoice ) {
534 534
         $items = array();
535 535
 
536 536
         foreach ( $invoice->get_items() as $item ) {
@@ -568,15 +568,15 @@  discard block
 block discarded – undo
568 568
     }
569 569
 
570 570
     /**
571
-	 * Process Payment.
572
-	 *
573
-	 *
574
-	 * @param WPInv_Invoice $invoice Invoice.
575
-	 * @param array $submission_data Posted checkout fields.
576
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
577
-	 * @return array
578
-	 */
579
-	public function process_payment( $invoice, $submission_data, $submission ) {
571
+     * Process Payment.
572
+     *
573
+     *
574
+     * @param WPInv_Invoice $invoice Invoice.
575
+     * @param array $submission_data Posted checkout fields.
576
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
577
+     * @return array
578
+     */
579
+    public function process_payment( $invoice, $submission_data, $submission ) {
580 580
 
581 581
         // Validate the submitted data.
582 582
         $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice );
@@ -609,45 +609,45 @@  discard block
 block discarded – undo
609 609
 
610 610
         exit;
611 611
 
612
-	}
612
+    }
613 613
 	
614
-	/**
615
-	 * Processes the initial payment.
616
-	 *
614
+    /**
615
+     * Processes the initial payment.
616
+     *
617 617
      * @param WPInv_Invoice $invoice Invoice.
618
-	 */
619
-	protected function process_initial_payment( $invoice ) {
618
+     */
619
+    protected function process_initial_payment( $invoice ) {
620 620
 
621
-		$payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
621
+        $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
622 622
         $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
623
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
623
+        $result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
624 624
 
625
-		// Do we have an error?
626
-		if ( is_wp_error( $result ) ) {
627
-			wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
628
-			wpinv_send_back_to_checkout( $invoice );
629
-		}
625
+        // Do we have an error?
626
+        if ( is_wp_error( $result ) ) {
627
+            wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
628
+            wpinv_send_back_to_checkout( $invoice );
629
+        }
630 630
 
631
-		// Process the response.
632
-		$this->process_charge_response( $result, $invoice );
631
+        // Process the response.
632
+        $this->process_charge_response( $result, $invoice );
633 633
 
634
-		if ( wpinv_get_errors() ) {
635
-			wpinv_send_back_to_checkout( $invoice );
636
-		}
634
+        if ( wpinv_get_errors() ) {
635
+            wpinv_send_back_to_checkout( $invoice );
636
+        }
637 637
 
638
-	}
638
+    }
639 639
 
640 640
     /**
641
-	 * Processes recurring payments.
642
-	 *
641
+     * Processes recurring payments.
642
+     *
643 643
      * @param WPInv_Invoice $invoice Invoice.
644 644
      * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions.
645
-	 */
646
-	public function process_subscription( $invoice, $subscriptions ) {
645
+     */
646
+    public function process_subscription( $invoice, $subscriptions ) {
647 647
 
648 648
         // Check if there is an initial amount to charge.
649 649
         if ( (float) $invoice->get_total() > 0 ) {
650
-			$this->process_initial_payment( $invoice );
650
+            $this->process_initial_payment( $invoice );
651 651
         }
652 652
 
653 653
         // Activate the subscriptions.
@@ -665,36 +665,36 @@  discard block
 block discarded – undo
665 665
             }
666 666
         }
667 667
 
668
-		// Redirect to the success page.
668
+        // Redirect to the success page.
669 669
         wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
670 670
 
671 671
     }
672 672
 
673
-	/**
674
-	 * (Maybe) renews an authorize.net subscription profile.
675
-	 *
676
-	 *
673
+    /**
674
+     * (Maybe) renews an authorize.net subscription profile.
675
+     *
676
+     *
677 677
      * @param WPInv_Subscription $subscription
678
-	 */
679
-	public function maybe_renew_subscription( $subscription ) {
678
+     */
679
+    public function maybe_renew_subscription( $subscription ) {
680 680
 
681 681
         // Ensure its our subscription && it's active.
682 682
         if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
683 683
             $this->renew_subscription( $subscription );
684 684
         }
685 685
 
686
-	}
686
+    }
687 687
 
688 688
     /**
689
-	 * Renews a subscription.
690
-	 *
689
+     * Renews a subscription.
690
+     *
691 691
      * @param WPInv_Subscription $subscription
692
-	 */
693
-	public function renew_subscription( $subscription ) {
692
+     */
693
+    public function renew_subscription( $subscription ) {
694 694
 
695
-		// Generate the renewal invoice.
696
-		$new_invoice = $subscription->create_payment();
697
-		$old_invoice = $subscription->get_parent_payment();
695
+        // Generate the renewal invoice.
696
+        $new_invoice = $subscription->create_payment();
697
+        $old_invoice = $subscription->get_parent_payment();
698 698
 
699 699
         if ( empty( $new_invoice ) ) {
700 700
             $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false );
@@ -703,37 +703,37 @@  discard block
 block discarded – undo
703 703
         }
704 704
 
705 705
         // Charge the payment method.
706
-		$payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
707
-		$customer_profile   = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true );
708
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice );
709
-
710
-		// Do we have an error?
711
-		if ( is_wp_error( $result ) ) {
712
-
713
-			$old_invoice->add_note(
714
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
715
-				true,
716
-				false,
717
-				true
718
-			);
719
-			$subscription->failing();
720
-			return;
721
-
722
-		}
723
-
724
-		// Process the response.
725
-		$this->process_charge_response( $result, $new_invoice );
726
-
727
-		if ( wpinv_get_errors() ) {
728
-
729
-			$old_invoice->add_note(
730
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
731
-				true,
732
-				false,
733
-				true
734
-			);
735
-			$subscription->failing();
736
-			return;
706
+        $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
707
+        $customer_profile   = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true );
708
+        $result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice );
709
+
710
+        // Do we have an error?
711
+        if ( is_wp_error( $result ) ) {
712
+
713
+            $old_invoice->add_note(
714
+                sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
715
+                true,
716
+                false,
717
+                true
718
+            );
719
+            $subscription->failing();
720
+            return;
721
+
722
+        }
723
+
724
+        // Process the response.
725
+        $this->process_charge_response( $result, $new_invoice );
726
+
727
+        if ( wpinv_get_errors() ) {
728
+
729
+            $old_invoice->add_note(
730
+                sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
731
+                true,
732
+                false,
733
+                true
734
+            );
735
+            $subscription->failing();
736
+            return;
737 737
 
738 738
         }
739 739
 
@@ -742,13 +742,13 @@  discard block
 block discarded – undo
742 742
     }
743 743
 
744 744
     /**
745
-	 * Processes invoice addons.
746
-	 *
747
-	 * @param WPInv_Invoice $invoice
748
-	 * @param GetPaid_Form_Item[] $items
749
-	 * @return WPInv_Invoice
750
-	 */
751
-	public function process_addons( $invoice, $items ) {
745
+     * Processes invoice addons.
746
+     *
747
+     * @param WPInv_Invoice $invoice
748
+     * @param GetPaid_Form_Item[] $items
749
+     * @return WPInv_Invoice
750
+     */
751
+    public function process_addons( $invoice, $items ) {
752 752
 
753 753
         global $getpaid_authorize_addons;
754 754
 
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
         $invoice->recalculate_total();
769 769
 
770 770
         $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
771
-		$customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
771
+        $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
772 772
 
773 773
         add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 );
774 774
         $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
@@ -783,11 +783,11 @@  discard block
 block discarded – undo
783 783
     }
784 784
 
785 785
     /**
786
-	 * Processes invoice addons.
787
-	 *
786
+     * Processes invoice addons.
787
+     *
788 788
      * @param array $args
789
-	 * @return array
790
-	 */
789
+     * @return array
790
+     */
791 791
     public function filter_addons_request( $args ) {
792 792
 
793 793
         global $getpaid_authorize_addons;
@@ -821,11 +821,11 @@  discard block
 block discarded – undo
821 821
     }
822 822
 
823 823
     /**
824
-	 * Filters the gateway settings.
825
-	 *
826
-	 * @param array $admin_settings
827
-	 */
828
-	public function admin_settings( $admin_settings ) {
824
+     * Filters the gateway settings.
825
+     *
826
+     * @param array $admin_settings
827
+     */
828
+    public function admin_settings( $admin_settings ) {
829 829
 
830 830
         $currencies = sprintf(
831 831
             __( 'Supported Currencies: %s', 'invoicing' ),
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
             'readonly' => true,
866 866
         );
867 867
 
868
-		return $admin_settings;
869
-	}
868
+        return $admin_settings;
869
+    }
870 870
 
871 871
 }
Please login to merge, or discard this patch.
Spacing   +206 added lines, -206 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', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
27
+    protected $supports = array('subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups');
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           = getpaid_get_non_query_string_ipn_url( $this->id );
69
+        $this->title                = __('Credit Card / Debit Card', 'invoicing');
70
+        $this->method_title         = __('Authorize.Net', 'invoicing');
71
+        $this->notify_url           = getpaid_get_non_query_string_ipn_url($this->id);
72 72
 
73
-        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
74
-        add_filter( 'getpaid_authorizenet_sandbox_notice', array( $this, 'sandbox_notice' ) );
73
+        add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'));
74
+        add_filter('getpaid_authorizenet_sandbox_notice', array($this, 'sandbox_notice'));
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,79 +100,79 @@  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_address(), 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_address(), 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
 
142 142
             // In case the payment profile already exists remotely.
143
-            if ( 'dup_payment_profile' == $response->get_error_code() ) {
144
-                $customer_profile_id = strtok( $response->get_error_message(), '.' );
145
-                update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile_id );
146
-                return strtok( '.' );
143
+            if ('dup_payment_profile' == $response->get_error_code()) {
144
+                $customer_profile_id = strtok($response->get_error_message(), '.');
145
+                update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile_id);
146
+                return strtok('.');
147 147
             }
148 148
 
149 149
             // In case the customer profile already exists remotely.
150
-            if ( 'E00039' == $response->get_error_code() ) {
151
-                $customer_profile_id = str_replace( 'A duplicate record with ID ', '', $response->get_error_message() );
152
-                $customer_profile_id = str_replace( ' already exists.', '', $customer_profile_id );
153
-                return $this->create_customer_payment_profile( trim( $customer_profile_id ), $invoice, $submission_data, $save );
150
+            if ('E00039' == $response->get_error_code()) {
151
+                $customer_profile_id = str_replace('A duplicate record with ID ', '', $response->get_error_message());
152
+                $customer_profile_id = str_replace(' already exists.', '', $customer_profile_id);
153
+                return $this->create_customer_payment_profile(trim($customer_profile_id), $invoice, $submission_data, $save);
154 154
             }
155 155
 
156 156
             return $response;
157 157
         }
158 158
 
159
-        update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId );
159
+        update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId);
160 160
 
161 161
         // Save the payment token.
162
-        if ( $save ) {
162
+        if ($save) {
163 163
             $this->save_token(
164 164
                 array(
165 165
                     'id'      => $response->customerPaymentProfileIdList[0],
166
-                    'name'    => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . '&middot;&middot;&middot;&middot;' . substr( $submission_data['authorizenet']['cc_number'], -4 ),
166
+                    'name'    => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . '&middot;&middot;&middot;&middot;' . substr($submission_data['authorizenet']['cc_number'], -4),
167 167
                     'default' => true,
168
-                    'type'    => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live',
168
+                    'type'    => $this->is_sandbox($invoice) ? 'sandbox' : 'live',
169 169
                 )
170 170
             );
171 171
         }
172 172
 
173 173
         // Add a note about the validation response.
174 174
         $invoice->add_note(
175
-            sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ),
175
+            sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]),
176 176
             false,
177 177
             false,
178 178
             true
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @return string|WP_Error Profile id.
190 190
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile
191 191
 	 */
192
-	public function get_customer_profile( $profile_id ) {
192
+	public function get_customer_profile($profile_id) {
193 193
 
194 194
         // Generate args.
195 195
         $args = array(
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             )
200 200
         );
201 201
 
202
-        return $this->post( $args, false );
202
+        return $this->post($args, false);
203 203
 
204 204
     }
205 205
 
@@ -214,18 +214,18 @@  discard block
 block discarded – undo
214 214
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
215 215
 	 * @return string|WP_Error Profile id.
216 216
 	 */
217
-	public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
217
+	public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) {
218 218
 
219 219
         // Remove non-digits from the number
220
-        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] );
220
+        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']);
221 221
 
222 222
         // Prepare card details.
223
-        $payment_information                          = $this->get_payment_information( $submission_data['authorizenet'] );
223
+        $payment_information                          = $this->get_payment_information($submission_data['authorizenet']);
224 224
 
225 225
         // Authorize.NET does not support saving the same card twice.
226
-        $cached_information                           = $this->retrieve_payment_profile_from_cache( $payment_information, $customer_profile, $invoice );
226
+        $cached_information                           = $this->retrieve_payment_profile_from_cache($payment_information, $customer_profile, $invoice);
227 227
 
228
-        if ( $cached_information ) {
228
+        if ($cached_information) {
229 229
             return $cached_information;
230 230
         }
231 231
 
@@ -238,34 +238,34 @@  discard block
 block discarded – undo
238 238
 
239 239
                     // Billing information.
240 240
                     'billTo'           => array(
241
-                        'firstName'    => getpaid_limit_length( $invoice->get_first_name(), 50 ),
242
-                        'lastName'     => getpaid_limit_length( $invoice->get_last_name(), 50 ),
243
-                        'address'      => getpaid_limit_length( $invoice->get_address(), 60 ),
244
-                        'city'         => getpaid_limit_length( $invoice->get_city(), 40 ),
245
-                        'state'        => getpaid_limit_length( $invoice->get_state(), 40 ),
246
-                        'zip'          => getpaid_limit_length( $invoice->get_zip(), 20 ),
247
-                        'country'      => getpaid_limit_length( $invoice->get_country(), 60 ),
241
+                        'firstName'    => getpaid_limit_length($invoice->get_first_name(), 50),
242
+                        'lastName'     => getpaid_limit_length($invoice->get_last_name(), 50),
243
+                        'address'      => getpaid_limit_length($invoice->get_address(), 60),
244
+                        'city'         => getpaid_limit_length($invoice->get_city(), 40),
245
+                        'state'        => getpaid_limit_length($invoice->get_state(), 40),
246
+                        'zip'          => getpaid_limit_length($invoice->get_zip(), 20),
247
+                        'country'      => getpaid_limit_length($invoice->get_country(), 60),
248 248
                     ),
249 249
 
250 250
                     // Payment information.
251 251
                     'payment'          => $payment_information
252 252
                 ),
253
-                'validationMode'       => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode',
253
+                'validationMode'       => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode',
254 254
             )
255 255
         );
256 256
 
257
-        $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice );
257
+        $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice);
258 258
 
259
-        if ( is_wp_error( $response ) ) {
259
+        if (is_wp_error($response)) {
260 260
 
261 261
             // In case the payment profile already exists remotely.
262
-            if ( 'dup_payment_profile' == $response->get_error_code() ) {
263
-                $customer_profile_id = strtok( $response->get_error_message(), '.' );
264
-                $payment_profile_id  = strtok( '.' );
265
-                update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile_id );
262
+            if ('dup_payment_profile' == $response->get_error_code()) {
263
+                $customer_profile_id = strtok($response->get_error_message(), '.');
264
+                $payment_profile_id  = strtok('.');
265
+                update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile_id);
266 266
 
267 267
                 // Cache payment profile id.
268
-                $this->add_payment_profile_to_cache( $payment_information, $payment_profile_id );
268
+                $this->add_payment_profile_to_cache($payment_information, $payment_profile_id);
269 269
 
270 270
                 return $payment_profile_id;
271 271
             }
@@ -274,29 +274,29 @@  discard block
 block discarded – undo
274 274
         }
275 275
 
276 276
         // Save the payment token.
277
-        if ( $save ) {
277
+        if ($save) {
278 278
             $this->save_token(
279 279
                 array(
280 280
                     'id'      => $response->customerPaymentProfileId,
281
-                    'name'    => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' &middot;&middot;&middot;&middot; ' . substr( $submission_data['authorizenet']['cc_number'], -4 ),
281
+                    'name'    => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . ' &middot;&middot;&middot;&middot; ' . substr($submission_data['authorizenet']['cc_number'], -4),
282 282
                     'default' => true,
283
-                    'type'    => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live',
283
+                    'type'    => $this->is_sandbox($invoice) ? 'sandbox' : 'live',
284 284
                 )
285 285
             );
286 286
         }
287 287
 
288 288
         // Cache payment profile id.
289
-        $this->add_payment_profile_to_cache( $payment_information, $response->customerPaymentProfileId );
289
+        $this->add_payment_profile_to_cache($payment_information, $response->customerPaymentProfileId);
290 290
 
291 291
         // Add a note about the validation response.
292 292
         $invoice->add_note(
293
-            sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ),
293
+            sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse),
294 294
             false,
295 295
             false,
296 296
             true
297 297
         );
298 298
 
299
-        update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile );
299
+        update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile);
300 300
 
301 301
         return $response->customerPaymentProfileId;
302 302
     }
@@ -308,12 +308,12 @@  discard block
 block discarded – undo
308 308
      * @param array $payment_details.
309 309
 	 * @return array|false Profile id.
310 310
 	 */
311
-	public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) {
311
+	public function retrieve_payment_profile_from_cache($payment_details, $customer_profile, $invoice) {
312 312
 
313
-        $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
314
-        $payment_details    = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY );
313
+        $cached_information = get_option('getpaid_authorize_net_cached_profiles', array());
314
+        $payment_details    = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY);
315 315
 
316
-        if ( ! is_array( $cached_information ) || ! array_key_exists( $payment_details, $cached_information ) ) {
316
+        if (!is_array($cached_information) || !array_key_exists($payment_details, $cached_information)) {
317 317
             return false;
318 318
         }
319 319
 
@@ -322,13 +322,13 @@  discard block
 block discarded – undo
322 322
             'getCustomerPaymentProfileRequest' => array(
323 323
                 'merchantAuthentication'   => $this->get_auth_params(),
324 324
                 'customerProfileId'        => $customer_profile,
325
-                'customerPaymentProfileId' => $cached_information[ $payment_details ],
325
+                'customerPaymentProfileId' => $cached_information[$payment_details],
326 326
             )
327 327
         );
328 328
 
329
-        $response = $this->post( $args, $invoice );
329
+        $response = $this->post($args, $invoice);
330 330
 
331
-        return is_wp_error( $response ) ? false : $cached_information[ $payment_details ];
331
+        return is_wp_error($response) ? false : $cached_information[$payment_details];
332 332
 
333 333
     }
334 334
 
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
      * @param array $payment_details.
340 340
      * @param string $payment_profile_id.
341 341
 	 */
342
-	public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) {
342
+	public function add_payment_profile_to_cache($payment_details, $payment_profile_id) {
343 343
 
344
-        $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
345
-        $cached_information = is_array( $cached_information ) ? $cached_information : array();
346
-        $payment_details    = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY );
344
+        $cached_information = get_option('getpaid_authorize_net_cached_profiles', array());
345
+        $cached_information = is_array($cached_information) ? $cached_information : array();
346
+        $payment_details    = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY);
347 347
 
348
-        $cached_information[ $payment_details ] = $payment_profile_id;
349
-        update_option( 'getpaid_authorize_net_cached_profiles', $cached_information );
348
+        $cached_information[$payment_details] = $payment_profile_id;
349
+        update_option('getpaid_authorize_net_cached_profiles', $cached_information);
350 350
 
351 351
     }
352 352
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	 * @return string|WP_Error Profile id.
360 360
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile
361 361
 	 */
362
-	public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
362
+	public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) {
363 363
 
364 364
         // Generate args.
365 365
         $args = array(
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
             )
371 371
         );
372 372
 
373
-        return $this->post( $args, false );
373
+        return $this->post($args, false);
374 374
 
375 375
     }
376 376
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
      * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile
384 384
 	 * @return WP_Error|object
385 385
 	 */
386
-	public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
386
+	public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) {
387 387
 
388 388
         // Generate args.
389 389
         $args = array(
@@ -403,28 +403,28 @@  discard block
 block discarded – undo
403 403
                         )
404 404
                     ),
405 405
                     'order'                    => array(
406
-                        'invoiceNumber'        => getpaid_limit_length( $invoice->get_number(), 20 ),
406
+                        'invoiceNumber'        => getpaid_limit_length($invoice->get_number(), 20),
407 407
                     ),
408
-                    'lineItems'                => array( 'lineItem' => $this->get_line_items( $invoice ) ),
408
+                    'lineItems'                => array('lineItem' => $this->get_line_items($invoice)),
409 409
                     'tax'                      => array(
410 410
                         'amount'               => $invoice->get_total_tax(),
411
-                        'name'                 => __( 'TAX', 'invoicing' ),
411
+                        'name'                 => __('TAX', 'invoicing'),
412 412
                     ),
413
-                    'poNumber'                 => getpaid_limit_length( $invoice->get_number(), 25 ),
413
+                    'poNumber'                 => getpaid_limit_length($invoice->get_number(), 25),
414 414
                     'customer'                 => array(
415
-                        'id'                   => getpaid_limit_length( $invoice->get_user_id(), 25 ),
416
-                        'email'                => getpaid_limit_length( $invoice->get_email(), 25 ),
415
+                        'id'                   => getpaid_limit_length($invoice->get_user_id(), 25),
416
+                        'email'                => getpaid_limit_length($invoice->get_email(), 25),
417 417
                     ),
418 418
                     'customerIP'               => $invoice->get_ip(),
419 419
                 )
420 420
             )
421 421
         );
422 422
 
423
-        if ( 0 == $invoice->get_total_tax() ) {
424
-            unset( $args['createTransactionRequest']['transactionRequest']['tax'] );
423
+        if (0 == $invoice->get_total_tax()) {
424
+            unset($args['createTransactionRequest']['transactionRequest']['tax']);
425 425
         }
426 426
 
427
-        return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice );
427
+        return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice);
428 428
 
429 429
     }
430 430
 
@@ -434,29 +434,29 @@  discard block
 block discarded – undo
434 434
      * @param stdClass $result Api response.
435 435
 	 * @param WPInv_Invoice $invoice Invoice.
436 436
 	 */
437
-	public function process_charge_response( $result, $invoice ) {
437
+	public function process_charge_response($result, $invoice) {
438 438
 
439 439
         wpinv_clear_errors();
440 440
 		$response_code = (int) $result->transactionResponse->responseCode;
441 441
 
442 442
 		// Succeeded.
443
-		if ( 1 == $response_code || 4 == $response_code ) {
443
+		if (1 == $response_code || 4 == $response_code) {
444 444
 
445 445
 			// Maybe set a transaction id.
446
-			if ( ! empty( $result->transactionResponse->transId ) ) {
447
-				$invoice->set_transaction_id( $result->transactionResponse->transId );
446
+			if (!empty($result->transactionResponse->transId)) {
447
+				$invoice->set_transaction_id($result->transactionResponse->transId);
448 448
 			}
449 449
 
450
-			$invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true );
450
+			$invoice->add_note(sprintf(__('Authentication code: %s (%s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true);
451 451
 
452
-			if ( 1 == $response_code ) {
452
+			if (1 == $response_code) {
453 453
 				return $invoice->mark_paid();
454 454
 			}
455 455
 
456
-			$invoice->set_status( 'wpi-onhold' );
456
+			$invoice->set_status('wpi-onhold');
457 457
         	$invoice->add_note(
458 458
                 sprintf(
459
-                    __( 'Held for review: %s', 'invoicing' ),
459
+                    __('Held for review: %s', 'invoicing'),
460 460
                     $result->transactionResponse->messages->message[0]->description
461 461
                 )
462 462
 			);
@@ -465,11 +465,11 @@  discard block
 block discarded – undo
465 465
 
466 466
 		}
467 467
 
468
-        wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) );
468
+        wpinv_set_error('card_declined', __('Credit card declined.', 'invoicing'));
469 469
 
470
-        if ( ! empty( $result->transactionResponse->errors ) ) {
470
+        if (!empty($result->transactionResponse->errors)) {
471 471
             $errors = (object) $result->transactionResponse->errors;
472
-            wpinv_set_error( $errors->error[0]->errorCode, esc_html( $errors->error[0]->errorText ) );
472
+            wpinv_set_error($errors->error[0]->errorCode, esc_html($errors->error[0]->errorText));
473 473
         }
474 474
 
475 475
     }
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 	 * @param array $card Card details.
482 482
 	 * @return array
483 483
 	 */
484
-	public function get_payment_information( $card ) {
484
+	public function get_payment_information($card) {
485 485
         return array(
486 486
 
487
-            'creditCard'         => array (
487
+            'creditCard'         => array(
488 488
                 'cardNumber'     => $card['cc_number'],
489 489
                 'expirationDate' => $card['cc_expire_year'] . '-' . $card['cc_expire_month'],
490 490
                 'cardCode'       => $card['cc_cvv2'],
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 	 * @param WPInv_Invoice $invoice Invoice.
501 501
 	 * @return string
502 502
 	 */
503
-	public function get_customer_profile_meta_name( $invoice ) {
504
-        return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
503
+	public function get_customer_profile_meta_name($invoice) {
504
+        return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
505 505
     }
506 506
 
507 507
     /**
@@ -512,34 +512,34 @@  discard block
 block discarded – undo
512 512
      * @param WPInv_Invoice $invoice
513 513
 	 * @return WP_Error|string The payment profile id
514 514
 	 */
515
-	public function validate_submission_data( $submission_data, $invoice ) {
515
+	public function validate_submission_data($submission_data, $invoice) {
516 516
 
517 517
         // Validate authentication details.
518 518
         $auth = $this->get_auth_params();
519 519
 
520
-        if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) {
521
-            return new WP_Error( 'invalid_settings', __( 'Please set-up your login id and transaction key before using this gateway.', 'invoicing') );
520
+        if (empty($auth['name']) || empty($auth['transactionKey'])) {
521
+            return new WP_Error('invalid_settings', __('Please set-up your login id and transaction key before using this gateway.', 'invoicing'));
522 522
         }
523 523
 
524 524
         // Validate the payment method.
525
-        if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) {
526
-            return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing') );
525
+        if (empty($submission_data['getpaid-authorizenet-payment-method'])) {
526
+            return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing'));
527 527
         }
528 528
 
529 529
         // Are we adding a new payment method?
530
-        if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) {
530
+        if ('new' != $submission_data['getpaid-authorizenet-payment-method']) {
531 531
             return $submission_data['getpaid-authorizenet-payment-method'];
532 532
         }
533 533
 
534 534
         // Retrieve the customer profile id.
535
-        $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
535
+        $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
536 536
 
537 537
         // Create payment method.
538
-        if ( empty( $profile_id ) ) {
539
-            return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) );
538
+        if (empty($profile_id)) {
539
+            return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method']));
540 540
         }
541 541
 
542
-        return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) );
542
+        return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method']));
543 543
 
544 544
     }
545 545
 
@@ -550,32 +550,32 @@  discard block
 block discarded – undo
550 550
 	 * @param WPInv_Invoice $invoice Invoice.
551 551
 	 * @return array
552 552
 	 */
553
-	public function get_line_items( $invoice ) {
553
+	public function get_line_items($invoice) {
554 554
         $items = array();
555 555
 
556
-        foreach ( $invoice->get_items() as $item ) {
556
+        foreach ($invoice->get_items() as $item) {
557 557
 
558 558
             $amount  = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price();
559 559
             $items[] = array(
560
-                'itemId'      => getpaid_limit_length( $item->get_id(), 31 ),
561
-                'name'        => getpaid_limit_length( $item->get_raw_name(), 31 ),
562
-                'description' => getpaid_limit_length( $item->get_description(), 255 ),
563
-                'quantity'    => (string) ( $invoice->get_template() == 'amount' ? 1 : $item->get_quantity() ),
560
+                'itemId'      => getpaid_limit_length($item->get_id(), 31),
561
+                'name'        => getpaid_limit_length($item->get_raw_name(), 31),
562
+                'description' => getpaid_limit_length($item->get_description(), 255),
563
+                'quantity'    => (string) ($invoice->get_template() == 'amount' ? 1 : $item->get_quantity()),
564 564
                 'unitPrice'   => (float) $amount,
565 565
                 'taxable'     => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(),
566 566
             );
567 567
 
568 568
         }
569 569
 
570
-        foreach ( $invoice->get_fees() as $fee_name => $fee ) {
570
+        foreach ($invoice->get_fees() as $fee_name => $fee) {
571 571
 
572
-            $amount  = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee'];
572
+            $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee'];
573 573
 
574
-            if ( $amount > 0 ) {
574
+            if ($amount > 0) {
575 575
                 $items[] = array(
576
-                    'itemId'      => getpaid_limit_length( $fee_name, 31 ),
577
-                    'name'        => getpaid_limit_length( $fee_name, 31 ),
578
-                    'description' => getpaid_limit_length( $fee_name, 255 ),
576
+                    'itemId'      => getpaid_limit_length($fee_name, 31),
577
+                    'name'        => getpaid_limit_length($fee_name, 31),
578
+                    'description' => getpaid_limit_length($fee_name, 255),
579 579
                     'quantity'    => '1',
580 580
                     'unitPrice'   => (float) $amount,
581 581
                     'taxable'     => false,
@@ -596,36 +596,36 @@  discard block
 block discarded – undo
596 596
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
597 597
 	 * @return array
598 598
 	 */
599
-	public function process_payment( $invoice, $submission_data, $submission ) {
599
+	public function process_payment($invoice, $submission_data, $submission) {
600 600
 
601 601
         // Validate the submitted data.
602
-        $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice );
602
+        $payment_profile_id = $this->validate_submission_data($submission_data, $invoice);
603 603
 
604 604
         // Do we have an error?
605
-        if ( is_wp_error( $payment_profile_id ) ) {
606
-            wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() );
607
-            wpinv_send_back_to_checkout( $invoice );
605
+        if (is_wp_error($payment_profile_id)) {
606
+            wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message());
607
+            wpinv_send_back_to_checkout($invoice);
608 608
         }
609 609
 
610 610
         // Save the payment method to the order.
611
-        update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id );
611
+        update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id);
612 612
 
613 613
         // Check if this is a subscription or not.
614
-        $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
615
-        if ( ! empty( $subscriptions ) ) {
616
-            $this->process_subscription( $invoice, $subscriptions );
614
+        $subscriptions = getpaid_get_invoice_subscriptions($invoice);
615
+        if (!empty($subscriptions)) {
616
+            $this->process_subscription($invoice, $subscriptions);
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
-        $this->process_initial_payment( $invoice );
626
+        $this->process_initial_payment($invoice);
627 627
 
628
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
628
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
629 629
 
630 630
         exit;
631 631
 
@@ -636,23 +636,23 @@  discard block
 block discarded – undo
636 636
 	 *
637 637
      * @param WPInv_Invoice $invoice Invoice.
638 638
 	 */
639
-	protected function process_initial_payment( $invoice ) {
639
+	protected function process_initial_payment($invoice) {
640 640
 
641
-		$payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
642
-        $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
643
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
641
+		$payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
642
+        $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
643
+		$result             = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice);
644 644
 
645 645
 		// Do we have an error?
646
-		if ( is_wp_error( $result ) ) {
647
-			wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
648
-			wpinv_send_back_to_checkout( $invoice );
646
+		if (is_wp_error($result)) {
647
+			wpinv_set_error($result->get_error_code(), $result->get_error_message());
648
+			wpinv_send_back_to_checkout($invoice);
649 649
 		}
650 650
 
651 651
 		// Process the response.
652
-		$this->process_charge_response( $result, $invoice );
652
+		$this->process_charge_response($result, $invoice);
653 653
 
654
-		if ( wpinv_get_errors() ) {
655
-			wpinv_send_back_to_checkout( $invoice );
654
+		if (wpinv_get_errors()) {
655
+			wpinv_send_back_to_checkout($invoice);
656 656
 		}
657 657
 
658 658
 	}
@@ -663,30 +663,30 @@  discard block
 block discarded – undo
663 663
      * @param WPInv_Invoice $invoice Invoice.
664 664
      * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions.
665 665
 	 */
666
-	public function process_subscription( $invoice, $subscriptions ) {
666
+	public function process_subscription($invoice, $subscriptions) {
667 667
 
668 668
         // Check if there is an initial amount to charge.
669
-        if ( (float) $invoice->get_total() > 0 ) {
670
-			$this->process_initial_payment( $invoice );
669
+        if ((float) $invoice->get_total() > 0) {
670
+			$this->process_initial_payment($invoice);
671 671
         }
672 672
 
673 673
         // Activate the subscriptions.
674
-        $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
674
+        $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions);
675 675
 
676
-        foreach ( $subscriptions as $subscription ) {
677
-            if ( $subscription->exists() ) {
678
-                $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
679
-                $expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
676
+        foreach ($subscriptions as $subscription) {
677
+            if ($subscription->exists()) {
678
+                $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
679
+                $expiry   = date('Y-m-d H:i:s', (current_time('timestamp') + $duration));
680 680
 
681
-                $subscription->set_next_renewal_date( $expiry );
682
-                $subscription->set_date_created( current_time( 'mysql' ) );
683
-                $subscription->set_profile_id( $invoice->generate_key( 'authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) );
681
+                $subscription->set_next_renewal_date($expiry);
682
+                $subscription->set_date_created(current_time('mysql'));
683
+                $subscription->set_profile_id($invoice->generate_key('authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id()));
684 684
                 $subscription->activate();
685 685
             }
686 686
         }
687 687
 
688 688
 		// Redirect to the success page.
689
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
689
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
690 690
 
691 691
     }
692 692
 
@@ -696,11 +696,11 @@  discard block
 block discarded – undo
696 696
 	 *
697 697
      * @param WPInv_Subscription $subscription
698 698
 	 */
699
-	public function maybe_renew_subscription( $subscription ) {
699
+	public function maybe_renew_subscription($subscription) {
700 700
 
701 701
         // Ensure its our subscription && it's active.
702
-        if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
703
-            $this->renew_subscription( $subscription );
702
+        if ($this->id == $subscription->get_gateway() && $subscription->has_status('active trialling')) {
703
+            $this->renew_subscription($subscription);
704 704
         }
705 705
 
706 706
 	}
@@ -710,28 +710,28 @@  discard block
 block discarded – undo
710 710
 	 *
711 711
      * @param WPInv_Subscription $subscription
712 712
 	 */
713
-	public function renew_subscription( $subscription ) {
713
+	public function renew_subscription($subscription) {
714 714
 
715 715
 		// Generate the renewal invoice.
716 716
 		$new_invoice = $subscription->create_payment();
717 717
 		$old_invoice = $subscription->get_parent_payment();
718 718
 
719
-        if ( empty( $new_invoice ) ) {
720
-            $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false );
719
+        if (empty($new_invoice)) {
720
+            $old_invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false);
721 721
             $subscription->failing();
722 722
             return;
723 723
         }
724 724
 
725 725
         // Charge the payment method.
726
-		$payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
727
-		$customer_profile   = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true );
728
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice );
726
+		$payment_profile_id = get_post_meta($old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
727
+		$customer_profile   = get_user_meta($old_invoice->get_user_id(), $this->get_customer_profile_meta_name($old_invoice), true);
728
+		$result             = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice);
729 729
 
730 730
 		// Do we have an error?
731
-		if ( is_wp_error( $result ) ) {
731
+		if (is_wp_error($result)) {
732 732
 
733 733
 			$old_invoice->add_note(
734
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
734
+				sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()),
735 735
 				true,
736 736
 				false,
737 737
 				true
@@ -742,12 +742,12 @@  discard block
 block discarded – undo
742 742
 		}
743 743
 
744 744
 		// Process the response.
745
-		$this->process_charge_response( $result, $new_invoice );
745
+		$this->process_charge_response($result, $new_invoice);
746 746
 
747
-		if ( wpinv_get_errors() ) {
747
+		if (wpinv_get_errors()) {
748 748
 
749 749
 			$old_invoice->add_note(
750
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
750
+				sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()),
751 751
 				true,
752 752
 				false,
753 753
 				true
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 
758 758
         }
759 759
 
760
-        $subscription->add_payment( array(), $new_invoice );
760
+        $subscription->add_payment(array(), $new_invoice);
761 761
         $subscription->renew();
762 762
     }
763 763
 
@@ -768,34 +768,34 @@  discard block
 block discarded – undo
768 768
 	 * @param GetPaid_Form_Item[] $items
769 769
 	 * @return WPInv_Invoice
770 770
 	 */
771
-	public function process_addons( $invoice, $items ) {
771
+	public function process_addons($invoice, $items) {
772 772
 
773 773
         global $getpaid_authorize_addons;
774 774
 
775 775
         $getpaid_authorize_addons = array();
776
-        foreach ( $items as $item ) {
776
+        foreach ($items as $item) {
777 777
 
778
-            if ( is_null( $invoice->get_item( $item->get_id() ) ) && ! is_wp_error( $invoice->add_item( $item ) ) ) {
778
+            if (is_null($invoice->get_item($item->get_id())) && !is_wp_error($invoice->add_item($item))) {
779 779
                 $getpaid_authorize_addons[] = $item;
780 780
             }
781 781
 
782 782
         }
783 783
 
784
-        if ( empty( $getpaid_authorize_addons ) ) {
784
+        if (empty($getpaid_authorize_addons)) {
785 785
             return;
786 786
         }
787 787
 
788 788
         $invoice->recalculate_total();
789 789
 
790
-        $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
791
-		$customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
790
+        $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
791
+		$customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
792 792
 
793
-        add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 );
794
-        $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
795
-        remove_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ) );
793
+        add_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'), 10, 2);
794
+        $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice);
795
+        remove_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'));
796 796
 
797
-        if ( is_wp_error( $result ) ) {
798
-            wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
797
+        if (is_wp_error($result)) {
798
+            wpinv_set_error($result->get_error_code(), $result->get_error_message());
799 799
             return;
800 800
         }
801 801
 
@@ -808,19 +808,19 @@  discard block
 block discarded – undo
808 808
      * @param array $args
809 809
 	 * @return array
810 810
 	 */
811
-    public function filter_addons_request( $args ) {
811
+    public function filter_addons_request($args) {
812 812
 
813 813
         global $getpaid_authorize_addons;
814 814
         $total = 0;
815 815
 
816
-        foreach ( $getpaid_authorize_addons as $addon ) {
816
+        foreach ($getpaid_authorize_addons as $addon) {
817 817
             $total += $addon->get_sub_total();
818 818
         }
819 819
 
820 820
         $args['createTransactionRequest']['transactionRequest']['amount'] = $total;
821 821
 
822
-        if ( isset( $args['createTransactionRequest']['transactionRequest']['tax'] ) ) {
823
-            unset( $args['createTransactionRequest']['transactionRequest']['tax'] );
822
+        if (isset($args['createTransactionRequest']['transactionRequest']['tax'])) {
823
+            unset($args['createTransactionRequest']['transactionRequest']['tax']);
824 824
         }
825 825
 
826 826
         return $args;
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
     public function sandbox_notice() {
834 834
 
835 835
         return sprintf(
836
-            __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing' ),
836
+            __('SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing'),
837 837
             '<a href="https://developer.authorize.net/hello_world/testing_guide.html">',
838 838
             '</a>'
839 839
         );
@@ -845,42 +845,42 @@  discard block
 block discarded – undo
845 845
 	 *
846 846
 	 * @param array $admin_settings
847 847
 	 */
848
-	public function admin_settings( $admin_settings ) {
848
+	public function admin_settings($admin_settings) {
849 849
 
850 850
         $currencies = sprintf(
851
-            __( 'Supported Currencies: %s', 'invoicing' ),
852
-            implode( ', ', $this->currencies )
851
+            __('Supported Currencies: %s', 'invoicing'),
852
+            implode(', ', $this->currencies)
853 853
         );
854 854
 
855 855
         $admin_settings['authorizenet_active']['desc'] .= " ($currencies)";
856
-        $admin_settings['authorizenet_desc']['std']     = __( 'Pay securely using your credit or debit card.', 'invoicing' );
856
+        $admin_settings['authorizenet_desc']['std']     = __('Pay securely using your credit or debit card.', 'invoicing');
857 857
 
858 858
         $admin_settings['authorizenet_login_id'] = array(
859 859
             'type' => 'text',
860 860
             'id'   => 'authorizenet_login_id',
861
-            'name' => __( 'API Login ID', 'invoicing' ),
862
-            '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>',
861
+            'name' => __('API Login ID', 'invoicing'),
862
+            '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>',
863 863
         );
864 864
 
865 865
         $admin_settings['authorizenet_transaction_key'] = array(
866 866
             'type' => 'text',
867 867
             'id'   => 'authorizenet_transaction_key',
868
-            'name' => __( 'Transaction Key', 'invoicing' ),
868
+            'name' => __('Transaction Key', 'invoicing'),
869 869
         );
870 870
 
871 871
         $admin_settings['authorizenet_signature_key'] = array(
872 872
             'type' => 'text',
873 873
             'id'   => 'authorizenet_signature_key',
874
-            'name' => __( 'Signature Key', 'invoicing' ),
875
-            'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
874
+            'name' => __('Signature Key', 'invoicing'),
875
+            'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
876 876
         );
877 877
 
878 878
         $admin_settings['authorizenet_ipn_url'] = array(
879 879
             'type'     => 'ipn_url',
880 880
             'id'       => 'authorizenet_ipn_url',
881
-            'name'     => __( 'Webhook URL', 'invoicing' ),
881
+            'name'     => __('Webhook URL', 'invoicing'),
882 882
             'std'      => $this->notify_url,
883
-            '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>',
883
+            '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>',
884 884
             'custom'   => 'authorizenet',
885 885
             'readonly' => true,
886 886
         );
Please login to merge, or discard this patch.
includes/geolocation/class-getpaid-maxmind-geolocation.php 2 patches
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -16,165 +16,165 @@
 block discarded – undo
16 16
  */
17 17
 class GetPaid_MaxMind_Geolocation {
18 18
 
19
-	/**
20
-	 * The service responsible for interacting with the MaxMind database.
21
-	 *
22
-	 * @var GetPaid_MaxMind_Database_Service
23
-	 */
24
-	private $database_service;
25
-
26
-	/**
27
-	 * Initialize the integration.
28
-	 */
29
-	public function __construct() {
30
-
31
-		/**
32
-		 * Supports overriding the database service to be used.
33
-		 *
34
-		 * @since 1.0.19
35
-		 * @return mixed|null The geolocation database service.
36
-		 */
37
-		$this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null );
38
-		if ( null === $this->database_service ) {
39
-			$this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() );
40
-		}
41
-
42
-		// Bind to the scheduled updater action.
43
-		add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) );
44
-
45
-		// Bind to the geolocation filter for MaxMind database lookups.
46
-		add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 );
47
-
48
-		// Handle maxmind key updates.
49
-		add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) );
50
-
51
-	}
52
-
53
-	/**
54
-	 * Get database service.
55
-	 *
56
-	 * @return GetPaid_MaxMind_Database_Service|null
57
-	 */
58
-	public function get_database_service() {
59
-		return $this->database_service;
60
-	}
61
-
62
-	/**
63
-	 * Checks to make sure that the license key is valid.
64
-	 *
65
-	 * @param string $license_key The new license key.
66
-	 * @return string
67
-	 */
68
-	public function handle_key_updates( $license_key ) {
69
-
70
-		// Trim whitespaces and strip slashes.
71
-		$license_key = trim( $license_key );
72
-
73
-		// Abort if the license key is empty or unchanged.
74
-		if ( empty( $license_key ) ) {
75
-			return $license_key;
76
-		}
77
-
78
-		// Abort if a database exists and the license key is unchaged.
79
-		if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) {
80
-			return $license_key;
81
-		}
82
-
83
-		// Check the license key by attempting to download the Geolocation database.
84
-		$tmp_database_path = $this->database_service->download_database( $license_key );
85
-		if ( is_wp_error( $tmp_database_path ) ) {
86
-			getpaid_admin()->show_error( $tmp_database_path->get_error_message() );
87
-			return $license_key;
88
-		}
89
-
90
-		$this->update_database( /** @scrutinizer ignore-type */ $tmp_database_path );
91
-
92
-		return $license_key;
93
-	}
94
-
95
-	/**
96
-	 * Updates the database used for geolocation queries.
97
-	 *
98
-	 * @param string $tmp_database_path Temporary database path.
99
-	 */
100
-	public function update_database( $tmp_database_path = null ) {
101
-
102
-		// Allow us to easily interact with the filesystem.
103
-		require_once ABSPATH . 'wp-admin/includes/file.php';
104
-		WP_Filesystem();
105
-		global $wp_filesystem;
106
-
107
-		// Remove any existing archives to comply with the MaxMind TOS.
108
-		$target_database_path = $this->database_service->get_database_path();
109
-
110
-		// If there's no database path, we can't store the database.
111
-		if ( empty( $target_database_path ) ) {
112
-			return;
113
-		}
114
-
115
-		if ( $wp_filesystem->exists( $target_database_path ) ) {
116
-			$wp_filesystem->delete( $target_database_path );
117
-		}
118
-
119
-		// We can't download a database if there's no license key configured.
120
-		$license_key = wpinv_get_option( 'maxmind_license_key' );
121
-		if ( empty( $license_key ) ) {
122
-			return;
123
-		}
124
-
125
-		if ( empty( $tmp_database_path ) ) {
126
-			$tmp_database_path = $this->database_service->download_database( $license_key );
127
-		}
128
-
129
-		if ( is_wp_error( $tmp_database_path ) ) {
130
-			wpinv_error_log( $tmp_database_path->get_error_message() );
131
-			return;
132
-		}
133
-
134
-		// Move the new database into position.
135
-		$wp_filesystem->move( $tmp_database_path, $target_database_path, true );
136
-		$wp_filesystem->delete( dirname( $tmp_database_path ) );
137
-	}
138
-
139
-	/**
140
-	 * Performs a geolocation lookup against the MaxMind database for the given IP address.
141
-	 *
142
-	 * @param array  $data       Geolocation data.
143
-	 * @param string $ip_address The IP address to geolocate.
144
-	 * @return array Geolocation including country code, state, city and postcode based on an IP address.
145
-	 */
146
-	public function get_geolocation( $data, $ip_address ) {
147
-
148
-		if ( ! empty( $data['country'] ) || empty( $ip_address ) ) {
149
-			return $data;
150
-		}
151
-
152
-		$country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address );
153
-
154
-		return array(
155
-			'country'  => $country_code,
156
-			'state'    => '',
157
-			'city'     => '',
158
-			'postcode' => '',
159
-		);
160
-
161
-	}
162
-
163
-	/**
164
-	 * Fetches the prefix for the MaxMind database file.
165
-	 *
166
-	 * @return string
167
-	 */
168
-	private function get_database_prefix() {
169
-
170
-		$prefix = get_option( 'wpinv_maxmind_database_prefix' );
171
-
172
-		if ( empty( $prefix ) ) {
173
-			$prefix = md5( uniqid( 'wpinv' ) );
174
-			update_option( 'wpinv_maxmind_database_prefix', $prefix );
175
-		}
176
-
177
-		return $prefix;
178
-	}
19
+    /**
20
+     * The service responsible for interacting with the MaxMind database.
21
+     *
22
+     * @var GetPaid_MaxMind_Database_Service
23
+     */
24
+    private $database_service;
25
+
26
+    /**
27
+     * Initialize the integration.
28
+     */
29
+    public function __construct() {
30
+
31
+        /**
32
+         * Supports overriding the database service to be used.
33
+         *
34
+         * @since 1.0.19
35
+         * @return mixed|null The geolocation database service.
36
+         */
37
+        $this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null );
38
+        if ( null === $this->database_service ) {
39
+            $this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() );
40
+        }
41
+
42
+        // Bind to the scheduled updater action.
43
+        add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) );
44
+
45
+        // Bind to the geolocation filter for MaxMind database lookups.
46
+        add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 );
47
+
48
+        // Handle maxmind key updates.
49
+        add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) );
50
+
51
+    }
52
+
53
+    /**
54
+     * Get database service.
55
+     *
56
+     * @return GetPaid_MaxMind_Database_Service|null
57
+     */
58
+    public function get_database_service() {
59
+        return $this->database_service;
60
+    }
61
+
62
+    /**
63
+     * Checks to make sure that the license key is valid.
64
+     *
65
+     * @param string $license_key The new license key.
66
+     * @return string
67
+     */
68
+    public function handle_key_updates( $license_key ) {
69
+
70
+        // Trim whitespaces and strip slashes.
71
+        $license_key = trim( $license_key );
72
+
73
+        // Abort if the license key is empty or unchanged.
74
+        if ( empty( $license_key ) ) {
75
+            return $license_key;
76
+        }
77
+
78
+        // Abort if a database exists and the license key is unchaged.
79
+        if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) {
80
+            return $license_key;
81
+        }
82
+
83
+        // Check the license key by attempting to download the Geolocation database.
84
+        $tmp_database_path = $this->database_service->download_database( $license_key );
85
+        if ( is_wp_error( $tmp_database_path ) ) {
86
+            getpaid_admin()->show_error( $tmp_database_path->get_error_message() );
87
+            return $license_key;
88
+        }
89
+
90
+        $this->update_database( /** @scrutinizer ignore-type */ $tmp_database_path );
91
+
92
+        return $license_key;
93
+    }
94
+
95
+    /**
96
+     * Updates the database used for geolocation queries.
97
+     *
98
+     * @param string $tmp_database_path Temporary database path.
99
+     */
100
+    public function update_database( $tmp_database_path = null ) {
101
+
102
+        // Allow us to easily interact with the filesystem.
103
+        require_once ABSPATH . 'wp-admin/includes/file.php';
104
+        WP_Filesystem();
105
+        global $wp_filesystem;
106
+
107
+        // Remove any existing archives to comply with the MaxMind TOS.
108
+        $target_database_path = $this->database_service->get_database_path();
109
+
110
+        // If there's no database path, we can't store the database.
111
+        if ( empty( $target_database_path ) ) {
112
+            return;
113
+        }
114
+
115
+        if ( $wp_filesystem->exists( $target_database_path ) ) {
116
+            $wp_filesystem->delete( $target_database_path );
117
+        }
118
+
119
+        // We can't download a database if there's no license key configured.
120
+        $license_key = wpinv_get_option( 'maxmind_license_key' );
121
+        if ( empty( $license_key ) ) {
122
+            return;
123
+        }
124
+
125
+        if ( empty( $tmp_database_path ) ) {
126
+            $tmp_database_path = $this->database_service->download_database( $license_key );
127
+        }
128
+
129
+        if ( is_wp_error( $tmp_database_path ) ) {
130
+            wpinv_error_log( $tmp_database_path->get_error_message() );
131
+            return;
132
+        }
133
+
134
+        // Move the new database into position.
135
+        $wp_filesystem->move( $tmp_database_path, $target_database_path, true );
136
+        $wp_filesystem->delete( dirname( $tmp_database_path ) );
137
+    }
138
+
139
+    /**
140
+     * Performs a geolocation lookup against the MaxMind database for the given IP address.
141
+     *
142
+     * @param array  $data       Geolocation data.
143
+     * @param string $ip_address The IP address to geolocate.
144
+     * @return array Geolocation including country code, state, city and postcode based on an IP address.
145
+     */
146
+    public function get_geolocation( $data, $ip_address ) {
147
+
148
+        if ( ! empty( $data['country'] ) || empty( $ip_address ) ) {
149
+            return $data;
150
+        }
151
+
152
+        $country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address );
153
+
154
+        return array(
155
+            'country'  => $country_code,
156
+            'state'    => '',
157
+            'city'     => '',
158
+            'postcode' => '',
159
+        );
160
+
161
+    }
162
+
163
+    /**
164
+     * Fetches the prefix for the MaxMind database file.
165
+     *
166
+     * @return string
167
+     */
168
+    private function get_database_prefix() {
169
+
170
+        $prefix = get_option( 'wpinv_maxmind_database_prefix' );
171
+
172
+        if ( empty( $prefix ) ) {
173
+            $prefix = md5( uniqid( 'wpinv' ) );
174
+            update_option( 'wpinv_maxmind_database_prefix', $prefix );
175
+        }
176
+
177
+        return $prefix;
178
+    }
179 179
 
180 180
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 /**
13 13
  * Uses MaxMind for Geolocation
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 		 * @since 1.0.19
35 35
 		 * @return mixed|null The geolocation database service.
36 36
 		 */
37
-		$this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null );
38
-		if ( null === $this->database_service ) {
39
-			$this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() );
37
+		$this->database_service = apply_filters('getpaid_maxmind_geolocation_database_service', null);
38
+		if (null === $this->database_service) {
39
+			$this->database_service = new GetPaid_MaxMind_Database_Service($this->get_database_prefix());
40 40
 		}
41 41
 
42 42
 		// Bind to the scheduled updater action.
43
-		add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) );
43
+		add_action('getpaid_update_geoip_databases', array($this, 'update_database'));
44 44
 
45 45
 		// Bind to the geolocation filter for MaxMind database lookups.
46
-		add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 );
46
+		add_filter('getpaid_get_geolocation', array($this, 'get_geolocation'), 10, 2);
47 47
 
48 48
 		// Handle maxmind key updates.
49
-		add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) );
49
+		add_filter('wpinv_settings_sanitize_maxmind_license_key', array($this, 'handle_key_updates'));
50 50
 
51 51
 	}
52 52
 
@@ -65,29 +65,29 @@  discard block
 block discarded – undo
65 65
 	 * @param string $license_key The new license key.
66 66
 	 * @return string
67 67
 	 */
68
-	public function handle_key_updates( $license_key ) {
68
+	public function handle_key_updates($license_key) {
69 69
 
70 70
 		// Trim whitespaces and strip slashes.
71
-		$license_key = trim( $license_key );
71
+		$license_key = trim($license_key);
72 72
 
73 73
 		// Abort if the license key is empty or unchanged.
74
-		if ( empty( $license_key ) ) {
74
+		if (empty($license_key)) {
75 75
 			return $license_key;
76 76
 		}
77 77
 
78 78
 		// Abort if a database exists and the license key is unchaged.
79
-		if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) {
79
+		if (file_exists($this->database_service->get_database_path() && $license_key == wpinv_get_option('maxmind_license_key'))) {
80 80
 			return $license_key;
81 81
 		}
82 82
 
83 83
 		// Check the license key by attempting to download the Geolocation database.
84
-		$tmp_database_path = $this->database_service->download_database( $license_key );
85
-		if ( is_wp_error( $tmp_database_path ) ) {
86
-			getpaid_admin()->show_error( $tmp_database_path->get_error_message() );
84
+		$tmp_database_path = $this->database_service->download_database($license_key);
85
+		if (is_wp_error($tmp_database_path)) {
86
+			getpaid_admin()->show_error($tmp_database_path->get_error_message());
87 87
 			return $license_key;
88 88
 		}
89 89
 
90
-		$this->update_database( /** @scrutinizer ignore-type */ $tmp_database_path );
90
+		$this->update_database(/** @scrutinizer ignore-type */ $tmp_database_path);
91 91
 
92 92
 		return $license_key;
93 93
 	}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @param string $tmp_database_path Temporary database path.
99 99
 	 */
100
-	public function update_database( $tmp_database_path = null ) {
100
+	public function update_database($tmp_database_path = null) {
101 101
 
102 102
 		// Allow us to easily interact with the filesystem.
103 103
 		require_once ABSPATH . 'wp-admin/includes/file.php';
@@ -108,32 +108,32 @@  discard block
 block discarded – undo
108 108
 		$target_database_path = $this->database_service->get_database_path();
109 109
 
110 110
 		// If there's no database path, we can't store the database.
111
-		if ( empty( $target_database_path ) ) {
111
+		if (empty($target_database_path)) {
112 112
 			return;
113 113
 		}
114 114
 
115
-		if ( $wp_filesystem->exists( $target_database_path ) ) {
116
-			$wp_filesystem->delete( $target_database_path );
115
+		if ($wp_filesystem->exists($target_database_path)) {
116
+			$wp_filesystem->delete($target_database_path);
117 117
 		}
118 118
 
119 119
 		// We can't download a database if there's no license key configured.
120
-		$license_key = wpinv_get_option( 'maxmind_license_key' );
121
-		if ( empty( $license_key ) ) {
120
+		$license_key = wpinv_get_option('maxmind_license_key');
121
+		if (empty($license_key)) {
122 122
 			return;
123 123
 		}
124 124
 
125
-		if ( empty( $tmp_database_path ) ) {
126
-			$tmp_database_path = $this->database_service->download_database( $license_key );
125
+		if (empty($tmp_database_path)) {
126
+			$tmp_database_path = $this->database_service->download_database($license_key);
127 127
 		}
128 128
 
129
-		if ( is_wp_error( $tmp_database_path ) ) {
130
-			wpinv_error_log( $tmp_database_path->get_error_message() );
129
+		if (is_wp_error($tmp_database_path)) {
130
+			wpinv_error_log($tmp_database_path->get_error_message());
131 131
 			return;
132 132
 		}
133 133
 
134 134
 		// Move the new database into position.
135
-		$wp_filesystem->move( $tmp_database_path, $target_database_path, true );
136
-		$wp_filesystem->delete( dirname( $tmp_database_path ) );
135
+		$wp_filesystem->move($tmp_database_path, $target_database_path, true);
136
+		$wp_filesystem->delete(dirname($tmp_database_path));
137 137
 	}
138 138
 
139 139
 	/**
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
 	 * @param string $ip_address The IP address to geolocate.
144 144
 	 * @return array Geolocation including country code, state, city and postcode based on an IP address.
145 145
 	 */
146
-	public function get_geolocation( $data, $ip_address ) {
146
+	public function get_geolocation($data, $ip_address) {
147 147
 
148
-		if ( ! empty( $data['country'] ) || empty( $ip_address ) ) {
148
+		if (!empty($data['country']) || empty($ip_address)) {
149 149
 			return $data;
150 150
 		}
151 151
 
152
-		$country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address );
152
+		$country_code = $this->database_service->get_iso_country_code_for_ip($ip_address);
153 153
 
154 154
 		return array(
155 155
 			'country'  => $country_code,
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	private function get_database_prefix() {
169 169
 
170
-		$prefix = get_option( 'wpinv_maxmind_database_prefix' );
170
+		$prefix = get_option('wpinv_maxmind_database_prefix');
171 171
 
172
-		if ( empty( $prefix ) ) {
173
-			$prefix = md5( uniqid( 'wpinv' ) );
174
-			update_option( 'wpinv_maxmind_database_prefix', $prefix );
172
+		if (empty($prefix)) {
173
+			$prefix = md5(uniqid('wpinv'));
174
+			update_option('wpinv_maxmind_database_prefix', $prefix);
175 175
 		}
176 176
 
177 177
 		return $prefix;
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-manual-gateway.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Manual_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 = 'manual';
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', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
34
-	public $order = 11;
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34
+    public $order = 11;
35 35
 
36 36
     /**
37
-	 * Class constructor.
38
-	 */
39
-	public function __construct() {
37
+     * Class constructor.
38
+     */
39
+    public function __construct() {
40 40
         parent::__construct();
41 41
 
42 42
         $this->title        = __( 'Test Gateway', 'invoicing' );
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
     }
47 47
 
48 48
     /**
49
-	 * Process Payment.
50
-	 *
51
-	 *
52
-	 * @param WPInv_Invoice $invoice Invoice.
53
-	 * @param array $submission_data Posted checkout fields.
54
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
55
-	 * @return array
56
-	 */
57
-	public function process_payment( $invoice, $submission_data, $submission ) {
49
+     * Process Payment.
50
+     *
51
+     *
52
+     * @param WPInv_Invoice $invoice Invoice.
53
+     * @param array $submission_data Posted checkout fields.
54
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
55
+     * @return array
56
+     */
57
+    public function process_payment( $invoice, $submission_data, $submission ) {
58 58
 
59 59
         // Mark it as paid.
60 60
         $invoice->mark_paid();
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
     }
86 86
 
87 87
     /**
88
-	 * (Maybe) renews a manual subscription profile.
89
-	 *
90
-	 *
88
+     * (Maybe) renews a manual subscription profile.
89
+     *
90
+     *
91 91
      * @param WPInv_Subscription $subscription
92
-	 */
93
-	public function maybe_renew_subscription( $subscription ) {
92
+     */
93
+    public function maybe_renew_subscription( $subscription ) {
94 94
 
95 95
         // Ensure its our subscription && it's active.
96 96
         if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
     }
111 111
 
112 112
     /**
113
-	 * Processes invoice addons.
114
-	 *
115
-	 * @param WPInv_Invoice $invoice
116
-	 * @param GetPaid_Form_Item[] $items
117
-	 * @return WPInv_Invoice
118
-	 */
119
-	public function process_addons( $invoice, $items ) {
113
+     * Processes invoice addons.
114
+     *
115
+     * @param WPInv_Invoice $invoice
116
+     * @param GetPaid_Form_Item[] $items
117
+     * @return WPInv_Invoice
118
+     */
119
+    public function process_addons( $invoice, $items ) {
120 120
 
121 121
         foreach ( $items as $item ) {
122 122
             $invoice->add_item( $item );
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Manual 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', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
27
+    protected $supports = array('subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
 	public function __construct() {
40 40
         parent::__construct();
41 41
 
42
-        $this->title        = __( 'Test Gateway', 'invoicing' );
43
-        $this->method_title = __( 'Test Gateway', 'invoicing' );
42
+        $this->title        = __('Test Gateway', 'invoicing');
43
+        $this->method_title = __('Test Gateway', 'invoicing');
44 44
 
45
-        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
45
+        add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'));
46 46
     }
47 47
 
48 48
     /**
@@ -54,25 +54,25 @@  discard block
 block discarded – undo
54 54
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
55 55
 	 * @return array
56 56
 	 */
57
-	public function process_payment( $invoice, $submission_data, $submission ) {
57
+	public function process_payment($invoice, $submission_data, $submission) {
58 58
 
59 59
         // Mark it as paid.
60 60
         $invoice->mark_paid();
61 61
 
62 62
         // (Maybe) activate subscriptions.
63
-        $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
63
+        $subscriptions = getpaid_get_invoice_subscriptions($invoice);
64 64
 
65
-        if ( ! empty( $subscriptions ) ) {
66
-            $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
65
+        if (!empty($subscriptions)) {
66
+            $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions);
67 67
 
68
-            foreach ( $subscriptions as $subscription ) {
69
-                if ( $subscription->exists() ) {
70
-                    $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
71
-                    $expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
68
+            foreach ($subscriptions as $subscription) {
69
+                if ($subscription->exists()) {
70
+                    $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
71
+                    $expiry   = date('Y-m-d H:i:s', (current_time('timestamp') + $duration));
72 72
 
73
-                    $subscription->set_next_renewal_date( $expiry );
74
-                    $subscription->set_date_created( current_time( 'mysql' ) );
75
-                    $subscription->set_profile_id( $invoice->generate_key( 'manual_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) );
73
+                    $subscription->set_next_renewal_date($expiry);
74
+                    $subscription->set_date_created(current_time('mysql'));
75
+                    $subscription->set_profile_id($invoice->generate_key('manual_sub_' . $invoice->get_id() . '_' . $subscription->get_id()));
76 76
                     $subscription->activate();
77 77
                 }
78 78
             }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         }
81 81
 
82 82
         // Send to the success page.
83
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
83
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
84 84
 
85 85
     }
86 86
 
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
      * @param WPInv_Subscription $subscription
92 92
 	 */
93
-	public function maybe_renew_subscription( $subscription ) {
93
+	public function maybe_renew_subscription($subscription) {
94 94
 
95 95
         // Ensure its our subscription && it's active.
96
-        if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
96
+        if ($this->id == $subscription->get_gateway() && $subscription->has_status('active trialling')) {
97 97
 
98 98
             // Renew the subscription.
99 99
             $subscription->add_payment(
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
 	 * @param GetPaid_Form_Item[] $items
117 117
 	 * @return WPInv_Invoice
118 118
 	 */
119
-	public function process_addons( $invoice, $items ) {
119
+	public function process_addons($invoice, $items) {
120 120
 
121
-        foreach ( $items as $item ) {
122
-            $invoice->add_item( $item );
121
+        foreach ($items as $item) {
122
+            $invoice->add_item($item);
123 123
         }
124 124
 
125 125
         $invoice->recalculate_total();
Please login to merge, or discard this patch.
includes/class-wpinv-addons.php 3 patches
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 if ( ! defined( 'ABSPATH' ) ) {
9
-	exit;
9
+    exit;
10 10
 }
11 11
 
12 12
 /**
@@ -15,71 +15,71 @@  discard block
 block discarded – undo
15 15
 class WPInv_Admin_Addons extends Ayecode_Addons {
16 16
 
17 17
 
18
-	/**
19
-	 * Get the extensions page tabs.
20
-	 *
21
-	 * @return array of tabs.
22
-	 */
23
-	public function get_tabs(){
24
-		$tabs = array(
25
-			'addons' => __("Addons", "invoicing"),
18
+    /**
19
+     * Get the extensions page tabs.
20
+     *
21
+     * @return array of tabs.
22
+     */
23
+    public function get_tabs(){
24
+        $tabs = array(
25
+            'addons' => __("Addons", "invoicing"),
26 26
             'gateways' => __("Payment Gateways", "invoicing"),
27 27
             'recommended_plugins' => __("Recommended plugins", "invoicing"),
28 28
             'membership' => __("Membership", "invoicing"),
29
-		);
30
-
31
-		return $tabs;
32
-	}
33
-
34
-	/**
35
-	 * Get section content for the addons screen.
36
-	 *
37
-	 * @param  string $section_id
38
-	 *
39
-	 * @return array
40
-	 */
41
-	public function get_section_data( $section_id ) {
42
-		$section      = self::get_tab( $section_id );
43
-		$api_url = "https://wpinvoicing.com/edd-api/v2/products/";
44
-		$section_data = new stdClass();
45
-
46
-		if($section_id=='recommended_plugins'){
47
-			$section_data->products = self::get_recommend_wp_plugins_edd_formatted();
48
-		}
49
-		elseif ( ! empty( $section ) ) {
50
-			if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing
51
-			//if ( 1==1) {
52
-
53
-				$query_args = array( 'category' => $section_id, 'number' => 100);
54
-				$query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id);
55
-
56
-				$raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout'     => 15, ) );
57
-
58
-				if ( ! is_wp_error( $raw_section ) ) {
59
-					$section_data = json_decode( wp_remote_retrieve_body( $raw_section ) );
60
-
61
-					if ( ! empty( $section_data->products ) ) {
62
-						set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS );
63
-					}
64
-				}
65
-			}
66
-		}
67
-
68
-		$products = isset($section_data->products) ? $section_data->products : '';
69
-
70
-		return apply_filters( 'wpi_addons_section_data', $products, $section_id );
71
-	}
72
-
73
-	/**
74
-	 * Outputs a button.
75
-	 *ccc
76
-	 * @param string $url
77
-	 * @param string $text
78
-	 * @param string $theme
79
-	 * @param string $plugin
80
-	 */
81
-	public function output_button( $addon ) {
82
-		$current_tab     = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] );
29
+        );
30
+
31
+        return $tabs;
32
+    }
33
+
34
+    /**
35
+     * Get section content for the addons screen.
36
+     *
37
+     * @param  string $section_id
38
+     *
39
+     * @return array
40
+     */
41
+    public function get_section_data( $section_id ) {
42
+        $section      = self::get_tab( $section_id );
43
+        $api_url = "https://wpinvoicing.com/edd-api/v2/products/";
44
+        $section_data = new stdClass();
45
+
46
+        if($section_id=='recommended_plugins'){
47
+            $section_data->products = self::get_recommend_wp_plugins_edd_formatted();
48
+        }
49
+        elseif ( ! empty( $section ) ) {
50
+            if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing
51
+            //if ( 1==1) {
52
+
53
+                $query_args = array( 'category' => $section_id, 'number' => 100);
54
+                $query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id);
55
+
56
+                $raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout'     => 15, ) );
57
+
58
+                if ( ! is_wp_error( $raw_section ) ) {
59
+                    $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) );
60
+
61
+                    if ( ! empty( $section_data->products ) ) {
62
+                        set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS );
63
+                    }
64
+                }
65
+            }
66
+        }
67
+
68
+        $products = isset($section_data->products) ? $section_data->products : '';
69
+
70
+        return apply_filters( 'wpi_addons_section_data', $products, $section_id );
71
+    }
72
+
73
+    /**
74
+     * Outputs a button.
75
+     *ccc
76
+     * @param string $url
77
+     * @param string $text
78
+     * @param string $theme
79
+     * @param string $plugin
80
+     */
81
+    public function output_button( $addon ) {
82
+        $current_tab     = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] );
83 83
 //		$button_text = __('Free','invoicing');
84 84
 //		$licensing = false;
85 85
 //		$installed = false;
@@ -91,123 +91,123 @@  discard block
 block discarded – undo
91 91
 //		$install_status = 'get';
92 92
 //		$onclick = '';
93 93
 
94
-		$wp_org_themes = array('supreme-directory','directory-starter');
95
-
96
-		$button_args = array(
97
-			'type' => ($current_tab == 'addons' || $current_tab =='gateways') ? 'addons' : $current_tab,
98
-			'id' => isset($addon->info->id) ? absint($addon->info->id) : '',
99
-			'title' => isset($addon->info->title) ? $addon->info->title : '',
100
-			'button_text' => __('Free','invoicing'),
101
-			'price_text' => __('Free','invoicing'),
102
-			'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product
103
-			'url' => isset($addon->info->link) ? $addon->info->link : '', // button url
104
-			'class' => 'button-primary',
105
-			'install_status' => 'get',
106
-			'installed' => false,
107
-			'price' => '',
108
-			'licensing' => isset($addon->licensing->enabled) && $addon->licensing->enabled ? true : false,
109
-			'license' => isset($addon->licensing->license) && $addon->licensing->license ? $addon->licensing->license : '',
110
-			'onclick' => '',
111
-			'slug' => isset($addon->info->slug) ? $addon->info->slug : '',
112
-			'active' => false,
113
-			'file' => '',
114
-			'update_url' => '',
115
-		);
116
-
117
-		if( 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug )){
118
-			include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
119
-			$status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>""));
120
-			$button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install';
121
-			$button_args['file'] = isset($status['file']) ? $status['file'] : '';
122
-		}elseif( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){
123
-			include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
124
-			if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;}
125
-			$status = self::install_plugin_install_status($addon);
126
-			$button_args['file'] = isset($status['file']) ? $status['file'] : '';
127
-			if(isset($status['status'])){$button_args['install_status'] = $status['status'];}
128
-			$button_args['update_url'] = "https://wpinvoicing.com";
129
-		}elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) {
130
-			if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;}
131
-			$button_args['installed'] = self::is_theme_installed($addon);
132
-			if(!in_array($button_args['slug'],$wp_org_themes)){
133
-				$button_args['update_url'] = "https://wpinvoicing.com";
134
-			}
135
-		}
136
-
137
-		// set price
138
-		if(isset($addon->pricing) && !empty($addon->pricing)){
139
-			if(is_object($addon->pricing)){
140
-				$prices = (Array)$addon->pricing;
141
-				$button_args['price'] = reset($prices);
142
-			}elseif(isset($addon->pricing)){
143
-				$button_args['price'] = $addon->pricing;
144
-			}
145
-		}
146
-
147
-		// set price text
148
-		if( $button_args['price'] && $button_args['price'] != '0.00' ){
149
-			$button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']);
150
-		}
151
-
152
-
153
-		// set if installed
154
-		if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){
155
-			$button_args['installed'] = true;
156
-		}
94
+        $wp_org_themes = array('supreme-directory','directory-starter');
95
+
96
+        $button_args = array(
97
+            'type' => ($current_tab == 'addons' || $current_tab =='gateways') ? 'addons' : $current_tab,
98
+            'id' => isset($addon->info->id) ? absint($addon->info->id) : '',
99
+            'title' => isset($addon->info->title) ? $addon->info->title : '',
100
+            'button_text' => __('Free','invoicing'),
101
+            'price_text' => __('Free','invoicing'),
102
+            'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product
103
+            'url' => isset($addon->info->link) ? $addon->info->link : '', // button url
104
+            'class' => 'button-primary',
105
+            'install_status' => 'get',
106
+            'installed' => false,
107
+            'price' => '',
108
+            'licensing' => isset($addon->licensing->enabled) && $addon->licensing->enabled ? true : false,
109
+            'license' => isset($addon->licensing->license) && $addon->licensing->license ? $addon->licensing->license : '',
110
+            'onclick' => '',
111
+            'slug' => isset($addon->info->slug) ? $addon->info->slug : '',
112
+            'active' => false,
113
+            'file' => '',
114
+            'update_url' => '',
115
+        );
116
+
117
+        if( 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug )){
118
+            include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
119
+            $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>""));
120
+            $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install';
121
+            $button_args['file'] = isset($status['file']) ? $status['file'] : '';
122
+        }elseif( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){
123
+            include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
124
+            if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;}
125
+            $status = self::install_plugin_install_status($addon);
126
+            $button_args['file'] = isset($status['file']) ? $status['file'] : '';
127
+            if(isset($status['status'])){$button_args['install_status'] = $status['status'];}
128
+            $button_args['update_url'] = "https://wpinvoicing.com";
129
+        }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) {
130
+            if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;}
131
+            $button_args['installed'] = self::is_theme_installed($addon);
132
+            if(!in_array($button_args['slug'],$wp_org_themes)){
133
+                $button_args['update_url'] = "https://wpinvoicing.com";
134
+            }
135
+        }
136
+
137
+        // set price
138
+        if(isset($addon->pricing) && !empty($addon->pricing)){
139
+            if(is_object($addon->pricing)){
140
+                $prices = (Array)$addon->pricing;
141
+                $button_args['price'] = reset($prices);
142
+            }elseif(isset($addon->pricing)){
143
+                $button_args['price'] = $addon->pricing;
144
+            }
145
+        }
146
+
147
+        // set price text
148
+        if( $button_args['price'] && $button_args['price'] != '0.00' ){
149
+            $button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']);
150
+        }
151
+
152
+
153
+        // set if installed
154
+        if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){
155
+            $button_args['installed'] = true;
156
+        }
157 157
 
158 158
 //		print_r($button_args);
159
-		// set if active
160
-		if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){
161
-			if($button_args['type'] != 'themes'){
162
-				$button_args['active'] = is_plugin_active($button_args['file']);
163
-			}else{
164
-				$button_args['active'] = self::is_theme_active($addon);
165
-			}
166
-		}
167
-
168
-		// set button text and class
169
-		if($button_args['active']){
170
-			$button_args['button_text'] = __('Active','invoicing');
171
-			$button_args['class'] = ' button-secondary disabled ';
172
-		}elseif($button_args['installed']){
173
-			$button_args['button_text'] = __('Activate','invoicing');
174
-
175
-			if($button_args['type'] != 'themes'){
176
-				if ( current_user_can( 'manage_options' ) ) {
177
-					$button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']);
178
-				}else{
179
-					$button_args['url'] = '#';
180
-				}
181
-			}else{
182
-				if ( current_user_can( 'switch_themes' ) ) {
183
-					$button_args['url'] = self::get_theme_activation_url($addon);
184
-				}else{
185
-					$button_args['url'] = '#';
186
-				}
187
-			}
188
-
189
-		}else{
190
-			if($button_args['type'] == 'recommended_plugins'){
191
-				$button_args['button_text'] = __('Install','invoicing');
192
-			}else{
193
-				$button_args['button_text'] = __('Get it','invoicing');
194
-
195
-				/*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){
159
+        // set if active
160
+        if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){
161
+            if($button_args['type'] != 'themes'){
162
+                $button_args['active'] = is_plugin_active($button_args['file']);
163
+            }else{
164
+                $button_args['active'] = self::is_theme_active($addon);
165
+            }
166
+        }
167
+
168
+        // set button text and class
169
+        if($button_args['active']){
170
+            $button_args['button_text'] = __('Active','invoicing');
171
+            $button_args['class'] = ' button-secondary disabled ';
172
+        }elseif($button_args['installed']){
173
+            $button_args['button_text'] = __('Activate','invoicing');
174
+
175
+            if($button_args['type'] != 'themes'){
176
+                if ( current_user_can( 'manage_options' ) ) {
177
+                    $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']);
178
+                }else{
179
+                    $button_args['url'] = '#';
180
+                }
181
+            }else{
182
+                if ( current_user_can( 'switch_themes' ) ) {
183
+                    $button_args['url'] = self::get_theme_activation_url($addon);
184
+                }else{
185
+                    $button_args['url'] = '#';
186
+                }
187
+            }
188
+
189
+        }else{
190
+            if($button_args['type'] == 'recommended_plugins'){
191
+                $button_args['button_text'] = __('Install','invoicing');
192
+            }else{
193
+                $button_args['button_text'] = __('Get it','invoicing');
194
+
195
+                /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){
196 196
 					$button_args['button_text'] = __('Install','invoicing');
197 197
 					$button_args['url'] = self::get_theme_install_url($button_args['slug']);
198 198
 					$button_args['onclick'] = 'gd_set_button_installing(this);';
199 199
 				}*/
200 200
 
201
-			}
202
-		}
201
+            }
202
+        }
203 203
 
204 204
 		
205
-		// filter the button arguments
206
-		$button_args = apply_filters('edd_api_button_args',$button_args);
205
+        // filter the button arguments
206
+        $button_args = apply_filters('edd_api_button_args',$button_args);
207 207
 //		print_r($button_args);
208
-		// set price text
209
-		if(isset($button_args['price_text'])){
210
-			?>
208
+        // set price text
209
+        if(isset($button_args['price_text'])){
210
+            ?>
211 211
 			<a
212 212
 				target="_blank"
213 213
 				class="addons-price-text"
@@ -215,15 +215,15 @@  discard block
 block discarded – undo
215 215
 				<?php echo esc_html( $button_args['price_text'] ); ?>
216 216
 			</a>
217 217
 			<?php
218
-		}
218
+        }
219 219
 
220 220
 
221
-		$target = '';
222
-		if ( ! empty( $button_args['url'] ) ) {
223
-			$target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" ';
224
-		}
221
+        $target = '';
222
+        if ( ! empty( $button_args['url'] ) ) {
223
+            $target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" ';
224
+        }
225 225
 
226
-		?>
226
+        ?>
227 227
 		<a
228 228
 			data-licence="<?php echo esc_attr($button_args['license']);?>"
229 229
 			data-licensing="<?php echo $button_args['licensing'] ? 1 : 0;?>"
@@ -246,33 +246,33 @@  discard block
 block discarded – undo
246 246
 		<?php
247 247
 
248 248
 
249
-	}
250
-
251
-
252
-	/**
253
-	 * Handles output of the addons page in admin.
254
-	 */
255
-	public function output() {
256
-		$tabs            = self::get_tabs();
257
-		$sections        = self::get_sections();
258
-		$theme           = wp_get_theme();
259
-		$section_keys    = array_keys( $sections );
260
-		$current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys );
261
-		$current_tab     = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] );
262
-		include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' );
263
-	}
264
-
265
-	/**
266
-	 * A list of recommended wp.org plugins.
267
-	 * @return array
268
-	 */
269
-	public function get_recommend_wp_plugins(){
270
-		$plugins = array(
249
+    }
250
+
251
+
252
+    /**
253
+     * Handles output of the addons page in admin.
254
+     */
255
+    public function output() {
256
+        $tabs            = self::get_tabs();
257
+        $sections        = self::get_sections();
258
+        $theme           = wp_get_theme();
259
+        $section_keys    = array_keys( $sections );
260
+        $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys );
261
+        $current_tab     = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] );
262
+        include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' );
263
+    }
264
+
265
+    /**
266
+     * A list of recommended wp.org plugins.
267
+     * @return array
268
+     */
269
+    public function get_recommend_wp_plugins(){
270
+        $plugins = array(
271 271
             'invoicing-quotes' => array(
272 272
                 'url'   => 'https://wordpress.org/plugins/invoicing-quotes/',
273 273
                 'slug'   => 'invoicing-quotes',
274
-				'name'   => 'Quotes',
275
-				'thumbnail'  => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.jpg',
274
+                'name'   => 'Quotes',
275
+                'thumbnail'  => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.jpg',
276 276
                 'desc'   => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.','invoicing'),
277 277
             ),
278 278
             'geodirectory' => array(
@@ -287,8 +287,8 @@  discard block
 block discarded – undo
287 287
                 'name'   => 'UsersWP',
288 288
                 'desc'   => __('Allow frontend user login and registration as well as have slick profile pages.','invoicing'),
289 289
             ),
290
-		);
290
+        );
291 291
 
292
-		return $plugins;
293
-	}
292
+        return $plugins;
293
+    }
294 294
 }
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * All Invoicing extensions screen related functions can be found here.
6 6
  *
7 7
  */
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if (!defined('ABSPATH')) {
9 9
 	exit;
10 10
 }
11 11
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @return array of tabs.
22 22
 	 */
23
-	public function get_tabs(){
23
+	public function get_tabs() {
24 24
 		$tabs = array(
25 25
 			'addons' => __("Addons", "invoicing"),
26 26
             'gateways' => __("Payment Gateways", "invoicing"),
@@ -38,28 +38,28 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return array
40 40
 	 */
41
-	public function get_section_data( $section_id ) {
42
-		$section      = self::get_tab( $section_id );
41
+	public function get_section_data($section_id) {
42
+		$section      = self::get_tab($section_id);
43 43
 		$api_url = "https://wpinvoicing.com/edd-api/v2/products/";
44 44
 		$section_data = new stdClass();
45 45
 
46
-		if($section_id=='recommended_plugins'){
46
+		if ($section_id == 'recommended_plugins') {
47 47
 			$section_data->products = self::get_recommend_wp_plugins_edd_formatted();
48 48
 		}
49
-		elseif ( ! empty( $section ) ) {
50
-			if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing
49
+		elseif (!empty($section)) {
50
+			if (false === ($section_data = get_transient('wpi_addons_section_' . $section_id))) { //@todo restore after testing
51 51
 			//if ( 1==1) {
52 52
 
53
-				$query_args = array( 'category' => $section_id, 'number' => 100);
54
-				$query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id);
53
+				$query_args = array('category' => $section_id, 'number' => 100);
54
+				$query_args = apply_filters('wpeu_edd_api_query_args', $query_args, $api_url, $section_id);
55 55
 
56
-				$raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout'     => 15, ) );
56
+				$raw_section = wp_safe_remote_get(esc_url_raw(add_query_arg($query_args, $api_url)), array('user-agent' => 'Invoicing Addons Page', 'timeout'     => 15,));
57 57
 
58
-				if ( ! is_wp_error( $raw_section ) ) {
59
-					$section_data = json_decode( wp_remote_retrieve_body( $raw_section ) );
58
+				if (!is_wp_error($raw_section)) {
59
+					$section_data = json_decode(wp_remote_retrieve_body($raw_section));
60 60
 
61
-					if ( ! empty( $section_data->products ) ) {
62
-						set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS );
61
+					if (!empty($section_data->products)) {
62
+						set_transient('wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS);
63 63
 					}
64 64
 				}
65 65
 			}
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 		$products = isset($section_data->products) ? $section_data->products : '';
69 69
 
70
-		return apply_filters( 'wpi_addons_section_data', $products, $section_id );
70
+		return apply_filters('wpi_addons_section_data', $products, $section_id);
71 71
 	}
72 72
 
73 73
 	/**
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	 * @param string $theme
79 79
 	 * @param string $plugin
80 80
 	 */
81
-	public function output_button( $addon ) {
82
-		$current_tab     = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] );
81
+	public function output_button($addon) {
82
+		$current_tab = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']);
83 83
 //		$button_text = __('Free','invoicing');
84 84
 //		$licensing = false;
85 85
 //		$installed = false;
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 //		$install_status = 'get';
92 92
 //		$onclick = '';
93 93
 
94
-		$wp_org_themes = array('supreme-directory','directory-starter');
94
+		$wp_org_themes = array('supreme-directory', 'directory-starter');
95 95
 
96 96
 		$button_args = array(
97
-			'type' => ($current_tab == 'addons' || $current_tab =='gateways') ? 'addons' : $current_tab,
97
+			'type' => ($current_tab == 'addons' || $current_tab == 'gateways') ? 'addons' : $current_tab,
98 98
 			'id' => isset($addon->info->id) ? absint($addon->info->id) : '',
99 99
 			'title' => isset($addon->info->title) ? $addon->info->title : '',
100
-			'button_text' => __('Free','invoicing'),
101
-			'price_text' => __('Free','invoicing'),
100
+			'button_text' => __('Free', 'invoicing'),
101
+			'price_text' => __('Free', 'invoicing'),
102 102
 			'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product
103 103
 			'url' => isset($addon->info->link) ? $addon->info->link : '', // button url
104 104
 			'class' => 'button-primary',
@@ -114,83 +114,83 @@  discard block
 block discarded – undo
114 114
 			'update_url' => '',
115 115
 		);
116 116
 
117
-		if( 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug )){
118
-			include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
119
-			$status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>""));
117
+		if ('getpaid-stripe-payments' == $addon->info->slug || ($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug)) {
118
+			include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); //for plugins_api..
119
+			$status = install_plugin_install_status(array("slug"=>$button_args['slug'], "version"=>""));
120 120
 			$button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install';
121 121
 			$button_args['file'] = isset($status['file']) ? $status['file'] : '';
122
-		}elseif( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){
123
-			include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
124
-			if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;}
122
+		}elseif (($current_tab == 'addons' || $current_tab == 'gateways') && isset($addon->info->id) && $addon->info->id) {
123
+			include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); //for plugins_api..
124
+			if (!empty($addon->licensing->edd_slug)) {$button_args['slug'] = $addon->licensing->edd_slug; }
125 125
 			$status = self::install_plugin_install_status($addon);
126 126
 			$button_args['file'] = isset($status['file']) ? $status['file'] : '';
127
-			if(isset($status['status'])){$button_args['install_status'] = $status['status'];}
127
+			if (isset($status['status'])) {$button_args['install_status'] = $status['status']; }
128 128
 			$button_args['update_url'] = "https://wpinvoicing.com";
129
-		}elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) {
130
-			if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;}
129
+		}elseif ($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) {
130
+			if (!empty($addon->licensing->edd_slug)) {$button_args['slug'] = $addon->licensing->edd_slug; }
131 131
 			$button_args['installed'] = self::is_theme_installed($addon);
132
-			if(!in_array($button_args['slug'],$wp_org_themes)){
132
+			if (!in_array($button_args['slug'], $wp_org_themes)) {
133 133
 				$button_args['update_url'] = "https://wpinvoicing.com";
134 134
 			}
135 135
 		}
136 136
 
137 137
 		// set price
138
-		if(isset($addon->pricing) && !empty($addon->pricing)){
139
-			if(is_object($addon->pricing)){
140
-				$prices = (Array)$addon->pricing;
138
+		if (isset($addon->pricing) && !empty($addon->pricing)) {
139
+			if (is_object($addon->pricing)) {
140
+				$prices = (Array) $addon->pricing;
141 141
 				$button_args['price'] = reset($prices);
142
-			}elseif(isset($addon->pricing)){
142
+			}elseif (isset($addon->pricing)) {
143 143
 				$button_args['price'] = $addon->pricing;
144 144
 			}
145 145
 		}
146 146
 
147 147
 		// set price text
148
-		if( $button_args['price'] && $button_args['price'] != '0.00' ){
149
-			$button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']);
148
+		if ($button_args['price'] && $button_args['price'] != '0.00') {
149
+			$button_args['price_text'] = sprintf(__('From: $%d', 'invoicing'), $button_args['price']);
150 150
 		}
151 151
 
152 152
 
153 153
 		// set if installed
154
-		if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){
154
+		if (in_array($button_args['install_status'], array('installed', 'latest_installed', 'update_available', 'newer_installed'))) {
155 155
 			$button_args['installed'] = true;
156 156
 		}
157 157
 
158 158
 //		print_r($button_args);
159 159
 		// set if active
160
-		if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){
161
-			if($button_args['type'] != 'themes'){
160
+		if ($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')) {
161
+			if ($button_args['type'] != 'themes') {
162 162
 				$button_args['active'] = is_plugin_active($button_args['file']);
163
-			}else{
163
+			} else {
164 164
 				$button_args['active'] = self::is_theme_active($addon);
165 165
 			}
166 166
 		}
167 167
 
168 168
 		// set button text and class
169
-		if($button_args['active']){
170
-			$button_args['button_text'] = __('Active','invoicing');
169
+		if ($button_args['active']) {
170
+			$button_args['button_text'] = __('Active', 'invoicing');
171 171
 			$button_args['class'] = ' button-secondary disabled ';
172
-		}elseif($button_args['installed']){
173
-			$button_args['button_text'] = __('Activate','invoicing');
172
+		}elseif ($button_args['installed']) {
173
+			$button_args['button_text'] = __('Activate', 'invoicing');
174 174
 
175
-			if($button_args['type'] != 'themes'){
176
-				if ( current_user_can( 'manage_options' ) ) {
177
-					$button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']);
178
-				}else{
175
+			if ($button_args['type'] != 'themes') {
176
+				if (current_user_can('manage_options')) {
177
+					$button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . $button_args['file']), 'activate-plugin_' . $button_args['file']);
178
+				} else {
179 179
 					$button_args['url'] = '#';
180 180
 				}
181
-			}else{
182
-				if ( current_user_can( 'switch_themes' ) ) {
181
+			} else {
182
+				if (current_user_can('switch_themes')) {
183 183
 					$button_args['url'] = self::get_theme_activation_url($addon);
184
-				}else{
184
+				} else {
185 185
 					$button_args['url'] = '#';
186 186
 				}
187 187
 			}
188 188
 
189
-		}else{
190
-			if($button_args['type'] == 'recommended_plugins'){
191
-				$button_args['button_text'] = __('Install','invoicing');
192
-			}else{
193
-				$button_args['button_text'] = __('Get it','invoicing');
189
+		} else {
190
+			if ($button_args['type'] == 'recommended_plugins') {
191
+				$button_args['button_text'] = __('Install', 'invoicing');
192
+			} else {
193
+				$button_args['button_text'] = __('Get it', 'invoicing');
194 194
 
195 195
 				/*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){
196 196
 					$button_args['button_text'] = __('Install','invoicing');
@@ -203,45 +203,45 @@  discard block
 block discarded – undo
203 203
 
204 204
 		
205 205
 		// filter the button arguments
206
-		$button_args = apply_filters('edd_api_button_args',$button_args);
206
+		$button_args = apply_filters('edd_api_button_args', $button_args);
207 207
 //		print_r($button_args);
208 208
 		// set price text
209
-		if(isset($button_args['price_text'])){
209
+		if (isset($button_args['price_text'])) {
210 210
 			?>
211 211
 			<a
212 212
 				target="_blank"
213 213
 				class="addons-price-text"
214
-				href="<?php echo esc_url( $button_args['link'] ); ?>">
215
-				<?php echo esc_html( $button_args['price_text'] ); ?>
214
+				href="<?php echo esc_url($button_args['link']); ?>">
215
+				<?php echo esc_html($button_args['price_text']); ?>
216 216
 			</a>
217 217
 			<?php
218 218
 		}
219 219
 
220 220
 
221 221
 		$target = '';
222
-		if ( ! empty( $button_args['url'] ) ) {
222
+		if (!empty($button_args['url'])) {
223 223
 			$target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" ';
224 224
 		}
225 225
 
226 226
 		?>
227 227
 		<a
228
-			data-licence="<?php echo esc_attr($button_args['license']);?>"
229
-			data-licensing="<?php echo $button_args['licensing'] ? 1 : 0;?>"
230
-			data-title="<?php echo esc_attr($button_args['title']);?>"
231
-			data-type="<?php echo esc_attr($button_args['type']);?>"
232
-			data-text-error-message="<?php _e('Something went wrong!','invoicing');?>"
233
-			data-text-activate="<?php _e('Activate','invoicing');?>"
234
-			data-text-activating="<?php _e('Activating','invoicing');?>"
235
-			data-text-deactivate="<?php _e('Deactivate','invoicing');?>"
236
-			data-text-installed="<?php _e('Installed','invoicing');?>"
237
-			data-text-install="<?php _e('Install','invoicing');?>"
238
-			data-text-installing="<?php _e('Installing','invoicing');?>"
239
-			data-text-error="<?php _e('Error','invoicing');?>"
240
-			<?php if(!empty($button_args['onclick'])){echo " onclick='".$button_args['onclick']."' ";}?>
241
-			<?php echo $target;?>
242
-			class="addons-button  <?php echo esc_attr( $button_args['class'] ); ?>"
243
-			href="<?php echo esc_url( $button_args['url'] ); ?>">
244
-			<?php echo esc_html( $button_args['button_text'] ); ?>
228
+			data-licence="<?php echo esc_attr($button_args['license']); ?>"
229
+			data-licensing="<?php echo $button_args['licensing'] ? 1 : 0; ?>"
230
+			data-title="<?php echo esc_attr($button_args['title']); ?>"
231
+			data-type="<?php echo esc_attr($button_args['type']); ?>"
232
+			data-text-error-message="<?php _e('Something went wrong!', 'invoicing'); ?>"
233
+			data-text-activate="<?php _e('Activate', 'invoicing'); ?>"
234
+			data-text-activating="<?php _e('Activating', 'invoicing'); ?>"
235
+			data-text-deactivate="<?php _e('Deactivate', 'invoicing'); ?>"
236
+			data-text-installed="<?php _e('Installed', 'invoicing'); ?>"
237
+			data-text-install="<?php _e('Install', 'invoicing'); ?>"
238
+			data-text-installing="<?php _e('Installing', 'invoicing'); ?>"
239
+			data-text-error="<?php _e('Error', 'invoicing'); ?>"
240
+			<?php if (!empty($button_args['onclick'])) {echo " onclick='" . $button_args['onclick'] . "' "; }?>
241
+			<?php echo $target; ?>
242
+			class="addons-button  <?php echo esc_attr($button_args['class']); ?>"
243
+			href="<?php echo esc_url($button_args['url']); ?>">
244
+			<?php echo esc_html($button_args['button_text']); ?>
245 245
 		</a>
246 246
 		<?php
247 247
 
@@ -256,36 +256,36 @@  discard block
 block discarded – undo
256 256
 		$tabs            = self::get_tabs();
257 257
 		$sections        = self::get_sections();
258 258
 		$theme           = wp_get_theme();
259
-		$section_keys    = array_keys( $sections );
260
-		$current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys );
261
-		$current_tab     = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] );
262
-		include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' );
259
+		$section_keys    = array_keys($sections);
260
+		$current_section = isset($_GET['section']) ? sanitize_text_field($_GET['section']) : current($section_keys);
261
+		$current_tab     = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']);
262
+		include_once(WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php');
263 263
 	}
264 264
 
265 265
 	/**
266 266
 	 * A list of recommended wp.org plugins.
267 267
 	 * @return array
268 268
 	 */
269
-	public function get_recommend_wp_plugins(){
269
+	public function get_recommend_wp_plugins() {
270 270
 		$plugins = array(
271 271
             'invoicing-quotes' => array(
272 272
                 'url'   => 'https://wordpress.org/plugins/invoicing-quotes/',
273 273
                 'slug'   => 'invoicing-quotes',
274 274
 				'name'   => 'Quotes',
275 275
 				'thumbnail'  => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.jpg',
276
-                'desc'   => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.','invoicing'),
276
+                'desc'   => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.', 'invoicing'),
277 277
             ),
278 278
             'geodirectory' => array(
279 279
                 'url'   => 'https://wordpress.org/plugins/geodirectory/',
280 280
                 'slug'   => 'geodirectory',
281 281
                 'name'   => 'GeoDirectory',
282
-                'desc'   => __('Turn any WordPress theme into a global business directory portal.','invoicing'),
282
+                'desc'   => __('Turn any WordPress theme into a global business directory portal.', 'invoicing'),
283 283
             ),
284 284
             'userswp' => array(
285 285
                 'url'   => 'https://wordpress.org/plugins/userswp/',
286 286
                 'slug'   => 'userswp',
287 287
                 'name'   => 'UsersWP',
288
-                'desc'   => __('Allow frontend user login and registration as well as have slick profile pages.','invoicing'),
288
+                'desc'   => __('Allow frontend user login and registration as well as have slick profile pages.', 'invoicing'),
289 289
             ),
290 290
 		);
291 291
 
Please login to merge, or discard this patch.
Braces   +11 added lines, -12 removed lines patch added patch discarded remove patch
@@ -45,8 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
 		if($section_id=='recommended_plugins'){
47 47
 			$section_data->products = self::get_recommend_wp_plugins_edd_formatted();
48
-		}
49
-		elseif ( ! empty( $section ) ) {
48
+		} elseif ( ! empty( $section ) ) {
50 49
 			if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing
51 50
 			//if ( 1==1) {
52 51
 
@@ -119,14 +118,14 @@  discard block
 block discarded – undo
119 118
 			$status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>""));
120 119
 			$button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install';
121 120
 			$button_args['file'] = isset($status['file']) ? $status['file'] : '';
122
-		}elseif( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){
121
+		} elseif( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){
123 122
 			include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
124 123
 			if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;}
125 124
 			$status = self::install_plugin_install_status($addon);
126 125
 			$button_args['file'] = isset($status['file']) ? $status['file'] : '';
127 126
 			if(isset($status['status'])){$button_args['install_status'] = $status['status'];}
128 127
 			$button_args['update_url'] = "https://wpinvoicing.com";
129
-		}elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) {
128
+		} elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) {
130 129
 			if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;}
131 130
 			$button_args['installed'] = self::is_theme_installed($addon);
132 131
 			if(!in_array($button_args['slug'],$wp_org_themes)){
@@ -139,7 +138,7 @@  discard block
 block discarded – undo
139 138
 			if(is_object($addon->pricing)){
140 139
 				$prices = (Array)$addon->pricing;
141 140
 				$button_args['price'] = reset($prices);
142
-			}elseif(isset($addon->pricing)){
141
+			} elseif(isset($addon->pricing)){
143 142
 				$button_args['price'] = $addon->pricing;
144 143
 			}
145 144
 		}
@@ -160,7 +159,7 @@  discard block
 block discarded – undo
160 159
 		if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){
161 160
 			if($button_args['type'] != 'themes'){
162 161
 				$button_args['active'] = is_plugin_active($button_args['file']);
163
-			}else{
162
+			} else{
164 163
 				$button_args['active'] = self::is_theme_active($addon);
165 164
 			}
166 165
 		}
@@ -169,27 +168,27 @@  discard block
 block discarded – undo
169 168
 		if($button_args['active']){
170 169
 			$button_args['button_text'] = __('Active','invoicing');
171 170
 			$button_args['class'] = ' button-secondary disabled ';
172
-		}elseif($button_args['installed']){
171
+		} elseif($button_args['installed']){
173 172
 			$button_args['button_text'] = __('Activate','invoicing');
174 173
 
175 174
 			if($button_args['type'] != 'themes'){
176 175
 				if ( current_user_can( 'manage_options' ) ) {
177 176
 					$button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']);
178
-				}else{
177
+				} else{
179 178
 					$button_args['url'] = '#';
180 179
 				}
181
-			}else{
180
+			} else{
182 181
 				if ( current_user_can( 'switch_themes' ) ) {
183 182
 					$button_args['url'] = self::get_theme_activation_url($addon);
184
-				}else{
183
+				} else{
185 184
 					$button_args['url'] = '#';
186 185
 				}
187 186
 			}
188 187
 
189
-		}else{
188
+		} else{
190 189
 			if($button_args['type'] == 'recommended_plugins'){
191 190
 				$button_args['button_text'] = __('Install','invoicing');
192
-			}else{
191
+			} else{
193 192
 				$button_args['button_text'] = __('Get it','invoicing');
194 193
 
195 194
 				/*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-data.php 2 patches
Indentation   +863 added lines, -863 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 if ( ! defined( 'ABSPATH' ) ) {
12
-	exit;
12
+    exit;
13 13
 }
14 14
 
15 15
 /**
@@ -21,356 +21,356 @@  discard block
 block discarded – undo
21 21
  */
22 22
 abstract class GetPaid_Data {
23 23
 
24
-	/**
25
-	 * ID for this object.
26
-	 *
27
-	 * @since 1.0.19
28
-	 * @var int
29
-	 */
30
-	protected $id = 0;
31
-
32
-	/**
33
-	 * Core data for this object. Name value pairs (name + default value).
34
-	 *
35
-	 * @since 1.0.19
36
-	 * @var array
37
-	 */
38
-	protected $data = array();
39
-
40
-	/**
41
-	 * Core data changes for this object.
42
-	 *
43
-	 * @since 1.0.19
44
-	 * @var array
45
-	 */
46
-	protected $changes = array();
47
-
48
-	/**
49
-	 * This is false until the object is read from the DB.
50
-	 *
51
-	 * @since 1.0.19
52
-	 * @var bool
53
-	 */
54
-	protected $object_read = false;
55
-
56
-	/**
57
-	 * This is the name of this object type.
58
-	 *
59
-	 * @since 1.0.19
60
-	 * @var string
61
-	 */
62
-	protected $object_type = 'data';
63
-
64
-	/**
65
-	 * Extra data for this object. Name value pairs (name + default value).
66
-	 * Used as a standard way for sub classes (like item types) to add
67
-	 * additional information to an inherited class.
68
-	 *
69
-	 * @since 1.0.19
70
-	 * @var array
71
-	 */
72
-	protected $extra_data = array();
73
-
74
-	/**
75
-	 * Set to _data on construct so we can track and reset data if needed.
76
-	 *
77
-	 * @since 1.0.19
78
-	 * @var array
79
-	 */
80
-	protected $default_data = array();
81
-
82
-	/**
83
-	 * Contains a reference to the data store for this class.
84
-	 *
85
-	 * @since 1.0.19
86
-	 * @var GetPaid_Data_Store
87
-	 */
88
-	protected $data_store;
89
-
90
-	/**
91
-	 * Stores meta in cache for future reads.
92
-	 * A group must be set to to enable caching.
93
-	 *
94
-	 * @since 1.0.19
95
-	 * @var string
96
-	 */
97
-	protected $cache_group = '';
98
-
99
-	/**
100
-	 * Stores the last error.
101
-	 *
102
-	 * @since 1.0.19
103
-	 * @var string
104
-	 */
105
-	public $last_error = '';
106
-
107
-	/**
108
-	 * Stores additional meta data.
109
-	 *
110
-	 * @since 1.0.19
111
-	 * @var array
112
-	 */
113
-	protected $meta_data = null;
114
-
115
-	/**
116
-	 * Default constructor.
117
-	 *
118
-	 * @param int|object|array|string $read ID to load from the DB (optional) or already queried data.
119
-	 */
120
-	public function __construct( $read = 0 ) {
121
-		$this->data         = array_merge( $this->data, $this->extra_data );
122
-		$this->default_data = $this->data;
123
-	}
124
-
125
-	/**
126
-	 * Only store the object ID to avoid serializing the data object instance.
127
-	 *
128
-	 * @return array
129
-	 */
130
-	public function __sleep() {
131
-		return array( 'id' );
132
-	}
133
-
134
-	/**
135
-	 * Re-run the constructor with the object ID.
136
-	 *
137
-	 * If the object no longer exists, remove the ID.
138
-	 */
139
-	public function __wakeup() {
140
-		$this->__construct( absint( $this->id ) );
141
-
142
-		if ( ! empty( $this->last_error ) ) {
143
-			$this->set_id( 0 );
144
-		}
145
-
146
-	}
147
-
148
-	/**
149
-	 * When the object is cloned, make sure meta is duplicated correctly.
150
-	 *
151
-	 * @since 1.0.19
152
-	 */
153
-	public function __clone() {
154
-		$this->maybe_read_meta_data();
155
-		if ( ! empty( $this->meta_data ) ) {
156
-			foreach ( $this->meta_data as $array_key => $meta ) {
157
-				$this->meta_data[ $array_key ] = clone $meta;
158
-				if ( ! empty( $meta->id ) ) {
159
-					$this->meta_data[ $array_key ]->id = null;
160
-				}
161
-			}
162
-		}
163
-	}
164
-
165
-	/**
166
-	 * Get the data store.
167
-	 *
168
-	 * @since  1.0.19
169
-	 * @return object
170
-	 */
171
-	public function get_data_store() {
172
-		return $this->data_store;
173
-	}
174
-
175
-	/**
176
-	 * Get the object type.
177
-	 *
178
-	 * @since  1.0.19
179
-	 * @return string
180
-	 */
181
-	public function get_object_type() {
182
-		return $this->object_type;
183
-	}
184
-
185
-	/**
186
-	 * Returns the unique ID for this object.
187
-	 *
188
-	 * @since  1.0.19
189
-	 * @return int
190
-	 */
191
-	public function get_id() {
192
-		return $this->id;
193
-	}
194
-
195
-	/**
196
-	 * Get form status.
197
-	 *
198
-	 * @since 1.0.19
199
-	 * @param  string $context View or edit context.
200
-	 * @return string
201
-	 */
202
-	public function get_status( $context = 'view' ) {
203
-		return $this->get_prop( 'status', $context );
204
-    }
205
-
206
-	/**
207
-	 * Delete an object, set the ID to 0, and return result.
208
-	 *
209
-	 * @since  1.0.19
210
-	 * @param  bool $force_delete Should the data be deleted permanently.
211
-	 * @return bool result
212
-	 */
213
-	public function delete( $force_delete = false ) {
214
-		if ( $this->data_store && $this->exists() ) {
215
-			$this->data_store->delete( $this, array( 'force_delete' => $force_delete ) );
216
-			$this->set_id( 0 );
217
-			return true;
218
-		}
219
-		return false;
220
-	}
221
-
222
-	/**
223
-	 * Save should create or update based on object existence.
224
-	 *
225
-	 * @since  1.0.19
226
-	 * @return int
227
-	 */
228
-	public function save() {
229
-		if ( ! $this->data_store ) {
230
-			return $this->get_id();
231
-		}
232
-
233
-		/**
234
-		 * Trigger action before saving to the DB. Allows you to adjust object props before save.
235
-		 *
236
-		 * @param GetPaid_Data          $this The object being saved.
237
-		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
238
-		 */
239
-		do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store );
240
-
241
-		if ( $this->get_id() ) {
242
-			$this->data_store->update( $this );
243
-		} else {
244
-			$this->data_store->create( $this );
245
-		}
246
-
247
-		/**
248
-		 * Trigger action after saving to the DB.
249
-		 *
250
-		 * @param GetPaid_Data          $this The object being saved.
251
-		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
252
-		 */
253
-		do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store );
254
-
255
-		return $this->get_id();
256
-	}
257
-
258
-	/**
259
-	 * Change data to JSON format.
260
-	 *
261
-	 * @since  1.0.19
262
-	 * @return string Data in JSON format.
263
-	 */
264
-	public function __toString() {
265
-		return wp_json_encode( $this->get_data() );
266
-	}
267
-
268
-	/**
269
-	 * Returns all data for this object.
270
-	 *
271
-	 * @since  1.0.19
272
-	 * @return array
273
-	 */
274
-	public function get_data() {
275
-		return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) );
276
-	}
277
-
278
-	/**
279
-	 * Returns array of expected data keys for this object.
280
-	 *
281
-	 * @since   1.0.19
282
-	 * @return array
283
-	 */
284
-	public function get_data_keys() {
285
-		return array_keys( $this->data );
286
-	}
287
-
288
-	/**
289
-	 * Returns all "extra" data keys for an object (for sub objects like item types).
290
-	 *
291
-	 * @since  1.0.19
292
-	 * @return array
293
-	 */
294
-	public function get_extra_data_keys() {
295
-		return array_keys( $this->extra_data );
296
-	}
297
-
298
-	/**
299
-	 * Filter null meta values from array.
300
-	 *
301
-	 * @since  1.0.19
302
-	 * @param mixed $meta Meta value to check.
303
-	 * @return bool
304
-	 */
305
-	protected function filter_null_meta( $meta ) {
306
-		return ! is_null( $meta->value );
307
-	}
308
-
309
-	/**
310
-	 * Get All Meta Data.
311
-	 *
312
-	 * @since 1.0.19
313
-	 * @return array of objects.
314
-	 */
315
-	public function get_meta_data() {
316
-		$this->maybe_read_meta_data();
317
-		return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) );
318
-	}
319
-
320
-	/**
321
-	 * Check if the key is an internal one.
322
-	 *
323
-	 * @since  1.0.19
324
-	 * @param  string $key Key to check.
325
-	 * @return bool   true if it's an internal key, false otherwise
326
-	 */
327
-	protected function is_internal_meta_key( $key ) {
328
-		$internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true );
329
-
330
-		if ( ! $internal_meta_key ) {
331
-			return false;
332
-		}
333
-
334
-		$has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) );
335
-
336
-		if ( ! $has_setter_or_getter ) {
337
-			return false;
338
-		}
339
-
340
-		/* translators: %s: $key Key to check */
341
-		getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'invoicing' ), $key ), '1.0.19' );
342
-
343
-		return true;
344
-	}
345
-
346
-	/**
347
-	 * Magic method for setting data fields.
348
-	 *
349
-	 * This method does not update custom fields in the database.
350
-	 *
351
-	 * @since 1.0.19
352
-	 * @access public
353
-	 *
354
-	 */
355
-	public function __set( $key, $value ) {
356
-
357
-		if ( 'id' == strtolower( $key ) ) {
358
-			return $this->set_id( $value );
359
-		}
360
-
361
-		if ( method_exists( $this, "set_$key") ) {
362
-
363
-			/* translators: %s: $key Key to set */
364
-			getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' );
365
-
366
-			call_user_func( array( $this, "set_$key" ), $value );
367
-		} else {
368
-			$this->set_prop( $key, $value );
369
-		}
370
-
371
-	}
372
-
373
-	/**
24
+    /**
25
+     * ID for this object.
26
+     *
27
+     * @since 1.0.19
28
+     * @var int
29
+     */
30
+    protected $id = 0;
31
+
32
+    /**
33
+     * Core data for this object. Name value pairs (name + default value).
34
+     *
35
+     * @since 1.0.19
36
+     * @var array
37
+     */
38
+    protected $data = array();
39
+
40
+    /**
41
+     * Core data changes for this object.
42
+     *
43
+     * @since 1.0.19
44
+     * @var array
45
+     */
46
+    protected $changes = array();
47
+
48
+    /**
49
+     * This is false until the object is read from the DB.
50
+     *
51
+     * @since 1.0.19
52
+     * @var bool
53
+     */
54
+    protected $object_read = false;
55
+
56
+    /**
57
+     * This is the name of this object type.
58
+     *
59
+     * @since 1.0.19
60
+     * @var string
61
+     */
62
+    protected $object_type = 'data';
63
+
64
+    /**
65
+     * Extra data for this object. Name value pairs (name + default value).
66
+     * Used as a standard way for sub classes (like item types) to add
67
+     * additional information to an inherited class.
68
+     *
69
+     * @since 1.0.19
70
+     * @var array
71
+     */
72
+    protected $extra_data = array();
73
+
74
+    /**
75
+     * Set to _data on construct so we can track and reset data if needed.
76
+     *
77
+     * @since 1.0.19
78
+     * @var array
79
+     */
80
+    protected $default_data = array();
81
+
82
+    /**
83
+     * Contains a reference to the data store for this class.
84
+     *
85
+     * @since 1.0.19
86
+     * @var GetPaid_Data_Store
87
+     */
88
+    protected $data_store;
89
+
90
+    /**
91
+     * Stores meta in cache for future reads.
92
+     * A group must be set to to enable caching.
93
+     *
94
+     * @since 1.0.19
95
+     * @var string
96
+     */
97
+    protected $cache_group = '';
98
+
99
+    /**
100
+     * Stores the last error.
101
+     *
102
+     * @since 1.0.19
103
+     * @var string
104
+     */
105
+    public $last_error = '';
106
+
107
+    /**
108
+     * Stores additional meta data.
109
+     *
110
+     * @since 1.0.19
111
+     * @var array
112
+     */
113
+    protected $meta_data = null;
114
+
115
+    /**
116
+     * Default constructor.
117
+     *
118
+     * @param int|object|array|string $read ID to load from the DB (optional) or already queried data.
119
+     */
120
+    public function __construct( $read = 0 ) {
121
+        $this->data         = array_merge( $this->data, $this->extra_data );
122
+        $this->default_data = $this->data;
123
+    }
124
+
125
+    /**
126
+     * Only store the object ID to avoid serializing the data object instance.
127
+     *
128
+     * @return array
129
+     */
130
+    public function __sleep() {
131
+        return array( 'id' );
132
+    }
133
+
134
+    /**
135
+     * Re-run the constructor with the object ID.
136
+     *
137
+     * If the object no longer exists, remove the ID.
138
+     */
139
+    public function __wakeup() {
140
+        $this->__construct( absint( $this->id ) );
141
+
142
+        if ( ! empty( $this->last_error ) ) {
143
+            $this->set_id( 0 );
144
+        }
145
+
146
+    }
147
+
148
+    /**
149
+     * When the object is cloned, make sure meta is duplicated correctly.
150
+     *
151
+     * @since 1.0.19
152
+     */
153
+    public function __clone() {
154
+        $this->maybe_read_meta_data();
155
+        if ( ! empty( $this->meta_data ) ) {
156
+            foreach ( $this->meta_data as $array_key => $meta ) {
157
+                $this->meta_data[ $array_key ] = clone $meta;
158
+                if ( ! empty( $meta->id ) ) {
159
+                    $this->meta_data[ $array_key ]->id = null;
160
+                }
161
+            }
162
+        }
163
+    }
164
+
165
+    /**
166
+     * Get the data store.
167
+     *
168
+     * @since  1.0.19
169
+     * @return object
170
+     */
171
+    public function get_data_store() {
172
+        return $this->data_store;
173
+    }
174
+
175
+    /**
176
+     * Get the object type.
177
+     *
178
+     * @since  1.0.19
179
+     * @return string
180
+     */
181
+    public function get_object_type() {
182
+        return $this->object_type;
183
+    }
184
+
185
+    /**
186
+     * Returns the unique ID for this object.
187
+     *
188
+     * @since  1.0.19
189
+     * @return int
190
+     */
191
+    public function get_id() {
192
+        return $this->id;
193
+    }
194
+
195
+    /**
196
+     * Get form status.
197
+     *
198
+     * @since 1.0.19
199
+     * @param  string $context View or edit context.
200
+     * @return string
201
+     */
202
+    public function get_status( $context = 'view' ) {
203
+        return $this->get_prop( 'status', $context );
204
+    }
205
+
206
+    /**
207
+     * Delete an object, set the ID to 0, and return result.
208
+     *
209
+     * @since  1.0.19
210
+     * @param  bool $force_delete Should the data be deleted permanently.
211
+     * @return bool result
212
+     */
213
+    public function delete( $force_delete = false ) {
214
+        if ( $this->data_store && $this->exists() ) {
215
+            $this->data_store->delete( $this, array( 'force_delete' => $force_delete ) );
216
+            $this->set_id( 0 );
217
+            return true;
218
+        }
219
+        return false;
220
+    }
221
+
222
+    /**
223
+     * Save should create or update based on object existence.
224
+     *
225
+     * @since  1.0.19
226
+     * @return int
227
+     */
228
+    public function save() {
229
+        if ( ! $this->data_store ) {
230
+            return $this->get_id();
231
+        }
232
+
233
+        /**
234
+         * Trigger action before saving to the DB. Allows you to adjust object props before save.
235
+         *
236
+         * @param GetPaid_Data          $this The object being saved.
237
+         * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
238
+         */
239
+        do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store );
240
+
241
+        if ( $this->get_id() ) {
242
+            $this->data_store->update( $this );
243
+        } else {
244
+            $this->data_store->create( $this );
245
+        }
246
+
247
+        /**
248
+         * Trigger action after saving to the DB.
249
+         *
250
+         * @param GetPaid_Data          $this The object being saved.
251
+         * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
252
+         */
253
+        do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store );
254
+
255
+        return $this->get_id();
256
+    }
257
+
258
+    /**
259
+     * Change data to JSON format.
260
+     *
261
+     * @since  1.0.19
262
+     * @return string Data in JSON format.
263
+     */
264
+    public function __toString() {
265
+        return wp_json_encode( $this->get_data() );
266
+    }
267
+
268
+    /**
269
+     * Returns all data for this object.
270
+     *
271
+     * @since  1.0.19
272
+     * @return array
273
+     */
274
+    public function get_data() {
275
+        return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) );
276
+    }
277
+
278
+    /**
279
+     * Returns array of expected data keys for this object.
280
+     *
281
+     * @since   1.0.19
282
+     * @return array
283
+     */
284
+    public function get_data_keys() {
285
+        return array_keys( $this->data );
286
+    }
287
+
288
+    /**
289
+     * Returns all "extra" data keys for an object (for sub objects like item types).
290
+     *
291
+     * @since  1.0.19
292
+     * @return array
293
+     */
294
+    public function get_extra_data_keys() {
295
+        return array_keys( $this->extra_data );
296
+    }
297
+
298
+    /**
299
+     * Filter null meta values from array.
300
+     *
301
+     * @since  1.0.19
302
+     * @param mixed $meta Meta value to check.
303
+     * @return bool
304
+     */
305
+    protected function filter_null_meta( $meta ) {
306
+        return ! is_null( $meta->value );
307
+    }
308
+
309
+    /**
310
+     * Get All Meta Data.
311
+     *
312
+     * @since 1.0.19
313
+     * @return array of objects.
314
+     */
315
+    public function get_meta_data() {
316
+        $this->maybe_read_meta_data();
317
+        return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) );
318
+    }
319
+
320
+    /**
321
+     * Check if the key is an internal one.
322
+     *
323
+     * @since  1.0.19
324
+     * @param  string $key Key to check.
325
+     * @return bool   true if it's an internal key, false otherwise
326
+     */
327
+    protected function is_internal_meta_key( $key ) {
328
+        $internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true );
329
+
330
+        if ( ! $internal_meta_key ) {
331
+            return false;
332
+        }
333
+
334
+        $has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) );
335
+
336
+        if ( ! $has_setter_or_getter ) {
337
+            return false;
338
+        }
339
+
340
+        /* translators: %s: $key Key to check */
341
+        getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'invoicing' ), $key ), '1.0.19' );
342
+
343
+        return true;
344
+    }
345
+
346
+    /**
347
+     * Magic method for setting data fields.
348
+     *
349
+     * This method does not update custom fields in the database.
350
+     *
351
+     * @since 1.0.19
352
+     * @access public
353
+     *
354
+     */
355
+    public function __set( $key, $value ) {
356
+
357
+        if ( 'id' == strtolower( $key ) ) {
358
+            return $this->set_id( $value );
359
+        }
360
+
361
+        if ( method_exists( $this, "set_$key") ) {
362
+
363
+            /* translators: %s: $key Key to set */
364
+            getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' );
365
+
366
+            call_user_func( array( $this, "set_$key" ), $value );
367
+        } else {
368
+            $this->set_prop( $key, $value );
369
+        }
370
+
371
+    }
372
+
373
+    /**
374 374
      * Margic method for retrieving a property.
375 375
      */
376 376
     public function __get( $key ) {
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
         // Check if we have a helper method for that.
379 379
         if ( method_exists( $this, 'get_' . $key ) ) {
380 380
 
381
-			if ( 'post_type' != $key ) {
382
-				/* translators: %s: $key Key to set */
383
-				getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' );
384
-			}
381
+            if ( 'post_type' != $key ) {
382
+                /* translators: %s: $key Key to set */
383
+                getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' );
384
+            }
385 385
 
386 386
             return call_user_func( array( $this, 'get_' . $key ) );
387 387
         }
@@ -391,515 +391,515 @@  discard block
 block discarded – undo
391 391
             return $this->post->$key;
392 392
         }
393 393
 
394
-		return $this->get_prop( $key );
395
-
396
-    }
397
-
398
-	/**
399
-	 * Get Meta Data by Key.
400
-	 *
401
-	 * @since  1.0.19
402
-	 * @param  string $key Meta Key.
403
-	 * @param  bool   $single return first found meta with key, or all with $key.
404
-	 * @param  string $context What the value is for. Valid values are view and edit.
405
-	 * @return mixed
406
-	 */
407
-	public function get_meta( $key = '', $single = true, $context = 'view' ) {
408
-
409
-		// Check if this is an internal meta key.
410
-		$_key = str_replace( '_wpinv', '', $key );
411
-		$_key = str_replace( 'wpinv', '', $_key );
412
-		if ( $this->is_internal_meta_key( $key ) ) {
413
-			$function = 'get_' . $_key;
414
-
415
-			if ( is_callable( array( $this, $function ) ) ) {
416
-				return $this->{$function}();
417
-			}
418
-		}
419
-
420
-		// Read the meta data if not yet read.
421
-		$this->maybe_read_meta_data();
422
-		$meta_data  = $this->get_meta_data();
423
-		$array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true );
424
-		$value      = $single ? '' : array();
425
-
426
-		if ( ! empty( $array_keys ) ) {
427
-			// We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()).
428
-			if ( $single ) {
429
-				$value = $meta_data[ current( $array_keys ) ]->value;
430
-			} else {
431
-				$value = array_intersect_key( $meta_data, array_flip( $array_keys ) );
432
-			}
433
-		}
434
-
435
-		if ( 'view' === $context ) {
436
-			$value = apply_filters( $this->get_hook_prefix() . $key, $value, $this );
437
-		}
438
-
439
-		return $value;
440
-	}
441
-
442
-	/**
443
-	 * See if meta data exists, since get_meta always returns a '' or array().
444
-	 *
445
-	 * @since  1.0.19
446
-	 * @param  string $key Meta Key.
447
-	 * @return boolean
448
-	 */
449
-	public function meta_exists( $key = '' ) {
450
-		$this->maybe_read_meta_data();
451
-		$array_keys = wp_list_pluck( $this->get_meta_data(), 'key' );
452
-		return in_array( $key, $array_keys, true );
453
-	}
454
-
455
-	/**
456
-	 * Set all meta data from array.
457
-	 *
458
-	 * @since 1.0.19
459
-	 * @param array $data Key/Value pairs.
460
-	 */
461
-	public function set_meta_data( $data ) {
462
-		if ( ! empty( $data ) && is_array( $data ) ) {
463
-			$this->maybe_read_meta_data();
464
-			foreach ( $data as $meta ) {
465
-				$meta = (array) $meta;
466
-				if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) {
467
-					$this->meta_data[] = new GetPaid_Meta_Data(
468
-						array(
469
-							'id'    => $meta['id'],
470
-							'key'   => $meta['key'],
471
-							'value' => $meta['value'],
472
-						)
473
-					);
474
-				}
475
-			}
476
-		}
477
-	}
478
-
479
-	/**
480
-	 * Add meta data.
481
-	 *
482
-	 * @since 1.0.19
483
-	 *
484
-	 * @param string       $key Meta key.
485
-	 * @param string|array $value Meta value.
486
-	 * @param bool         $unique Should this be a unique key?.
487
-	 */
488
-	public function add_meta_data( $key, $value, $unique = false ) {
489
-		if ( $this->is_internal_meta_key( $key ) ) {
490
-			$function = 'set_' . $key;
491
-
492
-			if ( is_callable( array( $this, $function ) ) ) {
493
-				return $this->{$function}( $value );
494
-			}
495
-		}
496
-
497
-		$this->maybe_read_meta_data();
498
-		if ( $unique ) {
499
-			$this->delete_meta_data( $key );
500
-		}
501
-		$this->meta_data[] = new GetPaid_Meta_Data(
502
-			array(
503
-				'key'   => $key,
504
-				'value' => $value,
505
-			)
506
-		);
507
-
508
-		$this->save();
509
-	}
510
-
511
-	/**
512
-	 * Update meta data by key or ID, if provided.
513
-	 *
514
-	 * @since  1.0.19
515
-	 *
516
-	 * @param  string       $key Meta key.
517
-	 * @param  string|array $value Meta value.
518
-	 * @param  int          $meta_id Meta ID.
519
-	 */
520
-	public function update_meta_data( $key, $value, $meta_id = 0 ) {
521
-		if ( $this->is_internal_meta_key( $key ) ) {
522
-			$function = 'set_' . $key;
523
-
524
-			if ( is_callable( array( $this, $function ) ) ) {
525
-				return $this->{$function}( $value );
526
-			}
527
-		}
528
-
529
-		$this->maybe_read_meta_data();
530
-
531
-		$array_key = false;
532
-
533
-		if ( $meta_id ) {
534
-			$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true );
535
-			$array_key  = $array_keys ? current( $array_keys ) : false;
536
-		} else {
537
-			// Find matches by key.
538
-			$matches = array();
539
-			foreach ( $this->meta_data as $meta_data_array_key => $meta ) {
540
-				if ( $meta->key === $key ) {
541
-					$matches[] = $meta_data_array_key;
542
-				}
543
-			}
544
-
545
-			if ( ! empty( $matches ) ) {
546
-				// Set matches to null so only one key gets the new value.
547
-				foreach ( $matches as $meta_data_array_key ) {
548
-					$this->meta_data[ $meta_data_array_key ]->value = null;
549
-				}
550
-				$array_key = current( $matches );
551
-			}
552
-		}
553
-
554
-		if ( false !== $array_key ) {
555
-			$meta        = $this->meta_data[ $array_key ];
556
-			$meta->key   = $key;
557
-			$meta->value = $value;
558
-		} else {
559
-			$this->add_meta_data( $key, $value, true );
560
-		}
561
-	}
562
-
563
-	/**
564
-	 * Delete meta data.
565
-	 *
566
-	 * @since 1.0.19
567
-	 * @param string $key Meta key.
568
-	 */
569
-	public function delete_meta_data( $key ) {
570
-		$this->maybe_read_meta_data();
571
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true );
572
-
573
-		if ( $array_keys ) {
574
-			foreach ( $array_keys as $array_key ) {
575
-				$this->meta_data[ $array_key ]->value = null;
576
-			}
577
-		}
578
-	}
579
-
580
-	/**
581
-	 * Delete meta data.
582
-	 *
583
-	 * @since 1.0.19
584
-	 * @param int $mid Meta ID.
585
-	 */
586
-	public function delete_meta_data_by_mid( $mid ) {
587
-		$this->maybe_read_meta_data();
588
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true );
589
-
590
-		if ( $array_keys ) {
591
-			foreach ( $array_keys as $array_key ) {
592
-				$this->meta_data[ $array_key ]->value = null;
593
-			}
594
-		}
595
-	}
596
-
597
-	/**
598
-	 * Read meta data if null.
599
-	 *
600
-	 * @since 1.0.19
601
-	 */
602
-	protected function maybe_read_meta_data() {
603
-		if ( is_null( $this->meta_data ) ) {
604
-			$this->read_meta_data();
605
-		}
606
-	}
607
-
608
-	/**
609
-	 * Read Meta Data from the database. Ignore any internal properties.
610
-	 * Uses it's own caches because get_metadata does not provide meta_ids.
611
-	 *
612
-	 * @since 1.0.19
613
-	 * @param bool $force_read True to force a new DB read (and update cache).
614
-	 */
615
-	public function read_meta_data( $force_read = false ) {
616
-
617
-		// Reset meta data.
618
-		$this->meta_data = array();
619
-
620
-		// Maybe abort early.
621
-		if ( ! $this->get_id() || ! $this->data_store ) {
622
-			return;
623
-		}
624
-
625
-		// Only read from cache if the cache key is set.
626
-		$cache_key = null;
627
-		if ( ! $force_read && ! empty( $this->cache_group ) ) {
628
-			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
629
-			$raw_meta_data = wp_cache_get( $cache_key, $this->cache_group );
630
-		}
631
-
632
-		// Should we force read?
633
-		if ( empty( $raw_meta_data ) ) {
634
-			$raw_meta_data = $this->data_store->read_meta( $this );
635
-
636
-			if ( ! empty( $cache_key ) ) {
637
-				wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
638
-			}
639
-
640
-		}
641
-
642
-		// Set meta data.
643
-		if ( is_array( $raw_meta_data ) ) {
644
-
645
-			foreach ( $raw_meta_data as $meta ) {
646
-				$this->meta_data[] = new GetPaid_Meta_Data(
647
-					array(
648
-						'id'    => (int) $meta->meta_id,
649
-						'key'   => $meta->meta_key,
650
-						'value' => maybe_unserialize( $meta->meta_value ),
651
-					)
652
-				);
653
-			}
654
-
655
-		}
656
-
657
-	}
658
-
659
-	/**
660
-	 * Update Meta Data in the database.
661
-	 *
662
-	 * @since 1.0.19
663
-	 */
664
-	public function save_meta_data() {
665
-		if ( ! $this->data_store || is_null( $this->meta_data ) ) {
666
-			return;
667
-		}
668
-		foreach ( $this->meta_data as $array_key => $meta ) {
669
-			if ( is_null( $meta->value ) ) {
670
-				if ( ! empty( $meta->id ) ) {
671
-					$this->data_store->delete_meta( $this, $meta );
672
-					unset( $this->meta_data[ $array_key ] );
673
-				}
674
-			} elseif ( empty( $meta->id ) ) {
675
-				$meta->id = $this->data_store->add_meta( $this, $meta );
676
-				$meta->apply_changes();
677
-			} else {
678
-				if ( $meta->get_changes() ) {
679
-					$this->data_store->update_meta( $this, $meta );
680
-					$meta->apply_changes();
681
-				}
682
-			}
683
-		}
684
-		if ( ! empty( $this->cache_group ) ) {
685
-			$cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
686
-			wp_cache_delete( $cache_key, $this->cache_group );
687
-		}
688
-	}
689
-
690
-	/**
691
-	 * Set ID.
692
-	 *
693
-	 * @since 1.0.19
694
-	 * @param int $id ID.
695
-	 */
696
-	public function set_id( $id ) {
697
-		$this->id = absint( $id );
698
-	}
699
-
700
-	/**
701
-	 * Sets item status.
702
-	 *
703
-	 * @since 1.0.19
704
-	 * @param string $status New status.
705
-	 * @return array details of change.
706
-	 */
707
-	public function set_status( $status ) {
394
+        return $this->get_prop( $key );
395
+
396
+    }
397
+
398
+    /**
399
+     * Get Meta Data by Key.
400
+     *
401
+     * @since  1.0.19
402
+     * @param  string $key Meta Key.
403
+     * @param  bool   $single return first found meta with key, or all with $key.
404
+     * @param  string $context What the value is for. Valid values are view and edit.
405
+     * @return mixed
406
+     */
407
+    public function get_meta( $key = '', $single = true, $context = 'view' ) {
408
+
409
+        // Check if this is an internal meta key.
410
+        $_key = str_replace( '_wpinv', '', $key );
411
+        $_key = str_replace( 'wpinv', '', $_key );
412
+        if ( $this->is_internal_meta_key( $key ) ) {
413
+            $function = 'get_' . $_key;
414
+
415
+            if ( is_callable( array( $this, $function ) ) ) {
416
+                return $this->{$function}();
417
+            }
418
+        }
419
+
420
+        // Read the meta data if not yet read.
421
+        $this->maybe_read_meta_data();
422
+        $meta_data  = $this->get_meta_data();
423
+        $array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true );
424
+        $value      = $single ? '' : array();
425
+
426
+        if ( ! empty( $array_keys ) ) {
427
+            // We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()).
428
+            if ( $single ) {
429
+                $value = $meta_data[ current( $array_keys ) ]->value;
430
+            } else {
431
+                $value = array_intersect_key( $meta_data, array_flip( $array_keys ) );
432
+            }
433
+        }
434
+
435
+        if ( 'view' === $context ) {
436
+            $value = apply_filters( $this->get_hook_prefix() . $key, $value, $this );
437
+        }
438
+
439
+        return $value;
440
+    }
441
+
442
+    /**
443
+     * See if meta data exists, since get_meta always returns a '' or array().
444
+     *
445
+     * @since  1.0.19
446
+     * @param  string $key Meta Key.
447
+     * @return boolean
448
+     */
449
+    public function meta_exists( $key = '' ) {
450
+        $this->maybe_read_meta_data();
451
+        $array_keys = wp_list_pluck( $this->get_meta_data(), 'key' );
452
+        return in_array( $key, $array_keys, true );
453
+    }
454
+
455
+    /**
456
+     * Set all meta data from array.
457
+     *
458
+     * @since 1.0.19
459
+     * @param array $data Key/Value pairs.
460
+     */
461
+    public function set_meta_data( $data ) {
462
+        if ( ! empty( $data ) && is_array( $data ) ) {
463
+            $this->maybe_read_meta_data();
464
+            foreach ( $data as $meta ) {
465
+                $meta = (array) $meta;
466
+                if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) {
467
+                    $this->meta_data[] = new GetPaid_Meta_Data(
468
+                        array(
469
+                            'id'    => $meta['id'],
470
+                            'key'   => $meta['key'],
471
+                            'value' => $meta['value'],
472
+                        )
473
+                    );
474
+                }
475
+            }
476
+        }
477
+    }
478
+
479
+    /**
480
+     * Add meta data.
481
+     *
482
+     * @since 1.0.19
483
+     *
484
+     * @param string       $key Meta key.
485
+     * @param string|array $value Meta value.
486
+     * @param bool         $unique Should this be a unique key?.
487
+     */
488
+    public function add_meta_data( $key, $value, $unique = false ) {
489
+        if ( $this->is_internal_meta_key( $key ) ) {
490
+            $function = 'set_' . $key;
491
+
492
+            if ( is_callable( array( $this, $function ) ) ) {
493
+                return $this->{$function}( $value );
494
+            }
495
+        }
496
+
497
+        $this->maybe_read_meta_data();
498
+        if ( $unique ) {
499
+            $this->delete_meta_data( $key );
500
+        }
501
+        $this->meta_data[] = new GetPaid_Meta_Data(
502
+            array(
503
+                'key'   => $key,
504
+                'value' => $value,
505
+            )
506
+        );
507
+
508
+        $this->save();
509
+    }
510
+
511
+    /**
512
+     * Update meta data by key or ID, if provided.
513
+     *
514
+     * @since  1.0.19
515
+     *
516
+     * @param  string       $key Meta key.
517
+     * @param  string|array $value Meta value.
518
+     * @param  int          $meta_id Meta ID.
519
+     */
520
+    public function update_meta_data( $key, $value, $meta_id = 0 ) {
521
+        if ( $this->is_internal_meta_key( $key ) ) {
522
+            $function = 'set_' . $key;
523
+
524
+            if ( is_callable( array( $this, $function ) ) ) {
525
+                return $this->{$function}( $value );
526
+            }
527
+        }
528
+
529
+        $this->maybe_read_meta_data();
530
+
531
+        $array_key = false;
532
+
533
+        if ( $meta_id ) {
534
+            $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true );
535
+            $array_key  = $array_keys ? current( $array_keys ) : false;
536
+        } else {
537
+            // Find matches by key.
538
+            $matches = array();
539
+            foreach ( $this->meta_data as $meta_data_array_key => $meta ) {
540
+                if ( $meta->key === $key ) {
541
+                    $matches[] = $meta_data_array_key;
542
+                }
543
+            }
544
+
545
+            if ( ! empty( $matches ) ) {
546
+                // Set matches to null so only one key gets the new value.
547
+                foreach ( $matches as $meta_data_array_key ) {
548
+                    $this->meta_data[ $meta_data_array_key ]->value = null;
549
+                }
550
+                $array_key = current( $matches );
551
+            }
552
+        }
553
+
554
+        if ( false !== $array_key ) {
555
+            $meta        = $this->meta_data[ $array_key ];
556
+            $meta->key   = $key;
557
+            $meta->value = $value;
558
+        } else {
559
+            $this->add_meta_data( $key, $value, true );
560
+        }
561
+    }
562
+
563
+    /**
564
+     * Delete meta data.
565
+     *
566
+     * @since 1.0.19
567
+     * @param string $key Meta key.
568
+     */
569
+    public function delete_meta_data( $key ) {
570
+        $this->maybe_read_meta_data();
571
+        $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true );
572
+
573
+        if ( $array_keys ) {
574
+            foreach ( $array_keys as $array_key ) {
575
+                $this->meta_data[ $array_key ]->value = null;
576
+            }
577
+        }
578
+    }
579
+
580
+    /**
581
+     * Delete meta data.
582
+     *
583
+     * @since 1.0.19
584
+     * @param int $mid Meta ID.
585
+     */
586
+    public function delete_meta_data_by_mid( $mid ) {
587
+        $this->maybe_read_meta_data();
588
+        $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true );
589
+
590
+        if ( $array_keys ) {
591
+            foreach ( $array_keys as $array_key ) {
592
+                $this->meta_data[ $array_key ]->value = null;
593
+            }
594
+        }
595
+    }
596
+
597
+    /**
598
+     * Read meta data if null.
599
+     *
600
+     * @since 1.0.19
601
+     */
602
+    protected function maybe_read_meta_data() {
603
+        if ( is_null( $this->meta_data ) ) {
604
+            $this->read_meta_data();
605
+        }
606
+    }
607
+
608
+    /**
609
+     * Read Meta Data from the database. Ignore any internal properties.
610
+     * Uses it's own caches because get_metadata does not provide meta_ids.
611
+     *
612
+     * @since 1.0.19
613
+     * @param bool $force_read True to force a new DB read (and update cache).
614
+     */
615
+    public function read_meta_data( $force_read = false ) {
616
+
617
+        // Reset meta data.
618
+        $this->meta_data = array();
619
+
620
+        // Maybe abort early.
621
+        if ( ! $this->get_id() || ! $this->data_store ) {
622
+            return;
623
+        }
624
+
625
+        // Only read from cache if the cache key is set.
626
+        $cache_key = null;
627
+        if ( ! $force_read && ! empty( $this->cache_group ) ) {
628
+            $cache_key     = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
629
+            $raw_meta_data = wp_cache_get( $cache_key, $this->cache_group );
630
+        }
631
+
632
+        // Should we force read?
633
+        if ( empty( $raw_meta_data ) ) {
634
+            $raw_meta_data = $this->data_store->read_meta( $this );
635
+
636
+            if ( ! empty( $cache_key ) ) {
637
+                wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
638
+            }
639
+
640
+        }
641
+
642
+        // Set meta data.
643
+        if ( is_array( $raw_meta_data ) ) {
644
+
645
+            foreach ( $raw_meta_data as $meta ) {
646
+                $this->meta_data[] = new GetPaid_Meta_Data(
647
+                    array(
648
+                        'id'    => (int) $meta->meta_id,
649
+                        'key'   => $meta->meta_key,
650
+                        'value' => maybe_unserialize( $meta->meta_value ),
651
+                    )
652
+                );
653
+            }
654
+
655
+        }
656
+
657
+    }
658
+
659
+    /**
660
+     * Update Meta Data in the database.
661
+     *
662
+     * @since 1.0.19
663
+     */
664
+    public function save_meta_data() {
665
+        if ( ! $this->data_store || is_null( $this->meta_data ) ) {
666
+            return;
667
+        }
668
+        foreach ( $this->meta_data as $array_key => $meta ) {
669
+            if ( is_null( $meta->value ) ) {
670
+                if ( ! empty( $meta->id ) ) {
671
+                    $this->data_store->delete_meta( $this, $meta );
672
+                    unset( $this->meta_data[ $array_key ] );
673
+                }
674
+            } elseif ( empty( $meta->id ) ) {
675
+                $meta->id = $this->data_store->add_meta( $this, $meta );
676
+                $meta->apply_changes();
677
+            } else {
678
+                if ( $meta->get_changes() ) {
679
+                    $this->data_store->update_meta( $this, $meta );
680
+                    $meta->apply_changes();
681
+                }
682
+            }
683
+        }
684
+        if ( ! empty( $this->cache_group ) ) {
685
+            $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
686
+            wp_cache_delete( $cache_key, $this->cache_group );
687
+        }
688
+    }
689
+
690
+    /**
691
+     * Set ID.
692
+     *
693
+     * @since 1.0.19
694
+     * @param int $id ID.
695
+     */
696
+    public function set_id( $id ) {
697
+        $this->id = absint( $id );
698
+    }
699
+
700
+    /**
701
+     * Sets item status.
702
+     *
703
+     * @since 1.0.19
704
+     * @param string $status New status.
705
+     * @return array details of change.
706
+     */
707
+    public function set_status( $status ) {
708 708
         $old_status = $this->get_status();
709 709
 
710
-		$this->set_prop( 'status', $status );
711
-
712
-		return array(
713
-			'from' => $old_status,
714
-			'to'   => $status,
715
-		);
716
-    }
717
-
718
-	/**
719
-	 * Set all props to default values.
720
-	 *
721
-	 * @since 1.0.19
722
-	 */
723
-	public function set_defaults() {
724
-		$this->data    = $this->default_data;
725
-		$this->changes = array();
726
-		$this->set_object_read( false );
727
-	}
728
-
729
-	/**
730
-	 * Set object read property.
731
-	 *
732
-	 * @since 1.0.19
733
-	 * @param boolean $read Should read?.
734
-	 */
735
-	public function set_object_read( $read = true ) {
736
-		$this->object_read = (bool) $read;
737
-	}
738
-
739
-	/**
740
-	 * Get object read property.
741
-	 *
742
-	 * @since  1.0.19
743
-	 * @return boolean
744
-	 */
745
-	public function get_object_read() {
746
-		return (bool) $this->object_read;
747
-	}
748
-
749
-	/**
750
-	 * Set a collection of props in one go, collect any errors, and return the result.
751
-	 * Only sets using public methods.
752
-	 *
753
-	 * @since  1.0.19
754
-	 *
755
-	 * @param array  $props Key value pairs to set. Key is the prop and should map to a setter function name.
756
-	 * @param string $context In what context to run this.
757
-	 *
758
-	 * @return bool|WP_Error
759
-	 */
760
-	public function set_props( $props, $context = 'set' ) {
761
-		$errors = false;
762
-
763
-		$props = wp_unslash( $props );
764
-		foreach ( $props as $prop => $value ) {
765
-			try {
766
-				/**
767
-				 * Checks if the prop being set is allowed, and the value is not null.
768
-				 */
769
-				if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
770
-					continue;
771
-				}
772
-				$setter = "set_$prop";
773
-
774
-				if ( is_callable( array( $this, $setter ) ) ) {
775
-					$this->{$setter}( $value );
776
-				}
777
-			} catch ( Exception $e ) {
778
-				if ( ! $errors ) {
779
-					$errors = new WP_Error();
780
-				}
781
-				$errors->add( $e->getCode(), $e->getMessage() );
782
-				$this->last_error = $e->getMessage();
783
-			}
784
-		}
785
-
786
-		return $errors && count( $errors->get_error_codes() ) ? $errors : true;
787
-	}
788
-
789
-	/**
790
-	 * Sets a prop for a setter method.
791
-	 *
792
-	 * This stores changes in a special array so we can track what needs saving
793
-	 * the the DB later.
794
-	 *
795
-	 * @since 1.0.19
796
-	 * @param string $prop Name of prop to set.
797
-	 * @param mixed  $value Value of the prop.
798
-	 */
799
-	protected function set_prop( $prop, $value ) {
800
-		if ( array_key_exists( $prop, $this->data ) ) {
801
-			if ( true === $this->object_read ) {
802
-				if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
803
-					$this->changes[ $prop ] = $value;
804
-				}
805
-			} else {
806
-				$this->data[ $prop ] = $value;
807
-			}
808
-		}
809
-	}
810
-
811
-	/**
812
-	 * Return data changes only.
813
-	 *
814
-	 * @since 1.0.19
815
-	 * @return array
816
-	 */
817
-	public function get_changes() {
818
-		return $this->changes;
819
-	}
820
-
821
-	/**
822
-	 * Merge changes with data and clear.
823
-	 *
824
-	 * @since 1.0.19
825
-	 */
826
-	public function apply_changes() {
827
-		$this->data    = array_replace( $this->data, $this->changes );
828
-		$this->changes = array();
829
-	}
830
-
831
-	/**
832
-	 * Prefix for action and filter hooks on data.
833
-	 *
834
-	 * @since  1.0.19
835
-	 * @return string
836
-	 */
837
-	protected function get_hook_prefix() {
838
-		return 'wpinv_get_' . $this->object_type . '_';
839
-	}
840
-
841
-	/**
842
-	 * Gets a prop for a getter method.
843
-	 *
844
-	 * Gets the value from either current pending changes, or the data itself.
845
-	 * Context controls what happens to the value before it's returned.
846
-	 *
847
-	 * @since  1.0.19
848
-	 * @param  string $prop Name of prop to get.
849
-	 * @param  string $context What the value is for. Valid values are view and edit.
850
-	 * @return mixed
851
-	 */
852
-	protected function get_prop( $prop, $context = 'view' ) {
853
-		$value = null;
854
-
855
-		if ( array_key_exists( $prop, $this->data ) ) {
856
-			$value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
857
-
858
-			if ( 'view' === $context ) {
859
-				$value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
860
-			}
861
-		}
862
-
863
-		return $value;
864
-	}
865
-
866
-	/**
867
-	 * Sets a date prop whilst handling formatting and datetime objects.
868
-	 *
869
-	 * @since 1.0.19
870
-	 * @param string         $prop Name of prop to set.
871
-	 * @param string|integer $value Value of the prop.
872
-	 */
873
-	protected function set_date_prop( $prop, $value ) {
874
-
875
-		if ( empty( $value ) ) {
876
-			$this->set_prop( $prop, null );
877
-			return;
878
-		}
879
-		$this->set_prop( $prop, $value );
880
-
881
-	}
882
-
883
-	/**
884
-	 * When invalid data is found, throw an exception unless reading from the DB.
885
-	 *
886
-	 * @since 1.0.19
887
-	 * @param string $code             Error code.
888
-	 * @param string $message          Error message.
889
-	 */
890
-	protected function error( $code, $message ) {
891
-		$this->last_error = $message;
892
-	}
893
-
894
-	/**
895
-	 * Checks if the object is saved in the database
896
-	 *
897
-	 * @since 1.0.19
898
-	 * @return bool
899
-	 */
900
-	public function exists() {
901
-		$id = $this->get_id();
902
-		return ! empty( $id );
903
-	}
710
+        $this->set_prop( 'status', $status );
711
+
712
+        return array(
713
+            'from' => $old_status,
714
+            'to'   => $status,
715
+        );
716
+    }
717
+
718
+    /**
719
+     * Set all props to default values.
720
+     *
721
+     * @since 1.0.19
722
+     */
723
+    public function set_defaults() {
724
+        $this->data    = $this->default_data;
725
+        $this->changes = array();
726
+        $this->set_object_read( false );
727
+    }
728
+
729
+    /**
730
+     * Set object read property.
731
+     *
732
+     * @since 1.0.19
733
+     * @param boolean $read Should read?.
734
+     */
735
+    public function set_object_read( $read = true ) {
736
+        $this->object_read = (bool) $read;
737
+    }
738
+
739
+    /**
740
+     * Get object read property.
741
+     *
742
+     * @since  1.0.19
743
+     * @return boolean
744
+     */
745
+    public function get_object_read() {
746
+        return (bool) $this->object_read;
747
+    }
748
+
749
+    /**
750
+     * Set a collection of props in one go, collect any errors, and return the result.
751
+     * Only sets using public methods.
752
+     *
753
+     * @since  1.0.19
754
+     *
755
+     * @param array  $props Key value pairs to set. Key is the prop and should map to a setter function name.
756
+     * @param string $context In what context to run this.
757
+     *
758
+     * @return bool|WP_Error
759
+     */
760
+    public function set_props( $props, $context = 'set' ) {
761
+        $errors = false;
762
+
763
+        $props = wp_unslash( $props );
764
+        foreach ( $props as $prop => $value ) {
765
+            try {
766
+                /**
767
+                 * Checks if the prop being set is allowed, and the value is not null.
768
+                 */
769
+                if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
770
+                    continue;
771
+                }
772
+                $setter = "set_$prop";
773
+
774
+                if ( is_callable( array( $this, $setter ) ) ) {
775
+                    $this->{$setter}( $value );
776
+                }
777
+            } catch ( Exception $e ) {
778
+                if ( ! $errors ) {
779
+                    $errors = new WP_Error();
780
+                }
781
+                $errors->add( $e->getCode(), $e->getMessage() );
782
+                $this->last_error = $e->getMessage();
783
+            }
784
+        }
785
+
786
+        return $errors && count( $errors->get_error_codes() ) ? $errors : true;
787
+    }
788
+
789
+    /**
790
+     * Sets a prop for a setter method.
791
+     *
792
+     * This stores changes in a special array so we can track what needs saving
793
+     * the the DB later.
794
+     *
795
+     * @since 1.0.19
796
+     * @param string $prop Name of prop to set.
797
+     * @param mixed  $value Value of the prop.
798
+     */
799
+    protected function set_prop( $prop, $value ) {
800
+        if ( array_key_exists( $prop, $this->data ) ) {
801
+            if ( true === $this->object_read ) {
802
+                if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
803
+                    $this->changes[ $prop ] = $value;
804
+                }
805
+            } else {
806
+                $this->data[ $prop ] = $value;
807
+            }
808
+        }
809
+    }
810
+
811
+    /**
812
+     * Return data changes only.
813
+     *
814
+     * @since 1.0.19
815
+     * @return array
816
+     */
817
+    public function get_changes() {
818
+        return $this->changes;
819
+    }
820
+
821
+    /**
822
+     * Merge changes with data and clear.
823
+     *
824
+     * @since 1.0.19
825
+     */
826
+    public function apply_changes() {
827
+        $this->data    = array_replace( $this->data, $this->changes );
828
+        $this->changes = array();
829
+    }
830
+
831
+    /**
832
+     * Prefix for action and filter hooks on data.
833
+     *
834
+     * @since  1.0.19
835
+     * @return string
836
+     */
837
+    protected function get_hook_prefix() {
838
+        return 'wpinv_get_' . $this->object_type . '_';
839
+    }
840
+
841
+    /**
842
+     * Gets a prop for a getter method.
843
+     *
844
+     * Gets the value from either current pending changes, or the data itself.
845
+     * Context controls what happens to the value before it's returned.
846
+     *
847
+     * @since  1.0.19
848
+     * @param  string $prop Name of prop to get.
849
+     * @param  string $context What the value is for. Valid values are view and edit.
850
+     * @return mixed
851
+     */
852
+    protected function get_prop( $prop, $context = 'view' ) {
853
+        $value = null;
854
+
855
+        if ( array_key_exists( $prop, $this->data ) ) {
856
+            $value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
857
+
858
+            if ( 'view' === $context ) {
859
+                $value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
860
+            }
861
+        }
862
+
863
+        return $value;
864
+    }
865
+
866
+    /**
867
+     * Sets a date prop whilst handling formatting and datetime objects.
868
+     *
869
+     * @since 1.0.19
870
+     * @param string         $prop Name of prop to set.
871
+     * @param string|integer $value Value of the prop.
872
+     */
873
+    protected function set_date_prop( $prop, $value ) {
874
+
875
+        if ( empty( $value ) ) {
876
+            $this->set_prop( $prop, null );
877
+            return;
878
+        }
879
+        $this->set_prop( $prop, $value );
880
+
881
+    }
882
+
883
+    /**
884
+     * When invalid data is found, throw an exception unless reading from the DB.
885
+     *
886
+     * @since 1.0.19
887
+     * @param string $code             Error code.
888
+     * @param string $message          Error message.
889
+     */
890
+    protected function error( $code, $message ) {
891
+        $this->last_error = $message;
892
+    }
893
+
894
+    /**
895
+     * Checks if the object is saved in the database
896
+     *
897
+     * @since 1.0.19
898
+     * @return bool
899
+     */
900
+    public function exists() {
901
+        $id = $this->get_id();
902
+        return ! empty( $id );
903
+    }
904 904
 
905 905
 }
Please login to merge, or discard this patch.
Spacing   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  *
9 9
  */
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if (!defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @param int|object|array|string $read ID to load from the DB (optional) or already queried data.
119 119
 	 */
120
-	public function __construct( $read = 0 ) {
121
-		$this->data         = array_merge( $this->data, $this->extra_data );
120
+	public function __construct($read = 0) {
121
+		$this->data         = array_merge($this->data, $this->extra_data);
122 122
 		$this->default_data = $this->data;
123 123
 	}
124 124
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @return array
129 129
 	 */
130 130
 	public function __sleep() {
131
-		return array( 'id' );
131
+		return array('id');
132 132
 	}
133 133
 
134 134
 	/**
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 	 * If the object no longer exists, remove the ID.
138 138
 	 */
139 139
 	public function __wakeup() {
140
-		$this->__construct( absint( $this->id ) );
140
+		$this->__construct(absint($this->id));
141 141
 
142
-		if ( ! empty( $this->last_error ) ) {
143
-			$this->set_id( 0 );
142
+		if (!empty($this->last_error)) {
143
+			$this->set_id(0);
144 144
 		}
145 145
 
146 146
 	}
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function __clone() {
154 154
 		$this->maybe_read_meta_data();
155
-		if ( ! empty( $this->meta_data ) ) {
156
-			foreach ( $this->meta_data as $array_key => $meta ) {
157
-				$this->meta_data[ $array_key ] = clone $meta;
158
-				if ( ! empty( $meta->id ) ) {
159
-					$this->meta_data[ $array_key ]->id = null;
155
+		if (!empty($this->meta_data)) {
156
+			foreach ($this->meta_data as $array_key => $meta) {
157
+				$this->meta_data[$array_key] = clone $meta;
158
+				if (!empty($meta->id)) {
159
+					$this->meta_data[$array_key]->id = null;
160 160
 				}
161 161
 			}
162 162
 		}
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $context View or edit context.
200 200
 	 * @return string
201 201
 	 */
202
-	public function get_status( $context = 'view' ) {
203
-		return $this->get_prop( 'status', $context );
202
+	public function get_status($context = 'view') {
203
+		return $this->get_prop('status', $context);
204 204
     }
205 205
 
206 206
 	/**
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
 	 * @param  bool $force_delete Should the data be deleted permanently.
211 211
 	 * @return bool result
212 212
 	 */
213
-	public function delete( $force_delete = false ) {
214
-		if ( $this->data_store && $this->exists() ) {
215
-			$this->data_store->delete( $this, array( 'force_delete' => $force_delete ) );
216
-			$this->set_id( 0 );
213
+	public function delete($force_delete = false) {
214
+		if ($this->data_store && $this->exists()) {
215
+			$this->data_store->delete($this, array('force_delete' => $force_delete));
216
+			$this->set_id(0);
217 217
 			return true;
218 218
 		}
219 219
 		return false;
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 * @return int
227 227
 	 */
228 228
 	public function save() {
229
-		if ( ! $this->data_store ) {
229
+		if (!$this->data_store) {
230 230
 			return $this->get_id();
231 231
 		}
232 232
 
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
 		 * @param GetPaid_Data          $this The object being saved.
237 237
 		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
238 238
 		 */
239
-		do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store );
239
+		do_action('getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store);
240 240
 
241
-		if ( $this->get_id() ) {
242
-			$this->data_store->update( $this );
241
+		if ($this->get_id()) {
242
+			$this->data_store->update($this);
243 243
 		} else {
244
-			$this->data_store->create( $this );
244
+			$this->data_store->create($this);
245 245
 		}
246 246
 
247 247
 		/**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		 * @param GetPaid_Data          $this The object being saved.
251 251
 		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
252 252
 		 */
253
-		do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store );
253
+		do_action('getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store);
254 254
 
255 255
 		return $this->get_id();
256 256
 	}
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 * @return string Data in JSON format.
263 263
 	 */
264 264
 	public function __toString() {
265
-		return wp_json_encode( $this->get_data() );
265
+		return wp_json_encode($this->get_data());
266 266
 	}
267 267
 
268 268
 	/**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @return array
273 273
 	 */
274 274
 	public function get_data() {
275
-		return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) );
275
+		return array_merge(array('id' => $this->get_id()), $this->data, array('meta_data' => $this->get_meta_data()));
276 276
 	}
277 277
 
278 278
 	/**
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @return array
283 283
 	 */
284 284
 	public function get_data_keys() {
285
-		return array_keys( $this->data );
285
+		return array_keys($this->data);
286 286
 	}
287 287
 
288 288
 	/**
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 * @return array
293 293
 	 */
294 294
 	public function get_extra_data_keys() {
295
-		return array_keys( $this->extra_data );
295
+		return array_keys($this->extra_data);
296 296
 	}
297 297
 
298 298
 	/**
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 	 * @param mixed $meta Meta value to check.
303 303
 	 * @return bool
304 304
 	 */
305
-	protected function filter_null_meta( $meta ) {
306
-		return ! is_null( $meta->value );
305
+	protected function filter_null_meta($meta) {
306
+		return !is_null($meta->value);
307 307
 	}
308 308
 
309 309
 	/**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	public function get_meta_data() {
316 316
 		$this->maybe_read_meta_data();
317
-		return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) );
317
+		return array_values(array_filter($this->meta_data, array($this, 'filter_null_meta')));
318 318
 	}
319 319
 
320 320
 	/**
@@ -324,21 +324,21 @@  discard block
 block discarded – undo
324 324
 	 * @param  string $key Key to check.
325 325
 	 * @return bool   true if it's an internal key, false otherwise
326 326
 	 */
327
-	protected function is_internal_meta_key( $key ) {
328
-		$internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true );
327
+	protected function is_internal_meta_key($key) {
328
+		$internal_meta_key = !empty($key) && $this->data_store && in_array($key, $this->data_store->get_internal_meta_keys(), true);
329 329
 
330
-		if ( ! $internal_meta_key ) {
330
+		if (!$internal_meta_key) {
331 331
 			return false;
332 332
 		}
333 333
 
334
-		$has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) );
334
+		$has_setter_or_getter = is_callable(array($this, 'set_' . $key)) || is_callable(array($this, 'get_' . $key));
335 335
 
336
-		if ( ! $has_setter_or_getter ) {
336
+		if (!$has_setter_or_getter) {
337 337
 			return false;
338 338
 		}
339 339
 
340 340
 		/* translators: %s: $key Key to check */
341
-		getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'invoicing' ), $key ), '1.0.19' );
341
+		getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'invoicing'), $key), '1.0.19');
342 342
 
343 343
 		return true;
344 344
 	}
@@ -352,20 +352,20 @@  discard block
 block discarded – undo
352 352
 	 * @access public
353 353
 	 *
354 354
 	 */
355
-	public function __set( $key, $value ) {
355
+	public function __set($key, $value) {
356 356
 
357
-		if ( 'id' == strtolower( $key ) ) {
358
-			return $this->set_id( $value );
357
+		if ('id' == strtolower($key)) {
358
+			return $this->set_id($value);
359 359
 		}
360 360
 
361
-		if ( method_exists( $this, "set_$key") ) {
361
+		if (method_exists($this, "set_$key")) {
362 362
 
363 363
 			/* translators: %s: $key Key to set */
364
-			getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' );
364
+			getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing'), $key), '1.0.19');
365 365
 
366
-			call_user_func( array( $this, "set_$key" ), $value );
366
+			call_user_func(array($this, "set_$key"), $value);
367 367
 		} else {
368
-			$this->set_prop( $key, $value );
368
+			$this->set_prop($key, $value);
369 369
 		}
370 370
 
371 371
 	}
@@ -373,25 +373,25 @@  discard block
 block discarded – undo
373 373
 	/**
374 374
      * Margic method for retrieving a property.
375 375
      */
376
-    public function __get( $key ) {
376
+    public function __get($key) {
377 377
 
378 378
         // Check if we have a helper method for that.
379
-        if ( method_exists( $this, 'get_' . $key ) ) {
379
+        if (method_exists($this, 'get_' . $key)) {
380 380
 
381
-			if ( 'post_type' != $key ) {
381
+			if ('post_type' != $key) {
382 382
 				/* translators: %s: $key Key to set */
383
-				getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' );
383
+				getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing'), $key), '1.0.19');
384 384
 			}
385 385
 
386
-            return call_user_func( array( $this, 'get_' . $key ) );
386
+            return call_user_func(array($this, 'get_' . $key));
387 387
         }
388 388
 
389 389
         // Check if the key is in the associated $post object.
390
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
390
+        if (!empty($this->post) && isset($this->post->$key)) {
391 391
             return $this->post->$key;
392 392
         }
393 393
 
394
-		return $this->get_prop( $key );
394
+		return $this->get_prop($key);
395 395
 
396 396
     }
397 397
 
@@ -404,15 +404,15 @@  discard block
 block discarded – undo
404 404
 	 * @param  string $context What the value is for. Valid values are view and edit.
405 405
 	 * @return mixed
406 406
 	 */
407
-	public function get_meta( $key = '', $single = true, $context = 'view' ) {
407
+	public function get_meta($key = '', $single = true, $context = 'view') {
408 408
 
409 409
 		// Check if this is an internal meta key.
410
-		$_key = str_replace( '_wpinv', '', $key );
411
-		$_key = str_replace( 'wpinv', '', $_key );
412
-		if ( $this->is_internal_meta_key( $key ) ) {
410
+		$_key = str_replace('_wpinv', '', $key);
411
+		$_key = str_replace('wpinv', '', $_key);
412
+		if ($this->is_internal_meta_key($key)) {
413 413
 			$function = 'get_' . $_key;
414 414
 
415
-			if ( is_callable( array( $this, $function ) ) ) {
415
+			if (is_callable(array($this, $function))) {
416 416
 				return $this->{$function}();
417 417
 			}
418 418
 		}
@@ -420,20 +420,20 @@  discard block
 block discarded – undo
420 420
 		// Read the meta data if not yet read.
421 421
 		$this->maybe_read_meta_data();
422 422
 		$meta_data  = $this->get_meta_data();
423
-		$array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true );
423
+		$array_keys = array_keys(wp_list_pluck($meta_data, 'key'), $key, true);
424 424
 		$value      = $single ? '' : array();
425 425
 
426
-		if ( ! empty( $array_keys ) ) {
426
+		if (!empty($array_keys)) {
427 427
 			// We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()).
428
-			if ( $single ) {
429
-				$value = $meta_data[ current( $array_keys ) ]->value;
428
+			if ($single) {
429
+				$value = $meta_data[current($array_keys)]->value;
430 430
 			} else {
431
-				$value = array_intersect_key( $meta_data, array_flip( $array_keys ) );
431
+				$value = array_intersect_key($meta_data, array_flip($array_keys));
432 432
 			}
433 433
 		}
434 434
 
435
-		if ( 'view' === $context ) {
436
-			$value = apply_filters( $this->get_hook_prefix() . $key, $value, $this );
435
+		if ('view' === $context) {
436
+			$value = apply_filters($this->get_hook_prefix() . $key, $value, $this);
437 437
 		}
438 438
 
439 439
 		return $value;
@@ -446,10 +446,10 @@  discard block
 block discarded – undo
446 446
 	 * @param  string $key Meta Key.
447 447
 	 * @return boolean
448 448
 	 */
449
-	public function meta_exists( $key = '' ) {
449
+	public function meta_exists($key = '') {
450 450
 		$this->maybe_read_meta_data();
451
-		$array_keys = wp_list_pluck( $this->get_meta_data(), 'key' );
452
-		return in_array( $key, $array_keys, true );
451
+		$array_keys = wp_list_pluck($this->get_meta_data(), 'key');
452
+		return in_array($key, $array_keys, true);
453 453
 	}
454 454
 
455 455
 	/**
@@ -458,12 +458,12 @@  discard block
 block discarded – undo
458 458
 	 * @since 1.0.19
459 459
 	 * @param array $data Key/Value pairs.
460 460
 	 */
461
-	public function set_meta_data( $data ) {
462
-		if ( ! empty( $data ) && is_array( $data ) ) {
461
+	public function set_meta_data($data) {
462
+		if (!empty($data) && is_array($data)) {
463 463
 			$this->maybe_read_meta_data();
464
-			foreach ( $data as $meta ) {
464
+			foreach ($data as $meta) {
465 465
 				$meta = (array) $meta;
466
-				if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) {
466
+				if (isset($meta['key'], $meta['value'], $meta['id'])) {
467 467
 					$this->meta_data[] = new GetPaid_Meta_Data(
468 468
 						array(
469 469
 							'id'    => $meta['id'],
@@ -485,18 +485,18 @@  discard block
 block discarded – undo
485 485
 	 * @param string|array $value Meta value.
486 486
 	 * @param bool         $unique Should this be a unique key?.
487 487
 	 */
488
-	public function add_meta_data( $key, $value, $unique = false ) {
489
-		if ( $this->is_internal_meta_key( $key ) ) {
488
+	public function add_meta_data($key, $value, $unique = false) {
489
+		if ($this->is_internal_meta_key($key)) {
490 490
 			$function = 'set_' . $key;
491 491
 
492
-			if ( is_callable( array( $this, $function ) ) ) {
493
-				return $this->{$function}( $value );
492
+			if (is_callable(array($this, $function))) {
493
+				return $this->{$function}($value);
494 494
 			}
495 495
 		}
496 496
 
497 497
 		$this->maybe_read_meta_data();
498
-		if ( $unique ) {
499
-			$this->delete_meta_data( $key );
498
+		if ($unique) {
499
+			$this->delete_meta_data($key);
500 500
 		}
501 501
 		$this->meta_data[] = new GetPaid_Meta_Data(
502 502
 			array(
@@ -517,12 +517,12 @@  discard block
 block discarded – undo
517 517
 	 * @param  string|array $value Meta value.
518 518
 	 * @param  int          $meta_id Meta ID.
519 519
 	 */
520
-	public function update_meta_data( $key, $value, $meta_id = 0 ) {
521
-		if ( $this->is_internal_meta_key( $key ) ) {
520
+	public function update_meta_data($key, $value, $meta_id = 0) {
521
+		if ($this->is_internal_meta_key($key)) {
522 522
 			$function = 'set_' . $key;
523 523
 
524
-			if ( is_callable( array( $this, $function ) ) ) {
525
-				return $this->{$function}( $value );
524
+			if (is_callable(array($this, $function))) {
525
+				return $this->{$function}($value);
526 526
 			}
527 527
 		}
528 528
 
@@ -530,33 +530,33 @@  discard block
 block discarded – undo
530 530
 
531 531
 		$array_key = false;
532 532
 
533
-		if ( $meta_id ) {
534
-			$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true );
535
-			$array_key  = $array_keys ? current( $array_keys ) : false;
533
+		if ($meta_id) {
534
+			$array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), $meta_id, true);
535
+			$array_key  = $array_keys ? current($array_keys) : false;
536 536
 		} else {
537 537
 			// Find matches by key.
538 538
 			$matches = array();
539
-			foreach ( $this->meta_data as $meta_data_array_key => $meta ) {
540
-				if ( $meta->key === $key ) {
539
+			foreach ($this->meta_data as $meta_data_array_key => $meta) {
540
+				if ($meta->key === $key) {
541 541
 					$matches[] = $meta_data_array_key;
542 542
 				}
543 543
 			}
544 544
 
545
-			if ( ! empty( $matches ) ) {
545
+			if (!empty($matches)) {
546 546
 				// Set matches to null so only one key gets the new value.
547
-				foreach ( $matches as $meta_data_array_key ) {
548
-					$this->meta_data[ $meta_data_array_key ]->value = null;
547
+				foreach ($matches as $meta_data_array_key) {
548
+					$this->meta_data[$meta_data_array_key]->value = null;
549 549
 				}
550
-				$array_key = current( $matches );
550
+				$array_key = current($matches);
551 551
 			}
552 552
 		}
553 553
 
554
-		if ( false !== $array_key ) {
555
-			$meta        = $this->meta_data[ $array_key ];
554
+		if (false !== $array_key) {
555
+			$meta        = $this->meta_data[$array_key];
556 556
 			$meta->key   = $key;
557 557
 			$meta->value = $value;
558 558
 		} else {
559
-			$this->add_meta_data( $key, $value, true );
559
+			$this->add_meta_data($key, $value, true);
560 560
 		}
561 561
 	}
562 562
 
@@ -566,13 +566,13 @@  discard block
 block discarded – undo
566 566
 	 * @since 1.0.19
567 567
 	 * @param string $key Meta key.
568 568
 	 */
569
-	public function delete_meta_data( $key ) {
569
+	public function delete_meta_data($key) {
570 570
 		$this->maybe_read_meta_data();
571
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true );
571
+		$array_keys = array_keys(wp_list_pluck($this->meta_data, 'key'), $key, true);
572 572
 
573
-		if ( $array_keys ) {
574
-			foreach ( $array_keys as $array_key ) {
575
-				$this->meta_data[ $array_key ]->value = null;
573
+		if ($array_keys) {
574
+			foreach ($array_keys as $array_key) {
575
+				$this->meta_data[$array_key]->value = null;
576 576
 			}
577 577
 		}
578 578
 	}
@@ -583,13 +583,13 @@  discard block
 block discarded – undo
583 583
 	 * @since 1.0.19
584 584
 	 * @param int $mid Meta ID.
585 585
 	 */
586
-	public function delete_meta_data_by_mid( $mid ) {
586
+	public function delete_meta_data_by_mid($mid) {
587 587
 		$this->maybe_read_meta_data();
588
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true );
588
+		$array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), (int) $mid, true);
589 589
 
590
-		if ( $array_keys ) {
591
-			foreach ( $array_keys as $array_key ) {
592
-				$this->meta_data[ $array_key ]->value = null;
590
+		if ($array_keys) {
591
+			foreach ($array_keys as $array_key) {
592
+				$this->meta_data[$array_key]->value = null;
593 593
 			}
594 594
 		}
595 595
 	}
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	 * @since 1.0.19
601 601
 	 */
602 602
 	protected function maybe_read_meta_data() {
603
-		if ( is_null( $this->meta_data ) ) {
603
+		if (is_null($this->meta_data)) {
604 604
 			$this->read_meta_data();
605 605
 		}
606 606
 	}
@@ -612,42 +612,42 @@  discard block
 block discarded – undo
612 612
 	 * @since 1.0.19
613 613
 	 * @param bool $force_read True to force a new DB read (and update cache).
614 614
 	 */
615
-	public function read_meta_data( $force_read = false ) {
615
+	public function read_meta_data($force_read = false) {
616 616
 
617 617
 		// Reset meta data.
618 618
 		$this->meta_data = array();
619 619
 
620 620
 		// Maybe abort early.
621
-		if ( ! $this->get_id() || ! $this->data_store ) {
621
+		if (!$this->get_id() || !$this->data_store) {
622 622
 			return;
623 623
 		}
624 624
 
625 625
 		// Only read from cache if the cache key is set.
626 626
 		$cache_key = null;
627
-		if ( ! $force_read && ! empty( $this->cache_group ) ) {
628
-			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
629
-			$raw_meta_data = wp_cache_get( $cache_key, $this->cache_group );
627
+		if (!$force_read && !empty($this->cache_group)) {
628
+			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id();
629
+			$raw_meta_data = wp_cache_get($cache_key, $this->cache_group);
630 630
 		}
631 631
 
632 632
 		// Should we force read?
633
-		if ( empty( $raw_meta_data ) ) {
634
-			$raw_meta_data = $this->data_store->read_meta( $this );
633
+		if (empty($raw_meta_data)) {
634
+			$raw_meta_data = $this->data_store->read_meta($this);
635 635
 
636
-			if ( ! empty( $cache_key ) ) {
637
-				wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
636
+			if (!empty($cache_key)) {
637
+				wp_cache_set($cache_key, $raw_meta_data, $this->cache_group);
638 638
 			}
639 639
 
640 640
 		}
641 641
 
642 642
 		// Set meta data.
643
-		if ( is_array( $raw_meta_data ) ) {
643
+		if (is_array($raw_meta_data)) {
644 644
 
645
-			foreach ( $raw_meta_data as $meta ) {
645
+			foreach ($raw_meta_data as $meta) {
646 646
 				$this->meta_data[] = new GetPaid_Meta_Data(
647 647
 					array(
648 648
 						'id'    => (int) $meta->meta_id,
649 649
 						'key'   => $meta->meta_key,
650
-						'value' => maybe_unserialize( $meta->meta_value ),
650
+						'value' => maybe_unserialize($meta->meta_value),
651 651
 					)
652 652
 				);
653 653
 			}
@@ -662,28 +662,28 @@  discard block
 block discarded – undo
662 662
 	 * @since 1.0.19
663 663
 	 */
664 664
 	public function save_meta_data() {
665
-		if ( ! $this->data_store || is_null( $this->meta_data ) ) {
665
+		if (!$this->data_store || is_null($this->meta_data)) {
666 666
 			return;
667 667
 		}
668
-		foreach ( $this->meta_data as $array_key => $meta ) {
669
-			if ( is_null( $meta->value ) ) {
670
-				if ( ! empty( $meta->id ) ) {
671
-					$this->data_store->delete_meta( $this, $meta );
672
-					unset( $this->meta_data[ $array_key ] );
668
+		foreach ($this->meta_data as $array_key => $meta) {
669
+			if (is_null($meta->value)) {
670
+				if (!empty($meta->id)) {
671
+					$this->data_store->delete_meta($this, $meta);
672
+					unset($this->meta_data[$array_key]);
673 673
 				}
674
-			} elseif ( empty( $meta->id ) ) {
675
-				$meta->id = $this->data_store->add_meta( $this, $meta );
674
+			} elseif (empty($meta->id)) {
675
+				$meta->id = $this->data_store->add_meta($this, $meta);
676 676
 				$meta->apply_changes();
677 677
 			} else {
678
-				if ( $meta->get_changes() ) {
679
-					$this->data_store->update_meta( $this, $meta );
678
+				if ($meta->get_changes()) {
679
+					$this->data_store->update_meta($this, $meta);
680 680
 					$meta->apply_changes();
681 681
 				}
682 682
 			}
683 683
 		}
684
-		if ( ! empty( $this->cache_group ) ) {
685
-			$cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
686
-			wp_cache_delete( $cache_key, $this->cache_group );
684
+		if (!empty($this->cache_group)) {
685
+			$cache_key = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id();
686
+			wp_cache_delete($cache_key, $this->cache_group);
687 687
 		}
688 688
 	}
689 689
 
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
 	 * @since 1.0.19
694 694
 	 * @param int $id ID.
695 695
 	 */
696
-	public function set_id( $id ) {
697
-		$this->id = absint( $id );
696
+	public function set_id($id) {
697
+		$this->id = absint($id);
698 698
 	}
699 699
 
700 700
 	/**
@@ -704,10 +704,10 @@  discard block
 block discarded – undo
704 704
 	 * @param string $status New status.
705 705
 	 * @return array details of change.
706 706
 	 */
707
-	public function set_status( $status ) {
707
+	public function set_status($status) {
708 708
         $old_status = $this->get_status();
709 709
 
710
-		$this->set_prop( 'status', $status );
710
+		$this->set_prop('status', $status);
711 711
 
712 712
 		return array(
713 713
 			'from' => $old_status,
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	public function set_defaults() {
724 724
 		$this->data    = $this->default_data;
725 725
 		$this->changes = array();
726
-		$this->set_object_read( false );
726
+		$this->set_object_read(false);
727 727
 	}
728 728
 
729 729
 	/**
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 	 * @since 1.0.19
733 733
 	 * @param boolean $read Should read?.
734 734
 	 */
735
-	public function set_object_read( $read = true ) {
735
+	public function set_object_read($read = true) {
736 736
 		$this->object_read = (bool) $read;
737 737
 	}
738 738
 
@@ -757,33 +757,33 @@  discard block
 block discarded – undo
757 757
 	 *
758 758
 	 * @return bool|WP_Error
759 759
 	 */
760
-	public function set_props( $props, $context = 'set' ) {
760
+	public function set_props($props, $context = 'set') {
761 761
 		$errors = false;
762 762
 
763
-		$props = wp_unslash( $props );
764
-		foreach ( $props as $prop => $value ) {
763
+		$props = wp_unslash($props);
764
+		foreach ($props as $prop => $value) {
765 765
 			try {
766 766
 				/**
767 767
 				 * Checks if the prop being set is allowed, and the value is not null.
768 768
 				 */
769
-				if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
769
+				if (is_null($value) || in_array($prop, array('prop', 'date_prop', 'meta_data'), true)) {
770 770
 					continue;
771 771
 				}
772 772
 				$setter = "set_$prop";
773 773
 
774
-				if ( is_callable( array( $this, $setter ) ) ) {
775
-					$this->{$setter}( $value );
774
+				if (is_callable(array($this, $setter))) {
775
+					$this->{$setter}($value);
776 776
 				}
777
-			} catch ( Exception $e ) {
778
-				if ( ! $errors ) {
777
+			} catch (Exception $e) {
778
+				if (!$errors) {
779 779
 					$errors = new WP_Error();
780 780
 				}
781
-				$errors->add( $e->getCode(), $e->getMessage() );
781
+				$errors->add($e->getCode(), $e->getMessage());
782 782
 				$this->last_error = $e->getMessage();
783 783
 			}
784 784
 		}
785 785
 
786
-		return $errors && count( $errors->get_error_codes() ) ? $errors : true;
786
+		return $errors && count($errors->get_error_codes()) ? $errors : true;
787 787
 	}
788 788
 
789 789
 	/**
@@ -796,14 +796,14 @@  discard block
 block discarded – undo
796 796
 	 * @param string $prop Name of prop to set.
797 797
 	 * @param mixed  $value Value of the prop.
798 798
 	 */
799
-	protected function set_prop( $prop, $value ) {
800
-		if ( array_key_exists( $prop, $this->data ) ) {
801
-			if ( true === $this->object_read ) {
802
-				if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
803
-					$this->changes[ $prop ] = $value;
799
+	protected function set_prop($prop, $value) {
800
+		if (array_key_exists($prop, $this->data)) {
801
+			if (true === $this->object_read) {
802
+				if ($value !== $this->data[$prop] || array_key_exists($prop, $this->changes)) {
803
+					$this->changes[$prop] = $value;
804 804
 				}
805 805
 			} else {
806
-				$this->data[ $prop ] = $value;
806
+				$this->data[$prop] = $value;
807 807
 			}
808 808
 		}
809 809
 	}
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 	 * @since 1.0.19
825 825
 	 */
826 826
 	public function apply_changes() {
827
-		$this->data    = array_replace( $this->data, $this->changes );
827
+		$this->data    = array_replace($this->data, $this->changes);
828 828
 		$this->changes = array();
829 829
 	}
830 830
 
@@ -849,14 +849,14 @@  discard block
 block discarded – undo
849 849
 	 * @param  string $context What the value is for. Valid values are view and edit.
850 850
 	 * @return mixed
851 851
 	 */
852
-	protected function get_prop( $prop, $context = 'view' ) {
852
+	protected function get_prop($prop, $context = 'view') {
853 853
 		$value = null;
854 854
 
855
-		if ( array_key_exists( $prop, $this->data ) ) {
856
-			$value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
855
+		if (array_key_exists($prop, $this->data)) {
856
+			$value = array_key_exists($prop, $this->changes) ? $this->changes[$prop] : $this->data[$prop];
857 857
 
858
-			if ( 'view' === $context ) {
859
-				$value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
858
+			if ('view' === $context) {
859
+				$value = apply_filters($this->get_hook_prefix() . $prop, $value, $this);
860 860
 			}
861 861
 		}
862 862
 
@@ -870,13 +870,13 @@  discard block
 block discarded – undo
870 870
 	 * @param string         $prop Name of prop to set.
871 871
 	 * @param string|integer $value Value of the prop.
872 872
 	 */
873
-	protected function set_date_prop( $prop, $value ) {
873
+	protected function set_date_prop($prop, $value) {
874 874
 
875
-		if ( empty( $value ) ) {
876
-			$this->set_prop( $prop, null );
875
+		if (empty($value)) {
876
+			$this->set_prop($prop, null);
877 877
 			return;
878 878
 		}
879
-		$this->set_prop( $prop, $value );
879
+		$this->set_prop($prop, $value);
880 880
 
881 881
 	}
882 882
 
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 	 * @param string $code             Error code.
888 888
 	 * @param string $message          Error message.
889 889
 	 */
890
-	protected function error( $code, $message ) {
890
+	protected function error($code, $message) {
891 891
 		$this->last_error = $message;
892 892
 	}
893 893
 
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 	 */
900 900
 	public function exists() {
901 901
 		$id = $this->get_id();
902
-		return ! empty( $id );
902
+		return !empty($id);
903 903
 	}
904 904
 
905 905
 }
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
  */
109 109
 function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
110 110
 
111
-	$invoice_statuses = array(
112
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
111
+    $invoice_statuses = array(
112
+        'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
113 113
         'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
114 114
         'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
115
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
116
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
117
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
115
+        'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
116
+        'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
117
+        'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
118 118
         'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
119 119
         'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
120 120
     );
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         $invoice = $invoice->get_post_type();
132 132
     }
133 133
 
134
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
134
+    return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
135 135
 }
136 136
 
137 137
 /**
@@ -249,25 +249,25 @@  discard block
 block discarded – undo
249 249
  * @return string
250 250
  */
251 251
 function getpaid_get_price_format() {
252
-	$currency_pos = wpinv_currency_position();
253
-	$format       = '%1$s%2$s';
254
-
255
-	switch ( $currency_pos ) {
256
-		case 'left':
257
-			$format = '%1$s%2$s';
258
-			break;
259
-		case 'right':
260
-			$format = '%2$s%1$s';
261
-			break;
262
-		case 'left_space':
263
-			$format = '%1$s&nbsp;%2$s';
264
-			break;
265
-		case 'right_space':
266
-			$format = '%2$s&nbsp;%1$s';
267
-			break;
268
-	}
269
-
270
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
252
+    $currency_pos = wpinv_currency_position();
253
+    $format       = '%1$s%2$s';
254
+
255
+    switch ( $currency_pos ) {
256
+        case 'left':
257
+            $format = '%1$s%2$s';
258
+            break;
259
+        case 'right':
260
+            $format = '%2$s%1$s';
261
+            break;
262
+        case 'left_space':
263
+            $format = '%1$s&nbsp;%2$s';
264
+            break;
265
+        case 'right_space':
266
+            $format = '%2$s&nbsp;%1$s';
267
+            break;
268
+    }
269
+
270
+    return apply_filters( 'getpaid_price_format', $format, $currency_pos );
271 271
 }
272 272
 
273 273
 /**
@@ -362,13 +362,13 @@  discard block
 block discarded – undo
362 362
  * @param mixed  $value Value.
363 363
  */
364 364
 function getpaid_maybe_define_constant( $name, $value ) {
365
-	if ( ! defined( $name ) ) {
366
-		define( $name, $value );
367
-	}
365
+    if ( ! defined( $name ) ) {
366
+        define( $name, $value );
367
+    }
368 368
 }
369 369
 
370 370
 function wpinv_get_php_arg_separator_output() {
371
-	return ini_get( 'arg_separator.output' );
371
+    return ini_get( 'arg_separator.output' );
372 372
 }
373 373
 
374 374
 function wpinv_rgb_from_hex( $color ) {
@@ -722,11 +722,11 @@  discard block
 block discarded – undo
722 722
         $list = array();
723 723
     }
724 724
 
725
-	if ( ! is_array( $list ) ) {
726
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
727
-	}
725
+    if ( ! is_array( $list ) ) {
726
+        return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
727
+    }
728 728
 
729
-	return $list;
729
+    return $list;
730 730
 }
731 731
 
732 732
 /**
@@ -746,9 +746,9 @@  discard block
 block discarded – undo
746 746
     }
747 747
 
748 748
     $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
749
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
749
+    wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
750 750
 
751
-	return $data;
751
+    return $data;
752 752
 }
753 753
 
754 754
 /**
@@ -777,17 +777,17 @@  discard block
 block discarded – undo
777 777
  */
778 778
 function wpinv_clean( $var ) {
779 779
 
780
-	if ( is_array( $var ) ) {
781
-		return array_map( 'wpinv_clean', $var );
780
+    if ( is_array( $var ) ) {
781
+        return array_map( 'wpinv_clean', $var );
782 782
     }
783 783
 
784 784
     if ( is_object( $var ) ) {
785
-		$object_vars = get_object_vars( $var );
786
-		foreach ( $object_vars as $property_name => $property_value ) {
787
-			$var->$property_name = wpinv_clean( $property_value );
785
+        $object_vars = get_object_vars( $var );
786
+        foreach ( $object_vars as $property_name => $property_value ) {
787
+            $var->$property_name = wpinv_clean( $property_value );
788 788
         }
789 789
         return $var;
790
-	}
790
+    }
791 791
 
792 792
     return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var;
793 793
 }
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
  */
801 801
 function getpaid_convert_price_string_to_options( $str ) {
802 802
 
803
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
803
+    $raw_options = array_map( 'trim', explode( ',', $str ) );
804 804
     $options     = array();
805 805
 
806 806
     foreach ( $raw_options as $option ) {
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
  * @return string
884 884
  */
885 885
 function getpaid_date_format() {
886
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
886
+    return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
887 887
 }
888 888
 
889 889
 /**
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
  * @return string
893 893
  */
894 894
 function getpaid_time_format() {
895
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
895
+    return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
896 896
 }
897 897
 
898 898
 /**
@@ -905,15 +905,15 @@  discard block
 block discarded – undo
905 905
 function getpaid_limit_length( $string, $limit ) {
906 906
     $str_limit = $limit - 3;
907 907
 
908
-	if ( function_exists( 'mb_strimwidth' ) ) {
909
-		if ( mb_strlen( $string ) > $limit ) {
910
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
911
-		}
912
-	} else {
913
-		if ( strlen( $string ) > $limit ) {
914
-			$string = substr( $string, 0, $str_limit ) . '...';
915
-		}
916
-	}
908
+    if ( function_exists( 'mb_strimwidth' ) ) {
909
+        if ( mb_strlen( $string ) > $limit ) {
910
+            $string = mb_strimwidth( $string, 0, $str_limit ) . '...';
911
+        }
912
+    } else {
913
+        if ( strlen( $string ) > $limit ) {
914
+            $string = substr( $string, 0, $str_limit ) . '...';
915
+        }
916
+    }
917 917
     return $string;
918 918
 
919 919
 }
Please login to merge, or discard this patch.
Spacing   +268 added lines, -268 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
  * Are we supporting item quantities?
@@ -20,35 +20,35 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function wpinv_get_ip() {
22 22
 
23
-    if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) {
24
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) );
23
+    if (isset($_SERVER['HTTP_X_REAL_IP'])) {
24
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP']));
25 25
     }
26 26
 
27
-    if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
27
+    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
28 28
         // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2
29 29
         // Make sure we always only send through the first IP in the list which should always be the client IP.
30
-        return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) );
30
+        return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR']))))));
31 31
     }
32 32
 
33
-    if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
34
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) );
33
+    if (isset($_SERVER['HTTP_CLIENT_IP'])) {
34
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP']));
35 35
     }
36 36
 
37
-    if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
38
-        return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
37
+    if (isset($_SERVER['REMOTE_ADDR'])) {
38
+        return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']));
39 39
     }
40 40
 
41 41
     return '';
42 42
 }
43 43
 
44 44
 function wpinv_get_user_agent() {
45
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
46
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
45
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
46
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
47 47
     } else {
48 48
         $user_agent = '';
49 49
     }
50 50
 
51
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
51
+    return apply_filters('wpinv_get_user_agent', $user_agent);
52 52
 }
53 53
 
54 54
 /**
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
  * @param string $amount The amount to sanitize.
58 58
  * @return float
59 59
  */
60
-function getpaid_standardize_amount( $amount ) {
60
+function getpaid_standardize_amount($amount) {
61 61
 
62
-    $amount = str_replace( wpinv_thousands_separator(), '', $amount );
63
-    $amount = str_replace( wpinv_decimal_separator(), '.', $amount );
64
-    if ( is_numeric( $amount ) ) {
65
-        return floatval( $amount );
62
+    $amount = str_replace(wpinv_thousands_separator(), '', $amount);
63
+    $amount = str_replace(wpinv_decimal_separator(), '.', $amount);
64
+    if (is_numeric($amount)) {
65
+        return floatval($amount);
66 66
     }
67 67
 
68 68
     // Cast the remaining to a float.
69
-    return wpinv_round_amount( preg_replace( '/[^0-9\.\-]/', '', $amount ) );
69
+    return wpinv_round_amount(preg_replace('/[^0-9\.\-]/', '', $amount));
70 70
 
71 71
 }
72 72
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
  *
76 76
  * @param string $amount The amount to sanitize.
77 77
  */
78
-function getpaid_unstandardize_amount( $amount ) {
79
-    return str_replace( '.', wpinv_decimal_separator(), $amount );
78
+function getpaid_unstandardize_amount($amount) {
79
+    return str_replace('.', wpinv_decimal_separator(), $amount);
80 80
 }
81 81
 
82 82
 /**
@@ -84,23 +84,23 @@  discard block
 block discarded – undo
84 84
  * 
85 85
  * @param string $amount The amount to sanitize.
86 86
  */
87
-function wpinv_sanitize_amount( $amount ) {
87
+function wpinv_sanitize_amount($amount) {
88 88
 
89
-    if ( is_numeric( $amount ) ) {
90
-        return floatval( $amount );
89
+    if (is_numeric($amount)) {
90
+        return floatval($amount);
91 91
     }
92 92
 
93 93
     // Separate the decimals and thousands.
94
-    $amount    = explode( wpinv_decimal_separator(), $amount );
94
+    $amount    = explode(wpinv_decimal_separator(), $amount);
95 95
 
96 96
     // Remove thousands.
97
-    $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] );
97
+    $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]);
98 98
 
99 99
     // Convert back to string.
100
-    $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
100
+    $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
101 101
 
102 102
     // Cast the remaining to a float.
103
-    return (float) preg_replace( '/[^0-9\.\-]/', '', $amount );
103
+    return (float) preg_replace('/[^0-9\.\-]/', '', $amount);
104 104
 
105 105
 }
106 106
 
@@ -110,19 +110,19 @@  discard block
 block discarded – undo
110 110
  * @param float $amount
111 111
  * @param float|string|int|null $decimals
112 112
  */
113
-function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) {
113
+function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) {
114 114
 
115
-    if ( $decimals === null ) {
115
+    if ($decimals === null) {
116 116
         $decimals = wpinv_decimals();
117 117
     }
118 118
 
119
-    if ( $use_sprintf ) {
120
-        $amount = sprintf( "%.{$decimals}f", (float) $amount );
119
+    if ($use_sprintf) {
120
+        $amount = sprintf("%.{$decimals}f", (float) $amount);
121 121
     } else {
122
-        $amount = round( (float) $amount, absint( $decimals ) );
122
+        $amount = round((float) $amount, absint($decimals));
123 123
     }
124 124
 
125
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
125
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
126 126
 }
127 127
 
128 128
 /**
@@ -134,32 +134,32 @@  discard block
 block discarded – undo
134 134
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
135 135
  * @return array
136 136
  */
137
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
137
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
138 138
 
139 139
 	$invoice_statuses = array(
140
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
141
-        'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
142
-        'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
143
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
144
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
145
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
146
-        'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
147
-        'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
140
+		'wpi-pending'    => _x('Pending payment', 'Invoice status', 'invoicing'),
141
+        'publish'        => _x('Paid', 'Invoice status', 'invoicing'),
142
+        'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'),
143
+		'wpi-onhold'     => _x('On hold', 'Invoice status', 'invoicing'),
144
+		'wpi-cancelled'  => _x('Cancelled', 'Invoice status', 'invoicing'),
145
+		'wpi-refunded'   => _x('Refunded', 'Invoice status', 'invoicing'),
146
+        'wpi-failed'     => _x('Failed', 'Invoice status', 'invoicing'),
147
+        'wpi-renewal'    => _x('Renewal Payment', 'Invoice status', 'invoicing'),
148 148
     );
149 149
 
150
-    if ( $draft ) {
151
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
150
+    if ($draft) {
151
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
152 152
     }
153 153
 
154
-    if ( $trashed ) {
155
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
154
+    if ($trashed) {
155
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
156 156
     }
157 157
 
158
-    if ( $invoice instanceof WPInv_Invoice ) {
158
+    if ($invoice instanceof WPInv_Invoice) {
159 159
         $invoice = $invoice->get_post_type();
160 160
     }
161 161
 
162
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
162
+	return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
163 163
 }
164 164
 
165 165
 /**
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
  * @param string $status The raw status
169 169
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
170 170
  */
171
-function wpinv_status_nicename( $status, $invoice = false ) {
172
-    $statuses = wpinv_get_invoice_statuses( true, true, $invoice );
173
-    $status   = isset( $statuses[$status] ) ? $statuses[$status] : $status;
171
+function wpinv_status_nicename($status, $invoice = false) {
172
+    $statuses = wpinv_get_invoice_statuses(true, true, $invoice);
173
+    $status   = isset($statuses[$status]) ? $statuses[$status] : $status;
174 174
 
175
-    return sanitize_text_field( $status );
175
+    return sanitize_text_field($status);
176 176
 }
177 177
 
178 178
 /**
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
  * 
181 181
  * @param string $current
182 182
  */
183
-function wpinv_get_currency( $current = '' ) {
183
+function wpinv_get_currency($current = '') {
184 184
 
185
-    if ( empty( $current ) ) {
186
-        $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) );
185
+    if (empty($current)) {
186
+        $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD'));
187 187
     }
188 188
 
189
-    return trim( strtoupper( $current ) );
189
+    return trim(strtoupper($current));
190 190
 }
191 191
 
192 192
 /**
@@ -194,25 +194,25 @@  discard block
 block discarded – undo
194 194
  * 
195 195
  * @param string|null $currency The currency code. Defaults to the default currency.
196 196
  */
197
-function wpinv_currency_symbol( $currency = null ) {
197
+function wpinv_currency_symbol($currency = null) {
198 198
 
199 199
     // Prepare the currency.
200
-    $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency );
200
+    $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency);
201 201
 
202 202
     // Fetch all symbols.
203 203
     $symbols = wpinv_get_currency_symbols();
204 204
 
205 205
     // Fetch this currencies symbol.
206
-    $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency;
206
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
207 207
 
208 208
     // Filter the symbol.
209
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
209
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
210 210
 }
211 211
 
212 212
 function wpinv_currency_position() {
213
-    $position = wpinv_get_option( 'currency_position', 'left' );
213
+    $position = wpinv_get_option('currency_position', 'left');
214 214
     
215
-    return apply_filters( 'wpinv_currency_position', $position );
215
+    return apply_filters('wpinv_currency_position', $position);
216 216
 }
217 217
 
218 218
 /**
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
  * 
221 221
  * @param $string|null $current
222 222
  */
223
-function wpinv_thousands_separator( $current = null ) {
223
+function wpinv_thousands_separator($current = null) {
224 224
 
225
-    if ( null == $current ) {
226
-        $current = wpinv_get_option( 'thousands_separator', ',' );
225
+    if (null == $current) {
226
+        $current = wpinv_get_option('thousands_separator', ',');
227 227
     }
228 228
 
229
-    return trim( $current );
229
+    return trim($current);
230 230
 }
231 231
 
232 232
 /**
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
  * 
235 235
  * @param $string|null $current
236 236
  */
237
-function wpinv_decimal_separator( $current = null ) {
237
+function wpinv_decimal_separator($current = null) {
238 238
 
239
-    if ( null == $current ) {
240
-        $current = wpinv_get_option( 'decimal_separator', '.' );
239
+    if (null == $current) {
240
+        $current = wpinv_get_option('decimal_separator', '.');
241 241
     }
242 242
     
243
-    return trim( $current );
243
+    return trim($current);
244 244
 }
245 245
 
246 246
 /**
@@ -248,27 +248,27 @@  discard block
 block discarded – undo
248 248
  * 
249 249
  * @param $string|null $current
250 250
  */
251
-function wpinv_decimals( $current = null ) {
251
+function wpinv_decimals($current = null) {
252 252
 
253
-    if ( null == $current ) {
254
-        $current = wpinv_get_option( 'decimals', 2 );
253
+    if (null == $current) {
254
+        $current = wpinv_get_option('decimals', 2);
255 255
     }
256 256
     
257
-    return absint( $current );
257
+    return absint($current);
258 258
 }
259 259
 
260 260
 /**
261 261
  * Retrieves a list of all supported currencies.
262 262
  */
263 263
 function wpinv_get_currencies() {
264
-    return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) );
264
+    return apply_filters('wpinv_currencies', wpinv_get_data('currencies'));
265 265
 }
266 266
 
267 267
 /**
268 268
  * Retrieves a list of all currency symbols.
269 269
  */
270 270
 function wpinv_get_currency_symbols() {
271
-    return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) );
271
+    return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols'));
272 272
 }
273 273
 
274 274
 /**
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	$currency_pos = wpinv_currency_position();
281 281
 	$format       = '%1$s%2$s';
282 282
 
283
-	switch ( $currency_pos ) {
283
+	switch ($currency_pos) {
284 284
 		case 'left':
285 285
 			$format = '%1$s%2$s';
286 286
 			break;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 			break;
296 296
 	}
297 297
 
298
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
298
+	return apply_filters('getpaid_price_format', $format, $currency_pos);
299 299
 }
300 300
 
301 301
 /**
@@ -305,25 +305,25 @@  discard block
 block discarded – undo
305 305
  * @param  string $currency Currency.
306 306
  * @return string
307 307
  */
308
-function wpinv_price( $amount = 0, $currency = '' ) {
308
+function wpinv_price($amount = 0, $currency = '') {
309 309
 
310 310
     // Backwards compatibility.
311
-    $amount             = wpinv_sanitize_amount( $amount );
311
+    $amount             = wpinv_sanitize_amount($amount);
312 312
 
313 313
     // Prepare variables.
314
-    $currency           = wpinv_get_currency( $currency );
314
+    $currency           = wpinv_get_currency($currency);
315 315
     $amount             = (float) $amount;
316 316
     $unformatted_amount = $amount;
317 317
     $negative           = $amount < 0;
318
-    $amount             = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) );
319
-    $amount             = wpinv_format_amount( $amount );
318
+    $amount             = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount));
319
+    $amount             = wpinv_format_amount($amount);
320 320
 
321 321
     // Format the amount.
322 322
     $format             = getpaid_get_price_format();
323
-    $formatted_amount   = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount );
323
+    $formatted_amount   = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount);
324 324
 
325 325
     // Filter the formatting.
326
-    return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount );
326
+    return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount);
327 327
 }
328 328
 
329 329
 /**
@@ -334,25 +334,25 @@  discard block
 block discarded – undo
334 334
  * @param  bool     $calculate Whether or not to apply separators.
335 335
  * @return string
336 336
  */
337
-function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) {
337
+function wpinv_format_amount($amount, $decimals = null, $calculate = false) {
338 338
     $thousands_sep = wpinv_thousands_separator();
339 339
     $decimal_sep   = wpinv_decimal_separator();
340
-    $decimals      = wpinv_decimals( $decimals );
341
-    $amount        = wpinv_sanitize_amount( $amount );
340
+    $decimals      = wpinv_decimals($decimals);
341
+    $amount        = wpinv_sanitize_amount($amount);
342 342
 
343
-    if ( $calculate ) {
343
+    if ($calculate) {
344 344
         return $amount;
345 345
     }
346 346
 
347 347
     // Fomart the amount.
348
-    return number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
348
+    return number_format($amount, $decimals, $decimal_sep, $thousands_sep);
349 349
 }
350 350
 
351
-function wpinv_sanitize_key( $key ) {
351
+function wpinv_sanitize_key($key) {
352 352
     $raw_key = $key;
353
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
353
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
354 354
 
355
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
355
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
356 356
 }
357 357
 
358 358
 /**
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
  * 
361 361
  * @param $str the file whose extension should be retrieved.
362 362
  */
363
-function wpinv_get_file_extension( $str ) {
364
-    $filetype = wp_check_filetype( $str );
363
+function wpinv_get_file_extension($str) {
364
+    $filetype = wp_check_filetype($str);
365 365
     return $filetype['ext'];
366 366
 }
367 367
 
@@ -370,16 +370,16 @@  discard block
 block discarded – undo
370 370
  * 
371 371
  * @param string $string
372 372
  */
373
-function wpinv_string_is_image_url( $string ) {
374
-    $extension = strtolower( wpinv_get_file_extension( $string ) );
375
-    return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true );
373
+function wpinv_string_is_image_url($string) {
374
+    $extension = strtolower(wpinv_get_file_extension($string));
375
+    return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true);
376 376
 }
377 377
 
378 378
 /**
379 379
  * Returns the current URL.
380 380
  */
381 381
 function wpinv_get_current_page_url() {
382
-    return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
382
+    return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
383 383
 }
384 384
 
385 385
 /**
@@ -389,46 +389,46 @@  discard block
 block discarded – undo
389 389
  * @param string $name  Constant name.
390 390
  * @param mixed  $value Value.
391 391
  */
392
-function getpaid_maybe_define_constant( $name, $value ) {
393
-	if ( ! defined( $name ) ) {
394
-		define( $name, $value );
392
+function getpaid_maybe_define_constant($name, $value) {
393
+	if (!defined($name)) {
394
+		define($name, $value);
395 395
 	}
396 396
 }
397 397
 
398 398
 function wpinv_get_php_arg_separator_output() {
399
-	return ini_get( 'arg_separator.output' );
399
+	return ini_get('arg_separator.output');
400 400
 }
401 401
 
402
-function wpinv_rgb_from_hex( $color ) {
403
-    $color = str_replace( '#', '', $color );
402
+function wpinv_rgb_from_hex($color) {
403
+    $color = str_replace('#', '', $color);
404 404
 
405 405
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
406
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
407
-    if ( empty( $color ) ) {
406
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
407
+    if (empty($color)) {
408 408
         return NULL;
409 409
     }
410 410
 
411
-    $color = str_split( $color );
411
+    $color = str_split($color);
412 412
 
413 413
     $rgb      = array();
414
-    $rgb['R'] = hexdec( $color[0] . $color[1] );
415
-    $rgb['G'] = hexdec( $color[2] . $color[3] );
416
-    $rgb['B'] = hexdec( $color[4] . $color[5] );
414
+    $rgb['R'] = hexdec($color[0] . $color[1]);
415
+    $rgb['G'] = hexdec($color[2] . $color[3]);
416
+    $rgb['B'] = hexdec($color[4] . $color[5]);
417 417
 
418 418
     return $rgb;
419 419
 }
420 420
 
421
-function wpinv_hex_darker( $color, $factor = 30 ) {
422
-    $base  = wpinv_rgb_from_hex( $color );
421
+function wpinv_hex_darker($color, $factor = 30) {
422
+    $base  = wpinv_rgb_from_hex($color);
423 423
     $color = '#';
424 424
 
425
-    foreach ( $base as $k => $v ) {
425
+    foreach ($base as $k => $v) {
426 426
         $amount      = $v / 100;
427
-        $amount      = round( $amount * $factor );
427
+        $amount      = round($amount * $factor);
428 428
         $new_decimal = $v - $amount;
429 429
 
430
-        $new_hex_component = dechex( $new_decimal );
431
-        if ( strlen( $new_hex_component ) < 2 ) {
430
+        $new_hex_component = dechex($new_decimal);
431
+        if (strlen($new_hex_component) < 2) {
432 432
             $new_hex_component = "0" . $new_hex_component;
433 433
         }
434 434
         $color .= $new_hex_component;
@@ -437,18 +437,18 @@  discard block
 block discarded – undo
437 437
     return $color;
438 438
 }
439 439
 
440
-function wpinv_hex_lighter( $color, $factor = 30 ) {
441
-    $base  = wpinv_rgb_from_hex( $color );
440
+function wpinv_hex_lighter($color, $factor = 30) {
441
+    $base  = wpinv_rgb_from_hex($color);
442 442
     $color = '#';
443 443
 
444
-    foreach ( $base as $k => $v ) {
444
+    foreach ($base as $k => $v) {
445 445
         $amount      = 255 - $v;
446 446
         $amount      = $amount / 100;
447
-        $amount      = round( $amount * $factor );
447
+        $amount      = round($amount * $factor);
448 448
         $new_decimal = $v + $amount;
449 449
 
450
-        $new_hex_component = dechex( $new_decimal );
451
-        if ( strlen( $new_hex_component ) < 2 ) {
450
+        $new_hex_component = dechex($new_decimal);
451
+        if (strlen($new_hex_component) < 2) {
452 452
             $new_hex_component = "0" . $new_hex_component;
453 453
         }
454 454
         $color .= $new_hex_component;
@@ -457,22 +457,22 @@  discard block
 block discarded – undo
457 457
     return $color;
458 458
 }
459 459
 
460
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
461
-    $hex = str_replace( '#', '', $color );
460
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
461
+    $hex = str_replace('#', '', $color);
462 462
 
463
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
464
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
465
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
463
+    $c_r = hexdec(substr($hex, 0, 2));
464
+    $c_g = hexdec(substr($hex, 2, 2));
465
+    $c_b = hexdec(substr($hex, 4, 2));
466 466
 
467
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
467
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
468 468
 
469 469
     return $brightness > 155 ? $dark : $light;
470 470
 }
471 471
 
472
-function wpinv_format_hex( $hex ) {
473
-    $hex = trim( str_replace( '#', '', $hex ) );
472
+function wpinv_format_hex($hex) {
473
+    $hex = trim(str_replace('#', '', $hex));
474 474
 
475
-    if ( strlen( $hex ) == 3 ) {
475
+    if (strlen($hex) == 3) {
476 476
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
477 477
     }
478 478
 
@@ -492,12 +492,12 @@  discard block
 block discarded – undo
492 492
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
493 493
  * @return string
494 494
  */
495
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
496
-    if ( function_exists( 'mb_strimwidth' ) ) {
497
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
495
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
496
+    if (function_exists('mb_strimwidth')) {
497
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
498 498
     }
499 499
     
500
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
500
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
501 501
 }
502 502
 
503 503
 /**
@@ -509,28 +509,28 @@  discard block
 block discarded – undo
509 509
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
510 510
  * @return int Returns the number of characters in string.
511 511
  */
512
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
513
-    if ( function_exists( 'mb_strlen' ) ) {
514
-        return mb_strlen( $str, $encoding );
512
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
513
+    if (function_exists('mb_strlen')) {
514
+        return mb_strlen($str, $encoding);
515 515
     }
516 516
         
517
-    return strlen( $str );
517
+    return strlen($str);
518 518
 }
519 519
 
520
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
521
-    if ( function_exists( 'mb_strtolower' ) ) {
522
-        return mb_strtolower( $str, $encoding );
520
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
521
+    if (function_exists('mb_strtolower')) {
522
+        return mb_strtolower($str, $encoding);
523 523
     }
524 524
     
525
-    return strtolower( $str );
525
+    return strtolower($str);
526 526
 }
527 527
 
528
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
529
-    if ( function_exists( 'mb_strtoupper' ) ) {
530
-        return mb_strtoupper( $str, $encoding );
528
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
529
+    if (function_exists('mb_strtoupper')) {
530
+        return mb_strtoupper($str, $encoding);
531 531
     }
532 532
     
533
-    return strtoupper( $str );
533
+    return strtoupper($str);
534 534
 }
535 535
 
536 536
 /**
@@ -544,12 +544,12 @@  discard block
 block discarded – undo
544 544
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
545 545
  * @return int Returns the position of the first occurrence of search in the string.
546 546
  */
547
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
548
-    if ( function_exists( 'mb_strpos' ) ) {
549
-        return mb_strpos( $str, $find, $offset, $encoding );
547
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
548
+    if (function_exists('mb_strpos')) {
549
+        return mb_strpos($str, $find, $offset, $encoding);
550 550
     }
551 551
         
552
-    return strpos( $str, $find, $offset );
552
+    return strpos($str, $find, $offset);
553 553
 }
554 554
 
555 555
 /**
@@ -563,12 +563,12 @@  discard block
 block discarded – undo
563 563
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
564 564
  * @return int Returns the position of the last occurrence of search.
565 565
  */
566
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
567
-    if ( function_exists( 'mb_strrpos' ) ) {
568
-        return mb_strrpos( $str, $find, $offset, $encoding );
566
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
567
+    if (function_exists('mb_strrpos')) {
568
+        return mb_strrpos($str, $find, $offset, $encoding);
569 569
     }
570 570
         
571
-    return strrpos( $str, $find, $offset );
571
+    return strrpos($str, $find, $offset);
572 572
 }
573 573
 
574 574
 /**
@@ -583,16 +583,16 @@  discard block
 block discarded – undo
583 583
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
584 584
  * @return string
585 585
  */
586
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
587
-    if ( function_exists( 'mb_substr' ) ) {
588
-        if ( $length === null ) {
589
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
586
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
587
+    if (function_exists('mb_substr')) {
588
+        if ($length === null) {
589
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
590 590
         } else {
591
-            return mb_substr( $str, $start, $length, $encoding );
591
+            return mb_substr($str, $start, $length, $encoding);
592 592
         }
593 593
     }
594 594
         
595
-    return substr( $str, $start, $length );
595
+    return substr($str, $start, $length);
596 596
 }
597 597
 
598 598
 /**
@@ -604,48 +604,48 @@  discard block
 block discarded – undo
604 604
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
605 605
  * @return string The width of string.
606 606
  */
607
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
608
-    if ( function_exists( 'mb_strwidth' ) ) {
609
-        return mb_strwidth( $str, $encoding );
607
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
608
+    if (function_exists('mb_strwidth')) {
609
+        return mb_strwidth($str, $encoding);
610 610
     }
611 611
     
612
-    return wpinv_utf8_strlen( $str, $encoding );
612
+    return wpinv_utf8_strlen($str, $encoding);
613 613
 }
614 614
 
615
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
616
-    if ( function_exists( 'mb_strlen' ) ) {
617
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
615
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
616
+    if (function_exists('mb_strlen')) {
617
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
618 618
         $str_end = "";
619 619
         
620
-        if ( $lower_str_end ) {
621
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
620
+        if ($lower_str_end) {
621
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
622 622
         } else {
623
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
623
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
624 624
         }
625 625
 
626 626
         return $first_letter . $str_end;
627 627
     }
628 628
     
629
-    return ucfirst( $str );
629
+    return ucfirst($str);
630 630
 }
631 631
 
632
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
633
-    if ( function_exists( 'mb_convert_case' ) ) {
634
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
632
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
633
+    if (function_exists('mb_convert_case')) {
634
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
635 635
     }
636 636
     
637
-    return ucwords( $str );
637
+    return ucwords($str);
638 638
 }
639 639
 
640
-function wpinv_period_in_days( $period, $unit ) {
641
-    $period = absint( $period );
640
+function wpinv_period_in_days($period, $unit) {
641
+    $period = absint($period);
642 642
     
643
-    if ( $period > 0 ) {
644
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
643
+    if ($period > 0) {
644
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
645 645
             $period = $period * 7;
646
-        } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
646
+        } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) {
647 647
             $period = $period * 30;
648
-        } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
648
+        } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) {
649 649
             $period = $period * 365;
650 650
         }
651 651
     }
@@ -653,14 +653,14 @@  discard block
 block discarded – undo
653 653
     return $period;
654 654
 }
655 655
 
656
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
657
-    if ( function_exists( 'cal_days_in_month' ) ) {
658
-        return cal_days_in_month( $calendar, $month, $year );
656
+function wpinv_cal_days_in_month($calendar, $month, $year) {
657
+    if (function_exists('cal_days_in_month')) {
658
+        return cal_days_in_month($calendar, $month, $year);
659 659
     }
660 660
 
661 661
     // Fallback in case the calendar extension is not loaded in PHP
662 662
     // Only supports Gregorian calendar
663
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
663
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
664 664
 }
665 665
 
666 666
 /**
@@ -671,12 +671,12 @@  discard block
 block discarded – undo
671 671
  *
672 672
  * @return string
673 673
  */
674
-function wpi_help_tip( $tip, $allow_html = false ) {
674
+function wpi_help_tip($tip, $allow_html = false) {
675 675
 
676
-    if ( $allow_html ) {
677
-        $tip = wpi_sanitize_tooltip( $tip );
676
+    if ($allow_html) {
677
+        $tip = wpi_sanitize_tooltip($tip);
678 678
     } else {
679
-        $tip = esc_attr( $tip );
679
+        $tip = esc_attr($tip);
680 680
     }
681 681
 
682 682
     return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -690,8 +690,8 @@  discard block
 block discarded – undo
690 690
  * @param string $var
691 691
  * @return string
692 692
  */
693
-function wpi_sanitize_tooltip( $var ) {
694
-    return wp_kses( html_entity_decode( $var ), array(
693
+function wpi_sanitize_tooltip($var) {
694
+    return wp_kses(html_entity_decode($var), array(
695 695
         'br'     => array(),
696 696
         'em'     => array(),
697 697
         'strong' => array(),
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
         'li'     => array(),
703 703
         'ol'     => array(),
704 704
         'p'      => array(),
705
-    ) );
705
+    ));
706 706
 }
707 707
 
708 708
 /**
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
  */
713 713
 function wpinv_get_screen_ids() {
714 714
 
715
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
715
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
716 716
 
717 717
     $screen_ids = array(
718 718
         'toplevel_page_' . $screen_id,
@@ -731,10 +731,10 @@  discard block
 block discarded – undo
731 731
         'getpaid_page_wpinv-reports',
732 732
         'getpaid_page_wpi-addons',
733 733
         'getpaid_page_wpinv-customers',
734
-        'gp-setup',// setup wizard
734
+        'gp-setup', // setup wizard
735 735
     );
736 736
 
737
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
737
+    return apply_filters('wpinv_screen_ids', $screen_ids);
738 738
 }
739 739
 
740 740
 /**
@@ -745,14 +745,14 @@  discard block
 block discarded – undo
745 745
  * @param array|string $list List of values.
746 746
  * @return array Sanitized array of values.
747 747
  */
748
-function wpinv_parse_list( $list ) {
748
+function wpinv_parse_list($list) {
749 749
 
750
-    if ( empty( $list ) ) {
750
+    if (empty($list)) {
751 751
         $list = array();
752 752
     }
753 753
 
754
-	if ( ! is_array( $list ) ) {
755
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
754
+	if (!is_array($list)) {
755
+		return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
756 756
 	}
757 757
 
758 758
 	return $list;
@@ -766,16 +766,16 @@  discard block
 block discarded – undo
766 766
  * @param string $key Type of data to fetch.
767 767
  * @return mixed Fetched data.
768 768
  */
769
-function wpinv_get_data( $key ) {
769
+function wpinv_get_data($key) {
770 770
 
771 771
     // Try fetching it from the cache.
772
-    $data = wp_cache_get( "wpinv-data-$key", 'wpinv' );
773
-    if( $data ) {
772
+    $data = wp_cache_get("wpinv-data-$key", 'wpinv');
773
+    if ($data) {
774 774
         return $data;
775 775
     }
776 776
 
777
-    $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
778
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
777
+    $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php");
778
+	wp_cache_set("wpinv-data-$key", $data, 'wpinv');
779 779
 
780 780
 	return $data;
781 781
 }
@@ -789,10 +789,10 @@  discard block
 block discarded – undo
789 789
  * @param bool $first_empty Whether or not the first item in the list should be empty
790 790
  * @return mixed Fetched data.
791 791
  */
792
-function wpinv_maybe_add_empty_option( $options, $first_empty ) {
792
+function wpinv_maybe_add_empty_option($options, $first_empty) {
793 793
 
794
-    if ( ! empty( $options ) && $first_empty ) {
795
-        return array_merge( array( '' => '' ), $options );
794
+    if (!empty($options) && $first_empty) {
795
+        return array_merge(array('' => ''), $options);
796 796
     }
797 797
     return $options;
798 798
 
@@ -804,21 +804,21 @@  discard block
 block discarded – undo
804 804
  * @param mixed $var Data to sanitize.
805 805
  * @return string|array
806 806
  */
807
-function wpinv_clean( $var ) {
807
+function wpinv_clean($var) {
808 808
 
809
-	if ( is_array( $var ) ) {
810
-		return array_map( 'wpinv_clean', $var );
809
+	if (is_array($var)) {
810
+		return array_map('wpinv_clean', $var);
811 811
     }
812 812
 
813
-    if ( is_object( $var ) ) {
814
-		$object_vars = get_object_vars( $var );
815
-		foreach ( $object_vars as $property_name => $property_value ) {
816
-			$var->$property_name = wpinv_clean( $property_value );
813
+    if (is_object($var)) {
814
+		$object_vars = get_object_vars($var);
815
+		foreach ($object_vars as $property_name => $property_value) {
816
+			$var->$property_name = wpinv_clean($property_value);
817 817
         }
818 818
         return $var;
819 819
 	}
820 820
 
821
-    return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var;
821
+    return is_string($var) ? sanitize_text_field(stripslashes($var)) : $var;
822 822
 }
823 823
 
824 824
 /**
@@ -827,43 +827,43 @@  discard block
 block discarded – undo
827 827
  * @param string $str Data to convert.
828 828
  * @return string|array
829 829
  */
830
-function getpaid_convert_price_string_to_options( $str ) {
830
+function getpaid_convert_price_string_to_options($str) {
831 831
 
832
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
833
-    $options     = array();
832
+	$raw_options = array_map('trim', explode(',', $str));
833
+    $options = array();
834 834
 
835
-    foreach ( $raw_options as $option ) {
835
+    foreach ($raw_options as $option) {
836 836
 
837
-        if ( '' == $option ) {
837
+        if ('' == $option) {
838 838
             continue;
839 839
         }
840 840
 
841
-        $option = array_map( 'trim', explode( '|', $option ) );
841
+        $option = array_map('trim', explode('|', $option));
842 842
 
843 843
         $price = null;
844 844
         $label = null;
845 845
 
846
-        if ( isset( $option[0] ) && '' !=  $option[0] ) {
847
-            $label  = $option[0];
846
+        if (isset($option[0]) && '' != $option[0]) {
847
+            $label = $option[0];
848 848
         }
849 849
 
850
-        if ( isset( $option[1] ) && '' !=  $option[1] ) {
850
+        if (isset($option[1]) && '' != $option[1]) {
851 851
             $price = $option[1];
852 852
         }
853 853
 
854
-        if ( ! isset( $price ) ) {
854
+        if (!isset($price)) {
855 855
             $price = $label;
856 856
         }
857 857
 
858
-        if ( ! isset( $price ) || ! is_numeric( $price ) ) {
858
+        if (!isset($price) || !is_numeric($price)) {
859 859
             continue;
860 860
         }
861 861
 
862
-        if ( ! isset( $label ) ) {
862
+        if (!isset($label)) {
863 863
             $label = $price;
864 864
         }
865 865
 
866
-        $options[ "$label|$price" ] = $label;
866
+        $options["$label|$price"] = $label;
867 867
     }
868 868
 
869 869
     return $options;
@@ -872,27 +872,27 @@  discard block
 block discarded – undo
872 872
 /**
873 873
  * Returns the help tip.
874 874
  */
875
-function getpaid_get_help_tip( $tip, $additional_classes = '' ) {
876
-    $additional_classes = sanitize_html_class( $additional_classes );
877
-    $tip                = esc_attr__( $tip );
875
+function getpaid_get_help_tip($tip, $additional_classes = '') {
876
+    $additional_classes = sanitize_html_class($additional_classes);
877
+    $tip                = esc_attr__($tip);
878 878
     return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>";
879 879
 }
880 880
 
881 881
 /**
882 882
  * Formats a date
883 883
  */
884
-function getpaid_format_date( $date, $with_time = false ) {
884
+function getpaid_format_date($date, $with_time = false) {
885 885
 
886
-    if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) {
886
+    if (empty($date) || $date == '0000-00-00 00:00:00') {
887 887
         return '';
888 888
     }
889 889
 
890 890
     $format = getpaid_date_format();
891 891
 
892
-    if ( $with_time ) {
892
+    if ($with_time) {
893 893
         $format .= ' ' . getpaid_time_format();
894 894
     }
895
-    return date_i18n( $format, strtotime( $date ) );
895
+    return date_i18n($format, strtotime($date));
896 896
 
897 897
 }
898 898
 
@@ -901,9 +901,9 @@  discard block
 block discarded – undo
901 901
  *
902 902
  * @return string
903 903
  */
904
-function getpaid_format_date_value( $date, $default = "&mdash;", $with_time = false ) {
905
-    $date = getpaid_format_date( $date, $with_time );
906
-    return empty( $date ) ? $default : $date;
904
+function getpaid_format_date_value($date, $default = "&mdash;", $with_time = false) {
905
+    $date = getpaid_format_date($date, $with_time);
906
+    return empty($date) ? $default : $date;
907 907
 }
908 908
 
909 909
 /**
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
  * @return string
913 913
  */
914 914
 function getpaid_date_format() {
915
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
915
+	return apply_filters('getpaid_date_format', get_option('date_format'));
916 916
 }
917 917
 
918 918
 /**
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
  * @return string
922 922
  */
923 923
 function getpaid_time_format() {
924
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
924
+	return apply_filters('getpaid_time_format', get_option('time_format'));
925 925
 }
926 926
 
927 927
 /**
@@ -931,16 +931,16 @@  discard block
 block discarded – undo
931 931
  * @param  integer $limit Limit size in characters.
932 932
  * @return string
933 933
  */
934
-function getpaid_limit_length( $string, $limit ) {
934
+function getpaid_limit_length($string, $limit) {
935 935
     $str_limit = $limit - 3;
936 936
 
937
-	if ( function_exists( 'mb_strimwidth' ) ) {
938
-		if ( mb_strlen( $string ) > $limit ) {
939
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
937
+	if (function_exists('mb_strimwidth')) {
938
+		if (mb_strlen($string) > $limit) {
939
+			$string = mb_strimwidth($string, 0, $str_limit) . '...';
940 940
 		}
941 941
 	} else {
942
-		if ( strlen( $string ) > $limit ) {
943
-			$string = substr( $string, 0, $str_limit ) . '...';
942
+		if (strlen($string) > $limit) {
943
+			$string = substr($string, 0, $str_limit) . '...';
944 944
 		}
945 945
 	}
946 946
     return $string;
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
  * @since 1.0.19
955 955
  */
956 956
 function getpaid_api() {
957
-    return getpaid()->get( 'api' );
957
+    return getpaid()->get('api');
958 958
 }
959 959
 
960 960
 /**
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
  * @since 1.0.19
965 965
  */
966 966
 function getpaid_post_types() {
967
-    return getpaid()->get( 'post_types' );
967
+    return getpaid()->get('post_types');
968 968
 }
969 969
 
970 970
 /**
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
  * @since 1.0.19
975 975
  */
976 976
 function getpaid_session() {
977
-    return getpaid()->get( 'session' );
977
+    return getpaid()->get('session');
978 978
 }
979 979
 
980 980
 /**
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
  * @since 1.0.19
985 985
  */
986 986
 function getpaid_notes() {
987
-    return getpaid()->get( 'notes' );
987
+    return getpaid()->get('notes');
988 988
 }
989 989
 
990 990
 /**
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
  * @return GetPaid_Admin
994 994
  */
995 995
 function getpaid_admin() {
996
-    return getpaid()->get( 'admin' );
996
+    return getpaid()->get('admin');
997 997
 }
998 998
 
999 999
 /**
@@ -1003,8 +1003,8 @@  discard block
 block discarded – undo
1003 1003
  * @param string $base the base url
1004 1004
  * @return string
1005 1005
  */
1006
-function getpaid_get_authenticated_action_url( $action, $base = false ) {
1007
-    return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' );
1006
+function getpaid_get_authenticated_action_url($action, $base = false) {
1007
+    return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce');
1008 1008
 }
1009 1009
 
1010 1010
 /**
@@ -1012,11 +1012,11 @@  discard block
 block discarded – undo
1012 1012
  *
1013 1013
  * @return string
1014 1014
  */
1015
-function getpaid_get_post_type_label( $post_type, $plural = true ) {
1015
+function getpaid_get_post_type_label($post_type, $plural = true) {
1016 1016
 
1017
-    $post_type = get_post_type_object( $post_type );
1017
+    $post_type = get_post_type_object($post_type);
1018 1018
 
1019
-    if ( ! is_object( $post_type ) ) {
1019
+    if (!is_object($post_type)) {
1020 1020
         return null;
1021 1021
     }
1022 1022
 
@@ -1029,18 +1029,18 @@  discard block
 block discarded – undo
1029 1029
  *
1030 1030
  * @return mixed|null
1031 1031
  */
1032
-function getpaid_get_array_field( $array, $key, $secondary_key = null ) {
1032
+function getpaid_get_array_field($array, $key, $secondary_key = null) {
1033 1033
 
1034
-    if ( ! is_array( $array ) ) {
1034
+    if (!is_array($array)) {
1035 1035
         return null;
1036 1036
     }
1037 1037
 
1038
-    if ( ! empty( $secondary_key ) ) {
1039
-        $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array();
1040
-        return getpaid_get_array_field( $array, $key );
1038
+    if (!empty($secondary_key)) {
1039
+        $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array();
1040
+        return getpaid_get_array_field($array, $key);
1041 1041
     }
1042 1042
 
1043
-    return isset( $array[ $key ] ) ? $array[ $key ] : null;
1043
+    return isset($array[$key]) ? $array[$key] : null;
1044 1044
 
1045 1045
 }
1046 1046
 
@@ -1049,12 +1049,12 @@  discard block
 block discarded – undo
1049 1049
  *
1050 1050
  * @return array
1051 1051
  */
1052
-function getpaid_array_merge_if_empty( $args, $defaults ) {
1052
+function getpaid_array_merge_if_empty($args, $defaults) {
1053 1053
 
1054
-    foreach ( $defaults as $key => $value ) {
1054
+    foreach ($defaults as $key => $value) {
1055 1055
 
1056
-        if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) {
1057
-            $args[ $key ] = $value;
1056
+        if (array_key_exists($key, $args) && empty($args[$key])) {
1057
+            $args[$key] = $value;
1058 1058
         }
1059 1059
 
1060 1060
     }
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2520 added lines, -2520 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,
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
         'subtotal'             => 0,
68 68
         'total_discount'       => 0,
69 69
         'total_tax'            => 0,
70
-		'total_fees'           => 0,
71
-		'total'                => 0,
70
+        'total_fees'           => 0,
71
+        'total'                => 0,
72 72
         'fees'                 => array(),
73 73
         'discounts'            => array(),
74 74
         'taxes'                => array(),
@@ -80,22 +80,22 @@  discard block
 block discarded – undo
80 80
         'transaction_id'       => '',
81 81
         'currency'             => '',
82 82
         'disable_taxes'        => false,
83
-		'subscription_id'      => null,
84
-		'remote_subscription_id' => null,
85
-		'is_viewed'            => false,
86
-		'email_cc'             => '',
87
-		'template'             => 'quantity', // hours, amount only
88
-		'created_via'          => null,
83
+        'subscription_id'      => null,
84
+        'remote_subscription_id' => null,
85
+        'is_viewed'            => false,
86
+        'email_cc'             => '',
87
+        'template'             => 'quantity', // hours, amount only
88
+        'created_via'          => null,
89 89
     );
90 90
 
91 91
     /**
92
-	 * Stores meta in cache for future reads.
93
-	 *
94
-	 * A group must be set to to enable caching.
95
-	 *
96
-	 * @var string
97
-	 */
98
-	protected $cache_group = 'getpaid_invoices';
92
+     * Stores meta in cache for future reads.
93
+     *
94
+     * A group must be set to to enable caching.
95
+     *
96
+     * @var string
97
+     */
98
+    protected $cache_group = 'getpaid_invoices';
99 99
 
100 100
     /**
101 101
      * Stores a reference to the original WP_Post object
@@ -109,111 +109,111 @@  discard block
 block discarded – undo
109 109
      *
110 110
      * @var int
111 111
      */
112
-	protected $recurring_item = null;
112
+    protected $recurring_item = null;
113 113
 
114
-	/**
114
+    /**
115 115
      * Stores an array of item totals.
116
-	 *
117
-	 * e.g $totals['discount'] = array(
118
-	 * 		'initial'   => 10,
119
-	 * 		'recurring' => 10,
120
-	 * )
116
+     *
117
+     * e.g $totals['discount'] = array(
118
+     * 		'initial'   => 10,
119
+     * 		'recurring' => 10,
120
+     * )
121 121
      *
122 122
      * @var array
123 123
      */
124
-	protected $totals = array();
124
+    protected $totals = array();
125 125
 
126
-	/**
126
+    /**
127 127
      * Tax rate.
128
-	 *
128
+     *
129 129
      * @var float
130 130
      */
131
-	protected $tax_rate = 0;
131
+    protected $tax_rate = 0;
132 132
 
133
-	/**
134
-	 * Stores the status transition information.
135
-	 *
136
-	 * @since 1.0.19
137
-	 * @var bool|array
138
-	 */
139
-	protected $status_transition = false;
133
+    /**
134
+     * Stores the status transition information.
135
+     *
136
+     * @since 1.0.19
137
+     * @var bool|array
138
+     */
139
+    protected $status_transition = false;
140 140
 
141 141
     /**
142
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
143
-	 *
144
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
145
-	 */
142
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
143
+     *
144
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
145
+     */
146 146
     public function __construct( $invoice = 0 ) {
147 147
 
148 148
         parent::__construct( $invoice );
149 149
 
150
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
151
-			$this->set_id( (int) $invoice );
152
-		} elseif ( $invoice instanceof self ) {
153
-			$this->set_id( $invoice->get_id() );
154
-		} elseif ( ! empty( $invoice->ID ) ) {
155
-			$this->set_id( $invoice->ID );
156
-		} elseif ( is_array( $invoice ) ) {
157
-			$this->set_props( $invoice );
158
-
159
-			if ( isset( $invoice['ID'] ) ) {
160
-				$this->set_id( $invoice['ID'] );
161
-			}
162
-
163
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
164
-			$this->set_id( $invoice_id );
165
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
166
-			$this->set_id( $invoice_id );
167
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
168
-			$this->set_id( $invoice_id );
169
-		} else {
170
-			$this->set_object_read( true );
171
-		}
150
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
151
+            $this->set_id( (int) $invoice );
152
+        } elseif ( $invoice instanceof self ) {
153
+            $this->set_id( $invoice->get_id() );
154
+        } elseif ( ! empty( $invoice->ID ) ) {
155
+            $this->set_id( $invoice->ID );
156
+        } elseif ( is_array( $invoice ) ) {
157
+            $this->set_props( $invoice );
158
+
159
+            if ( isset( $invoice['ID'] ) ) {
160
+                $this->set_id( $invoice['ID'] );
161
+            }
162
+
163
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
164
+            $this->set_id( $invoice_id );
165
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
166
+            $this->set_id( $invoice_id );
167
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
168
+            $this->set_id( $invoice_id );
169
+        } else {
170
+            $this->set_object_read( true );
171
+        }
172 172
 
173 173
         // Load the datastore.
174
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
174
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
175 175
 
176
-		if ( $this->get_id() > 0 ) {
176
+        if ( $this->get_id() > 0 ) {
177 177
             $this->post = get_post( $this->get_id() );
178 178
             $this->ID   = $this->get_id();
179
-			$this->data_store->read( $this );
179
+            $this->data_store->read( $this );
180 180
         }
181 181
 
182 182
     }
183 183
 
184 184
     /**
185
-	 * Given an invoice key/number, it returns its id.
186
-	 *
187
-	 *
188
-	 * @static
189
-	 * @param string $value The invoice key or number
190
-	 * @param string $field Either key, transaction_id or number.
191
-	 * @since 1.0.15
192
-	 * @return int
193
-	 */
194
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
185
+     * Given an invoice key/number, it returns its id.
186
+     *
187
+     *
188
+     * @static
189
+     * @param string $value The invoice key or number
190
+     * @param string $field Either key, transaction_id or number.
191
+     * @since 1.0.15
192
+     * @return int
193
+     */
194
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
195 195
         global $wpdb;
196 196
 
197
-		// Trim the value.
198
-		$value = trim( $value );
197
+        // Trim the value.
198
+        $value = trim( $value );
199 199
 
200
-		if ( empty( $value ) ) {
201
-			return 0;
202
-		}
200
+        if ( empty( $value ) ) {
201
+            return 0;
202
+        }
203 203
 
204 204
         // Valid fields.
205 205
         $fields = array( 'key', 'number', 'transaction_id' );
206 206
 
207
-		// Ensure a field has been passed.
208
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
209
-			return 0;
210
-		}
207
+        // Ensure a field has been passed.
208
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
209
+            return 0;
210
+        }
211 211
 
212
-		// Maybe retrieve from the cache.
213
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
214
-		if ( false !== $invoice_id ) {
215
-			return $invoice_id;
216
-		}
212
+        // Maybe retrieve from the cache.
213
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
214
+        if ( false !== $invoice_id ) {
215
+            return $invoice_id;
216
+        }
217 217
 
218 218
         // Fetch from the db.
219 219
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
222 222
         );
223 223
 
224
-		// Update the cache with our data
225
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
224
+        // Update the cache with our data
225
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
226 226
 
227
-		return $invoice_id;
227
+        return $invoice_id;
228 228
     }
229 229
 
230 230
     /**
@@ -250,83 +250,83 @@  discard block
 block discarded – undo
250 250
     */
251 251
 
252 252
     /**
253
-	 * Get parent invoice ID.
254
-	 *
255
-	 * @since 1.0.19
256
-	 * @param  string $context View or edit context.
257
-	 * @return int
258
-	 */
259
-	public function get_parent_id( $context = 'view' ) {
260
-		return (int) $this->get_prop( 'parent_id', $context );
253
+     * Get parent invoice ID.
254
+     *
255
+     * @since 1.0.19
256
+     * @param  string $context View or edit context.
257
+     * @return int
258
+     */
259
+    public function get_parent_id( $context = 'view' ) {
260
+        return (int) $this->get_prop( 'parent_id', $context );
261 261
     }
262 262
 
263 263
     /**
264
-	 * Get parent invoice.
265
-	 *
266
-	 * @since 1.0.19
267
-	 * @return WPInv_Invoice
268
-	 */
264
+     * Get parent invoice.
265
+     *
266
+     * @since 1.0.19
267
+     * @return WPInv_Invoice
268
+     */
269 269
     public function get_parent_payment() {
270 270
         return new WPInv_Invoice( $this->get_parent_id() );
271 271
     }
272 272
 
273 273
     /**
274
-	 * Alias for self::get_parent_payment().
275
-	 *
276
-	 * @since 1.0.19
277
-	 * @return WPInv_Invoice
278
-	 */
274
+     * Alias for self::get_parent_payment().
275
+     *
276
+     * @since 1.0.19
277
+     * @return WPInv_Invoice
278
+     */
279 279
     public function get_parent() {
280 280
         return $this->get_parent_payment();
281 281
     }
282 282
 
283 283
     /**
284
-	 * Get invoice status.
285
-	 *
286
-	 * @since 1.0.19
287
-	 * @param  string $context View or edit context.
288
-	 * @return string
289
-	 */
290
-	public function get_status( $context = 'view' ) {
291
-		return $this->get_prop( 'status', $context );
292
-	}
284
+     * Get invoice status.
285
+     *
286
+     * @since 1.0.19
287
+     * @param  string $context View or edit context.
288
+     * @return string
289
+     */
290
+    public function get_status( $context = 'view' ) {
291
+        return $this->get_prop( 'status', $context );
292
+    }
293 293
 	
294
-	/**
295
-	 * Retrieves an array of possible invoice statuses.
296
-	 *
297
-	 * @since 1.0.19
298
-	 * @return array
299
-	 */
300
-	public function get_all_statuses() {
301
-		return wpinv_get_invoice_statuses( true, true, $this );
302
-    }
303
-
304
-    /**
305
-	 * Get invoice status nice name.
306
-	 *
307
-	 * @since 1.0.19
308
-	 * @return string
309
-	 */
294
+    /**
295
+     * Retrieves an array of possible invoice statuses.
296
+     *
297
+     * @since 1.0.19
298
+     * @return array
299
+     */
300
+    public function get_all_statuses() {
301
+        return wpinv_get_invoice_statuses( true, true, $this );
302
+    }
303
+
304
+    /**
305
+     * Get invoice status nice name.
306
+     *
307
+     * @since 1.0.19
308
+     * @return string
309
+     */
310 310
     public function get_status_nicename() {
311
-		$statuses = $this->get_all_statuses();
311
+        $statuses = $this->get_all_statuses();
312 312
 
313 313
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
314 314
 
315 315
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
316 316
     }
317 317
 
318
-	/**
319
-	 * Retrieves the invoice status class
320
-	 *
321
-	 * @since  1.0.19
322
-	 * @return string
323
-	 */
324
-	public function get_status_class() {
325
-		$statuses = getpaid_get_invoice_status_classes();
326
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
327
-	}
318
+    /**
319
+     * Retrieves the invoice status class
320
+     *
321
+     * @since  1.0.19
322
+     * @return string
323
+     */
324
+    public function get_status_class() {
325
+        $statuses = getpaid_get_invoice_status_classes();
326
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
327
+    }
328 328
 
329
-	/**
329
+    /**
330 330
      * Retrieves the invoice status label html
331 331
      *
332 332
      * @since  1.0.0
@@ -334,263 +334,263 @@  discard block
 block discarded – undo
334 334
      */
335 335
     public function get_status_label_html() {
336 336
 
337
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
338
-		$status       = sanitize_html_class( $this->get_status() );
339
-		$class        = esc_attr( $this->get_status_class() );
337
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
338
+        $status       = sanitize_html_class( $this->get_status() );
339
+        $class        = esc_attr( $this->get_status_class() );
340 340
 
341
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
342
-	}
341
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
342
+    }
343 343
 
344 344
     /**
345
-	 * Get plugin version when the invoice was created.
346
-	 *
347
-	 * @since 1.0.19
348
-	 * @param  string $context View or edit context.
349
-	 * @return string
350
-	 */
351
-	public function get_version( $context = 'view' ) {
352
-		return $this->get_prop( 'version', $context );
353
-	}
345
+     * Get plugin version when the invoice was created.
346
+     *
347
+     * @since 1.0.19
348
+     * @param  string $context View or edit context.
349
+     * @return string
350
+     */
351
+    public function get_version( $context = 'view' ) {
352
+        return $this->get_prop( 'version', $context );
353
+    }
354 354
 
355
-	/**
356
-	 * @deprecated
357
-	 */
358
-	public function get_invoice_date( $format = true ) {
359
-		$date      = getpaid_format_date( $this->get_date_completed() );
360
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
361
-		$formatted = getpaid_format_date( $date );
355
+    /**
356
+     * @deprecated
357
+     */
358
+    public function get_invoice_date( $format = true ) {
359
+        $date      = getpaid_format_date( $this->get_date_completed() );
360
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
361
+        $formatted = getpaid_format_date( $date );
362 362
 
363
-		if ( $format ) {
364
-			return $formatted;
365
-		}
363
+        if ( $format ) {
364
+            return $formatted;
365
+        }
366 366
 
367
-		return empty( $formatted ) ? '' : $date;
367
+        return empty( $formatted ) ? '' : $date;
368 368
 
369 369
     }
370 370
 
371 371
     /**
372
-	 * Get date when the invoice was created.
373
-	 *
374
-	 * @since 1.0.19
375
-	 * @param  string $context View or edit context.
376
-	 * @return string
377
-	 */
378
-	public function get_date_created( $context = 'view' ) {
379
-		return $this->get_prop( 'date_created', $context );
380
-	}
372
+     * Get date when the invoice was created.
373
+     *
374
+     * @since 1.0.19
375
+     * @param  string $context View or edit context.
376
+     * @return string
377
+     */
378
+    public function get_date_created( $context = 'view' ) {
379
+        return $this->get_prop( 'date_created', $context );
380
+    }
381 381
 	
382
-	/**
383
-	 * Alias for self::get_date_created().
384
-	 *
385
-	 * @since 1.0.19
386
-	 * @param  string $context View or edit context.
387
-	 * @return string
388
-	 */
389
-	public function get_created_date( $context = 'view' ) {
390
-		return $this->get_date_created( $context );
391
-    }
392
-
393
-    /**
394
-	 * Get GMT date when the invoice was created.
395
-	 *
396
-	 * @since 1.0.19
397
-	 * @param  string $context View or edit context.
398
-	 * @return string
399
-	 */
400
-	public function get_date_created_gmt( $context = 'view' ) {
382
+    /**
383
+     * Alias for self::get_date_created().
384
+     *
385
+     * @since 1.0.19
386
+     * @param  string $context View or edit context.
387
+     * @return string
388
+     */
389
+    public function get_created_date( $context = 'view' ) {
390
+        return $this->get_date_created( $context );
391
+    }
392
+
393
+    /**
394
+     * Get GMT date when the invoice was created.
395
+     *
396
+     * @since 1.0.19
397
+     * @param  string $context View or edit context.
398
+     * @return string
399
+     */
400
+    public function get_date_created_gmt( $context = 'view' ) {
401 401
         $date = $this->get_date_created( $context );
402 402
 
403 403
         if ( $date ) {
404 404
             $date = get_gmt_from_date( $date );
405 405
         }
406
-		return $date;
406
+        return $date;
407 407
     }
408 408
 
409 409
     /**
410
-	 * Get date when the invoice was last modified.
411
-	 *
412
-	 * @since 1.0.19
413
-	 * @param  string $context View or edit context.
414
-	 * @return string
415
-	 */
416
-	public function get_date_modified( $context = 'view' ) {
417
-		return $this->get_prop( 'date_modified', $context );
418
-	}
410
+     * Get date when the invoice was last modified.
411
+     *
412
+     * @since 1.0.19
413
+     * @param  string $context View or edit context.
414
+     * @return string
415
+     */
416
+    public function get_date_modified( $context = 'view' ) {
417
+        return $this->get_prop( 'date_modified', $context );
418
+    }
419 419
 
420
-	/**
421
-	 * Alias for self::get_date_modified().
422
-	 *
423
-	 * @since 1.0.19
424
-	 * @param  string $context View or edit context.
425
-	 * @return string
426
-	 */
427
-	public function get_modified_date( $context = 'view' ) {
428
-		return $this->get_date_modified( $context );
420
+    /**
421
+     * Alias for self::get_date_modified().
422
+     *
423
+     * @since 1.0.19
424
+     * @param  string $context View or edit context.
425
+     * @return string
426
+     */
427
+    public function get_modified_date( $context = 'view' ) {
428
+        return $this->get_date_modified( $context );
429 429
     }
430 430
 
431 431
     /**
432
-	 * Get GMT date when the invoice was last modified.
433
-	 *
434
-	 * @since 1.0.19
435
-	 * @param  string $context View or edit context.
436
-	 * @return string
437
-	 */
438
-	public function get_date_modified_gmt( $context = 'view' ) {
432
+     * Get GMT date when the invoice was last modified.
433
+     *
434
+     * @since 1.0.19
435
+     * @param  string $context View or edit context.
436
+     * @return string
437
+     */
438
+    public function get_date_modified_gmt( $context = 'view' ) {
439 439
         $date = $this->get_date_modified( $context );
440 440
 
441 441
         if ( $date ) {
442 442
             $date = get_gmt_from_date( $date );
443 443
         }
444
-		return $date;
444
+        return $date;
445 445
     }
446 446
 
447 447
     /**
448
-	 * Get the invoice due date.
449
-	 *
450
-	 * @since 1.0.19
451
-	 * @param  string $context View or edit context.
452
-	 * @return string
453
-	 */
454
-	public function get_due_date( $context = 'view' ) {
455
-		return $this->get_prop( 'due_date', $context );
448
+     * Get the invoice due date.
449
+     *
450
+     * @since 1.0.19
451
+     * @param  string $context View or edit context.
452
+     * @return string
453
+     */
454
+    public function get_due_date( $context = 'view' ) {
455
+        return $this->get_prop( 'due_date', $context );
456 456
     }
457 457
 
458 458
     /**
459
-	 * Alias for self::get_due_date().
460
-	 *
461
-	 * @since 1.0.19
462
-	 * @param  string $context View or edit context.
463
-	 * @return string
464
-	 */
465
-	public function get_date_due( $context = 'view' ) {
466
-		return $this->get_due_date( $context );
459
+     * Alias for self::get_due_date().
460
+     *
461
+     * @since 1.0.19
462
+     * @param  string $context View or edit context.
463
+     * @return string
464
+     */
465
+    public function get_date_due( $context = 'view' ) {
466
+        return $this->get_due_date( $context );
467 467
     }
468 468
 
469 469
     /**
470
-	 * Get the invoice GMT due date.
471
-	 *
472
-	 * @since 1.0.19
473
-	 * @param  string $context View or edit context.
474
-	 * @return string
475
-	 */
476
-	public function get_due_date_gmt( $context = 'view' ) {
470
+     * Get the invoice GMT due date.
471
+     *
472
+     * @since 1.0.19
473
+     * @param  string $context View or edit context.
474
+     * @return string
475
+     */
476
+    public function get_due_date_gmt( $context = 'view' ) {
477 477
         $date = $this->get_due_date( $context );
478 478
 
479 479
         if ( $date ) {
480 480
             $date = get_gmt_from_date( $date );
481 481
         }
482
-		return $date;
482
+        return $date;
483 483
     }
484 484
 
485 485
     /**
486
-	 * Alias for self::get_due_date_gmt().
487
-	 *
488
-	 * @since 1.0.19
489
-	 * @param  string $context View or edit context.
490
-	 * @return string
491
-	 */
492
-	public function get_gmt_date_due( $context = 'view' ) {
493
-		return $this->get_due_date_gmt( $context );
486
+     * Alias for self::get_due_date_gmt().
487
+     *
488
+     * @since 1.0.19
489
+     * @param  string $context View or edit context.
490
+     * @return string
491
+     */
492
+    public function get_gmt_date_due( $context = 'view' ) {
493
+        return $this->get_due_date_gmt( $context );
494 494
     }
495 495
 
496 496
     /**
497
-	 * Get date when the invoice was completed.
498
-	 *
499
-	 * @since 1.0.19
500
-	 * @param  string $context View or edit context.
501
-	 * @return string
502
-	 */
503
-	public function get_completed_date( $context = 'view' ) {
504
-		return $this->get_prop( 'completed_date', $context );
497
+     * Get date when the invoice was completed.
498
+     *
499
+     * @since 1.0.19
500
+     * @param  string $context View or edit context.
501
+     * @return string
502
+     */
503
+    public function get_completed_date( $context = 'view' ) {
504
+        return $this->get_prop( 'completed_date', $context );
505 505
     }
506 506
 
507 507
     /**
508
-	 * Alias for self::get_completed_date().
509
-	 *
510
-	 * @since 1.0.19
511
-	 * @param  string $context View or edit context.
512
-	 * @return string
513
-	 */
514
-	public function get_date_completed( $context = 'view' ) {
515
-		return $this->get_completed_date( $context );
508
+     * Alias for self::get_completed_date().
509
+     *
510
+     * @since 1.0.19
511
+     * @param  string $context View or edit context.
512
+     * @return string
513
+     */
514
+    public function get_date_completed( $context = 'view' ) {
515
+        return $this->get_completed_date( $context );
516 516
     }
517 517
 
518 518
     /**
519
-	 * Get GMT date when the invoice was was completed.
520
-	 *
521
-	 * @since 1.0.19
522
-	 * @param  string $context View or edit context.
523
-	 * @return string
524
-	 */
525
-	public function get_completed_date_gmt( $context = 'view' ) {
519
+     * Get GMT date when the invoice was was completed.
520
+     *
521
+     * @since 1.0.19
522
+     * @param  string $context View or edit context.
523
+     * @return string
524
+     */
525
+    public function get_completed_date_gmt( $context = 'view' ) {
526 526
         $date = $this->get_completed_date( $context );
527 527
 
528 528
         if ( $date ) {
529 529
             $date = get_gmt_from_date( $date );
530 530
         }
531
-		return $date;
531
+        return $date;
532 532
     }
533 533
 
534 534
     /**
535
-	 * Alias for self::get_completed_date_gmt().
536
-	 *
537
-	 * @since 1.0.19
538
-	 * @param  string $context View or edit context.
539
-	 * @return string
540
-	 */
541
-	public function get_gmt_completed_date( $context = 'view' ) {
542
-		return $this->get_completed_date_gmt( $context );
535
+     * Alias for self::get_completed_date_gmt().
536
+     *
537
+     * @since 1.0.19
538
+     * @param  string $context View or edit context.
539
+     * @return string
540
+     */
541
+    public function get_gmt_completed_date( $context = 'view' ) {
542
+        return $this->get_completed_date_gmt( $context );
543 543
     }
544 544
 
545 545
     /**
546
-	 * Get the invoice number.
547
-	 *
548
-	 * @since 1.0.19
549
-	 * @param  string $context View or edit context.
550
-	 * @return string
551
-	 */
552
-	public function get_number( $context = 'view' ) {
553
-		$number = $this->get_prop( 'number', $context );
546
+     * Get the invoice number.
547
+     *
548
+     * @since 1.0.19
549
+     * @param  string $context View or edit context.
550
+     * @return string
551
+     */
552
+    public function get_number( $context = 'view' ) {
553
+        $number = $this->get_prop( 'number', $context );
554 554
 
555
-		if ( empty( $number ) ) {
556
-			$number = $this->generate_number();
557
-			$this->set_number( $this->generate_number() );
558
-		}
555
+        if ( empty( $number ) ) {
556
+            $number = $this->generate_number();
557
+            $this->set_number( $this->generate_number() );
558
+        }
559 559
 
560
-		return $number;
560
+        return $number;
561 561
     }
562 562
 
563
-	/**
564
-	 * Set the invoice number.
565
-	 *
566
-	 * @since 1.0.19
567
-	 */
568
-	public function maybe_set_number() {
563
+    /**
564
+     * Set the invoice number.
565
+     *
566
+     * @since 1.0.19
567
+     */
568
+    public function maybe_set_number() {
569 569
         $number = $this->get_number();
570 570
 
571 571
         if ( empty( $number ) || $this->get_id() == $number ) {
572
-			$this->set_number( $this->generate_number() );
572
+            $this->set_number( $this->generate_number() );
573 573
         }
574 574
 
575
-	}
575
+    }
576 576
 
577 577
     /**
578
-	 * Get the invoice key.
579
-	 *
580
-	 * @since 1.0.19
581
-	 * @param  string $context View or edit context.
582
-	 * @return string
583
-	 */
584
-	public function get_key( $context = 'view' ) {
578
+     * Get the invoice key.
579
+     *
580
+     * @since 1.0.19
581
+     * @param  string $context View or edit context.
582
+     * @return string
583
+     */
584
+    public function get_key( $context = 'view' ) {
585 585
         return $this->get_prop( 'key', $context );
586
-	}
587
-
588
-	/**
589
-	 * Set the invoice key.
590
-	 *
591
-	 * @since 1.0.19
592
-	 */
593
-	public function maybe_set_key() {
586
+    }
587
+
588
+    /**
589
+     * Set the invoice key.
590
+     *
591
+     * @since 1.0.19
592
+     */
593
+    public function maybe_set_key() {
594 594
         $key = $this->get_key();
595 595
 
596 596
         if ( empty( $key ) ) {
@@ -601,140 +601,140 @@  discard block
 block discarded – undo
601 601
     }
602 602
 
603 603
     /**
604
-	 * Get the invoice type.
605
-	 *
606
-	 * @since 1.0.19
607
-	 * @param  string $context View or edit context.
608
-	 * @return string
609
-	 */
610
-	public function get_type( $context = 'view' ) {
604
+     * Get the invoice type.
605
+     *
606
+     * @since 1.0.19
607
+     * @param  string $context View or edit context.
608
+     * @return string
609
+     */
610
+    public function get_type( $context = 'view' ) {
611 611
         return $this->get_prop( 'type', $context );
612
-	}
613
-
614
-	/**
615
-	 * Returns the post type name.
616
-	 *
617
-	 * @since 1.0.19
618
-	 * @return string
619
-	 */
620
-	public function get_invoice_quote_type() {
612
+    }
613
+
614
+    /**
615
+     * Returns the post type name.
616
+     *
617
+     * @since 1.0.19
618
+     * @return string
619
+     */
620
+    public function get_invoice_quote_type() {
621 621
         return getpaid_get_post_type_label( $this->get_post_type(), false );
622 622
     }
623 623
 
624 624
     /**
625
-	 * Get the invoice post type label.
626
-	 *
627
-	 * @since 1.0.19
628
-	 * @param  string $context View or edit context.
629
-	 * @return string
630
-	 */
631
-	public function get_label( $context = 'view' ) {
625
+     * Get the invoice post type label.
626
+     *
627
+     * @since 1.0.19
628
+     * @param  string $context View or edit context.
629
+     * @return string
630
+     */
631
+    public function get_label( $context = 'view' ) {
632 632
         return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
633
-	}
634
-
635
-	/**
636
-	 * Get the invoice post type.
637
-	 *
638
-	 * @since 1.0.19
639
-	 * @param  string $context View or edit context.
640
-	 * @return string
641
-	 */
642
-	public function get_post_type( $context = 'view' ) {
633
+    }
634
+
635
+    /**
636
+     * Get the invoice post type.
637
+     *
638
+     * @since 1.0.19
639
+     * @param  string $context View or edit context.
640
+     * @return string
641
+     */
642
+    public function get_post_type( $context = 'view' ) {
643 643
         return $this->get_prop( 'post_type', $context );
644 644
     }
645 645
 
646 646
     /**
647
-	 * Get the invoice mode.
648
-	 *
649
-	 * @since 1.0.19
650
-	 * @param  string $context View or edit context.
651
-	 * @return string
652
-	 */
653
-	public function get_mode( $context = 'view' ) {
647
+     * Get the invoice mode.
648
+     *
649
+     * @since 1.0.19
650
+     * @param  string $context View or edit context.
651
+     * @return string
652
+     */
653
+    public function get_mode( $context = 'view' ) {
654 654
         return $this->get_prop( 'mode', $context );
655 655
     }
656 656
 
657 657
     /**
658
-	 * Get the invoice path.
659
-	 *
660
-	 * @since 1.0.19
661
-	 * @param  string $context View or edit context.
662
-	 * @return string
663
-	 */
664
-	public function get_path( $context = 'view' ) {
658
+     * Get the invoice path.
659
+     *
660
+     * @since 1.0.19
661
+     * @param  string $context View or edit context.
662
+     * @return string
663
+     */
664
+    public function get_path( $context = 'view' ) {
665 665
         $path   = $this->get_prop( 'path', $context );
666
-		$prefix = $this->get_type();
666
+        $prefix = $this->get_type();
667 667
 
668
-		if ( 0 !== strpos( $path, $prefix ) ) {
669
-			$path = sanitize_title(  $prefix . '-' . $this->get_id()  );
670
-			$this->set_path( $path );
671
-		}
668
+        if ( 0 !== strpos( $path, $prefix ) ) {
669
+            $path = sanitize_title(  $prefix . '-' . $this->get_id()  );
670
+            $this->set_path( $path );
671
+        }
672 672
 
673
-		return $path;
673
+        return $path;
674 674
     }
675 675
 
676 676
     /**
677
-	 * Get the invoice name/title.
678
-	 *
679
-	 * @since 1.0.19
680
-	 * @param  string $context View or edit context.
681
-	 * @return string
682
-	 */
683
-	public function get_name( $context = 'view' ) {
677
+     * Get the invoice name/title.
678
+     *
679
+     * @since 1.0.19
680
+     * @param  string $context View or edit context.
681
+     * @return string
682
+     */
683
+    public function get_name( $context = 'view' ) {
684 684
         return $this->get_prop( 'title', $context );
685 685
     }
686 686
 
687 687
     /**
688
-	 * Alias of self::get_name().
689
-	 *
690
-	 * @since 1.0.19
691
-	 * @param  string $context View or edit context.
692
-	 * @return string
693
-	 */
694
-	public function get_title( $context = 'view' ) {
695
-		return $this->get_name( $context );
688
+     * Alias of self::get_name().
689
+     *
690
+     * @since 1.0.19
691
+     * @param  string $context View or edit context.
692
+     * @return string
693
+     */
694
+    public function get_title( $context = 'view' ) {
695
+        return $this->get_name( $context );
696 696
     }
697 697
 
698 698
     /**
699
-	 * Get the invoice description.
700
-	 *
701
-	 * @since 1.0.19
702
-	 * @param  string $context View or edit context.
703
-	 * @return string
704
-	 */
705
-	public function get_description( $context = 'view' ) {
706
-		return $this->get_prop( 'description', $context );
699
+     * Get the invoice description.
700
+     *
701
+     * @since 1.0.19
702
+     * @param  string $context View or edit context.
703
+     * @return string
704
+     */
705
+    public function get_description( $context = 'view' ) {
706
+        return $this->get_prop( 'description', $context );
707 707
     }
708 708
 
709 709
     /**
710
-	 * Alias of self::get_description().
711
-	 *
712
-	 * @since 1.0.19
713
-	 * @param  string $context View or edit context.
714
-	 * @return string
715
-	 */
716
-	public function get_excerpt( $context = 'view' ) {
717
-		return $this->get_description( $context );
710
+     * Alias of self::get_description().
711
+     *
712
+     * @since 1.0.19
713
+     * @param  string $context View or edit context.
714
+     * @return string
715
+     */
716
+    public function get_excerpt( $context = 'view' ) {
717
+        return $this->get_description( $context );
718 718
     }
719 719
 
720 720
     /**
721
-	 * Alias of self::get_description().
722
-	 *
723
-	 * @since 1.0.19
724
-	 * @param  string $context View or edit context.
725
-	 * @return string
726
-	 */
727
-	public function get_summary( $context = 'view' ) {
728
-		return $this->get_description( $context );
721
+     * Alias of self::get_description().
722
+     *
723
+     * @since 1.0.19
724
+     * @param  string $context View or edit context.
725
+     * @return string
726
+     */
727
+    public function get_summary( $context = 'view' ) {
728
+        return $this->get_description( $context );
729 729
     }
730 730
 
731 731
     /**
732
-	 * Returns the user info.
733
-	 *
734
-	 * @since 1.0.19
732
+     * Returns the user info.
733
+     *
734
+     * @since 1.0.19
735 735
      * @param  string $context View or edit context.
736
-	 * @return array
737
-	 */
736
+     * @return array
737
+     */
738 738
     public function get_user_info( $context = 'view' ) {
739 739
 
740 740
         $user_info = array(
@@ -751,616 +751,616 @@  discard block
 block discarded – undo
751 751
             'company'    => $this->get_company( $context ),
752 752
             'vat_number' => $this->get_vat_number( $context ),
753 753
             'discount'   => $this->get_discount_code( $context ),
754
-		);
754
+        );
755 755
 
756
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
756
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
757 757
 
758 758
     }
759 759
 
760 760
     /**
761
-	 * Get the customer id.
762
-	 *
763
-	 * @since 1.0.19
764
-	 * @param  string $context View or edit context.
765
-	 * @return int
766
-	 */
767
-	public function get_author( $context = 'view' ) {
768
-		return (int) $this->get_prop( 'author', $context );
761
+     * Get the customer id.
762
+     *
763
+     * @since 1.0.19
764
+     * @param  string $context View or edit context.
765
+     * @return int
766
+     */
767
+    public function get_author( $context = 'view' ) {
768
+        return (int) $this->get_prop( 'author', $context );
769 769
     }
770 770
 
771 771
     /**
772
-	 * Alias of self::get_author().
773
-	 *
774
-	 * @since 1.0.19
775
-	 * @param  string $context View or edit context.
776
-	 * @return int
777
-	 */
778
-	public function get_user_id( $context = 'view' ) {
779
-		return $this->get_author( $context );
772
+     * Alias of self::get_author().
773
+     *
774
+     * @since 1.0.19
775
+     * @param  string $context View or edit context.
776
+     * @return int
777
+     */
778
+    public function get_user_id( $context = 'view' ) {
779
+        return $this->get_author( $context );
780 780
     }
781 781
 
782
-     /**
783
-	 * Alias of self::get_author().
784
-	 *
785
-	 * @since 1.0.19
786
-	 * @param  string $context View or edit context.
787
-	 * @return int
788
-	 */
789
-	public function get_customer_id( $context = 'view' ) {
790
-		return $this->get_author( $context );
782
+        /**
783
+         * Alias of self::get_author().
784
+         *
785
+         * @since 1.0.19
786
+         * @param  string $context View or edit context.
787
+         * @return int
788
+         */
789
+    public function get_customer_id( $context = 'view' ) {
790
+        return $this->get_author( $context );
791 791
     }
792 792
 
793 793
     /**
794
-	 * Get the customer's ip.
795
-	 *
796
-	 * @since 1.0.19
797
-	 * @param  string $context View or edit context.
798
-	 * @return string
799
-	 */
800
-	public function get_ip( $context = 'view' ) {
801
-		return $this->get_prop( 'user_ip', $context );
794
+     * Get the customer's ip.
795
+     *
796
+     * @since 1.0.19
797
+     * @param  string $context View or edit context.
798
+     * @return string
799
+     */
800
+    public function get_ip( $context = 'view' ) {
801
+        return $this->get_prop( 'user_ip', $context );
802 802
     }
803 803
 
804 804
     /**
805
-	 * Alias of self::get_ip().
806
-	 *
807
-	 * @since 1.0.19
808
-	 * @param  string $context View or edit context.
809
-	 * @return string
810
-	 */
811
-	public function get_user_ip( $context = 'view' ) {
812
-		return $this->get_ip( $context );
805
+     * Alias of self::get_ip().
806
+     *
807
+     * @since 1.0.19
808
+     * @param  string $context View or edit context.
809
+     * @return string
810
+     */
811
+    public function get_user_ip( $context = 'view' ) {
812
+        return $this->get_ip( $context );
813 813
     }
814 814
 
815
-     /**
816
-	 * Alias of self::get_ip().
817
-	 *
818
-	 * @since 1.0.19
819
-	 * @param  string $context View or edit context.
820
-	 * @return string
821
-	 */
822
-	public function get_customer_ip( $context = 'view' ) {
823
-		return $this->get_ip( $context );
815
+        /**
816
+         * Alias of self::get_ip().
817
+         *
818
+         * @since 1.0.19
819
+         * @param  string $context View or edit context.
820
+         * @return string
821
+         */
822
+    public function get_customer_ip( $context = 'view' ) {
823
+        return $this->get_ip( $context );
824 824
     }
825 825
 
826 826
     /**
827
-	 * Get the customer's first name.
828
-	 *
829
-	 * @since 1.0.19
830
-	 * @param  string $context View or edit context.
831
-	 * @return string
832
-	 */
833
-	public function get_first_name( $context = 'view' ) {
834
-		return $this->get_prop( 'first_name', $context );
827
+     * Get the customer's first name.
828
+     *
829
+     * @since 1.0.19
830
+     * @param  string $context View or edit context.
831
+     * @return string
832
+     */
833
+    public function get_first_name( $context = 'view' ) {
834
+        return $this->get_prop( 'first_name', $context );
835 835
     }
836 836
 
837 837
     /**
838
-	 * Alias of self::get_first_name().
839
-	 *
840
-	 * @since 1.0.19
841
-	 * @param  string $context View or edit context.
842
-	 * @return string
843
-	 */
844
-	public function get_user_first_name( $context = 'view' ) {
845
-		return $this->get_first_name( $context );
838
+     * Alias of self::get_first_name().
839
+     *
840
+     * @since 1.0.19
841
+     * @param  string $context View or edit context.
842
+     * @return string
843
+     */
844
+    public function get_user_first_name( $context = 'view' ) {
845
+        return $this->get_first_name( $context );
846 846
     }
847 847
 
848
-     /**
849
-	 * Alias of self::get_first_name().
850
-	 *
851
-	 * @since 1.0.19
852
-	 * @param  string $context View or edit context.
853
-	 * @return string
854
-	 */
855
-	public function get_customer_first_name( $context = 'view' ) {
856
-		return $this->get_first_name( $context );
848
+        /**
849
+         * Alias of self::get_first_name().
850
+         *
851
+         * @since 1.0.19
852
+         * @param  string $context View or edit context.
853
+         * @return string
854
+         */
855
+    public function get_customer_first_name( $context = 'view' ) {
856
+        return $this->get_first_name( $context );
857 857
     }
858 858
 
859 859
     /**
860
-	 * Get the customer's last name.
861
-	 *
862
-	 * @since 1.0.19
863
-	 * @param  string $context View or edit context.
864
-	 * @return string
865
-	 */
866
-	public function get_last_name( $context = 'view' ) {
867
-		return $this->get_prop( 'last_name', $context );
860
+     * Get the customer's last name.
861
+     *
862
+     * @since 1.0.19
863
+     * @param  string $context View or edit context.
864
+     * @return string
865
+     */
866
+    public function get_last_name( $context = 'view' ) {
867
+        return $this->get_prop( 'last_name', $context );
868 868
     }
869 869
 
870 870
     /**
871
-	 * Alias of self::get_last_name().
872
-	 *
873
-	 * @since 1.0.19
874
-	 * @param  string $context View or edit context.
875
-	 * @return string
876
-	 */
877
-	public function get_user_last_name( $context = 'view' ) {
878
-		return $this->get_last_name( $context );
871
+     * Alias of self::get_last_name().
872
+     *
873
+     * @since 1.0.19
874
+     * @param  string $context View or edit context.
875
+     * @return string
876
+     */
877
+    public function get_user_last_name( $context = 'view' ) {
878
+        return $this->get_last_name( $context );
879 879
     }
880 880
 
881 881
     /**
882
-	 * Alias of self::get_last_name().
883
-	 *
884
-	 * @since 1.0.19
885
-	 * @param  string $context View or edit context.
886
-	 * @return string
887
-	 */
888
-	public function get_customer_last_name( $context = 'view' ) {
889
-		return $this->get_last_name( $context );
882
+     * Alias of self::get_last_name().
883
+     *
884
+     * @since 1.0.19
885
+     * @param  string $context View or edit context.
886
+     * @return string
887
+     */
888
+    public function get_customer_last_name( $context = 'view' ) {
889
+        return $this->get_last_name( $context );
890 890
     }
891 891
 
892 892
     /**
893
-	 * Get the customer's full name.
894
-	 *
895
-	 * @since 1.0.19
896
-	 * @param  string $context View or edit context.
897
-	 * @return string
898
-	 */
899
-	public function get_full_name( $context = 'view' ) {
900
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
893
+     * Get the customer's full name.
894
+     *
895
+     * @since 1.0.19
896
+     * @param  string $context View or edit context.
897
+     * @return string
898
+     */
899
+    public function get_full_name( $context = 'view' ) {
900
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
901 901
     }
902 902
 
903 903
     /**
904
-	 * Alias of self::get_full_name().
905
-	 *
906
-	 * @since 1.0.19
907
-	 * @param  string $context View or edit context.
908
-	 * @return string
909
-	 */
910
-	public function get_user_full_name( $context = 'view' ) {
911
-		return $this->get_full_name( $context );
904
+     * Alias of self::get_full_name().
905
+     *
906
+     * @since 1.0.19
907
+     * @param  string $context View or edit context.
908
+     * @return string
909
+     */
910
+    public function get_user_full_name( $context = 'view' ) {
911
+        return $this->get_full_name( $context );
912 912
     }
913 913
 
914 914
     /**
915
-	 * Alias of self::get_full_name().
916
-	 *
917
-	 * @since 1.0.19
918
-	 * @param  string $context View or edit context.
919
-	 * @return string
920
-	 */
921
-	public function get_customer_full_name( $context = 'view' ) {
922
-		return $this->get_full_name( $context );
915
+     * Alias of self::get_full_name().
916
+     *
917
+     * @since 1.0.19
918
+     * @param  string $context View or edit context.
919
+     * @return string
920
+     */
921
+    public function get_customer_full_name( $context = 'view' ) {
922
+        return $this->get_full_name( $context );
923 923
     }
924 924
 
925 925
     /**
926
-	 * Get the customer's phone number.
927
-	 *
928
-	 * @since 1.0.19
929
-	 * @param  string $context View or edit context.
930
-	 * @return string
931
-	 */
932
-	public function get_phone( $context = 'view' ) {
933
-		return $this->get_prop( 'phone', $context );
926
+     * Get the customer's phone number.
927
+     *
928
+     * @since 1.0.19
929
+     * @param  string $context View or edit context.
930
+     * @return string
931
+     */
932
+    public function get_phone( $context = 'view' ) {
933
+        return $this->get_prop( 'phone', $context );
934 934
     }
935 935
 
936 936
     /**
937
-	 * Alias of self::get_phone().
938
-	 *
939
-	 * @since 1.0.19
940
-	 * @param  string $context View or edit context.
941
-	 * @return string
942
-	 */
943
-	public function get_phone_number( $context = 'view' ) {
944
-		return $this->get_phone( $context );
937
+     * Alias of self::get_phone().
938
+     *
939
+     * @since 1.0.19
940
+     * @param  string $context View or edit context.
941
+     * @return string
942
+     */
943
+    public function get_phone_number( $context = 'view' ) {
944
+        return $this->get_phone( $context );
945 945
     }
946 946
 
947 947
     /**
948
-	 * Alias of self::get_phone().
949
-	 *
950
-	 * @since 1.0.19
951
-	 * @param  string $context View or edit context.
952
-	 * @return string
953
-	 */
954
-	public function get_user_phone( $context = 'view' ) {
955
-		return $this->get_phone( $context );
956
-    }
957
-
948
+     * Alias of self::get_phone().
949
+     *
950
+     * @since 1.0.19
951
+     * @param  string $context View or edit context.
952
+     * @return string
953
+     */
954
+    public function get_user_phone( $context = 'view' ) {
955
+        return $this->get_phone( $context );
956
+    }
957
+
958 958
     /**
959
-	 * Alias of self::get_phone().
960
-	 *
961
-	 * @since 1.0.19
962
-	 * @param  string $context View or edit context.
963
-	 * @return string
964
-	 */
965
-	public function get_customer_phone( $context = 'view' ) {
966
-		return $this->get_phone( $context );
959
+     * Alias of self::get_phone().
960
+     *
961
+     * @since 1.0.19
962
+     * @param  string $context View or edit context.
963
+     * @return string
964
+     */
965
+    public function get_customer_phone( $context = 'view' ) {
966
+        return $this->get_phone( $context );
967 967
     }
968 968
 
969 969
     /**
970
-	 * Get the customer's email address.
971
-	 *
972
-	 * @since 1.0.19
973
-	 * @param  string $context View or edit context.
974
-	 * @return string
975
-	 */
976
-	public function get_email( $context = 'view' ) {
977
-		return $this->get_prop( 'email', $context );
970
+     * Get the customer's email address.
971
+     *
972
+     * @since 1.0.19
973
+     * @param  string $context View or edit context.
974
+     * @return string
975
+     */
976
+    public function get_email( $context = 'view' ) {
977
+        return $this->get_prop( 'email', $context );
978 978
     }
979 979
 
980 980
     /**
981
-	 * Alias of self::get_email().
982
-	 *
983
-	 * @since 1.0.19
984
-	 * @param  string $context View or edit context.
985
-	 * @return string
986
-	 */
987
-	public function get_email_address( $context = 'view' ) {
988
-		return $this->get_email( $context );
981
+     * Alias of self::get_email().
982
+     *
983
+     * @since 1.0.19
984
+     * @param  string $context View or edit context.
985
+     * @return string
986
+     */
987
+    public function get_email_address( $context = 'view' ) {
988
+        return $this->get_email( $context );
989 989
     }
990 990
 
991 991
     /**
992
-	 * Alias of self::get_email().
993
-	 *
994
-	 * @since 1.0.19
995
-	 * @param  string $context View or edit context.
996
-	 * @return string
997
-	 */
998
-	public function get_user_email( $context = 'view' ) {
999
-		return $this->get_email( $context );
992
+     * Alias of self::get_email().
993
+     *
994
+     * @since 1.0.19
995
+     * @param  string $context View or edit context.
996
+     * @return string
997
+     */
998
+    public function get_user_email( $context = 'view' ) {
999
+        return $this->get_email( $context );
1000 1000
     }
1001 1001
 
1002 1002
     /**
1003
-	 * Alias of self::get_email().
1004
-	 *
1005
-	 * @since 1.0.19
1006
-	 * @param  string $context View or edit context.
1007
-	 * @return string
1008
-	 */
1009
-	public function get_customer_email( $context = 'view' ) {
1010
-		return $this->get_email( $context );
1003
+     * Alias of self::get_email().
1004
+     *
1005
+     * @since 1.0.19
1006
+     * @param  string $context View or edit context.
1007
+     * @return string
1008
+     */
1009
+    public function get_customer_email( $context = 'view' ) {
1010
+        return $this->get_email( $context );
1011 1011
     }
1012 1012
 
1013 1013
     /**
1014
-	 * Get the customer's country.
1015
-	 *
1016
-	 * @since 1.0.19
1017
-	 * @param  string $context View or edit context.
1018
-	 * @return string
1019
-	 */
1020
-	public function get_country( $context = 'view' ) {
1021
-		$country = $this->get_prop( 'country', $context );
1022
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1014
+     * Get the customer's country.
1015
+     *
1016
+     * @since 1.0.19
1017
+     * @param  string $context View or edit context.
1018
+     * @return string
1019
+     */
1020
+    public function get_country( $context = 'view' ) {
1021
+        $country = $this->get_prop( 'country', $context );
1022
+        return empty( $country ) ? wpinv_get_default_country() : $country;
1023 1023
     }
1024 1024
 
1025 1025
     /**
1026
-	 * Alias of self::get_country().
1027
-	 *
1028
-	 * @since 1.0.19
1029
-	 * @param  string $context View or edit context.
1030
-	 * @return string
1031
-	 */
1032
-	public function get_user_country( $context = 'view' ) {
1033
-		return $this->get_country( $context );
1026
+     * Alias of self::get_country().
1027
+     *
1028
+     * @since 1.0.19
1029
+     * @param  string $context View or edit context.
1030
+     * @return string
1031
+     */
1032
+    public function get_user_country( $context = 'view' ) {
1033
+        return $this->get_country( $context );
1034 1034
     }
1035 1035
 
1036 1036
     /**
1037
-	 * Alias of self::get_country().
1038
-	 *
1039
-	 * @since 1.0.19
1040
-	 * @param  string $context View or edit context.
1041
-	 * @return string
1042
-	 */
1043
-	public function get_customer_country( $context = 'view' ) {
1044
-		return $this->get_country( $context );
1037
+     * Alias of self::get_country().
1038
+     *
1039
+     * @since 1.0.19
1040
+     * @param  string $context View or edit context.
1041
+     * @return string
1042
+     */
1043
+    public function get_customer_country( $context = 'view' ) {
1044
+        return $this->get_country( $context );
1045 1045
     }
1046 1046
 
1047 1047
     /**
1048
-	 * Get the customer's state.
1049
-	 *
1050
-	 * @since 1.0.19
1051
-	 * @param  string $context View or edit context.
1052
-	 * @return string
1053
-	 */
1054
-	public function get_state( $context = 'view' ) {
1055
-		$state = $this->get_prop( 'state', $context );
1056
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1048
+     * Get the customer's state.
1049
+     *
1050
+     * @since 1.0.19
1051
+     * @param  string $context View or edit context.
1052
+     * @return string
1053
+     */
1054
+    public function get_state( $context = 'view' ) {
1055
+        $state = $this->get_prop( 'state', $context );
1056
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1057 1057
     }
1058 1058
 
1059 1059
     /**
1060
-	 * Alias of self::get_state().
1061
-	 *
1062
-	 * @since 1.0.19
1063
-	 * @param  string $context View or edit context.
1064
-	 * @return string
1065
-	 */
1066
-	public function get_user_state( $context = 'view' ) {
1067
-		return $this->get_state( $context );
1060
+     * Alias of self::get_state().
1061
+     *
1062
+     * @since 1.0.19
1063
+     * @param  string $context View or edit context.
1064
+     * @return string
1065
+     */
1066
+    public function get_user_state( $context = 'view' ) {
1067
+        return $this->get_state( $context );
1068 1068
     }
1069 1069
 
1070 1070
     /**
1071
-	 * Alias of self::get_state().
1072
-	 *
1073
-	 * @since 1.0.19
1074
-	 * @param  string $context View or edit context.
1075
-	 * @return string
1076
-	 */
1077
-	public function get_customer_state( $context = 'view' ) {
1078
-		return $this->get_state( $context );
1071
+     * Alias of self::get_state().
1072
+     *
1073
+     * @since 1.0.19
1074
+     * @param  string $context View or edit context.
1075
+     * @return string
1076
+     */
1077
+    public function get_customer_state( $context = 'view' ) {
1078
+        return $this->get_state( $context );
1079 1079
     }
1080 1080
 
1081 1081
     /**
1082
-	 * Get the customer's city.
1083
-	 *
1084
-	 * @since 1.0.19
1085
-	 * @param  string $context View or edit context.
1086
-	 * @return string
1087
-	 */
1088
-	public function get_city( $context = 'view' ) {
1089
-		return $this->get_prop( 'city', $context );
1082
+     * Get the customer's city.
1083
+     *
1084
+     * @since 1.0.19
1085
+     * @param  string $context View or edit context.
1086
+     * @return string
1087
+     */
1088
+    public function get_city( $context = 'view' ) {
1089
+        return $this->get_prop( 'city', $context );
1090 1090
     }
1091 1091
 
1092 1092
     /**
1093
-	 * Alias of self::get_city().
1094
-	 *
1095
-	 * @since 1.0.19
1096
-	 * @param  string $context View or edit context.
1097
-	 * @return string
1098
-	 */
1099
-	public function get_user_city( $context = 'view' ) {
1100
-		return $this->get_city( $context );
1093
+     * Alias of self::get_city().
1094
+     *
1095
+     * @since 1.0.19
1096
+     * @param  string $context View or edit context.
1097
+     * @return string
1098
+     */
1099
+    public function get_user_city( $context = 'view' ) {
1100
+        return $this->get_city( $context );
1101 1101
     }
1102 1102
 
1103 1103
     /**
1104
-	 * Alias of self::get_city().
1105
-	 *
1106
-	 * @since 1.0.19
1107
-	 * @param  string $context View or edit context.
1108
-	 * @return string
1109
-	 */
1110
-	public function get_customer_city( $context = 'view' ) {
1111
-		return $this->get_city( $context );
1104
+     * Alias of self::get_city().
1105
+     *
1106
+     * @since 1.0.19
1107
+     * @param  string $context View or edit context.
1108
+     * @return string
1109
+     */
1110
+    public function get_customer_city( $context = 'view' ) {
1111
+        return $this->get_city( $context );
1112 1112
     }
1113 1113
 
1114 1114
     /**
1115
-	 * Get the customer's zip.
1116
-	 *
1117
-	 * @since 1.0.19
1118
-	 * @param  string $context View or edit context.
1119
-	 * @return string
1120
-	 */
1121
-	public function get_zip( $context = 'view' ) {
1122
-		return $this->get_prop( 'zip', $context );
1115
+     * Get the customer's zip.
1116
+     *
1117
+     * @since 1.0.19
1118
+     * @param  string $context View or edit context.
1119
+     * @return string
1120
+     */
1121
+    public function get_zip( $context = 'view' ) {
1122
+        return $this->get_prop( 'zip', $context );
1123 1123
     }
1124 1124
 
1125 1125
     /**
1126
-	 * Alias of self::get_zip().
1127
-	 *
1128
-	 * @since 1.0.19
1129
-	 * @param  string $context View or edit context.
1130
-	 * @return string
1131
-	 */
1132
-	public function get_user_zip( $context = 'view' ) {
1133
-		return $this->get_zip( $context );
1126
+     * Alias of self::get_zip().
1127
+     *
1128
+     * @since 1.0.19
1129
+     * @param  string $context View or edit context.
1130
+     * @return string
1131
+     */
1132
+    public function get_user_zip( $context = 'view' ) {
1133
+        return $this->get_zip( $context );
1134 1134
     }
1135 1135
 
1136 1136
     /**
1137
-	 * Alias of self::get_zip().
1138
-	 *
1139
-	 * @since 1.0.19
1140
-	 * @param  string $context View or edit context.
1141
-	 * @return string
1142
-	 */
1143
-	public function get_customer_zip( $context = 'view' ) {
1144
-		return $this->get_zip( $context );
1137
+     * Alias of self::get_zip().
1138
+     *
1139
+     * @since 1.0.19
1140
+     * @param  string $context View or edit context.
1141
+     * @return string
1142
+     */
1143
+    public function get_customer_zip( $context = 'view' ) {
1144
+        return $this->get_zip( $context );
1145 1145
     }
1146 1146
 
1147 1147
     /**
1148
-	 * Get the customer's company.
1149
-	 *
1150
-	 * @since 1.0.19
1151
-	 * @param  string $context View or edit context.
1152
-	 * @return string
1153
-	 */
1154
-	public function get_company( $context = 'view' ) {
1155
-		return $this->get_prop( 'company', $context );
1148
+     * Get the customer's company.
1149
+     *
1150
+     * @since 1.0.19
1151
+     * @param  string $context View or edit context.
1152
+     * @return string
1153
+     */
1154
+    public function get_company( $context = 'view' ) {
1155
+        return $this->get_prop( 'company', $context );
1156 1156
     }
1157 1157
 
1158 1158
     /**
1159
-	 * Alias of self::get_company().
1160
-	 *
1161
-	 * @since 1.0.19
1162
-	 * @param  string $context View or edit context.
1163
-	 * @return string
1164
-	 */
1165
-	public function get_user_company( $context = 'view' ) {
1166
-		return $this->get_company( $context );
1159
+     * Alias of self::get_company().
1160
+     *
1161
+     * @since 1.0.19
1162
+     * @param  string $context View or edit context.
1163
+     * @return string
1164
+     */
1165
+    public function get_user_company( $context = 'view' ) {
1166
+        return $this->get_company( $context );
1167 1167
     }
1168 1168
 
1169 1169
     /**
1170
-	 * Alias of self::get_company().
1171
-	 *
1172
-	 * @since 1.0.19
1173
-	 * @param  string $context View or edit context.
1174
-	 * @return string
1175
-	 */
1176
-	public function get_customer_company( $context = 'view' ) {
1177
-		return $this->get_company( $context );
1170
+     * Alias of self::get_company().
1171
+     *
1172
+     * @since 1.0.19
1173
+     * @param  string $context View or edit context.
1174
+     * @return string
1175
+     */
1176
+    public function get_customer_company( $context = 'view' ) {
1177
+        return $this->get_company( $context );
1178 1178
     }
1179 1179
 
1180 1180
     /**
1181
-	 * Get the customer's vat number.
1182
-	 *
1183
-	 * @since 1.0.19
1184
-	 * @param  string $context View or edit context.
1185
-	 * @return string
1186
-	 */
1187
-	public function get_vat_number( $context = 'view' ) {
1188
-		return $this->get_prop( 'vat_number', $context );
1181
+     * Get the customer's vat number.
1182
+     *
1183
+     * @since 1.0.19
1184
+     * @param  string $context View or edit context.
1185
+     * @return string
1186
+     */
1187
+    public function get_vat_number( $context = 'view' ) {
1188
+        return $this->get_prop( 'vat_number', $context );
1189 1189
     }
1190 1190
 
1191 1191
     /**
1192
-	 * Alias of self::get_vat_number().
1193
-	 *
1194
-	 * @since 1.0.19
1195
-	 * @param  string $context View or edit context.
1196
-	 * @return string
1197
-	 */
1198
-	public function get_user_vat_number( $context = 'view' ) {
1199
-		return $this->get_vat_number( $context );
1192
+     * Alias of self::get_vat_number().
1193
+     *
1194
+     * @since 1.0.19
1195
+     * @param  string $context View or edit context.
1196
+     * @return string
1197
+     */
1198
+    public function get_user_vat_number( $context = 'view' ) {
1199
+        return $this->get_vat_number( $context );
1200 1200
     }
1201 1201
 
1202 1202
     /**
1203
-	 * Alias of self::get_vat_number().
1204
-	 *
1205
-	 * @since 1.0.19
1206
-	 * @param  string $context View or edit context.
1207
-	 * @return string
1208
-	 */
1209
-	public function get_customer_vat_number( $context = 'view' ) {
1210
-		return $this->get_vat_number( $context );
1203
+     * Alias of self::get_vat_number().
1204
+     *
1205
+     * @since 1.0.19
1206
+     * @param  string $context View or edit context.
1207
+     * @return string
1208
+     */
1209
+    public function get_customer_vat_number( $context = 'view' ) {
1210
+        return $this->get_vat_number( $context );
1211
+    }
1212
+
1213
+    /**
1214
+     * Get the customer's vat rate.
1215
+     *
1216
+     * @since 1.0.19
1217
+     * @param  string $context View or edit context.
1218
+     * @return string
1219
+     */
1220
+    public function get_vat_rate( $context = 'view' ) {
1221
+        return $this->get_prop( 'vat_rate', $context );
1222
+    }
1223
+
1224
+    /**
1225
+     * Alias of self::get_vat_rate().
1226
+     *
1227
+     * @since 1.0.19
1228
+     * @param  string $context View or edit context.
1229
+     * @return string
1230
+     */
1231
+    public function get_user_vat_rate( $context = 'view' ) {
1232
+        return $this->get_vat_rate( $context );
1211 1233
     }
1212 1234
 
1213 1235
     /**
1214
-	 * Get the customer's vat rate.
1215
-	 *
1216
-	 * @since 1.0.19
1217
-	 * @param  string $context View or edit context.
1218
-	 * @return string
1219
-	 */
1220
-	public function get_vat_rate( $context = 'view' ) {
1221
-		return $this->get_prop( 'vat_rate', $context );
1222
-    }
1223
-
1224
-    /**
1225
-	 * Alias of self::get_vat_rate().
1226
-	 *
1227
-	 * @since 1.0.19
1228
-	 * @param  string $context View or edit context.
1229
-	 * @return string
1230
-	 */
1231
-	public function get_user_vat_rate( $context = 'view' ) {
1232
-		return $this->get_vat_rate( $context );
1233
-    }
1234
-
1235
-    /**
1236
-	 * Alias of self::get_vat_rate().
1237
-	 *
1238
-	 * @since 1.0.19
1239
-	 * @param  string $context View or edit context.
1240
-	 * @return string
1241
-	 */
1242
-	public function get_customer_vat_rate( $context = 'view' ) {
1243
-		return $this->get_vat_rate( $context );
1244
-    }
1245
-
1246
-    /**
1247
-	 * Get the customer's address.
1248
-	 *
1249
-	 * @since 1.0.19
1250
-	 * @param  string $context View or edit context.
1251
-	 * @return string
1252
-	 */
1253
-	public function get_address( $context = 'view' ) {
1254
-		return $this->get_prop( 'address', $context );
1255
-    }
1256
-
1257
-    /**
1258
-	 * Alias of self::get_address().
1259
-	 *
1260
-	 * @since 1.0.19
1261
-	 * @param  string $context View or edit context.
1262
-	 * @return string
1263
-	 */
1264
-	public function get_user_address( $context = 'view' ) {
1265
-		return $this->get_address( $context );
1266
-    }
1267
-
1268
-    /**
1269
-	 * Alias of self::get_address().
1270
-	 *
1271
-	 * @since 1.0.19
1272
-	 * @param  string $context View or edit context.
1273
-	 * @return string
1274
-	 */
1275
-	public function get_customer_address( $context = 'view' ) {
1276
-		return $this->get_address( $context );
1277
-    }
1278
-
1279
-    /**
1280
-	 * Get whether the customer has viewed the invoice or not.
1281
-	 *
1282
-	 * @since 1.0.19
1283
-	 * @param  string $context View or edit context.
1284
-	 * @return bool
1285
-	 */
1286
-	public function get_is_viewed( $context = 'view' ) {
1287
-		return (bool) $this->get_prop( 'is_viewed', $context );
1288
-	}
1289
-
1290
-	/**
1291
-	 * Get other recipients for invoice communications.
1292
-	 *
1293
-	 * @since 1.0.19
1294
-	 * @param  string $context View or edit context.
1295
-	 * @return bool
1296
-	 */
1297
-	public function get_email_cc( $context = 'view' ) {
1298
-		return $this->get_prop( 'email_cc', $context );
1299
-	}
1300
-
1301
-	/**
1302
-	 * Get invoice template.
1303
-	 *
1304
-	 * @since 1.0.19
1305
-	 * @param  string $context View or edit context.
1306
-	 * @return bool
1307
-	 */
1308
-	public function get_template( $context = 'view' ) {
1309
-		return $this->get_prop( 'template', $context );
1310
-	}
1311
-
1312
-	/**
1313
-	 * Get invoice source.
1314
-	 *
1315
-	 * @since 1.0.19
1316
-	 * @param  string $context View or edit context.
1317
-	 * @return bool
1318
-	 */
1319
-	public function get_created_via( $context = 'view' ) {
1320
-		return $this->get_prop( 'created_via', $context );
1321
-	}
1322
-
1323
-	/**
1324
-	 * Get whether the customer has confirmed their address.
1325
-	 *
1326
-	 * @since 1.0.19
1327
-	 * @param  string $context View or edit context.
1328
-	 * @return bool
1329
-	 */
1330
-	public function get_address_confirmed( $context = 'view' ) {
1331
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1332
-    }
1333
-
1334
-    /**
1335
-	 * Alias of self::get_address_confirmed().
1336
-	 *
1337
-	 * @since 1.0.19
1338
-	 * @param  string $context View or edit context.
1339
-	 * @return bool
1340
-	 */
1341
-	public function get_user_address_confirmed( $context = 'view' ) {
1342
-		return $this->get_address_confirmed( $context );
1343
-    }
1344
-
1345
-    /**
1346
-	 * Alias of self::get_address().
1347
-	 *
1348
-	 * @since 1.0.19
1349
-	 * @param  string $context View or edit context.
1350
-	 * @return bool
1351
-	 */
1352
-	public function get_customer_address_confirmed( $context = 'view' ) {
1353
-		return $this->get_address_confirmed( $context );
1354
-    }
1355
-
1356
-    /**
1357
-	 * Get the invoice subtotal.
1358
-	 *
1359
-	 * @since 1.0.19
1360
-	 * @param  string $context View or edit context.
1361
-	 * @return float
1362
-	 */
1363
-	public function get_subtotal( $context = 'view' ) {
1236
+     * Alias of self::get_vat_rate().
1237
+     *
1238
+     * @since 1.0.19
1239
+     * @param  string $context View or edit context.
1240
+     * @return string
1241
+     */
1242
+    public function get_customer_vat_rate( $context = 'view' ) {
1243
+        return $this->get_vat_rate( $context );
1244
+    }
1245
+
1246
+    /**
1247
+     * Get the customer's address.
1248
+     *
1249
+     * @since 1.0.19
1250
+     * @param  string $context View or edit context.
1251
+     * @return string
1252
+     */
1253
+    public function get_address( $context = 'view' ) {
1254
+        return $this->get_prop( 'address', $context );
1255
+    }
1256
+
1257
+    /**
1258
+     * Alias of self::get_address().
1259
+     *
1260
+     * @since 1.0.19
1261
+     * @param  string $context View or edit context.
1262
+     * @return string
1263
+     */
1264
+    public function get_user_address( $context = 'view' ) {
1265
+        return $this->get_address( $context );
1266
+    }
1267
+
1268
+    /**
1269
+     * Alias of self::get_address().
1270
+     *
1271
+     * @since 1.0.19
1272
+     * @param  string $context View or edit context.
1273
+     * @return string
1274
+     */
1275
+    public function get_customer_address( $context = 'view' ) {
1276
+        return $this->get_address( $context );
1277
+    }
1278
+
1279
+    /**
1280
+     * Get whether the customer has viewed the invoice or not.
1281
+     *
1282
+     * @since 1.0.19
1283
+     * @param  string $context View or edit context.
1284
+     * @return bool
1285
+     */
1286
+    public function get_is_viewed( $context = 'view' ) {
1287
+        return (bool) $this->get_prop( 'is_viewed', $context );
1288
+    }
1289
+
1290
+    /**
1291
+     * Get other recipients for invoice communications.
1292
+     *
1293
+     * @since 1.0.19
1294
+     * @param  string $context View or edit context.
1295
+     * @return bool
1296
+     */
1297
+    public function get_email_cc( $context = 'view' ) {
1298
+        return $this->get_prop( 'email_cc', $context );
1299
+    }
1300
+
1301
+    /**
1302
+     * Get invoice template.
1303
+     *
1304
+     * @since 1.0.19
1305
+     * @param  string $context View or edit context.
1306
+     * @return bool
1307
+     */
1308
+    public function get_template( $context = 'view' ) {
1309
+        return $this->get_prop( 'template', $context );
1310
+    }
1311
+
1312
+    /**
1313
+     * Get invoice source.
1314
+     *
1315
+     * @since 1.0.19
1316
+     * @param  string $context View or edit context.
1317
+     * @return bool
1318
+     */
1319
+    public function get_created_via( $context = 'view' ) {
1320
+        return $this->get_prop( 'created_via', $context );
1321
+    }
1322
+
1323
+    /**
1324
+     * Get whether the customer has confirmed their address.
1325
+     *
1326
+     * @since 1.0.19
1327
+     * @param  string $context View or edit context.
1328
+     * @return bool
1329
+     */
1330
+    public function get_address_confirmed( $context = 'view' ) {
1331
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1332
+    }
1333
+
1334
+    /**
1335
+     * Alias of self::get_address_confirmed().
1336
+     *
1337
+     * @since 1.0.19
1338
+     * @param  string $context View or edit context.
1339
+     * @return bool
1340
+     */
1341
+    public function get_user_address_confirmed( $context = 'view' ) {
1342
+        return $this->get_address_confirmed( $context );
1343
+    }
1344
+
1345
+    /**
1346
+     * Alias of self::get_address().
1347
+     *
1348
+     * @since 1.0.19
1349
+     * @param  string $context View or edit context.
1350
+     * @return bool
1351
+     */
1352
+    public function get_customer_address_confirmed( $context = 'view' ) {
1353
+        return $this->get_address_confirmed( $context );
1354
+    }
1355
+
1356
+    /**
1357
+     * Get the invoice subtotal.
1358
+     *
1359
+     * @since 1.0.19
1360
+     * @param  string $context View or edit context.
1361
+     * @return float
1362
+     */
1363
+    public function get_subtotal( $context = 'view' ) {
1364 1364
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1365 1365
 
1366 1366
         // Backwards compatibility.
@@ -1372,192 +1372,192 @@  discard block
 block discarded – undo
1372 1372
     }
1373 1373
 
1374 1374
     /**
1375
-	 * Get the invoice discount total.
1376
-	 *
1377
-	 * @since 1.0.19
1378
-	 * @param  string $context View or edit context.
1379
-	 * @return float
1380
-	 */
1381
-	public function get_total_discount( $context = 'view' ) {
1382
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1375
+     * Get the invoice discount total.
1376
+     *
1377
+     * @since 1.0.19
1378
+     * @param  string $context View or edit context.
1379
+     * @return float
1380
+     */
1381
+    public function get_total_discount( $context = 'view' ) {
1382
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1383 1383
     }
1384 1384
 
1385 1385
     /**
1386
-	 * Get the invoice tax total.
1387
-	 *
1388
-	 * @since 1.0.19
1389
-	 * @param  string $context View or edit context.
1390
-	 * @return float
1391
-	 */
1392
-	public function get_total_tax( $context = 'view' ) {
1393
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1394
-	}
1386
+     * Get the invoice tax total.
1387
+     *
1388
+     * @since 1.0.19
1389
+     * @param  string $context View or edit context.
1390
+     * @return float
1391
+     */
1392
+    public function get_total_tax( $context = 'view' ) {
1393
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1394
+    }
1395 1395
 
1396
-	/**
1397
-	 * @deprecated
1398
-	 */
1399
-	public function get_final_tax( $currency = false ) {
1400
-		$tax = $this->get_total_tax();
1396
+    /**
1397
+     * @deprecated
1398
+     */
1399
+    public function get_final_tax( $currency = false ) {
1400
+        $tax = $this->get_total_tax();
1401 1401
 
1402 1402
         if ( $currency ) {
1403
-			return wpinv_price( $tax, $this->get_currency() );
1403
+            return wpinv_price( $tax, $this->get_currency() );
1404 1404
         }
1405 1405
 
1406 1406
         return $tax;
1407 1407
     }
1408 1408
 
1409 1409
     /**
1410
-	 * Get the invoice fees total.
1411
-	 *
1412
-	 * @since 1.0.19
1413
-	 * @param  string $context View or edit context.
1414
-	 * @return float
1415
-	 */
1416
-	public function get_total_fees( $context = 'view' ) {
1417
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1410
+     * Get the invoice fees total.
1411
+     *
1412
+     * @since 1.0.19
1413
+     * @param  string $context View or edit context.
1414
+     * @return float
1415
+     */
1416
+    public function get_total_fees( $context = 'view' ) {
1417
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1418
+    }
1419
+
1420
+    /**
1421
+     * Alias for self::get_total_fees().
1422
+     *
1423
+     * @since 1.0.19
1424
+     * @param  string $context View or edit context.
1425
+     * @return float
1426
+     */
1427
+    public function get_fees_total( $context = 'view' ) {
1428
+        return $this->get_total_fees( $context );
1418 1429
     }
1419 1430
 
1420 1431
     /**
1421
-	 * Alias for self::get_total_fees().
1422
-	 *
1423
-	 * @since 1.0.19
1424
-	 * @param  string $context View or edit context.
1425
-	 * @return float
1426
-	 */
1427
-	public function get_fees_total( $context = 'view' ) {
1428
-		return $this->get_total_fees( $context );
1432
+     * Get the invoice total.
1433
+     *
1434
+     * @since 1.0.19
1435
+     * @return float
1436
+     */
1437
+    public function get_total( $context = 'view' ) {
1438
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) );
1429 1439
     }
1430 1440
 
1431 1441
     /**
1432
-	 * Get the invoice total.
1433
-	 *
1434
-	 * @since 1.0.19
1442
+     * Retrieves the non-recurring total of items.
1443
+     *
1444
+     * @since 2.3.0
1435 1445
      * @return float
1436
-	 */
1437
-	public function get_total( $context = 'view' ) {
1438
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) );
1439
-	}
1440
-
1441
-	/**
1442
-	 * Retrieves the non-recurring total of items.
1443
-	 *
1444
-	 * @since 2.3.0
1445
-	 * @return float
1446
-	 */
1447
-	public function get_non_recurring_total() {
1448
-
1449
-		$subtotal = 0;
1450
-		foreach ( $this->get_items() as $item ) {
1451
-			if ( ! $item->is_recurring() ) {
1452
-				$subtotal += $item->get_sub_total();
1453
-			}
1454
-		}
1455
-
1456
-		foreach ( $this->get_fees() as $fee ) {
1457
-			if ( empty( $fee['recurring_fee'] ) ) {
1458
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1459
-			}
1460
-		}
1461
-
1462
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1446
+     */
1447
+    public function get_non_recurring_total() {
1448
+
1449
+        $subtotal = 0;
1450
+        foreach ( $this->get_items() as $item ) {
1451
+            if ( ! $item->is_recurring() ) {
1452
+                $subtotal += $item->get_sub_total();
1453
+            }
1454
+        }
1455
+
1456
+        foreach ( $this->get_fees() as $fee ) {
1457
+            if ( empty( $fee['recurring_fee'] ) ) {
1458
+                $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1459
+            }
1460
+        }
1461
+
1462
+        $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1463 1463
         return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1464 1464
 
1465 1465
     }
1466 1466
 
1467
-	/**
1468
-	 * Get the invoice totals.
1469
-	 *
1470
-	 * @since 1.0.19
1467
+    /**
1468
+     * Get the invoice totals.
1469
+     *
1470
+     * @since 1.0.19
1471 1471
      * @return array
1472
-	 */
1473
-	public function get_totals() {
1474
-		return $this->totals;
1472
+     */
1473
+    public function get_totals() {
1474
+        return $this->totals;
1475 1475
     }
1476 1476
 
1477 1477
     /**
1478
-	 * Get the initial invoice total.
1479
-	 *
1480
-	 * @since 1.0.19
1478
+     * Get the initial invoice total.
1479
+     *
1480
+     * @since 1.0.19
1481 1481
      * @param  string $context View or edit context.
1482 1482
      * @return float
1483
-	 */
1483
+     */
1484 1484
     public function get_initial_total() {
1485 1485
 
1486
-		if ( empty( $this->totals ) ) {
1487
-			$this->recalculate_total();
1488
-		}
1486
+        if ( empty( $this->totals ) ) {
1487
+            $this->recalculate_total();
1488
+        }
1489 1489
 
1490
-		$tax      = $this->totals['tax']['initial'];
1491
-		$fee      = $this->totals['fee']['initial'];
1492
-		$discount = $this->totals['discount']['initial'];
1493
-		$subtotal = $this->totals['subtotal']['initial'];
1494
-		$total    = $tax + $fee - $discount + $subtotal;
1490
+        $tax      = $this->totals['tax']['initial'];
1491
+        $fee      = $this->totals['fee']['initial'];
1492
+        $discount = $this->totals['discount']['initial'];
1493
+        $subtotal = $this->totals['subtotal']['initial'];
1494
+        $total    = $tax + $fee - $discount + $subtotal;
1495 1495
 
1496
-		if ( 0 > $total ) {
1497
-			$total = 0;
1498
-		}
1496
+        if ( 0 > $total ) {
1497
+            $total = 0;
1498
+        }
1499 1499
 
1500
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1500
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1501 1501
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1502
-	}
1502
+    }
1503 1503
 
1504
-	/**
1505
-	 * Get the recurring invoice total.
1506
-	 *
1507
-	 * @since 1.0.19
1504
+    /**
1505
+     * Get the recurring invoice total.
1506
+     *
1507
+     * @since 1.0.19
1508 1508
      * @param  string $context View or edit context.
1509 1509
      * @return float
1510
-	 */
1510
+     */
1511 1511
     public function get_recurring_total() {
1512 1512
 
1513
-		if ( empty( $this->totals ) ) {
1514
-			$this->recalculate_total();
1515
-		}
1513
+        if ( empty( $this->totals ) ) {
1514
+            $this->recalculate_total();
1515
+        }
1516 1516
 
1517
-		$tax      = $this->totals['tax']['recurring'];
1518
-		$fee      = $this->totals['fee']['recurring'];
1519
-		$discount = $this->totals['discount']['recurring'];
1520
-		$subtotal = $this->totals['subtotal']['recurring'];
1521
-		$total    = $tax + $fee - $discount + $subtotal;
1517
+        $tax      = $this->totals['tax']['recurring'];
1518
+        $fee      = $this->totals['fee']['recurring'];
1519
+        $discount = $this->totals['discount']['recurring'];
1520
+        $subtotal = $this->totals['subtotal']['recurring'];
1521
+        $total    = $tax + $fee - $discount + $subtotal;
1522 1522
 
1523
-		if ( 0 > $total ) {
1524
-			$total = 0;
1525
-		}
1523
+        if ( 0 > $total ) {
1524
+            $total = 0;
1525
+        }
1526 1526
 
1527
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1527
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1528 1528
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1529
-	}
1529
+    }
1530 1530
 
1531
-	/**
1532
-	 * Returns recurring payment details.
1533
-	 *
1534
-	 * @since 1.0.19
1531
+    /**
1532
+     * Returns recurring payment details.
1533
+     *
1534
+     * @since 1.0.19
1535 1535
      * @param  string $field Optionally provide a field to return.
1536
-	 * @param string $currency Whether to include the currency.
1536
+     * @param string $currency Whether to include the currency.
1537 1537
      * @return float|string
1538
-	 */
1538
+     */
1539 1539
     public function get_recurring_details( $field = '', $currency = false ) {
1540 1540
 
1541
-		// Maybe recalculate totals.
1542
-		if ( empty( $this->totals ) ) {
1543
-			$this->recalculate_total();
1544
-		}
1541
+        // Maybe recalculate totals.
1542
+        if ( empty( $this->totals ) ) {
1543
+            $this->recalculate_total();
1544
+        }
1545 1545
 
1546
-		// Prepare recurring totals.
1546
+        // Prepare recurring totals.
1547 1547
         $data = apply_filters(
1548
-			'wpinv_get_invoice_recurring_details',
1549
-			array(
1550
-				'cart_details' => $this->get_cart_details(),
1551
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1552
-				'discount'     => $this->totals['discount']['recurring'],
1553
-				'tax'          => $this->totals['tax']['recurring'],
1554
-				'fee'          => $this->totals['fee']['recurring'],
1555
-				'total'        => $this->get_recurring_total(),
1556
-			),
1557
-			$this,
1558
-			$field,
1559
-			$currency
1560
-		);
1548
+            'wpinv_get_invoice_recurring_details',
1549
+            array(
1550
+                'cart_details' => $this->get_cart_details(),
1551
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1552
+                'discount'     => $this->totals['discount']['recurring'],
1553
+                'tax'          => $this->totals['tax']['recurring'],
1554
+                'fee'          => $this->totals['fee']['recurring'],
1555
+                'total'        => $this->get_recurring_total(),
1556
+            ),
1557
+            $this,
1558
+            $field,
1559
+            $currency
1560
+        );
1561 1561
 
1562 1562
         if ( isset( $data[$field] ) ) {
1563 1563
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1567,166 +1567,166 @@  discard block
 block discarded – undo
1567 1567
     }
1568 1568
 
1569 1569
     /**
1570
-	 * Get the invoice fees.
1571
-	 *
1572
-	 * @since 1.0.19
1573
-	 * @param  string $context View or edit context.
1574
-	 * @return array
1575
-	 */
1576
-	public function get_fees( $context = 'view' ) {
1577
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1570
+     * Get the invoice fees.
1571
+     *
1572
+     * @since 1.0.19
1573
+     * @param  string $context View or edit context.
1574
+     * @return array
1575
+     */
1576
+    public function get_fees( $context = 'view' ) {
1577
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1578 1578
     }
1579 1579
 
1580 1580
     /**
1581
-	 * Get the invoice discounts.
1582
-	 *
1583
-	 * @since 1.0.19
1584
-	 * @param  string $context View or edit context.
1585
-	 * @return array
1586
-	 */
1587
-	public function get_discounts( $context = 'view' ) {
1588
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1581
+     * Get the invoice discounts.
1582
+     *
1583
+     * @since 1.0.19
1584
+     * @param  string $context View or edit context.
1585
+     * @return array
1586
+     */
1587
+    public function get_discounts( $context = 'view' ) {
1588
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1589 1589
     }
1590 1590
 
1591 1591
     /**
1592
-	 * Get the invoice taxes.
1593
-	 *
1594
-	 * @since 1.0.19
1595
-	 * @param  string $context View or edit context.
1596
-	 * @return array
1597
-	 */
1598
-	public function get_taxes( $context = 'view' ) {
1599
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1592
+     * Get the invoice taxes.
1593
+     *
1594
+     * @since 1.0.19
1595
+     * @param  string $context View or edit context.
1596
+     * @return array
1597
+     */
1598
+    public function get_taxes( $context = 'view' ) {
1599
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1600 1600
     }
1601 1601
 
1602 1602
     /**
1603
-	 * Get the invoice items.
1604
-	 *
1605
-	 * @since 1.0.19
1606
-	 * @param  string $context View or edit context.
1607
-	 * @return GetPaid_Form_Item[]
1608
-	 */
1609
-	public function get_items( $context = 'view' ) {
1603
+     * Get the invoice items.
1604
+     *
1605
+     * @since 1.0.19
1606
+     * @param  string $context View or edit context.
1607
+     * @return GetPaid_Form_Item[]
1608
+     */
1609
+    public function get_items( $context = 'view' ) {
1610 1610
         return $this->get_prop( 'items', $context );
1611
-	}
1611
+    }
1612 1612
 
1613
-	/**
1614
-	 * Get the invoice item ids.
1615
-	 *
1616
-	 * @since 1.0.19
1617
-	 * @return string
1618
-	 */
1619
-	public function get_item_ids() {
1620
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1613
+    /**
1614
+     * Get the invoice item ids.
1615
+     *
1616
+     * @since 1.0.19
1617
+     * @return string
1618
+     */
1619
+    public function get_item_ids() {
1620
+        return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1621 1621
     }
1622 1622
 
1623 1623
     /**
1624
-	 * Get the invoice's payment form.
1625
-	 *
1626
-	 * @since 1.0.19
1627
-	 * @param  string $context View or edit context.
1628
-	 * @return int
1629
-	 */
1630
-	public function get_payment_form( $context = 'view' ) {
1631
-		return intval( $this->get_prop( 'payment_form', $context ) );
1624
+     * Get the invoice's payment form.
1625
+     *
1626
+     * @since 1.0.19
1627
+     * @param  string $context View or edit context.
1628
+     * @return int
1629
+     */
1630
+    public function get_payment_form( $context = 'view' ) {
1631
+        return intval( $this->get_prop( 'payment_form', $context ) );
1632 1632
     }
1633 1633
 
1634 1634
     /**
1635
-	 * Get the invoice's submission id.
1636
-	 *
1637
-	 * @since 1.0.19
1638
-	 * @param  string $context View or edit context.
1639
-	 * @return string
1640
-	 */
1641
-	public function get_submission_id( $context = 'view' ) {
1642
-		return $this->get_prop( 'submission_id', $context );
1635
+     * Get the invoice's submission id.
1636
+     *
1637
+     * @since 1.0.19
1638
+     * @param  string $context View or edit context.
1639
+     * @return string
1640
+     */
1641
+    public function get_submission_id( $context = 'view' ) {
1642
+        return $this->get_prop( 'submission_id', $context );
1643 1643
     }
1644 1644
 
1645 1645
     /**
1646
-	 * Get the invoice's discount code.
1647
-	 *
1648
-	 * @since 1.0.19
1649
-	 * @param  string $context View or edit context.
1650
-	 * @return string
1651
-	 */
1652
-	public function get_discount_code( $context = 'view' ) {
1653
-		return $this->get_prop( 'discount_code', $context );
1646
+     * Get the invoice's discount code.
1647
+     *
1648
+     * @since 1.0.19
1649
+     * @param  string $context View or edit context.
1650
+     * @return string
1651
+     */
1652
+    public function get_discount_code( $context = 'view' ) {
1653
+        return $this->get_prop( 'discount_code', $context );
1654 1654
     }
1655 1655
 
1656 1656
     /**
1657
-	 * Get the invoice's gateway.
1658
-	 *
1659
-	 * @since 1.0.19
1660
-	 * @param  string $context View or edit context.
1661
-	 * @return string
1662
-	 */
1663
-	public function get_gateway( $context = 'view' ) {
1664
-		return $this->get_prop( 'gateway', $context );
1657
+     * Get the invoice's gateway.
1658
+     *
1659
+     * @since 1.0.19
1660
+     * @param  string $context View or edit context.
1661
+     * @return string
1662
+     */
1663
+    public function get_gateway( $context = 'view' ) {
1664
+        return $this->get_prop( 'gateway', $context );
1665 1665
     }
1666 1666
 
1667 1667
     /**
1668
-	 * Get the invoice's gateway display title.
1669
-	 *
1670
-	 * @since 1.0.19
1671
-	 * @return string
1672
-	 */
1668
+     * Get the invoice's gateway display title.
1669
+     *
1670
+     * @since 1.0.19
1671
+     * @return string
1672
+     */
1673 1673
     public function get_gateway_title() {
1674 1674
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1675 1675
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1676 1676
     }
1677 1677
 
1678 1678
     /**
1679
-	 * Get the invoice's transaction id.
1680
-	 *
1681
-	 * @since 1.0.19
1682
-	 * @param  string $context View or edit context.
1683
-	 * @return string
1684
-	 */
1685
-	public function get_transaction_id( $context = 'view' ) {
1686
-		return $this->get_prop( 'transaction_id', $context );
1679
+     * Get the invoice's transaction id.
1680
+     *
1681
+     * @since 1.0.19
1682
+     * @param  string $context View or edit context.
1683
+     * @return string
1684
+     */
1685
+    public function get_transaction_id( $context = 'view' ) {
1686
+        return $this->get_prop( 'transaction_id', $context );
1687 1687
     }
1688 1688
 
1689 1689
     /**
1690
-	 * Get the invoice's currency.
1691
-	 *
1692
-	 * @since 1.0.19
1693
-	 * @param  string $context View or edit context.
1694
-	 * @return string
1695
-	 */
1696
-	public function get_currency( $context = 'view' ) {
1690
+     * Get the invoice's currency.
1691
+     *
1692
+     * @since 1.0.19
1693
+     * @param  string $context View or edit context.
1694
+     * @return string
1695
+     */
1696
+    public function get_currency( $context = 'view' ) {
1697 1697
         $currency = $this->get_prop( 'currency', $context );
1698 1698
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1699 1699
     }
1700 1700
 
1701 1701
     /**
1702
-	 * Checks if we are charging taxes for this invoice.
1703
-	 *
1704
-	 * @since 1.0.19
1705
-	 * @param  string $context View or edit context.
1706
-	 * @return bool
1707
-	 */
1708
-	public function get_disable_taxes( $context = 'view' ) {
1702
+     * Checks if we are charging taxes for this invoice.
1703
+     *
1704
+     * @since 1.0.19
1705
+     * @param  string $context View or edit context.
1706
+     * @return bool
1707
+     */
1708
+    public function get_disable_taxes( $context = 'view' ) {
1709 1709
         return (bool) $this->get_prop( 'disable_taxes', $context );
1710 1710
     }
1711 1711
 
1712 1712
     /**
1713
-	 * Retrieves the subscription id for an invoice.
1714
-	 *
1715
-	 * @since 1.0.19
1716
-	 * @param  string $context View or edit context.
1717
-	 * @return int
1718
-	 */
1713
+     * Retrieves the subscription id for an invoice.
1714
+     *
1715
+     * @since 1.0.19
1716
+     * @param  string $context View or edit context.
1717
+     * @return int
1718
+     */
1719 1719
     public function get_subscription_id( $context = 'view' ) {
1720
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1721
-	}
1722
-
1723
-	/**
1724
-	 * Retrieves the remote subscription id for an invoice.
1725
-	 *
1726
-	 * @since 1.0.19
1727
-	 * @param  string $context View or edit context.
1728
-	 * @return int
1729
-	 */
1720
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1721
+    }
1722
+
1723
+    /**
1724
+     * Retrieves the remote subscription id for an invoice.
1725
+     *
1726
+     * @since 1.0.19
1727
+     * @param  string $context View or edit context.
1728
+     * @return int
1729
+     */
1730 1730
     public function get_remote_subscription_id( $context = 'view' ) {
1731 1731
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1732 1732
 
@@ -1739,12 +1739,12 @@  discard block
 block discarded – undo
1739 1739
     }
1740 1740
 
1741 1741
     /**
1742
-	 * Retrieves the payment meta for an invoice.
1743
-	 *
1744
-	 * @since 1.0.19
1745
-	 * @param  string $context View or edit context.
1746
-	 * @return array
1747
-	 */
1742
+     * Retrieves the payment meta for an invoice.
1743
+     *
1744
+     * @since 1.0.19
1745
+     * @param  string $context View or edit context.
1746
+     * @return array
1747
+     */
1748 1748
     public function get_payment_meta( $context = 'view' ) {
1749 1749
 
1750 1750
         return array(
@@ -1764,31 +1764,31 @@  discard block
 block discarded – undo
1764 1764
     }
1765 1765
 
1766 1766
     /**
1767
-	 * Retrieves the cart details for an invoice.
1768
-	 *
1769
-	 * @since 1.0.19
1770
-	 * @return array
1771
-	 */
1767
+     * Retrieves the cart details for an invoice.
1768
+     *
1769
+     * @since 1.0.19
1770
+     * @return array
1771
+     */
1772 1772
     public function get_cart_details() {
1773 1773
         $items        = $this->get_items();
1774 1774
         $cart_details = array();
1775 1775
 
1776 1776
         foreach ( $items as $item ) {
1777
-			$item->invoice_id = $this->get_id();
1777
+            $item->invoice_id = $this->get_id();
1778 1778
             $cart_details[]   = $item->prepare_data_for_saving();
1779 1779
         }
1780 1780
 
1781 1781
         return $cart_details;
1782
-	}
1782
+    }
1783 1783
 
1784
-	/**
1785
-	 * Retrieves the recurring item.
1786
-	 *
1787
-	 * @return null|GetPaid_Form_Item|int
1788
-	 */
1789
-	public function get_recurring( $object = false ) {
1784
+    /**
1785
+     * Retrieves the recurring item.
1786
+     *
1787
+     * @return null|GetPaid_Form_Item|int
1788
+     */
1789
+    public function get_recurring( $object = false ) {
1790 1790
 
1791
-		// Are we returning an object?
1791
+        // Are we returning an object?
1792 1792
         if ( $object ) {
1793 1793
             return $this->get_item( $this->recurring_item );
1794 1794
         }
@@ -1796,114 +1796,114 @@  discard block
 block discarded – undo
1796 1796
         return $this->recurring_item;
1797 1797
     }
1798 1798
 
1799
-	/**
1800
-	 * Retrieves the subscription name.
1801
-	 *
1802
-	 * @since 1.0.19
1803
-	 * @return string
1804
-	 */
1805
-	public function get_subscription_name() {
1799
+    /**
1800
+     * Retrieves the subscription name.
1801
+     *
1802
+     * @since 1.0.19
1803
+     * @return string
1804
+     */
1805
+    public function get_subscription_name() {
1806 1806
 
1807
-		// Retrieve the recurring name
1807
+        // Retrieve the recurring name
1808 1808
         $item = $this->get_recurring( true );
1809 1809
 
1810
-		// Abort if it does not exist.
1810
+        // Abort if it does not exist.
1811 1811
         if ( empty( $item ) ) {
1812 1812
             return '';
1813 1813
         }
1814 1814
 
1815
-		// Return the item name.
1815
+        // Return the item name.
1816 1816
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1817
-	}
1818
-
1819
-	/**
1820
-	 * Retrieves the view url.
1821
-	 *
1822
-	 * @since 1.0.19
1823
-	 * @return string
1824
-	 */
1825
-	public function get_view_url() {
1817
+    }
1818
+
1819
+    /**
1820
+     * Retrieves the view url.
1821
+     *
1822
+     * @since 1.0.19
1823
+     * @return string
1824
+     */
1825
+    public function get_view_url() {
1826 1826
         $invoice_url = get_permalink( $this->get_id() );
1827
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1827
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1828 1828
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1829
-	}
1829
+    }
1830 1830
 
1831
-	/**
1832
-	 * Retrieves the payment url.
1833
-	 *
1834
-	 * @since 1.0.19
1835
-	 * @return string
1836
-	 */
1837
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1831
+    /**
1832
+     * Retrieves the payment url.
1833
+     *
1834
+     * @since 1.0.19
1835
+     * @return string
1836
+     */
1837
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1838 1838
 
1839
-		// Retrieve the checkout url.
1839
+        // Retrieve the checkout url.
1840 1840
         $pay_url = wpinv_get_checkout_uri();
1841 1841
 
1842
-		// Maybe force ssl.
1842
+        // Maybe force ssl.
1843 1843
         if ( is_ssl() ) {
1844 1844
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1845 1845
         }
1846 1846
 
1847
-		// Add the invoice key.
1848
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1847
+        // Add the invoice key.
1848
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1849 1849
 
1850
-		// (Maybe?) add a secret
1850
+        // (Maybe?) add a secret
1851 1851
         if ( $secret ) {
1852 1852
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1853 1853
         }
1854 1854
 
1855 1855
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1856
-	}
1856
+    }
1857 1857
 	
1858
-	/**
1859
-	 * Retrieves the receipt url.
1860
-	 *
1861
-	 * @since 1.0.19
1862
-	 * @return string
1863
-	 */
1864
-	public function get_receipt_url() {
1865
-
1866
-		// Retrieve the checkout url.
1858
+    /**
1859
+     * Retrieves the receipt url.
1860
+     *
1861
+     * @since 1.0.19
1862
+     * @return string
1863
+     */
1864
+    public function get_receipt_url() {
1865
+
1866
+        // Retrieve the checkout url.
1867 1867
         $receipt_url = wpinv_get_success_page_uri();
1868 1868
 
1869
-		// Maybe force ssl.
1869
+        // Maybe force ssl.
1870 1870
         if ( is_ssl() ) {
1871 1871
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1872 1872
         }
1873 1873
 
1874
-		// Add the invoice key.
1875
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1874
+        // Add the invoice key.
1875
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1876 1876
 
1877 1877
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1878
-	}
1878
+    }
1879 1879
 	
1880
-	/**
1881
-	 * Retrieves the default status.
1882
-	 *
1883
-	 * @since 1.0.19
1884
-	 * @return string
1885
-	 */
1886
-	public function get_default_status() {
1887
-
1888
-		$type   = $this->get_type();
1889
-		$status = "wpi-$type-pending";
1890
-		return str_replace( '-invoice', '', $status );
1891
-
1892
-	}
1893
-
1894
-    /**
1895
-	 * Magic method for accessing invoice properties.
1896
-	 *
1897
-	 * @since 1.0.15
1898
-	 * @access public
1899
-	 *
1900
-	 * @param string $key Discount data to retrieve
1901
-	 * @param  string $context View or edit context.
1902
-	 * @return mixed Value of the given invoice property (if set).
1903
-	 */
1904
-	public function get( $key, $context = 'view' ) {
1880
+    /**
1881
+     * Retrieves the default status.
1882
+     *
1883
+     * @since 1.0.19
1884
+     * @return string
1885
+     */
1886
+    public function get_default_status() {
1887
+
1888
+        $type   = $this->get_type();
1889
+        $status = "wpi-$type-pending";
1890
+        return str_replace( '-invoice', '', $status );
1891
+
1892
+    }
1893
+
1894
+    /**
1895
+     * Magic method for accessing invoice properties.
1896
+     *
1897
+     * @since 1.0.15
1898
+     * @access public
1899
+     *
1900
+     * @param string $key Discount data to retrieve
1901
+     * @param  string $context View or edit context.
1902
+     * @return mixed Value of the given invoice property (if set).
1903
+     */
1904
+    public function get( $key, $context = 'view' ) {
1905 1905
         return $this->get_prop( $key, $context );
1906
-	}
1906
+    }
1907 1907
 
1908 1908
     /*
1909 1909
 	|--------------------------------------------------------------------------
@@ -1916,130 +1916,130 @@  discard block
 block discarded – undo
1916 1916
     */
1917 1917
 
1918 1918
     /**
1919
-	 * Magic method for setting invoice properties.
1920
-	 *
1921
-	 * @since 1.0.19
1922
-	 * @access public
1923
-	 *
1924
-	 * @param string $key Discount data to retrieve
1925
-	 * @param  mixed $value new value.
1926
-	 * @return mixed Value of the given invoice property (if set).
1927
-	 */
1928
-	public function set( $key, $value ) {
1919
+     * Magic method for setting invoice properties.
1920
+     *
1921
+     * @since 1.0.19
1922
+     * @access public
1923
+     *
1924
+     * @param string $key Discount data to retrieve
1925
+     * @param  mixed $value new value.
1926
+     * @return mixed Value of the given invoice property (if set).
1927
+     */
1928
+    public function set( $key, $value ) {
1929 1929
 
1930 1930
         $setter = "set_$key";
1931 1931
         if ( is_callable( array( $this, $setter ) ) ) {
1932 1932
             $this->{$setter}( $value );
1933 1933
         }
1934 1934
 
1935
-	}
1935
+    }
1936 1936
 
1937
-	/**
1938
-	 * Sets item status.
1939
-	 *
1940
-	 * @since 1.0.19
1941
-	 * @param string $new_status    New status.
1942
-	 * @param string $note          Optional note to add.
1943
-	 * @param bool   $manual_update Is this a manual status change?.
1944
-	 * @return array details of change.
1945
-	 */
1946
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1947
-		$old_status = $this->get_status();
1937
+    /**
1938
+     * Sets item status.
1939
+     *
1940
+     * @since 1.0.19
1941
+     * @param string $new_status    New status.
1942
+     * @param string $note          Optional note to add.
1943
+     * @param bool   $manual_update Is this a manual status change?.
1944
+     * @return array details of change.
1945
+     */
1946
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1947
+        $old_status = $this->get_status();
1948 1948
 
1949
-		$statuses = $this->get_all_statuses();
1949
+        $statuses = $this->get_all_statuses();
1950 1950
 
1951
-		if ( isset( $statuses[ 'draft' ] ) ) {
1952
-			unset( $statuses[ 'draft' ] );
1953
-		}
1951
+        if ( isset( $statuses[ 'draft' ] ) ) {
1952
+            unset( $statuses[ 'draft' ] );
1953
+        }
1954 1954
 
1955
-		$this->set_prop( 'status', $new_status );
1955
+        $this->set_prop( 'status', $new_status );
1956 1956
 
1957
-		// If setting the status, ensure it's set to a valid status.
1958
-		if ( true === $this->object_read ) {
1957
+        // If setting the status, ensure it's set to a valid status.
1958
+        if ( true === $this->object_read ) {
1959 1959
 
1960
-			// Only allow valid new status.
1961
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1962
-				$new_status = $this->get_default_status();
1963
-			}
1960
+            // Only allow valid new status.
1961
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1962
+                $new_status = $this->get_default_status();
1963
+            }
1964 1964
 
1965
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1966
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1967
-				$old_status = $this->get_default_status();
1968
-			}
1965
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1966
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1967
+                $old_status = $this->get_default_status();
1968
+            }
1969 1969
 
1970
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1971
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1972
-				$old_status = 'wpi-pending';
1973
-			}
1970
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1971
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1972
+                $old_status = 'wpi-pending';
1973
+            }
1974 1974
 
1975
-			if ( $old_status !== $new_status ) {
1976
-				$this->status_transition = array(
1977
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1978
-					'to'     => $new_status,
1979
-					'note'   => $note,
1980
-					'manual' => (bool) $manual_update,
1981
-				);
1975
+            if ( $old_status !== $new_status ) {
1976
+                $this->status_transition = array(
1977
+                    'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1978
+                    'to'     => $new_status,
1979
+                    'note'   => $note,
1980
+                    'manual' => (bool) $manual_update,
1981
+                );
1982 1982
 
1983
-				if ( $manual_update ) {
1984
-					do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1985
-				}
1983
+                if ( $manual_update ) {
1984
+                    do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1985
+                }
1986 1986
 
1987
-				$this->maybe_set_date_paid();
1987
+                $this->maybe_set_date_paid();
1988 1988
 
1989
-			}
1989
+            }
1990 1990
 
1991
-		}
1991
+        }
1992 1992
 
1993
-		return array(
1994
-			'from' => $old_status,
1995
-			'to'   => $new_status,
1996
-		);
1997
-	}
1993
+        return array(
1994
+            'from' => $old_status,
1995
+            'to'   => $new_status,
1996
+        );
1997
+    }
1998 1998
 
1999
-	/**
2000
-	 * Maybe set date paid.
2001
-	 *
2002
-	 * Sets the date paid variable when transitioning to the payment complete
2003
-	 * order status.
2004
-	 *
2005
-	 * @since 1.0.19
2006
-	 */
2007
-	public function maybe_set_date_paid() {
1999
+    /**
2000
+     * Maybe set date paid.
2001
+     *
2002
+     * Sets the date paid variable when transitioning to the payment complete
2003
+     * order status.
2004
+     *
2005
+     * @since 1.0.19
2006
+     */
2007
+    public function maybe_set_date_paid() {
2008 2008
 
2009
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2010
-			$this->set_date_completed( current_time( 'mysql' ) );
2011
-		}
2012
-	}
2009
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2010
+            $this->set_date_completed( current_time( 'mysql' ) );
2011
+        }
2012
+    }
2013 2013
 
2014 2014
     /**
2015
-	 * Set parent invoice ID.
2016
-	 *
2017
-	 * @since 1.0.19
2018
-	 */
2019
-	public function set_parent_id( $value ) {
2020
-		if ( $value && ( $value === $this->get_id() ) ) {
2021
-			return;
2022
-		}
2023
-		$this->set_prop( 'parent_id', absint( $value ) );
2015
+     * Set parent invoice ID.
2016
+     *
2017
+     * @since 1.0.19
2018
+     */
2019
+    public function set_parent_id( $value ) {
2020
+        if ( $value && ( $value === $this->get_id() ) ) {
2021
+            return;
2022
+        }
2023
+        $this->set_prop( 'parent_id', absint( $value ) );
2024 2024
     }
2025 2025
 
2026 2026
     /**
2027
-	 * Set plugin version when the invoice was created.
2028
-	 *
2029
-	 * @since 1.0.19
2030
-	 */
2031
-	public function set_version( $value ) {
2032
-		$this->set_prop( 'version', $value );
2027
+     * Set plugin version when the invoice was created.
2028
+     *
2029
+     * @since 1.0.19
2030
+     */
2031
+    public function set_version( $value ) {
2032
+        $this->set_prop( 'version', $value );
2033 2033
     }
2034
-
2035
-    /**
2036
-	 * Set date when the invoice was created.
2037
-	 *
2038
-	 * @since 1.0.19
2039
-	 * @param string $value Value to set.
2034
+
2035
+    /**
2036
+     * Set date when the invoice was created.
2037
+     *
2038
+     * @since 1.0.19
2039
+     * @param string $value Value to set.
2040 2040
      * @return bool Whether or not the date was set.
2041
-	 */
2042
-	public function set_date_created( $value ) {
2041
+     */
2042
+    public function set_date_created( $value ) {
2043 2043
         $date = strtotime( $value );
2044 2044
 
2045 2045
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2047,19 +2047,19 @@  discard block
 block discarded – undo
2047 2047
             return true;
2048 2048
         }
2049 2049
 
2050
-		$this->set_prop( 'date_created', '' );
2051
-		return false;
2050
+        $this->set_prop( 'date_created', '' );
2051
+        return false;
2052 2052
 
2053 2053
     }
2054 2054
 
2055 2055
     /**
2056
-	 * Set date invoice due date.
2057
-	 *
2058
-	 * @since 1.0.19
2059
-	 * @param string $value Value to set.
2056
+     * Set date invoice due date.
2057
+     *
2058
+     * @since 1.0.19
2059
+     * @param string $value Value to set.
2060 2060
      * @return bool Whether or not the date was set.
2061
-	 */
2062
-	public function set_due_date( $value ) {
2061
+     */
2062
+    public function set_due_date( $value ) {
2063 2063
         $date = strtotime( $value );
2064 2064
 
2065 2065
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2067,29 +2067,29 @@  discard block
 block discarded – undo
2067 2067
             return true;
2068 2068
         }
2069 2069
 
2070
-		$this->set_prop( 'due_date', '' );
2070
+        $this->set_prop( 'due_date', '' );
2071 2071
         return false;
2072 2072
 
2073 2073
     }
2074 2074
 
2075 2075
     /**
2076
-	 * Alias of self::set_due_date().
2077
-	 *
2078
-	 * @since 1.0.19
2079
-	 * @param  string $value New name.
2080
-	 */
2081
-	public function set_date_due( $value ) {
2082
-		$this->set_due_date( $value );
2076
+     * Alias of self::set_due_date().
2077
+     *
2078
+     * @since 1.0.19
2079
+     * @param  string $value New name.
2080
+     */
2081
+    public function set_date_due( $value ) {
2082
+        $this->set_due_date( $value );
2083 2083
     }
2084 2084
 
2085 2085
     /**
2086
-	 * Set date invoice was completed.
2087
-	 *
2088
-	 * @since 1.0.19
2089
-	 * @param string $value Value to set.
2086
+     * Set date invoice was completed.
2087
+     *
2088
+     * @since 1.0.19
2089
+     * @param string $value Value to set.
2090 2090
      * @return bool Whether or not the date was set.
2091
-	 */
2092
-	public function set_completed_date( $value ) {
2091
+     */
2092
+    public function set_completed_date( $value ) {
2093 2093
         $date = strtotime( $value );
2094 2094
 
2095 2095
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -2097,29 +2097,29 @@  discard block
 block discarded – undo
2097 2097
             return true;
2098 2098
         }
2099 2099
 
2100
-		$this->set_prop( 'completed_date', '' );
2100
+        $this->set_prop( 'completed_date', '' );
2101 2101
         return false;
2102 2102
 
2103 2103
     }
2104 2104
 
2105 2105
     /**
2106
-	 * Alias of self::set_completed_date().
2107
-	 *
2108
-	 * @since 1.0.19
2109
-	 * @param  string $value New name.
2110
-	 */
2111
-	public function set_date_completed( $value ) {
2112
-		$this->set_completed_date( $value );
2106
+     * Alias of self::set_completed_date().
2107
+     *
2108
+     * @since 1.0.19
2109
+     * @param  string $value New name.
2110
+     */
2111
+    public function set_date_completed( $value ) {
2112
+        $this->set_completed_date( $value );
2113 2113
     }
2114 2114
 
2115 2115
     /**
2116
-	 * Set date when the invoice was last modified.
2117
-	 *
2118
-	 * @since 1.0.19
2119
-	 * @param string $value Value to set.
2116
+     * Set date when the invoice was last modified.
2117
+     *
2118
+     * @since 1.0.19
2119
+     * @param string $value Value to set.
2120 2120
      * @return bool Whether or not the date was set.
2121
-	 */
2122
-	public function set_date_modified( $value ) {
2121
+     */
2122
+    public function set_date_modified( $value ) {
2123 2123
         $date = strtotime( $value );
2124 2124
 
2125 2125
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2127,788 +2127,788 @@  discard block
 block discarded – undo
2127 2127
             return true;
2128 2128
         }
2129 2129
 
2130
-		$this->set_prop( 'date_modified', '' );
2130
+        $this->set_prop( 'date_modified', '' );
2131 2131
         return false;
2132 2132
 
2133 2133
     }
2134 2134
 
2135 2135
     /**
2136
-	 * Set the invoice number.
2137
-	 *
2138
-	 * @since 1.0.19
2139
-	 * @param  string $value New number.
2140
-	 */
2141
-	public function set_number( $value ) {
2136
+     * Set the invoice number.
2137
+     *
2138
+     * @since 1.0.19
2139
+     * @param  string $value New number.
2140
+     */
2141
+    public function set_number( $value ) {
2142 2142
         $number = sanitize_text_field( $value );
2143
-		$this->set_prop( 'number', $number );
2143
+        $this->set_prop( 'number', $number );
2144 2144
     }
2145 2145
 
2146 2146
     /**
2147
-	 * Set the invoice type.
2148
-	 *
2149
-	 * @since 1.0.19
2150
-	 * @param  string $value Type.
2151
-	 */
2152
-	public function set_type( $value ) {
2147
+     * Set the invoice type.
2148
+     *
2149
+     * @since 1.0.19
2150
+     * @param  string $value Type.
2151
+     */
2152
+    public function set_type( $value ) {
2153 2153
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2154
-		$this->set_prop( 'type', $type );
2155
-	}
2154
+        $this->set_prop( 'type', $type );
2155
+    }
2156 2156
 
2157 2157
     /**
2158
-	 * Set the invoice post type.
2159
-	 *
2160
-	 * @since 1.0.19
2161
-	 * @param  string $value Post type.
2162
-	 */
2163
-	public function set_post_type( $value ) {
2158
+     * Set the invoice post type.
2159
+     *
2160
+     * @since 1.0.19
2161
+     * @param  string $value Post type.
2162
+     */
2163
+    public function set_post_type( $value ) {
2164 2164
         if ( getpaid_is_invoice_post_type( $value ) ) {
2165
-			$this->set_type( $value );
2165
+            $this->set_type( $value );
2166 2166
             $this->set_prop( 'post_type', $value );
2167 2167
         }
2168 2168
     }
2169 2169
 
2170 2170
     /**
2171
-	 * Set the invoice key.
2172
-	 *
2173
-	 * @since 1.0.19
2174
-	 * @param  string $value New key.
2175
-	 */
2176
-	public function set_key( $value ) {
2171
+     * Set the invoice key.
2172
+     *
2173
+     * @since 1.0.19
2174
+     * @param  string $value New key.
2175
+     */
2176
+    public function set_key( $value ) {
2177 2177
         $key = sanitize_text_field( $value );
2178
-		$this->set_prop( 'key', $key );
2178
+        $this->set_prop( 'key', $key );
2179 2179
     }
2180 2180
 
2181 2181
     /**
2182
-	 * Set the invoice mode.
2183
-	 *
2184
-	 * @since 1.0.19
2185
-	 * @param  string $value mode.
2186
-	 */
2187
-	public function set_mode( $value ) {
2182
+     * Set the invoice mode.
2183
+     *
2184
+     * @since 1.0.19
2185
+     * @param  string $value mode.
2186
+     */
2187
+    public function set_mode( $value ) {
2188 2188
         if ( in_array( $value, array( 'live', 'test' ) ) ) {
2189 2189
             $this->set_prop( 'mode', $value );
2190 2190
         }
2191 2191
     }
2192 2192
 
2193 2193
     /**
2194
-	 * Set the invoice path.
2195
-	 *
2196
-	 * @since 1.0.19
2197
-	 * @param  string $value path.
2198
-	 */
2199
-	public function set_path( $value ) {
2194
+     * Set the invoice path.
2195
+     *
2196
+     * @since 1.0.19
2197
+     * @param  string $value path.
2198
+     */
2199
+    public function set_path( $value ) {
2200 2200
         $this->set_prop( 'path', $value );
2201 2201
     }
2202 2202
 
2203 2203
     /**
2204
-	 * Set the invoice name.
2205
-	 *
2206
-	 * @since 1.0.19
2207
-	 * @param  string $value New name.
2208
-	 */
2209
-	public function set_name( $value ) {
2204
+     * Set the invoice name.
2205
+     *
2206
+     * @since 1.0.19
2207
+     * @param  string $value New name.
2208
+     */
2209
+    public function set_name( $value ) {
2210 2210
         $name = sanitize_text_field( $value );
2211
-		$this->set_prop( 'name', $name );
2211
+        $this->set_prop( 'name', $name );
2212 2212
     }
2213 2213
 
2214 2214
     /**
2215
-	 * Alias of self::set_name().
2216
-	 *
2217
-	 * @since 1.0.19
2218
-	 * @param  string $value New name.
2219
-	 */
2220
-	public function set_title( $value ) {
2221
-		$this->set_name( $value );
2215
+     * Alias of self::set_name().
2216
+     *
2217
+     * @since 1.0.19
2218
+     * @param  string $value New name.
2219
+     */
2220
+    public function set_title( $value ) {
2221
+        $this->set_name( $value );
2222 2222
     }
2223 2223
 
2224 2224
     /**
2225
-	 * Set the invoice description.
2226
-	 *
2227
-	 * @since 1.0.19
2228
-	 * @param  string $value New description.
2229
-	 */
2230
-	public function set_description( $value ) {
2225
+     * Set the invoice description.
2226
+     *
2227
+     * @since 1.0.19
2228
+     * @param  string $value New description.
2229
+     */
2230
+    public function set_description( $value ) {
2231 2231
         $description = wp_kses_post( $value );
2232
-		$this->set_prop( 'description', $description );
2232
+        $this->set_prop( 'description', $description );
2233
+    }
2234
+
2235
+    /**
2236
+     * Alias of self::set_description().
2237
+     *
2238
+     * @since 1.0.19
2239
+     * @param  string $value New description.
2240
+     */
2241
+    public function set_excerpt( $value ) {
2242
+        $this->set_description( $value );
2243
+    }
2244
+
2245
+    /**
2246
+     * Alias of self::set_description().
2247
+     *
2248
+     * @since 1.0.19
2249
+     * @param  string $value New description.
2250
+     */
2251
+    public function set_summary( $value ) {
2252
+        $this->set_description( $value );
2253
+    }
2254
+
2255
+    /**
2256
+     * Set the receiver of the invoice.
2257
+     *
2258
+     * @since 1.0.19
2259
+     * @param  int $value New author.
2260
+     */
2261
+    public function set_author( $value ) {
2262
+        $user = get_user_by( 'id', (int) $value );
2263
+
2264
+        if ( $user && $user->ID ) {
2265
+            $this->set_prop( 'author', $user->ID );
2266
+            $this->set_prop( 'email', $user->user_email );
2267
+        }
2268
+
2269
+    }
2270
+
2271
+    /**
2272
+     * Alias of self::set_author().
2273
+     *
2274
+     * @since 1.0.19
2275
+     * @param  int $value New user id.
2276
+     */
2277
+    public function set_user_id( $value ) {
2278
+        $this->set_author( $value );
2279
+    }
2280
+
2281
+    /**
2282
+     * Alias of self::set_author().
2283
+     *
2284
+     * @since 1.0.19
2285
+     * @param  int $value New user id.
2286
+     */
2287
+    public function set_customer_id( $value ) {
2288
+        $this->set_author( $value );
2289
+    }
2290
+
2291
+    /**
2292
+     * Set the customer's ip.
2293
+     *
2294
+     * @since 1.0.19
2295
+     * @param  string $value ip address.
2296
+     */
2297
+    public function set_ip( $value ) {
2298
+        $this->set_prop( 'ip', $value );
2299
+    }
2300
+
2301
+    /**
2302
+     * Alias of self::set_ip().
2303
+     *
2304
+     * @since 1.0.19
2305
+     * @param  string $value ip address.
2306
+     */
2307
+    public function set_user_ip( $value ) {
2308
+        $this->set_ip( $value );
2309
+    }
2310
+
2311
+    /**
2312
+     * Set the customer's first name.
2313
+     *
2314
+     * @since 1.0.19
2315
+     * @param  string $value first name.
2316
+     */
2317
+    public function set_first_name( $value ) {
2318
+        $this->set_prop( 'first_name', $value );
2233 2319
     }
2234 2320
 
2235 2321
     /**
2236
-	 * Alias of self::set_description().
2237
-	 *
2238
-	 * @since 1.0.19
2239
-	 * @param  string $value New description.
2240
-	 */
2241
-	public function set_excerpt( $value ) {
2242
-		$this->set_description( $value );
2322
+     * Alias of self::set_first_name().
2323
+     *
2324
+     * @since 1.0.19
2325
+     * @param  string $value first name.
2326
+     */
2327
+    public function set_user_first_name( $value ) {
2328
+        $this->set_first_name( $value );
2243 2329
     }
2244 2330
 
2245 2331
     /**
2246
-	 * Alias of self::set_description().
2247
-	 *
2248
-	 * @since 1.0.19
2249
-	 * @param  string $value New description.
2250
-	 */
2251
-	public function set_summary( $value ) {
2252
-		$this->set_description( $value );
2332
+     * Alias of self::set_first_name().
2333
+     *
2334
+     * @since 1.0.19
2335
+     * @param  string $value first name.
2336
+     */
2337
+    public function set_customer_first_name( $value ) {
2338
+        $this->set_first_name( $value );
2253 2339
     }
2254 2340
 
2255 2341
     /**
2256
-	 * Set the receiver of the invoice.
2257
-	 *
2258
-	 * @since 1.0.19
2259
-	 * @param  int $value New author.
2260
-	 */
2261
-	public function set_author( $value ) {
2262
-		$user = get_user_by( 'id', (int) $value );
2342
+     * Set the customer's last name.
2343
+     *
2344
+     * @since 1.0.19
2345
+     * @param  string $value last name.
2346
+     */
2347
+    public function set_last_name( $value ) {
2348
+        $this->set_prop( 'last_name', $value );
2349
+    }
2263 2350
 
2264
-		if ( $user && $user->ID ) {
2265
-			$this->set_prop( 'author', $user->ID );
2266
-			$this->set_prop( 'email', $user->user_email );
2267
-		}
2351
+    /**
2352
+     * Alias of self::set_last_name().
2353
+     *
2354
+     * @since 1.0.19
2355
+     * @param  string $value last name.
2356
+     */
2357
+    public function set_user_last_name( $value ) {
2358
+        $this->set_last_name( $value );
2359
+    }
2268 2360
 
2361
+    /**
2362
+     * Alias of self::set_last_name().
2363
+     *
2364
+     * @since 1.0.19
2365
+     * @param  string $value last name.
2366
+     */
2367
+    public function set_customer_last_name( $value ) {
2368
+        $this->set_last_name( $value );
2269 2369
     }
2270 2370
 
2271 2371
     /**
2272
-	 * Alias of self::set_author().
2273
-	 *
2274
-	 * @since 1.0.19
2275
-	 * @param  int $value New user id.
2276
-	 */
2277
-	public function set_user_id( $value ) {
2278
-		$this->set_author( $value );
2372
+     * Set the customer's phone number.
2373
+     *
2374
+     * @since 1.0.19
2375
+     * @param  string $value phone.
2376
+     */
2377
+    public function set_phone( $value ) {
2378
+        $this->set_prop( 'phone', $value );
2279 2379
     }
2280 2380
 
2281 2381
     /**
2282
-	 * Alias of self::set_author().
2283
-	 *
2284
-	 * @since 1.0.19
2285
-	 * @param  int $value New user id.
2286
-	 */
2287
-	public function set_customer_id( $value ) {
2288
-		$this->set_author( $value );
2382
+     * Alias of self::set_phone().
2383
+     *
2384
+     * @since 1.0.19
2385
+     * @param  string $value phone.
2386
+     */
2387
+    public function set_user_phone( $value ) {
2388
+        $this->set_phone( $value );
2289 2389
     }
2290 2390
 
2291 2391
     /**
2292
-	 * Set the customer's ip.
2293
-	 *
2294
-	 * @since 1.0.19
2295
-	 * @param  string $value ip address.
2296
-	 */
2297
-	public function set_ip( $value ) {
2298
-		$this->set_prop( 'ip', $value );
2392
+     * Alias of self::set_phone().
2393
+     *
2394
+     * @since 1.0.19
2395
+     * @param  string $value phone.
2396
+     */
2397
+    public function set_customer_phone( $value ) {
2398
+        $this->set_phone( $value );
2299 2399
     }
2300 2400
 
2301 2401
     /**
2302
-	 * Alias of self::set_ip().
2303
-	 *
2304
-	 * @since 1.0.19
2305
-	 * @param  string $value ip address.
2306
-	 */
2307
-	public function set_user_ip( $value ) {
2308
-		$this->set_ip( $value );
2402
+     * Alias of self::set_phone().
2403
+     *
2404
+     * @since 1.0.19
2405
+     * @param  string $value phone.
2406
+     */
2407
+    public function set_phone_number( $value ) {
2408
+        $this->set_phone( $value );
2309 2409
     }
2310 2410
 
2311 2411
     /**
2312
-	 * Set the customer's first name.
2313
-	 *
2314
-	 * @since 1.0.19
2315
-	 * @param  string $value first name.
2316
-	 */
2317
-	public function set_first_name( $value ) {
2318
-		$this->set_prop( 'first_name', $value );
2412
+     * Set the customer's email address.
2413
+     *
2414
+     * @since 1.0.19
2415
+     * @param  string $value email address.
2416
+     */
2417
+    public function set_email( $value ) {
2418
+        $this->set_prop( 'email', $value );
2319 2419
     }
2320 2420
 
2321 2421
     /**
2322
-	 * Alias of self::set_first_name().
2323
-	 *
2324
-	 * @since 1.0.19
2325
-	 * @param  string $value first name.
2326
-	 */
2327
-	public function set_user_first_name( $value ) {
2328
-		$this->set_first_name( $value );
2422
+     * Alias of self::set_email().
2423
+     *
2424
+     * @since 1.0.19
2425
+     * @param  string $value email address.
2426
+     */
2427
+    public function set_user_email( $value ) {
2428
+        $this->set_email( $value );
2329 2429
     }
2330 2430
 
2331 2431
     /**
2332
-	 * Alias of self::set_first_name().
2333
-	 *
2334
-	 * @since 1.0.19
2335
-	 * @param  string $value first name.
2336
-	 */
2337
-	public function set_customer_first_name( $value ) {
2338
-		$this->set_first_name( $value );
2432
+     * Alias of self::set_email().
2433
+     *
2434
+     * @since 1.0.19
2435
+     * @param  string $value email address.
2436
+     */
2437
+    public function set_email_address( $value ) {
2438
+        $this->set_email( $value );
2339 2439
     }
2340 2440
 
2341 2441
     /**
2342
-	 * Set the customer's last name.
2343
-	 *
2344
-	 * @since 1.0.19
2345
-	 * @param  string $value last name.
2346
-	 */
2347
-	public function set_last_name( $value ) {
2348
-		$this->set_prop( 'last_name', $value );
2442
+     * Alias of self::set_email().
2443
+     *
2444
+     * @since 1.0.19
2445
+     * @param  string $value email address.
2446
+     */
2447
+    public function set_customer_email( $value ) {
2448
+        $this->set_email( $value );
2349 2449
     }
2350 2450
 
2351 2451
     /**
2352
-	 * Alias of self::set_last_name().
2353
-	 *
2354
-	 * @since 1.0.19
2355
-	 * @param  string $value last name.
2356
-	 */
2357
-	public function set_user_last_name( $value ) {
2358
-		$this->set_last_name( $value );
2452
+     * Set the customer's country.
2453
+     *
2454
+     * @since 1.0.19
2455
+     * @param  string $value country.
2456
+     */
2457
+    public function set_country( $value ) {
2458
+        $this->set_prop( 'country', $value );
2459
+    }
2460
+
2461
+    /**
2462
+     * Alias of self::set_country().
2463
+     *
2464
+     * @since 1.0.19
2465
+     * @param  string $value country.
2466
+     */
2467
+    public function set_user_country( $value ) {
2468
+        $this->set_country( $value );
2469
+    }
2470
+
2471
+    /**
2472
+     * Alias of self::set_country().
2473
+     *
2474
+     * @since 1.0.19
2475
+     * @param  string $value country.
2476
+     */
2477
+    public function set_customer_country( $value ) {
2478
+        $this->set_country( $value );
2359 2479
     }
2360 2480
 
2361 2481
     /**
2362
-	 * Alias of self::set_last_name().
2363
-	 *
2364
-	 * @since 1.0.19
2365
-	 * @param  string $value last name.
2366
-	 */
2367
-	public function set_customer_last_name( $value ) {
2368
-		$this->set_last_name( $value );
2482
+     * Set the customer's state.
2483
+     *
2484
+     * @since 1.0.19
2485
+     * @param  string $value state.
2486
+     */
2487
+    public function set_state( $value ) {
2488
+        $this->set_prop( 'state', $value );
2369 2489
     }
2370 2490
 
2371 2491
     /**
2372
-	 * Set the customer's phone number.
2373
-	 *
2374
-	 * @since 1.0.19
2375
-	 * @param  string $value phone.
2376
-	 */
2377
-	public function set_phone( $value ) {
2378
-		$this->set_prop( 'phone', $value );
2492
+     * Alias of self::set_state().
2493
+     *
2494
+     * @since 1.0.19
2495
+     * @param  string $value state.
2496
+     */
2497
+    public function set_user_state( $value ) {
2498
+        $this->set_state( $value );
2499
+    }
2500
+
2501
+    /**
2502
+     * Alias of self::set_state().
2503
+     *
2504
+     * @since 1.0.19
2505
+     * @param  string $value state.
2506
+     */
2507
+    public function set_customer_state( $value ) {
2508
+        $this->set_state( $value );
2509
+    }
2510
+
2511
+    /**
2512
+     * Set the customer's city.
2513
+     *
2514
+     * @since 1.0.19
2515
+     * @param  string $value city.
2516
+     */
2517
+    public function set_city( $value ) {
2518
+        $this->set_prop( 'city', $value );
2519
+    }
2520
+
2521
+    /**
2522
+     * Alias of self::set_city().
2523
+     *
2524
+     * @since 1.0.19
2525
+     * @param  string $value city.
2526
+     */
2527
+    public function set_user_city( $value ) {
2528
+        $this->set_city( $value );
2379 2529
     }
2380 2530
 
2381 2531
     /**
2382
-	 * Alias of self::set_phone().
2383
-	 *
2384
-	 * @since 1.0.19
2385
-	 * @param  string $value phone.
2386
-	 */
2387
-	public function set_user_phone( $value ) {
2388
-		$this->set_phone( $value );
2532
+     * Alias of self::set_city().
2533
+     *
2534
+     * @since 1.0.19
2535
+     * @param  string $value city.
2536
+     */
2537
+    public function set_customer_city( $value ) {
2538
+        $this->set_city( $value );
2389 2539
     }
2390 2540
 
2391 2541
     /**
2392
-	 * Alias of self::set_phone().
2393
-	 *
2394
-	 * @since 1.0.19
2395
-	 * @param  string $value phone.
2396
-	 */
2397
-	public function set_customer_phone( $value ) {
2398
-		$this->set_phone( $value );
2542
+     * Set the customer's zip code.
2543
+     *
2544
+     * @since 1.0.19
2545
+     * @param  string $value zip.
2546
+     */
2547
+    public function set_zip( $value ) {
2548
+        $this->set_prop( 'zip', $value );
2399 2549
     }
2400 2550
 
2401 2551
     /**
2402
-	 * Alias of self::set_phone().
2403
-	 *
2404
-	 * @since 1.0.19
2405
-	 * @param  string $value phone.
2406
-	 */
2407
-	public function set_phone_number( $value ) {
2408
-		$this->set_phone( $value );
2552
+     * Alias of self::set_zip().
2553
+     *
2554
+     * @since 1.0.19
2555
+     * @param  string $value zip.
2556
+     */
2557
+    public function set_user_zip( $value ) {
2558
+        $this->set_zip( $value );
2409 2559
     }
2410 2560
 
2411 2561
     /**
2412
-	 * Set the customer's email address.
2413
-	 *
2414
-	 * @since 1.0.19
2415
-	 * @param  string $value email address.
2416
-	 */
2417
-	public function set_email( $value ) {
2418
-		$this->set_prop( 'email', $value );
2562
+     * Alias of self::set_zip().
2563
+     *
2564
+     * @since 1.0.19
2565
+     * @param  string $value zip.
2566
+     */
2567
+    public function set_customer_zip( $value ) {
2568
+        $this->set_zip( $value );
2419 2569
     }
2420 2570
 
2421 2571
     /**
2422
-	 * Alias of self::set_email().
2423
-	 *
2424
-	 * @since 1.0.19
2425
-	 * @param  string $value email address.
2426
-	 */
2427
-	public function set_user_email( $value ) {
2428
-		$this->set_email( $value );
2572
+     * Set the customer's company.
2573
+     *
2574
+     * @since 1.0.19
2575
+     * @param  string $value company.
2576
+     */
2577
+    public function set_company( $value ) {
2578
+        $this->set_prop( 'company', $value );
2429 2579
     }
2430 2580
 
2431 2581
     /**
2432
-	 * Alias of self::set_email().
2433
-	 *
2434
-	 * @since 1.0.19
2435
-	 * @param  string $value email address.
2436
-	 */
2437
-	public function set_email_address( $value ) {
2438
-		$this->set_email( $value );
2582
+     * Alias of self::set_company().
2583
+     *
2584
+     * @since 1.0.19
2585
+     * @param  string $value company.
2586
+     */
2587
+    public function set_user_company( $value ) {
2588
+        $this->set_company( $value );
2439 2589
     }
2440 2590
 
2441 2591
     /**
2442
-	 * Alias of self::set_email().
2443
-	 *
2444
-	 * @since 1.0.19
2445
-	 * @param  string $value email address.
2446
-	 */
2447
-	public function set_customer_email( $value ) {
2448
-		$this->set_email( $value );
2592
+     * Alias of self::set_company().
2593
+     *
2594
+     * @since 1.0.19
2595
+     * @param  string $value company.
2596
+     */
2597
+    public function set_customer_company( $value ) {
2598
+        $this->set_company( $value );
2449 2599
     }
2450 2600
 
2451 2601
     /**
2452
-	 * Set the customer's country.
2453
-	 *
2454
-	 * @since 1.0.19
2455
-	 * @param  string $value country.
2456
-	 */
2457
-	public function set_country( $value ) {
2458
-		$this->set_prop( 'country', $value );
2602
+     * Set the customer's var number.
2603
+     *
2604
+     * @since 1.0.19
2605
+     * @param  string $value var number.
2606
+     */
2607
+    public function set_vat_number( $value ) {
2608
+        $this->set_prop( 'vat_number', $value );
2459 2609
     }
2460 2610
 
2461 2611
     /**
2462
-	 * Alias of self::set_country().
2463
-	 *
2464
-	 * @since 1.0.19
2465
-	 * @param  string $value country.
2466
-	 */
2467
-	public function set_user_country( $value ) {
2468
-		$this->set_country( $value );
2612
+     * Alias of self::set_vat_number().
2613
+     *
2614
+     * @since 1.0.19
2615
+     * @param  string $value var number.
2616
+     */
2617
+    public function set_user_vat_number( $value ) {
2618
+        $this->set_vat_number( $value );
2469 2619
     }
2470 2620
 
2471 2621
     /**
2472
-	 * Alias of self::set_country().
2473
-	 *
2474
-	 * @since 1.0.19
2475
-	 * @param  string $value country.
2476
-	 */
2477
-	public function set_customer_country( $value ) {
2478
-		$this->set_country( $value );
2622
+     * Alias of self::set_vat_number().
2623
+     *
2624
+     * @since 1.0.19
2625
+     * @param  string $value var number.
2626
+     */
2627
+    public function set_customer_vat_number( $value ) {
2628
+        $this->set_vat_number( $value );
2479 2629
     }
2480 2630
 
2481 2631
     /**
2482
-	 * Set the customer's state.
2483
-	 *
2484
-	 * @since 1.0.19
2485
-	 * @param  string $value state.
2486
-	 */
2487
-	public function set_state( $value ) {
2488
-		$this->set_prop( 'state', $value );
2632
+     * Set the customer's vat rate.
2633
+     *
2634
+     * @since 1.0.19
2635
+     * @param  string $value var rate.
2636
+     */
2637
+    public function set_vat_rate( $value ) {
2638
+        $this->set_prop( 'vat_rate', $value );
2489 2639
     }
2490 2640
 
2491 2641
     /**
2492
-	 * Alias of self::set_state().
2493
-	 *
2494
-	 * @since 1.0.19
2495
-	 * @param  string $value state.
2496
-	 */
2497
-	public function set_user_state( $value ) {
2498
-		$this->set_state( $value );
2642
+     * Alias of self::set_vat_rate().
2643
+     *
2644
+     * @since 1.0.19
2645
+     * @param  string $value var number.
2646
+     */
2647
+    public function set_user_vat_rate( $value ) {
2648
+        $this->set_vat_rate( $value );
2499 2649
     }
2500 2650
 
2501 2651
     /**
2502
-	 * Alias of self::set_state().
2503
-	 *
2504
-	 * @since 1.0.19
2505
-	 * @param  string $value state.
2506
-	 */
2507
-	public function set_customer_state( $value ) {
2508
-		$this->set_state( $value );
2652
+     * Alias of self::set_vat_rate().
2653
+     *
2654
+     * @since 1.0.19
2655
+     * @param  string $value var number.
2656
+     */
2657
+    public function set_customer_vat_rate( $value ) {
2658
+        $this->set_vat_rate( $value );
2509 2659
     }
2510 2660
 
2511 2661
     /**
2512
-	 * Set the customer's city.
2513
-	 *
2514
-	 * @since 1.0.19
2515
-	 * @param  string $value city.
2516
-	 */
2517
-	public function set_city( $value ) {
2518
-		$this->set_prop( 'city', $value );
2662
+     * Set the customer's address.
2663
+     *
2664
+     * @since 1.0.19
2665
+     * @param  string $value address.
2666
+     */
2667
+    public function set_address( $value ) {
2668
+        $this->set_prop( 'address', $value );
2519 2669
     }
2520 2670
 
2521 2671
     /**
2522
-	 * Alias of self::set_city().
2523
-	 *
2524
-	 * @since 1.0.19
2525
-	 * @param  string $value city.
2526
-	 */
2527
-	public function set_user_city( $value ) {
2528
-		$this->set_city( $value );
2672
+     * Alias of self::set_address().
2673
+     *
2674
+     * @since 1.0.19
2675
+     * @param  string $value address.
2676
+     */
2677
+    public function set_user_address( $value ) {
2678
+        $this->set_address( $value );
2529 2679
     }
2530 2680
 
2531 2681
     /**
2532
-	 * Alias of self::set_city().
2533
-	 *
2534
-	 * @since 1.0.19
2535
-	 * @param  string $value city.
2536
-	 */
2537
-	public function set_customer_city( $value ) {
2538
-		$this->set_city( $value );
2682
+     * Alias of self::set_address().
2683
+     *
2684
+     * @since 1.0.19
2685
+     * @param  string $value address.
2686
+     */
2687
+    public function set_customer_address( $value ) {
2688
+        $this->set_address( $value );
2539 2689
     }
2540 2690
 
2541 2691
     /**
2542
-	 * Set the customer's zip code.
2543
-	 *
2544
-	 * @since 1.0.19
2545
-	 * @param  string $value zip.
2546
-	 */
2547
-	public function set_zip( $value ) {
2548
-		$this->set_prop( 'zip', $value );
2692
+     * Set whether the customer has viewed the invoice or not.
2693
+     *
2694
+     * @since 1.0.19
2695
+     * @param  int|bool $value confirmed.
2696
+     */
2697
+    public function set_is_viewed( $value ) {
2698
+        $this->set_prop( 'is_viewed', $value );
2549 2699
     }
2550 2700
 
2551 2701
     /**
2552
-	 * Alias of self::set_zip().
2553
-	 *
2554
-	 * @since 1.0.19
2555
-	 * @param  string $value zip.
2556
-	 */
2557
-	public function set_user_zip( $value ) {
2558
-		$this->set_zip( $value );
2702
+     * Set extra email recipients.
2703
+     *
2704
+     * @since 1.0.19
2705
+     * @param  string $value email recipients.
2706
+     */
2707
+    public function set_email_cc( $value ) {
2708
+        $this->set_prop( 'email_cc', $value );
2559 2709
     }
2560 2710
 
2561 2711
     /**
2562
-	 * Alias of self::set_zip().
2563
-	 *
2564
-	 * @since 1.0.19
2565
-	 * @param  string $value zip.
2566
-	 */
2567
-	public function set_customer_zip( $value ) {
2568
-		$this->set_zip( $value );
2712
+     * Set the invoice template.
2713
+     *
2714
+     * @since 1.0.19
2715
+     * @param  string $value template.
2716
+     */
2717
+    public function set_template( $value ) {
2718
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2719
+            $this->set_prop( 'template', $value );
2720
+        }
2569 2721
     }
2570 2722
 
2571 2723
     /**
2572
-	 * Set the customer's company.
2573
-	 *
2574
-	 * @since 1.0.19
2575
-	 * @param  string $value company.
2576
-	 */
2577
-	public function set_company( $value ) {
2578
-		$this->set_prop( 'company', $value );
2724
+     * Set the invoice source.
2725
+     *
2726
+     * @since 1.0.19
2727
+     * @param  string $value source.
2728
+     * @deprecated
2729
+     */
2730
+    public function created_via( $value ) {
2731
+        $this->set_created_via( sanitize_text_field( $value ) );
2579 2732
     }
2580 2733
 
2581 2734
     /**
2582
-	 * Alias of self::set_company().
2583
-	 *
2584
-	 * @since 1.0.19
2585
-	 * @param  string $value company.
2586
-	 */
2587
-	public function set_user_company( $value ) {
2588
-		$this->set_company( $value );
2735
+     * Set the invoice source.
2736
+     *
2737
+     * @since 1.0.19
2738
+     * @param  string $value source.
2739
+     */
2740
+    public function set_created_via( $value ) {
2741
+        $this->set_prop( 'created_via', sanitize_text_field( $value ) );
2589 2742
     }
2590 2743
 
2591 2744
     /**
2592
-	 * Alias of self::set_company().
2593
-	 *
2594
-	 * @since 1.0.19
2595
-	 * @param  string $value company.
2596
-	 */
2597
-	public function set_customer_company( $value ) {
2598
-		$this->set_company( $value );
2745
+     * Set the customer's address confirmed status.
2746
+     *
2747
+     * @since 1.0.19
2748
+     * @param  int|bool $value confirmed.
2749
+     */
2750
+    public function set_address_confirmed( $value ) {
2751
+        $this->set_prop( 'address_confirmed', $value );
2599 2752
     }
2600 2753
 
2601 2754
     /**
2602
-	 * Set the customer's var number.
2603
-	 *
2604
-	 * @since 1.0.19
2605
-	 * @param  string $value var number.
2606
-	 */
2607
-	public function set_vat_number( $value ) {
2608
-		$this->set_prop( 'vat_number', $value );
2755
+     * Alias of self::set_address_confirmed().
2756
+     *
2757
+     * @since 1.0.19
2758
+     * @param  int|bool $value confirmed.
2759
+     */
2760
+    public function set_user_address_confirmed( $value ) {
2761
+        $this->set_address_confirmed( $value );
2609 2762
     }
2610 2763
 
2611 2764
     /**
2612
-	 * Alias of self::set_vat_number().
2613
-	 *
2614
-	 * @since 1.0.19
2615
-	 * @param  string $value var number.
2616
-	 */
2617
-	public function set_user_vat_number( $value ) {
2618
-		$this->set_vat_number( $value );
2765
+     * Alias of self::set_address_confirmed().
2766
+     *
2767
+     * @since 1.0.19
2768
+     * @param  int|bool $value confirmed.
2769
+     */
2770
+    public function set_customer_address_confirmed( $value ) {
2771
+        $this->set_address_confirmed( $value );
2619 2772
     }
2620 2773
 
2621 2774
     /**
2622
-	 * Alias of self::set_vat_number().
2623
-	 *
2624
-	 * @since 1.0.19
2625
-	 * @param  string $value var number.
2626
-	 */
2627
-	public function set_customer_vat_number( $value ) {
2628
-		$this->set_vat_number( $value );
2775
+     * Set the invoice sub total.
2776
+     *
2777
+     * @since 1.0.19
2778
+     * @param  float $value sub total.
2779
+     */
2780
+    public function set_subtotal( $value ) {
2781
+        $this->set_prop( 'subtotal', max( 0, $value ) );
2629 2782
     }
2630 2783
 
2631 2784
     /**
2632
-	 * Set the customer's vat rate.
2633
-	 *
2634
-	 * @since 1.0.19
2635
-	 * @param  string $value var rate.
2636
-	 */
2637
-	public function set_vat_rate( $value ) {
2638
-		$this->set_prop( 'vat_rate', $value );
2785
+     * Set the invoice total.
2786
+     *
2787
+     * @since 1.0.19
2788
+     * @param  float $value sub total.
2789
+     */
2790
+    public function set_total( $value ) {
2791
+        $this->set_prop( 'total', max( 0, $value ) );
2639 2792
     }
2640 2793
 
2641 2794
     /**
2642
-	 * Alias of self::set_vat_rate().
2643
-	 *
2644
-	 * @since 1.0.19
2645
-	 * @param  string $value var number.
2646
-	 */
2647
-	public function set_user_vat_rate( $value ) {
2648
-		$this->set_vat_rate( $value );
2649
-    }
2650
-
2651
-    /**
2652
-	 * Alias of self::set_vat_rate().
2653
-	 *
2654
-	 * @since 1.0.19
2655
-	 * @param  string $value var number.
2656
-	 */
2657
-	public function set_customer_vat_rate( $value ) {
2658
-		$this->set_vat_rate( $value );
2659
-    }
2660
-
2661
-    /**
2662
-	 * Set the customer's address.
2663
-	 *
2664
-	 * @since 1.0.19
2665
-	 * @param  string $value address.
2666
-	 */
2667
-	public function set_address( $value ) {
2668
-		$this->set_prop( 'address', $value );
2669
-    }
2670
-
2671
-    /**
2672
-	 * Alias of self::set_address().
2673
-	 *
2674
-	 * @since 1.0.19
2675
-	 * @param  string $value address.
2676
-	 */
2677
-	public function set_user_address( $value ) {
2678
-		$this->set_address( $value );
2679
-    }
2680
-
2681
-    /**
2682
-	 * Alias of self::set_address().
2683
-	 *
2684
-	 * @since 1.0.19
2685
-	 * @param  string $value address.
2686
-	 */
2687
-	public function set_customer_address( $value ) {
2688
-		$this->set_address( $value );
2689
-    }
2690
-
2691
-    /**
2692
-	 * Set whether the customer has viewed the invoice or not.
2693
-	 *
2694
-	 * @since 1.0.19
2695
-	 * @param  int|bool $value confirmed.
2696
-	 */
2697
-	public function set_is_viewed( $value ) {
2698
-		$this->set_prop( 'is_viewed', $value );
2699
-	}
2700
-
2701
-	/**
2702
-	 * Set extra email recipients.
2703
-	 *
2704
-	 * @since 1.0.19
2705
-	 * @param  string $value email recipients.
2706
-	 */
2707
-	public function set_email_cc( $value ) {
2708
-		$this->set_prop( 'email_cc', $value );
2709
-	}
2710
-
2711
-	/**
2712
-	 * Set the invoice template.
2713
-	 *
2714
-	 * @since 1.0.19
2715
-	 * @param  string $value template.
2716
-	 */
2717
-	public function set_template( $value ) {
2718
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2719
-			$this->set_prop( 'template', $value );
2720
-		}
2721
-	}
2722
-
2723
-	/**
2724
-	 * Set the invoice source.
2725
-	 *
2726
-	 * @since 1.0.19
2727
-	 * @param  string $value source.
2728
-	 * @deprecated
2729
-	 */
2730
-	public function created_via( $value ) {
2731
-		$this->set_created_via( sanitize_text_field( $value ) );
2732
-	}
2733
-
2734
-	/**
2735
-	 * Set the invoice source.
2736
-	 *
2737
-	 * @since 1.0.19
2738
-	 * @param  string $value source.
2739
-	 */
2740
-	public function set_created_via( $value ) {
2741
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2742
-	}
2743
-
2744
-	/**
2745
-	 * Set the customer's address confirmed status.
2746
-	 *
2747
-	 * @since 1.0.19
2748
-	 * @param  int|bool $value confirmed.
2749
-	 */
2750
-	public function set_address_confirmed( $value ) {
2751
-		$this->set_prop( 'address_confirmed', $value );
2752
-    }
2753
-
2754
-    /**
2755
-	 * Alias of self::set_address_confirmed().
2756
-	 *
2757
-	 * @since 1.0.19
2758
-	 * @param  int|bool $value confirmed.
2759
-	 */
2760
-	public function set_user_address_confirmed( $value ) {
2761
-		$this->set_address_confirmed( $value );
2762
-    }
2763
-
2764
-    /**
2765
-	 * Alias of self::set_address_confirmed().
2766
-	 *
2767
-	 * @since 1.0.19
2768
-	 * @param  int|bool $value confirmed.
2769
-	 */
2770
-	public function set_customer_address_confirmed( $value ) {
2771
-		$this->set_address_confirmed( $value );
2772
-    }
2773
-
2774
-    /**
2775
-	 * Set the invoice sub total.
2776
-	 *
2777
-	 * @since 1.0.19
2778
-	 * @param  float $value sub total.
2779
-	 */
2780
-	public function set_subtotal( $value ) {
2781
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2782
-	}
2783
-
2784
-	/**
2785
-	 * Set the invoice total.
2786
-	 *
2787
-	 * @since 1.0.19
2788
-	 * @param  float $value sub total.
2789
-	 */
2790
-	public function set_total( $value ) {
2791
-		$this->set_prop( 'total', max( 0, $value ) );
2792
-    }
2793
-
2794
-    /**
2795
-	 * Set the invoice discount amount.
2796
-	 *
2797
-	 * @since 1.0.19
2798
-	 * @param  float $value discount total.
2799
-	 */
2800
-	public function set_total_discount( $value ) {
2801
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2795
+     * Set the invoice discount amount.
2796
+     *
2797
+     * @since 1.0.19
2798
+     * @param  float $value discount total.
2799
+     */
2800
+    public function set_total_discount( $value ) {
2801
+        $this->set_prop( 'total_discount', max( 0, $value ) );
2802 2802
     }
2803 2803
 
2804 2804
     /**
2805
-	 * Alias of self::set_total_discount().
2806
-	 *
2807
-	 * @since 1.0.19
2808
-	 * @param  float $value discount total.
2809
-	 */
2810
-	public function set_discount( $value ) {
2811
-		$this->set_total_discount( $value );
2805
+     * Alias of self::set_total_discount().
2806
+     *
2807
+     * @since 1.0.19
2808
+     * @param  float $value discount total.
2809
+     */
2810
+    public function set_discount( $value ) {
2811
+        $this->set_total_discount( $value );
2812 2812
     }
2813 2813
 
2814 2814
     /**
2815
-	 * Set the invoice tax amount.
2816
-	 *
2817
-	 * @since 1.0.19
2818
-	 * @param  float $value tax total.
2819
-	 */
2820
-	public function set_total_tax( $value ) {
2821
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2815
+     * Set the invoice tax amount.
2816
+     *
2817
+     * @since 1.0.19
2818
+     * @param  float $value tax total.
2819
+     */
2820
+    public function set_total_tax( $value ) {
2821
+        $this->set_prop( 'total_tax', max( 0, $value ) );
2822 2822
     }
2823 2823
 
2824 2824
     /**
2825
-	 * Alias of self::set_total_tax().
2826
-	 *
2827
-	 * @since 1.0.19
2828
-	 * @param  float $value tax total.
2829
-	 */
2830
-	public function set_tax_total( $value ) {
2831
-		$this->set_total_tax( $value );
2825
+     * Alias of self::set_total_tax().
2826
+     *
2827
+     * @since 1.0.19
2828
+     * @param  float $value tax total.
2829
+     */
2830
+    public function set_tax_total( $value ) {
2831
+        $this->set_total_tax( $value );
2832 2832
     }
2833 2833
 
2834 2834
     /**
2835
-	 * Set the invoice fees amount.
2836
-	 *
2837
-	 * @since 1.0.19
2838
-	 * @param  float $value fees total.
2839
-	 */
2840
-	public function set_total_fees( $value ) {
2841
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2835
+     * Set the invoice fees amount.
2836
+     *
2837
+     * @since 1.0.19
2838
+     * @param  float $value fees total.
2839
+     */
2840
+    public function set_total_fees( $value ) {
2841
+        $this->set_prop( 'total_fees', max( 0, $value ) );
2842 2842
     }
2843 2843
 
2844 2844
     /**
2845
-	 * Alias of self::set_total_fees().
2846
-	 *
2847
-	 * @since 1.0.19
2848
-	 * @param  float $value fees total.
2849
-	 */
2850
-	public function set_fees_total( $value ) {
2851
-		$this->set_total_fees( $value );
2845
+     * Alias of self::set_total_fees().
2846
+     *
2847
+     * @since 1.0.19
2848
+     * @param  float $value fees total.
2849
+     */
2850
+    public function set_fees_total( $value ) {
2851
+        $this->set_total_fees( $value );
2852 2852
     }
2853 2853
 
2854 2854
     /**
2855
-	 * Set the invoice fees.
2856
-	 *
2857
-	 * @since 1.0.19
2858
-	 * @param  array $value fees.
2859
-	 */
2860
-	public function set_fees( $value ) {
2855
+     * Set the invoice fees.
2856
+     *
2857
+     * @since 1.0.19
2858
+     * @param  array $value fees.
2859
+     */
2860
+    public function set_fees( $value ) {
2861 2861
 
2862
-		if ( ! is_array( $value ) ) {
2863
-			$value = array();
2864
-		}
2862
+        if ( ! is_array( $value ) ) {
2863
+            $value = array();
2864
+        }
2865 2865
 
2866
-		$this->set_prop( 'fees', $value );
2866
+        $this->set_prop( 'fees', $value );
2867 2867
 
2868 2868
     }
2869 2869
 
2870 2870
     /**
2871
-	 * Set the invoice taxes.
2872
-	 *
2873
-	 * @since 1.0.19
2874
-	 * @param  array $value taxes.
2875
-	 */
2876
-	public function set_taxes( $value ) {
2871
+     * Set the invoice taxes.
2872
+     *
2873
+     * @since 1.0.19
2874
+     * @param  array $value taxes.
2875
+     */
2876
+    public function set_taxes( $value ) {
2877 2877
 
2878
-		if ( ! is_array( $value ) ) {
2879
-			$value = array();
2880
-		}
2878
+        if ( ! is_array( $value ) ) {
2879
+            $value = array();
2880
+        }
2881 2881
 
2882
-		$this->set_prop( 'taxes', $value );
2882
+        $this->set_prop( 'taxes', $value );
2883 2883
 
2884 2884
     }
2885 2885
 
2886 2886
     /**
2887
-	 * Set the invoice discounts.
2888
-	 *
2889
-	 * @since 1.0.19
2890
-	 * @param  array $value discounts.
2891
-	 */
2892
-	public function set_discounts( $value ) {
2887
+     * Set the invoice discounts.
2888
+     *
2889
+     * @since 1.0.19
2890
+     * @param  array $value discounts.
2891
+     */
2892
+    public function set_discounts( $value ) {
2893 2893
 
2894
-		if ( ! is_array( $value ) ) {
2895
-			$value = array();
2896
-		}
2894
+        if ( ! is_array( $value ) ) {
2895
+            $value = array();
2896
+        }
2897 2897
 
2898
-		$this->set_prop( 'discounts', $value );
2898
+        $this->set_prop( 'discounts', $value );
2899 2899
     }
2900 2900
 
2901 2901
     /**
2902
-	 * Set the invoice items.
2903
-	 *
2904
-	 * @since 1.0.19
2905
-	 * @param  GetPaid_Form_Item[] $value items.
2906
-	 */
2907
-	public function set_items( $value ) {
2902
+     * Set the invoice items.
2903
+     *
2904
+     * @since 1.0.19
2905
+     * @param  GetPaid_Form_Item[] $value items.
2906
+     */
2907
+    public function set_items( $value ) {
2908 2908
 
2909 2909
         // Remove existing items.
2910 2910
         $this->set_prop( 'items', array() );
2911
-		$this->recurring_item = null;
2911
+        $this->recurring_item = null;
2912 2912
 
2913 2913
         // Ensure that we have an array.
2914 2914
         if ( ! is_array( $value ) ) {
@@ -2922,95 +2922,95 @@  discard block
 block discarded – undo
2922 2922
     }
2923 2923
 
2924 2924
     /**
2925
-	 * Set the payment form.
2926
-	 *
2927
-	 * @since 1.0.19
2928
-	 * @param  int $value payment form.
2929
-	 */
2930
-	public function set_payment_form( $value ) {
2931
-		$this->set_prop( 'payment_form', $value );
2925
+     * Set the payment form.
2926
+     *
2927
+     * @since 1.0.19
2928
+     * @param  int $value payment form.
2929
+     */
2930
+    public function set_payment_form( $value ) {
2931
+        $this->set_prop( 'payment_form', $value );
2932 2932
     }
2933 2933
 
2934 2934
     /**
2935
-	 * Set the submission id.
2936
-	 *
2937
-	 * @since 1.0.19
2938
-	 * @param  string $value submission id.
2939
-	 */
2940
-	public function set_submission_id( $value ) {
2941
-		$this->set_prop( 'submission_id', $value );
2935
+     * Set the submission id.
2936
+     *
2937
+     * @since 1.0.19
2938
+     * @param  string $value submission id.
2939
+     */
2940
+    public function set_submission_id( $value ) {
2941
+        $this->set_prop( 'submission_id', $value );
2942 2942
     }
2943 2943
 
2944 2944
     /**
2945
-	 * Set the discount code.
2946
-	 *
2947
-	 * @since 1.0.19
2948
-	 * @param  string $value discount code.
2949
-	 */
2950
-	public function set_discount_code( $value ) {
2951
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
2945
+     * Set the discount code.
2946
+     *
2947
+     * @since 1.0.19
2948
+     * @param  string $value discount code.
2949
+     */
2950
+    public function set_discount_code( $value ) {
2951
+        $this->set_prop( 'discount_code', sanitize_text_field( $value ) );
2952 2952
     }
2953 2953
 
2954 2954
     /**
2955
-	 * Set the gateway.
2956
-	 *
2957
-	 * @since 1.0.19
2958
-	 * @param  string $value gateway.
2959
-	 */
2960
-	public function set_gateway( $value ) {
2961
-		$this->set_prop( 'gateway', $value );
2955
+     * Set the gateway.
2956
+     *
2957
+     * @since 1.0.19
2958
+     * @param  string $value gateway.
2959
+     */
2960
+    public function set_gateway( $value ) {
2961
+        $this->set_prop( 'gateway', $value );
2962 2962
     }
2963 2963
 
2964 2964
     /**
2965
-	 * Set the transaction id.
2966
-	 *
2967
-	 * @since 1.0.19
2968
-	 * @param  string $value transaction id.
2969
-	 */
2970
-	public function set_transaction_id( $value ) {
2971
-		if ( ! empty( $value ) ) {
2972
-			$this->set_prop( 'transaction_id', $value );
2973
-		}
2965
+     * Set the transaction id.
2966
+     *
2967
+     * @since 1.0.19
2968
+     * @param  string $value transaction id.
2969
+     */
2970
+    public function set_transaction_id( $value ) {
2971
+        if ( ! empty( $value ) ) {
2972
+            $this->set_prop( 'transaction_id', $value );
2973
+        }
2974 2974
     }
2975 2975
 
2976 2976
     /**
2977
-	 * Set the currency id.
2978
-	 *
2979
-	 * @since 1.0.19
2980
-	 * @param  string $value currency id.
2981
-	 */
2982
-	public function set_currency( $value ) {
2983
-		$this->set_prop( 'currency', $value );
2977
+     * Set the currency id.
2978
+     *
2979
+     * @since 1.0.19
2980
+     * @param  string $value currency id.
2981
+     */
2982
+    public function set_currency( $value ) {
2983
+        $this->set_prop( 'currency', $value );
2984 2984
     }
2985 2985
 
2986
-	/**
2987
-	 * Set whether to disable taxes.
2988
-	 *
2989
-	 * @since 1.0.19
2990
-	 * @param  bool $value value.
2991
-	 */
2992
-	public function set_disable_taxes( $value ) {
2993
-		$this->set_prop( 'disable_taxes', (bool) $value );
2994
-	}
2986
+    /**
2987
+     * Set whether to disable taxes.
2988
+     *
2989
+     * @since 1.0.19
2990
+     * @param  bool $value value.
2991
+     */
2992
+    public function set_disable_taxes( $value ) {
2993
+        $this->set_prop( 'disable_taxes', (bool) $value );
2994
+    }
2995 2995
 
2996 2996
     /**
2997
-	 * Set the subscription id.
2998
-	 *
2999
-	 * @since 1.0.19
3000
-	 * @param  string $value subscription id.
3001
-	 */
3002
-	public function set_subscription_id( $value ) {
3003
-		$this->set_prop( 'subscription_id', $value );
3004
-	}
2997
+     * Set the subscription id.
2998
+     *
2999
+     * @since 1.0.19
3000
+     * @param  string $value subscription id.
3001
+     */
3002
+    public function set_subscription_id( $value ) {
3003
+        $this->set_prop( 'subscription_id', $value );
3004
+    }
3005 3005
 	
3006
-	/**
3007
-	 * Set the remote subscription id.
3008
-	 *
3009
-	 * @since 1.0.19
3010
-	 * @param  string $value subscription id.
3011
-	 */
3012
-	public function set_remote_subscription_id( $value ) {
3013
-		$this->set_prop( 'remote_subscription_id', $value );
3006
+    /**
3007
+     * Set the remote subscription id.
3008
+     *
3009
+     * @since 1.0.19
3010
+     * @param  string $value subscription id.
3011
+     */
3012
+    public function set_remote_subscription_id( $value ) {
3013
+        $this->set_prop( 'remote_subscription_id', $value );
3014 3014
     }
3015 3015
 
3016 3016
     /*
@@ -3049,24 +3049,24 @@  discard block
 block discarded – undo
3049 3049
      */
3050 3050
     public function is_taxable() {
3051 3051
         return ! $this->get_disable_taxes();
3052
-	}
3052
+    }
3053 3053
 
3054
-	/**
3055
-	 * @deprecated
3056
-	 */
3057
-	public function has_vat() {
3054
+    /**
3055
+     * @deprecated
3056
+     */
3057
+    public function has_vat() {
3058 3058
         return $this->is_taxable();
3059
-	}
3059
+    }
3060 3060
 
3061
-	/**
3062
-	 * Checks to see if the invoice requires payment.
3063
-	 */
3064
-	public function is_free() {
3061
+    /**
3062
+     * Checks to see if the invoice requires payment.
3063
+     */
3064
+    public function is_free() {
3065 3065
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3066 3066
 
3067
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3068
-			$is_free = false;
3069
-		}
3067
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3068
+            $is_free = false;
3069
+        }
3070 3070
 
3071 3071
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3072 3072
     }
@@ -3077,46 +3077,46 @@  discard block
 block discarded – undo
3077 3077
     public function is_paid() {
3078 3078
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3079 3079
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3080
-	}
3080
+    }
3081 3081
 
3082
-	/**
3082
+    /**
3083 3083
      * Checks if the invoice needs payment.
3084 3084
      */
3085
-	public function needs_payment() {
3086
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3085
+    public function needs_payment() {
3086
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3087 3087
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3088 3088
     }
3089 3089
   
3090
-	/**
3090
+    /**
3091 3091
      * Checks if the invoice is refunded.
3092 3092
      */
3093
-	public function is_refunded() {
3093
+    public function is_refunded() {
3094 3094
         $is_refunded = $this->has_status( 'wpi-refunded' );
3095 3095
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3096
-	}
3096
+    }
3097 3097
 
3098
-	/**
3098
+    /**
3099 3099
      * Checks if the invoice is held.
3100 3100
      */
3101
-	public function is_held() {
3101
+    public function is_held() {
3102 3102
         $is_held = $this->has_status( 'wpi-onhold' );
3103 3103
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3104
-	}
3104
+    }
3105 3105
 
3106
-	/**
3106
+    /**
3107 3107
      * Checks if the invoice is due.
3108 3108
      */
3109
-	public function is_due() {
3110
-		$due_date = $this->get_due_date();
3111
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3112
-	}
3109
+    public function is_due() {
3110
+        $due_date = $this->get_due_date();
3111
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3112
+    }
3113 3113
 
3114
-	/**
3114
+    /**
3115 3115
      * Checks if the invoice is draft.
3116 3116
      */
3117
-	public function is_draft() {
3117
+    public function is_draft() {
3118 3118
         return $this->has_status( 'draft, auto-draft' );
3119
-	}
3119
+    }
3120 3120
 
3121 3121
     /**
3122 3122
      * Checks if the invoice has a given status.
@@ -3124,9 +3124,9 @@  discard block
 block discarded – undo
3124 3124
     public function has_status( $status ) {
3125 3125
         $status = wpinv_parse_list( $status );
3126 3126
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3127
-	}
3127
+    }
3128 3128
 
3129
-	/**
3129
+    /**
3130 3130
      * Checks if the invoice is of a given type.
3131 3131
      */
3132 3132
     public function is_type( $type ) {
@@ -3149,25 +3149,25 @@  discard block
 block discarded – undo
3149 3149
      */
3150 3150
     public function has_free_trial() {
3151 3151
         return $this->is_recurring() && 0 == $this->get_initial_total();
3152
-	}
3152
+    }
3153 3153
 
3154
-	/**
3154
+    /**
3155 3155
      * @deprecated
3156 3156
      */
3157 3157
     public function is_free_trial() {
3158 3158
         $this->has_free_trial();
3159 3159
     }
3160 3160
 
3161
-	/**
3161
+    /**
3162 3162
      * Check if the initial payment if 0.
3163 3163
      *
3164 3164
      */
3165
-	public function is_initial_free() {
3165
+    public function is_initial_free() {
3166 3166
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3167 3167
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3168 3168
     }
3169 3169
 	
3170
-	/**
3170
+    /**
3171 3171
      * Check if the recurring item has a free trial.
3172 3172
      *
3173 3173
      */
@@ -3180,21 +3180,21 @@  discard block
 block discarded – undo
3180 3180
 
3181 3181
         $item = $this->get_recurring( true );
3182 3182
         return $item->has_free_trial();
3183
-	}
3183
+    }
3184 3184
 
3185
-	/**
3185
+    /**
3186 3186
      * Check if the free trial is a result of a discount.
3187 3187
      */
3188 3188
     public function is_free_trial_from_discount() {
3189
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3190
-	}
3189
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3190
+    }
3191 3191
 	
3192
-	/**
3192
+    /**
3193 3193
      * @deprecated
3194 3194
      */
3195 3195
     public function discount_first_payment_only() {
3196 3196
 
3197
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3197
+        $discount = wpinv_get_discount_obj( $this->get_discount_code() );
3198 3198
         if ( ! $discount->exists() || ! $this->is_recurring() ) {
3199 3199
             return true;
3200 3200
         }
@@ -3219,143 +3219,143 @@  discard block
 block discarded – undo
3219 3219
      */
3220 3220
     public function add_item( $item ) {
3221 3221
 
3222
-		if ( is_array( $item ) ) {
3223
-			$item = $this->process_array_item( $item );
3224
-		}
3222
+        if ( is_array( $item ) ) {
3223
+            $item = $this->process_array_item( $item );
3224
+        }
3225 3225
 
3226
-		if ( is_numeric( $item ) ) {
3227
-			$item = new GetPaid_Form_Item( $item );
3228
-		}
3226
+        if ( is_numeric( $item ) ) {
3227
+            $item = new GetPaid_Form_Item( $item );
3228
+        }
3229 3229
 
3230 3230
         // Make sure that it is available for purchase.
3231
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3232
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3231
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3232
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3233 3233
         }
3234 3234
 
3235 3235
         // Do we have a recurring item?
3236
-		if ( $item->is_recurring() ) {
3237
-			$this->recurring_item = $item->get_id();
3236
+        if ( $item->is_recurring() ) {
3237
+            $this->recurring_item = $item->get_id();
3238 3238
         }
3239 3239
 
3240 3240
         // Invoice id.
3241 3241
         $item->invoice_id = (int) $this->get_id();
3242 3242
 
3243
-		// Remove duplicates.
3244
-		$this->remove_item( $item->get_id() );
3243
+        // Remove duplicates.
3244
+        $this->remove_item( $item->get_id() );
3245 3245
 
3246
-		// Retrieve all items.
3246
+        // Retrieve all items.
3247 3247
         $items   = $this->get_items();
3248 3248
 
3249
-		// Add new item.
3249
+        // Add new item.
3250 3250
         $items[] = $item;
3251 3251
 
3252 3252
         $this->set_prop( 'items', $items );
3253 3253
 
3254
-		return true;
3255
-	}
3254
+        return true;
3255
+    }
3256 3256
 
3257
-	/**
3258
-	 * Converts an array to an item.
3259
-	 *
3260
-	 * @since 1.0.19
3261
-	 * @return GetPaid_Form_Item
3262
-	 */
3263
-	protected function process_array_item( $array ) {
3257
+    /**
3258
+     * Converts an array to an item.
3259
+     *
3260
+     * @since 1.0.19
3261
+     * @return GetPaid_Form_Item
3262
+     */
3263
+    protected function process_array_item( $array ) {
3264 3264
 
3265
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3266
-		$item    = new GetPaid_Form_Item( $item_id );
3265
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3266
+        $item    = new GetPaid_Form_Item( $item_id );
3267 3267
 
3268
-		// Set item data.
3269
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3270
-			if ( isset( $array[ "item_$key" ] ) ) {
3271
-				$method = "set_$key";
3272
-				$item->$method( $array[ "item_$key" ] );
3273
-			}
3274
-		}
3268
+        // Set item data.
3269
+        foreach ( array( 'name', 'price', 'description' ) as $key ) {
3270
+            if ( isset( $array[ "item_$key" ] ) ) {
3271
+                $method = "set_$key";
3272
+                $item->$method( $array[ "item_$key" ] );
3273
+            }
3274
+        }
3275 3275
 
3276
-		if ( isset( $array['quantity'] ) ) {
3277
-			$item->set_quantity( $array['quantity'] );
3278
-		}
3276
+        if ( isset( $array['quantity'] ) ) {
3277
+            $item->set_quantity( $array['quantity'] );
3278
+        }
3279 3279
 
3280
-		// Set item meta.
3281
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3282
-			$item->set_item_meta( $array['meta'] );
3283
-		}
3280
+        // Set item meta.
3281
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3282
+            $item->set_item_meta( $array['meta'] );
3283
+        }
3284 3284
 
3285
-		return $item;
3285
+        return $item;
3286 3286
 
3287
-	}
3287
+    }
3288 3288
 
3289 3289
     /**
3290
-	 * Retrieves a specific item.
3291
-	 *
3292
-	 * @since 1.0.19
3293
-	 * @return GetPaid_Form_Item|null
3294
-	 */
3295
-	public function get_item( $item_id ) {
3290
+     * Retrieves a specific item.
3291
+     *
3292
+     * @since 1.0.19
3293
+     * @return GetPaid_Form_Item|null
3294
+     */
3295
+    public function get_item( $item_id ) {
3296 3296
 
3297
-		foreach ( $this->get_items() as $item ) {
3298
-			if ( (int) $item_id == $item->get_id() ) {
3299
-				return $item;
3300
-			}
3301
-		}
3297
+        foreach ( $this->get_items() as $item ) {
3298
+            if ( (int) $item_id == $item->get_id() ) {
3299
+                return $item;
3300
+            }
3301
+        }
3302 3302
 
3303
-		return null;
3303
+        return null;
3304 3304
     }
3305 3305
 
3306 3306
     /**
3307
-	 * Removes a specific item.
3308
-	 *
3309
-	 * @since 1.0.19
3310
-	 */
3311
-	public function remove_item( $item_id ) {
3312
-		$items   = $this->get_items();
3313
-		$item_id = (int) $item_id;
3307
+     * Removes a specific item.
3308
+     *
3309
+     * @since 1.0.19
3310
+     */
3311
+    public function remove_item( $item_id ) {
3312
+        $items   = $this->get_items();
3313
+        $item_id = (int) $item_id;
3314 3314
 
3315
-		foreach ( $items as $index => $item ) {
3316
-			if ( (int) $item_id == $item->get_id() ) {
3317
-				unset( $items[ $index ] );
3318
-				$this->set_prop( 'items', $items );
3315
+        foreach ( $items as $index => $item ) {
3316
+            if ( (int) $item_id == $item->get_id() ) {
3317
+                unset( $items[ $index ] );
3318
+                $this->set_prop( 'items', $items );
3319 3319
 
3320
-				if ( $item_id == $this->recurring_item ) {
3321
-					$this->recurring_item = null;
3322
-				}
3320
+                if ( $item_id == $this->recurring_item ) {
3321
+                    $this->recurring_item = null;
3322
+                }
3323 3323
 
3324
-			}
3325
-		}
3324
+            }
3325
+        }
3326 3326
 
3327 3327
     }
3328 3328
 
3329 3329
     /**
3330
-	 * Adds a fee to the invoice.
3331
-	 *
3332
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3333
-	 * @since 1.0.19
3334
-	 */
3330
+     * Adds a fee to the invoice.
3331
+     *
3332
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3333
+     * @since 1.0.19
3334
+     */
3335 3335
     public function add_fee( $fee ) {
3336 3336
 
3337
-		$fees                 = $this->get_fees();
3338
-		$fees[ $fee['name'] ] = $fee;
3339
-		$this->set_prop( 'fees', $fees );
3337
+        $fees                 = $this->get_fees();
3338
+        $fees[ $fee['name'] ] = $fee;
3339
+        $this->set_prop( 'fees', $fees );
3340 3340
 
3341 3341
     }
3342 3342
 
3343 3343
     /**
3344
-	 * Retrieves a specific fee.
3345
-	 *
3346
-	 * @since 1.0.19
3347
-	 */
3348
-	public function get_fee( $fee ) {
3344
+     * Retrieves a specific fee.
3345
+     *
3346
+     * @since 1.0.19
3347
+     */
3348
+    public function get_fee( $fee ) {
3349 3349
         $fees = $this->get_fees();
3350
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3350
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3351 3351
     }
3352 3352
 
3353 3353
     /**
3354
-	 * Removes a specific fee.
3355
-	 *
3356
-	 * @since 1.0.19
3357
-	 */
3358
-	public function remove_fee( $fee ) {
3354
+     * Removes a specific fee.
3355
+     *
3356
+     * @since 1.0.19
3357
+     */
3358
+    public function remove_fee( $fee ) {
3359 3359
         $fees = $this->get_fees();
3360 3360
         if ( isset( $fees[ $fee ] ) ) {
3361 3361
             unset( $fees[ $fee ] );
@@ -3363,55 +3363,55 @@  discard block
 block discarded – undo
3363 3363
         }
3364 3364
     }
3365 3365
 
3366
-	/**
3367
-	 * Adds a discount to the invoice.
3368
-	 *
3369
-	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3370
-	 * @since 1.0.19
3371
-	 */
3372
-	public function add_discount( $discount ) {
3366
+    /**
3367
+     * Adds a discount to the invoice.
3368
+     *
3369
+     * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3370
+     * @since 1.0.19
3371
+     */
3372
+    public function add_discount( $discount ) {
3373 3373
 
3374
-		$discounts = $this->get_discounts();
3375
-		$discounts[ $discount['name'] ] = $discount;
3376
-		$this->set_prop( 'discounts', $discounts );
3374
+        $discounts = $this->get_discounts();
3375
+        $discounts[ $discount['name'] ] = $discount;
3376
+        $this->set_prop( 'discounts', $discounts );
3377 3377
 
3378
-	}
3378
+    }
3379 3379
 
3380 3380
     /**
3381
-	 * Retrieves a specific discount.
3382
-	 *
3383
-	 * @since 1.0.19
3384
-	 * @return float
3385
-	 */
3386
-	public function get_discount( $discount = false ) {
3381
+     * Retrieves a specific discount.
3382
+     *
3383
+     * @since 1.0.19
3384
+     * @return float
3385
+     */
3386
+    public function get_discount( $discount = false ) {
3387 3387
 
3388
-		// Backwards compatibilty.
3389
-		if ( empty( $discount ) ) {
3390
-			return $this->get_total_discount();
3391
-		}
3388
+        // Backwards compatibilty.
3389
+        if ( empty( $discount ) ) {
3390
+            return $this->get_total_discount();
3391
+        }
3392 3392
 
3393 3393
         $discounts = $this->get_discounts();
3394
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3394
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3395 3395
     }
3396 3396
 
3397 3397
     /**
3398
-	 * Removes a specific discount.
3399
-	 *
3400
-	 * @since 1.0.19
3401
-	 */
3402
-	public function remove_discount( $discount ) {
3398
+     * Removes a specific discount.
3399
+     *
3400
+     * @since 1.0.19
3401
+     */
3402
+    public function remove_discount( $discount ) {
3403 3403
         $discounts = $this->get_discounts();
3404 3404
         if ( isset( $discounts[ $discount ] ) ) {
3405 3405
             unset( $discounts[ $discount ] );
3406 3406
             $this->set_prop( 'discounts', $discounts );
3407 3407
         }
3408 3408
 
3409
-		if ( 'discount_code' == $discount ) {
3410
-			foreach ( $this->get_items() as $item ) {
3411
-				$item->item_discount           = 0;
3412
-				$item->recurring_item_discount = 0;
3413
-			}
3414
-		}
3409
+        if ( 'discount_code' == $discount ) {
3410
+            foreach ( $this->get_items() as $item ) {
3411
+                $item->item_discount           = 0;
3412
+                $item->recurring_item_discount = 0;
3413
+            }
3414
+        }
3415 3415
 
3416 3416
     }
3417 3417
 
@@ -3424,34 +3424,34 @@  discard block
 block discarded – undo
3424 3424
         if ( $this->is_taxable() ) {
3425 3425
 
3426 3426
             $taxes                 = $this->get_taxes();
3427
-			$taxes[ $tax['name'] ] = $tax;
3428
-			$this->set_prop( 'taxes', $tax );
3427
+            $taxes[ $tax['name'] ] = $tax;
3428
+            $this->set_prop( 'taxes', $tax );
3429 3429
 
3430 3430
         }
3431 3431
     }
3432 3432
 
3433 3433
     /**
3434
-	 * Retrieves a specific tax.
3435
-	 *
3436
-	 * @since 1.0.19
3437
-	 */
3438
-	public function get_tax( $tax = null ) {
3434
+     * Retrieves a specific tax.
3435
+     *
3436
+     * @since 1.0.19
3437
+     */
3438
+    public function get_tax( $tax = null ) {
3439 3439
 
3440
-		// Backwards compatility.
3441
-		if ( empty( $tax ) ) {
3442
-			return $this->get_total_tax();
3443
-		}
3440
+        // Backwards compatility.
3441
+        if ( empty( $tax ) ) {
3442
+            return $this->get_total_tax();
3443
+        }
3444 3444
 
3445 3445
         $taxes = $this->get_taxes();
3446
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3446
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3447 3447
     }
3448 3448
 
3449 3449
     /**
3450
-	 * Removes a specific tax.
3451
-	 *
3452
-	 * @since 1.0.19
3453
-	 */
3454
-	public function remove_tax( $tax ) {
3450
+     * Removes a specific tax.
3451
+     *
3452
+     * @since 1.0.19
3453
+     */
3454
+    public function remove_tax( $tax ) {
3455 3455
         $taxes = $this->get_taxes();
3456 3456
         if ( isset( $taxes[ $tax ] ) ) {
3457 3457
             unset( $taxes[ $tax ] );
@@ -3460,185 +3460,185 @@  discard block
 block discarded – undo
3460 3460
     }
3461 3461
 
3462 3462
     /**
3463
-	 * Recalculates the invoice subtotal.
3464
-	 *
3465
-	 * @since 1.0.19
3466
-	 * @return float The recalculated subtotal
3467
-	 */
3468
-	public function recalculate_subtotal() {
3463
+     * Recalculates the invoice subtotal.
3464
+     *
3465
+     * @since 1.0.19
3466
+     * @return float The recalculated subtotal
3467
+     */
3468
+    public function recalculate_subtotal() {
3469 3469
         $items     = $this->get_items();
3470
-		$subtotal  = 0;
3471
-		$recurring = 0;
3470
+        $subtotal  = 0;
3471
+        $recurring = 0;
3472 3472
 
3473 3473
         foreach ( $items as $item ) {
3474
-			$subtotal  += $item->get_sub_total();
3475
-			$recurring += $item->get_recurring_sub_total();
3474
+            $subtotal  += $item->get_sub_total();
3475
+            $recurring += $item->get_recurring_sub_total();
3476 3476
         }
3477 3477
 
3478
-		if ( wpinv_prices_include_tax() ) {
3479
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3480
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3481
-		}
3478
+        if ( wpinv_prices_include_tax() ) {
3479
+            $subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3480
+            $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3481
+        }
3482 3482
 
3483
-		$current = $this->is_renewal() ? $recurring : $subtotal;
3484
-		$this->set_subtotal( $current );
3483
+        $current = $this->is_renewal() ? $recurring : $subtotal;
3484
+        $this->set_subtotal( $current );
3485 3485
 
3486
-		$this->totals['subtotal'] = array(
3487
-			'initial'   => $subtotal,
3488
-			'recurring' => $recurring,
3489
-		);
3486
+        $this->totals['subtotal'] = array(
3487
+            'initial'   => $subtotal,
3488
+            'recurring' => $recurring,
3489
+        );
3490 3490
 
3491 3491
         return $current;
3492 3492
     }
3493 3493
 
3494 3494
     /**
3495
-	 * Recalculates the invoice discount total.
3496
-	 *
3497
-	 * @since 1.0.19
3498
-	 * @return float The recalculated discount
3499
-	 */
3500
-	public function recalculate_total_discount() {
3495
+     * Recalculates the invoice discount total.
3496
+     *
3497
+     * @since 1.0.19
3498
+     * @return float The recalculated discount
3499
+     */
3500
+    public function recalculate_total_discount() {
3501 3501
         $discounts = $this->get_discounts();
3502
-		$discount  = 0;
3503
-		$recurring = 0;
3502
+        $discount  = 0;
3503
+        $recurring = 0;
3504 3504
 
3505 3505
         foreach ( $discounts as $data ) {
3506
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3507
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3508
-		}
3506
+            $discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3507
+            $recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3508
+        }
3509 3509
 
3510
-		$current = $this->is_renewal() ? $recurring : $discount;
3510
+        $current = $this->is_renewal() ? $recurring : $discount;
3511 3511
 
3512
-		$this->set_total_discount( $current );
3512
+        $this->set_total_discount( $current );
3513 3513
 
3514
-		$this->totals['discount'] = array(
3515
-			'initial'   => $discount,
3516
-			'recurring' => $recurring,
3517
-		);
3514
+        $this->totals['discount'] = array(
3515
+            'initial'   => $discount,
3516
+            'recurring' => $recurring,
3517
+        );
3518 3518
 
3519
-		return $current;
3519
+        return $current;
3520 3520
 
3521 3521
     }
3522 3522
 
3523 3523
     /**
3524
-	 * Recalculates the invoice tax total.
3525
-	 *
3526
-	 * @since 1.0.19
3527
-	 * @return float The recalculated tax
3528
-	 */
3529
-	public function recalculate_total_tax() {
3524
+     * Recalculates the invoice tax total.
3525
+     *
3526
+     * @since 1.0.19
3527
+     * @return float The recalculated tax
3528
+     */
3529
+    public function recalculate_total_tax() {
3530 3530
 
3531
-		// Maybe disable taxes.
3532
-		$vat_number = $this->get_vat_number();
3533
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3531
+        // Maybe disable taxes.
3532
+        $vat_number = $this->get_vat_number();
3533
+        $skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3534 3534
 
3535
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3536
-			$skip_tax = false;
3537
-		}
3535
+        if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3536
+            $skip_tax = false;
3537
+        }
3538 3538
 
3539
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3539
+        if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3540 3540
 
3541
-			$this->totals['tax'] = array(
3542
-				'initial'   => 0,
3543
-				'recurring' => 0,
3544
-			);
3541
+            $this->totals['tax'] = array(
3542
+                'initial'   => 0,
3543
+                'recurring' => 0,
3544
+            );
3545 3545
 
3546
-			$this->tax_rate = 0;
3546
+            $this->tax_rate = 0;
3547 3547
 
3548
-			$this->set_taxes( array() );
3549
-			$current = 0;
3550
-		} else {
3548
+            $this->set_taxes( array() );
3549
+            $current = 0;
3550
+        } else {
3551 3551
 
3552
-			$item_taxes = array();
3552
+            $item_taxes = array();
3553 3553
 
3554
-			foreach ( $this->get_items() as $item ) {
3555
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3556
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3557
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3558
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3559
-				foreach ( $taxes as $name => $amount ) {
3560
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3561
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3554
+            foreach ( $this->get_items() as $item ) {
3555
+                $rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3556
+                $rates    = getpaid_filter_item_tax_rates( $item, $rates );
3557
+                $taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3558
+                $r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3559
+                foreach ( $taxes as $name => $amount ) {
3560
+                    $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3561
+                    $tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3562 3562
 
3563
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3564
-						$item_taxes[ $name ] = $tax;
3565
-						continue;
3566
-					}
3563
+                    if ( ! isset( $item_taxes[ $name ] ) ) {
3564
+                        $item_taxes[ $name ] = $tax;
3565
+                        continue;
3566
+                    }
3567 3567
 
3568
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3569
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3568
+                    $item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3569
+                    $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3570 3570
 
3571
-				}
3571
+                }
3572 3572
 
3573
-			}
3573
+            }
3574 3574
 
3575
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3576
-			$this->set_taxes( $item_taxes );
3575
+            $item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3576
+            $this->set_taxes( $item_taxes );
3577 3577
 
3578
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3579
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3578
+            $initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3579
+            $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3580 3580
 
3581
-			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3581
+            $current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3582 3582
 
3583
-			$this->totals['tax'] = array(
3584
-				'initial'   => $initial_tax,
3585
-				'recurring' => $recurring_tax,
3586
-			);
3583
+            $this->totals['tax'] = array(
3584
+                'initial'   => $initial_tax,
3585
+                'recurring' => $recurring_tax,
3586
+            );
3587 3587
 
3588
-		}
3588
+        }
3589 3589
 
3590
-		$this->set_total_tax( $current );
3590
+        $this->set_total_tax( $current );
3591 3591
 
3592
-		return $current;
3592
+        return $current;
3593 3593
 
3594 3594
     }
3595 3595
 
3596 3596
     /**
3597
-	 * Recalculates the invoice fees total.
3598
-	 *
3599
-	 * @since 1.0.19
3600
-	 * @return float The recalculated fee
3601
-	 */
3602
-	public function recalculate_total_fees() {
3603
-		$fees      = $this->get_fees();
3604
-		$fee       = 0;
3605
-		$recurring = 0;
3597
+     * Recalculates the invoice fees total.
3598
+     *
3599
+     * @since 1.0.19
3600
+     * @return float The recalculated fee
3601
+     */
3602
+    public function recalculate_total_fees() {
3603
+        $fees      = $this->get_fees();
3604
+        $fee       = 0;
3605
+        $recurring = 0;
3606 3606
 
3607 3607
         foreach ( $fees as $data ) {
3608
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3609
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3610
-		}
3608
+            $fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3609
+            $recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3610
+        }
3611 3611
 
3612
-		$current = $this->is_renewal() ? $recurring : $fee;
3613
-		$this->set_total_fees( $current );
3612
+        $current = $this->is_renewal() ? $recurring : $fee;
3613
+        $this->set_total_fees( $current );
3614 3614
 
3615
-		$this->totals['fee'] = array(
3616
-			'initial'   => $fee,
3617
-			'recurring' => $recurring,
3618
-		);
3615
+        $this->totals['fee'] = array(
3616
+            'initial'   => $fee,
3617
+            'recurring' => $recurring,
3618
+        );
3619 3619
 
3620 3620
         $this->set_total_fees( $fee );
3621 3621
         return $current;
3622 3622
     }
3623 3623
 
3624 3624
     /**
3625
-	 * Recalculates the invoice total.
3626
-	 *
3627
-	 * @since 1.0.19
3625
+     * Recalculates the invoice total.
3626
+     *
3627
+     * @since 1.0.19
3628 3628
      * @return float The invoice total
3629
-	 */
3630
-	public function recalculate_total() {
3629
+     */
3630
+    public function recalculate_total() {
3631 3631
         $this->recalculate_total_fees();
3632 3632
         $this->recalculate_total_discount();
3633
-		$this->recalculate_total_tax();
3634
-		$this->recalculate_subtotal();
3635
-		$this->set_total( $this->get_total_tax() + $this->get_total_fees() + $this->get_subtotal() - $this->get_total_discount() );
3636
-		return $this->get_total();
3637
-	}
3638
-
3639
-	/**
3640
-	 * @deprecated
3641
-	 */
3633
+        $this->recalculate_total_tax();
3634
+        $this->recalculate_subtotal();
3635
+        $this->set_total( $this->get_total_tax() + $this->get_total_fees() + $this->get_subtotal() - $this->get_total_discount() );
3636
+        return $this->get_total();
3637
+    }
3638
+
3639
+    /**
3640
+     * @deprecated
3641
+     */
3642 3642
     public function recalculate_totals() {
3643 3643
         $this->recalculate_total();
3644 3644
         $this->save( true );
@@ -3652,22 +3652,22 @@  discard block
 block discarded – undo
3652 3652
         return $this->get_data();
3653 3653
     }
3654 3654
 
3655
-	/**
3655
+    /**
3656 3656
      * Adds a system note to an invoice.
3657 3657
      *
3658 3658
      * @param string $note The note being added.
3659
-	 * @return int|false The new note's ID on success, false on failure.
3659
+     * @return int|false The new note's ID on success, false on failure.
3660 3660
      *
3661 3661
      */
3662 3662
     public function add_system_note( $note ) {
3663
-		return $this->add_note( $note, false, false, true );
3664
-	}
3663
+        return $this->add_note( $note, false, false, true );
3664
+    }
3665 3665
 
3666 3666
     /**
3667 3667
      * Adds a note to an invoice.
3668 3668
      *
3669 3669
      * @param string $note The note being added.
3670
-	 * @return int|false The new note's ID on success, false on failure.
3670
+     * @return int|false The new note's ID on success, false on failure.
3671 3671
      *
3672 3672
      */
3673 3673
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3677,21 +3677,21 @@  discard block
 block discarded – undo
3677 3677
             return false;
3678 3678
         }
3679 3679
 
3680
-		$author       = 'System';
3681
-		$author_email = '[email protected]';
3680
+        $author       = 'System';
3681
+        $author_email = '[email protected]';
3682 3682
 
3683
-		// If this is an admin comment or it has been added by the user.
3684
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3685
-			$user         = get_user_by( 'id', get_current_user_id() );
3683
+        // If this is an admin comment or it has been added by the user.
3684
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3685
+            $user         = get_user_by( 'id', get_current_user_id() );
3686 3686
             $author       = $user->display_name;
3687 3687
             $author_email = $user->user_email;
3688
-		}
3688
+        }
3689 3689
 
3690
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3690
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3691 3691
 
3692
-	}
3692
+    }
3693 3693
 
3694
-	/**
3694
+    /**
3695 3695
      * Generates a unique key for the invoice.
3696 3696
      */
3697 3697
     public function generate_key( $string = '' ) {
@@ -3711,113 +3711,113 @@  discard block
 block discarded – undo
3711 3711
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3712 3712
         }
3713 3713
 
3714
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3715
-
3716
-	}
3717
-
3718
-	/**
3719
-	 * Handle the status transition.
3720
-	 */
3721
-	protected function status_transition() {
3722
-		$status_transition = $this->status_transition;
3723
-
3724
-		// Reset status transition variable.
3725
-		$this->status_transition = false;
3714
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3726 3715
 
3727
-		if ( $status_transition ) {
3728
-			try {
3729
-
3730
-				// Fire a hook for the status change.
3731
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3732
-
3733
-				// @deprecated this is deprecated and will be removed in the future.
3734
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3735
-
3736
-				if ( ! empty( $status_transition['from'] ) ) {
3737
-
3738
-					/* translators: 1: old invoice status 2: new invoice status */
3739
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3740
-
3741
-					// Fire another hook.
3742
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3743
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3744
-
3745
-					// @deprecated this is deprecated and will be removed in the future.
3746
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3747
-
3748
-					// Note the transition occurred.
3749
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3750
-
3751
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3752
-					if (
3753
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3754
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3755
-					) {
3756
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3757
-					}
3758
-
3759
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3760
-					if (
3761
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3762
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3763
-					) {
3764
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3765
-					}
3766
-				} else {
3767
-					/* translators: %s: new invoice status */
3768
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3769
-
3770
-					// Note the transition occurred.
3771
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3716
+    }
3772 3717
 
3773
-				}
3774
-			} catch ( Exception $e ) {
3775
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3776
-			}
3777
-		}
3778
-	}
3718
+    /**
3719
+     * Handle the status transition.
3720
+     */
3721
+    protected function status_transition() {
3722
+        $status_transition = $this->status_transition;
3723
+
3724
+        // Reset status transition variable.
3725
+        $this->status_transition = false;
3726
+
3727
+        if ( $status_transition ) {
3728
+            try {
3729
+
3730
+                // Fire a hook for the status change.
3731
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3732
+
3733
+                // @deprecated this is deprecated and will be removed in the future.
3734
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3735
+
3736
+                if ( ! empty( $status_transition['from'] ) ) {
3737
+
3738
+                    /* translators: 1: old invoice status 2: new invoice status */
3739
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3740
+
3741
+                    // Fire another hook.
3742
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3743
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3744
+
3745
+                    // @deprecated this is deprecated and will be removed in the future.
3746
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3747
+
3748
+                    // Note the transition occurred.
3749
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3750
+
3751
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3752
+                    if (
3753
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3754
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3755
+                    ) {
3756
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3757
+                    }
3758
+
3759
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3760
+                    if (
3761
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3762
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3763
+                    ) {
3764
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3765
+                    }
3766
+                } else {
3767
+                    /* translators: %s: new invoice status */
3768
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3769
+
3770
+                    // Note the transition occurred.
3771
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3772
+
3773
+                }
3774
+            } catch ( Exception $e ) {
3775
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3776
+            }
3777
+        }
3778
+    }
3779 3779
 
3780
-	/**
3781
-	 * Updates an invoice status.
3782
-	 */
3783
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3780
+    /**
3781
+     * Updates an invoice status.
3782
+     */
3783
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3784 3784
 
3785
-		// Fires before updating a status.
3786
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3785
+        // Fires before updating a status.
3786
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3787 3787
 
3788
-		// Update the status.
3789
-		$this->set_status( $new_status, $note, $manual );
3788
+        // Update the status.
3789
+        $this->set_status( $new_status, $note, $manual );
3790 3790
 
3791
-		// Save the order.
3792
-		return $this->save();
3791
+        // Save the order.
3792
+        return $this->save();
3793 3793
 
3794
-	}
3794
+    }
3795 3795
 
3796
-	/**
3797
-	 * @deprecated
3798
-	 */
3799
-	public function refresh_item_ids() {
3796
+    /**
3797
+     * @deprecated
3798
+     */
3799
+    public function refresh_item_ids() {
3800 3800
         $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3801 3801
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3802
-	}
3802
+    }
3803 3803
 
3804
-	/**
3805
-	 * @deprecated
3806
-	 */
3807
-	public function update_items( $temp = false ) {
3804
+    /**
3805
+     * @deprecated
3806
+     */
3807
+    public function update_items( $temp = false ) {
3808 3808
 
3809
-		$this->set_items( $this->get_items() );
3809
+        $this->set_items( $this->get_items() );
3810 3810
 
3811
-		if ( ! $temp ) {
3812
-			$this->save();
3813
-		}
3811
+        if ( ! $temp ) {
3812
+            $this->save();
3813
+        }
3814 3814
 
3815 3815
         return $this;
3816
-	}
3816
+    }
3817 3817
 
3818
-	/**
3819
-	 * @deprecated
3820
-	 */
3818
+    /**
3819
+     * @deprecated
3820
+     */
3821 3821
     public function validate_discount() {
3822 3822
 
3823 3823
         $discount_code = $this->get_discount_code();
@@ -3833,93 +3833,93 @@  discard block
 block discarded – undo
3833 3833
 
3834 3834
     }
3835 3835
 
3836
-	/**
3837
-	 * Refunds an invoice.
3838
-	 */
3836
+    /**
3837
+     * Refunds an invoice.
3838
+     */
3839 3839
     public function refund() {
3840
-		$this->set_status( 'wpi-refunded' );
3840
+        $this->set_status( 'wpi-refunded' );
3841 3841
         $this->save();
3842
-	}
3842
+    }
3843 3843
 
3844
-	/**
3845
-	 * Marks an invoice as paid.
3846
-	 * 
3847
-	 * @param string $transaction_id
3848
-	 */
3844
+    /**
3845
+     * Marks an invoice as paid.
3846
+     * 
3847
+     * @param string $transaction_id
3848
+     */
3849 3849
     public function mark_paid( $transaction_id = null, $note = '' ) {
3850 3850
 
3851
-		// Set the transaction id.
3852
-		if ( empty( $transaction_id ) ) {
3853
-			$transaction_id = $this->generate_key('trans_');
3854
-		}
3851
+        // Set the transaction id.
3852
+        if ( empty( $transaction_id ) ) {
3853
+            $transaction_id = $this->generate_key('trans_');
3854
+        }
3855 3855
 
3856
-		if ( ! $this->get_transaction_id() ) {
3857
-			$this->set_transaction_id( $transaction_id );
3858
-		}
3856
+        if ( ! $this->get_transaction_id() ) {
3857
+            $this->set_transaction_id( $transaction_id );
3858
+        }
3859 3859
 
3860
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3861
-			return $this->save();
3862
-		}
3860
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3861
+            return $this->save();
3862
+        }
3863 3863
 
3864
-		// Set the completed date.
3865
-		$this->set_date_completed( current_time( 'mysql' ) );
3864
+        // Set the completed date.
3865
+        $this->set_date_completed( current_time( 'mysql' ) );
3866 3866
 
3867
-		// Set the new status.
3868
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3869
-		if ( $this->is_renewal() ) {
3867
+        // Set the new status.
3868
+        $gateway = sanitize_text_field( $this->get_gateway_title() );
3869
+        if ( $this->is_renewal() ) {
3870 3870
 
3871
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3872
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3871
+            $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3872
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3873 3873
 
3874
-			if ( 'none' == $this->get_gateway() ) {
3875
-				$_note = $note;
3876
-			}
3874
+            if ( 'none' == $this->get_gateway() ) {
3875
+                $_note = $note;
3876
+            }
3877 3877
 
3878
-			$this->set_status( 'wpi-renewal', $_note );
3878
+            $this->set_status( 'wpi-renewal', $_note );
3879 3879
 
3880
-		} else {
3880
+        } else {
3881 3881
 
3882
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3883
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3882
+            $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3883
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3884 3884
 
3885
-			if ( 'none' == $this->get_gateway() ) {
3886
-				$_note = $note;
3887
-			}
3885
+            if ( 'none' == $this->get_gateway() ) {
3886
+                $_note = $note;
3887
+            }
3888 3888
 
3889
-			$this->set_status( 'publish', $_note );
3889
+            $this->set_status( 'publish', $_note );
3890 3890
 
3891
-		}
3891
+        }
3892 3892
 
3893
-		// Set checkout mode.
3894
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3895
-		$this->set_mode( $mode );
3893
+        // Set checkout mode.
3894
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3895
+        $this->set_mode( $mode );
3896 3896
 
3897
-		// Save the invoice.
3897
+        // Save the invoice.
3898 3898
         $this->save();
3899
-	}
3900
-
3901
-	/**
3902
-	 * Save data to the database.
3903
-	 *
3904
-	 * @since 1.0.19
3905
-	 * @return int invoice ID
3906
-	 */
3907
-	public function save() {
3908
-		$this->maybe_set_date_paid();
3909
-		$this->maybe_set_key();
3910
-		parent::save();
3911
-		$this->clear_cache();
3912
-		$this->status_transition();
3913
-		return $this->get_id();
3914
-	}
3915
-
3916
-	/**
3899
+    }
3900
+
3901
+    /**
3902
+     * Save data to the database.
3903
+     *
3904
+     * @since 1.0.19
3905
+     * @return int invoice ID
3906
+     */
3907
+    public function save() {
3908
+        $this->maybe_set_date_paid();
3909
+        $this->maybe_set_key();
3910
+        parent::save();
3911
+        $this->clear_cache();
3912
+        $this->status_transition();
3913
+        return $this->get_id();
3914
+    }
3915
+
3916
+    /**
3917 3917
      * Clears the subscription's cache.
3918 3918
      */
3919 3919
     public function clear_cache() {
3920
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3921
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3922
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3923
-	}
3920
+        wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3921
+        wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3922
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3923
+    }
3924 3924
 
3925 3925
 }
Please login to merge, or discard this patch.
Spacing   +782 added lines, -782 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.
@@ -143,40 +143,40 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
145 145
 	 */
146
-    public function __construct( $invoice = 0 ) {
146
+    public function __construct($invoice = 0) {
147 147
 
148
-        parent::__construct( $invoice );
148
+        parent::__construct($invoice);
149 149
 
150
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
151
-			$this->set_id( (int) $invoice );
152
-		} elseif ( $invoice instanceof self ) {
153
-			$this->set_id( $invoice->get_id() );
154
-		} elseif ( ! empty( $invoice->ID ) ) {
155
-			$this->set_id( $invoice->ID );
156
-		} elseif ( is_array( $invoice ) ) {
157
-			$this->set_props( $invoice );
150
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) {
151
+			$this->set_id((int) $invoice);
152
+		} elseif ($invoice instanceof self) {
153
+			$this->set_id($invoice->get_id());
154
+		} elseif (!empty($invoice->ID)) {
155
+			$this->set_id($invoice->ID);
156
+		} elseif (is_array($invoice)) {
157
+			$this->set_props($invoice);
158 158
 
159
-			if ( isset( $invoice['ID'] ) ) {
160
-				$this->set_id( $invoice['ID'] );
159
+			if (isset($invoice['ID'])) {
160
+				$this->set_id($invoice['ID']);
161 161
 			}
162 162
 
163
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
164
-			$this->set_id( $invoice_id );
165
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
166
-			$this->set_id( $invoice_id );
167
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
168
-			$this->set_id( $invoice_id );
163
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
164
+			$this->set_id($invoice_id);
165
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
166
+			$this->set_id($invoice_id);
167
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
168
+			$this->set_id($invoice_id);
169 169
 		} else {
170
-			$this->set_object_read( true );
170
+			$this->set_object_read(true);
171 171
 		}
172 172
 
173 173
         // Load the datastore.
174
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
174
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
175 175
 
176
-		if ( $this->get_id() > 0 ) {
177
-            $this->post = get_post( $this->get_id() );
176
+		if ($this->get_id() > 0) {
177
+            $this->post = get_post($this->get_id());
178 178
             $this->ID   = $this->get_id();
179
-			$this->data_store->read( $this );
179
+			$this->data_store->read($this);
180 180
         }
181 181
 
182 182
     }
@@ -191,38 +191,38 @@  discard block
 block discarded – undo
191 191
 	 * @since 1.0.15
192 192
 	 * @return int
193 193
 	 */
194
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
194
+	public static function get_invoice_id_by_field($value, $field = 'key') {
195 195
         global $wpdb;
196 196
 
197 197
 		// Trim the value.
198
-		$value = trim( $value );
198
+		$value = trim($value);
199 199
 
200
-		if ( empty( $value ) ) {
200
+		if (empty($value)) {
201 201
 			return 0;
202 202
 		}
203 203
 
204 204
         // Valid fields.
205
-        $fields = array( 'key', 'number', 'transaction_id' );
205
+        $fields = array('key', 'number', 'transaction_id');
206 206
 
207 207
 		// Ensure a field has been passed.
208
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
208
+		if (empty($field) || !in_array($field, $fields)) {
209 209
 			return 0;
210 210
 		}
211 211
 
212 212
 		// Maybe retrieve from the cache.
213
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
214
-		if ( false !== $invoice_id ) {
213
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
214
+		if (false !== $invoice_id) {
215 215
 			return $invoice_id;
216 216
 		}
217 217
 
218 218
         // Fetch from the db.
219 219
         $table       = $wpdb->prefix . 'getpaid_invoices';
220 220
         $invoice_id  = (int) $wpdb->get_var(
221
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
221
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
222 222
         );
223 223
 
224 224
 		// Update the cache with our data
225
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
225
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
226 226
 
227 227
 		return $invoice_id;
228 228
     }
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
     /**
231 231
      * Checks if an invoice key is set.
232 232
      */
233
-    public function _isset( $key ) {
234
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
233
+    public function _isset($key) {
234
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
235 235
     }
236 236
 
237 237
     /*
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 	 * @param  string $context View or edit context.
257 257
 	 * @return int
258 258
 	 */
259
-	public function get_parent_id( $context = 'view' ) {
260
-		return (int) $this->get_prop( 'parent_id', $context );
259
+	public function get_parent_id($context = 'view') {
260
+		return (int) $this->get_prop('parent_id', $context);
261 261
     }
262 262
 
263 263
     /**
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 * @return WPInv_Invoice
268 268
 	 */
269 269
     public function get_parent_payment() {
270
-        return new WPInv_Invoice( $this->get_parent_id() );
270
+        return new WPInv_Invoice($this->get_parent_id());
271 271
     }
272 272
 
273 273
     /**
@@ -287,8 +287,8 @@  discard block
 block discarded – undo
287 287
 	 * @param  string $context View or edit context.
288 288
 	 * @return string
289 289
 	 */
290
-	public function get_status( $context = 'view' ) {
291
-		return $this->get_prop( 'status', $context );
290
+	public function get_status($context = 'view') {
291
+		return $this->get_prop('status', $context);
292 292
 	}
293 293
 	
294 294
 	/**
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	 * @return array
299 299
 	 */
300 300
 	public function get_all_statuses() {
301
-		return wpinv_get_invoice_statuses( true, true, $this );
301
+		return wpinv_get_invoice_statuses(true, true, $this);
302 302
     }
303 303
 
304 304
     /**
@@ -310,9 +310,9 @@  discard block
 block discarded – undo
310 310
     public function get_status_nicename() {
311 311
 		$statuses = $this->get_all_statuses();
312 312
 
313
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
313
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
314 314
 
315
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
315
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
316 316
     }
317 317
 
318 318
 	/**
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	 */
324 324
 	public function get_status_class() {
325 325
 		$statuses = getpaid_get_invoice_status_classes();
326
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
326
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark';
327 327
 	}
328 328
 
329 329
 	/**
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
      */
335 335
     public function get_status_label_html() {
336 336
 
337
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
338
-		$status       = sanitize_html_class( $this->get_status() );
339
-		$class        = esc_attr( $this->get_status_class() );
337
+		$status_label = sanitize_text_field($this->get_status_nicename());
338
+		$status       = sanitize_html_class($this->get_status());
339
+		$class        = esc_attr($this->get_status_class());
340 340
 
341 341
 		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
342 342
 	}
@@ -348,23 +348,23 @@  discard block
 block discarded – undo
348 348
 	 * @param  string $context View or edit context.
349 349
 	 * @return string
350 350
 	 */
351
-	public function get_version( $context = 'view' ) {
352
-		return $this->get_prop( 'version', $context );
351
+	public function get_version($context = 'view') {
352
+		return $this->get_prop('version', $context);
353 353
 	}
354 354
 
355 355
 	/**
356 356
 	 * @deprecated
357 357
 	 */
358
-	public function get_invoice_date( $format = true ) {
359
-		$date      = getpaid_format_date( $this->get_date_completed() );
360
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
361
-		$formatted = getpaid_format_date( $date );
358
+	public function get_invoice_date($format = true) {
359
+		$date      = getpaid_format_date($this->get_date_completed());
360
+		$date      = empty($date) ? $this->get_date_created() : $this->get_date_completed();
361
+		$formatted = getpaid_format_date($date);
362 362
 
363
-		if ( $format ) {
363
+		if ($format) {
364 364
 			return $formatted;
365 365
 		}
366 366
 
367
-		return empty( $formatted ) ? '' : $date;
367
+		return empty($formatted) ? '' : $date;
368 368
 
369 369
     }
370 370
 
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 	 * @param  string $context View or edit context.
376 376
 	 * @return string
377 377
 	 */
378
-	public function get_date_created( $context = 'view' ) {
379
-		return $this->get_prop( 'date_created', $context );
378
+	public function get_date_created($context = 'view') {
379
+		return $this->get_prop('date_created', $context);
380 380
 	}
381 381
 	
382 382
 	/**
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
 	 * @param  string $context View or edit context.
387 387
 	 * @return string
388 388
 	 */
389
-	public function get_created_date( $context = 'view' ) {
390
-		return $this->get_date_created( $context );
389
+	public function get_created_date($context = 'view') {
390
+		return $this->get_date_created($context);
391 391
     }
392 392
 
393 393
     /**
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 	 * @param  string $context View or edit context.
398 398
 	 * @return string
399 399
 	 */
400
-	public function get_date_created_gmt( $context = 'view' ) {
401
-        $date = $this->get_date_created( $context );
400
+	public function get_date_created_gmt($context = 'view') {
401
+        $date = $this->get_date_created($context);
402 402
 
403
-        if ( $date ) {
404
-            $date = get_gmt_from_date( $date );
403
+        if ($date) {
404
+            $date = get_gmt_from_date($date);
405 405
         }
406 406
 		return $date;
407 407
     }
@@ -413,8 +413,8 @@  discard block
 block discarded – undo
413 413
 	 * @param  string $context View or edit context.
414 414
 	 * @return string
415 415
 	 */
416
-	public function get_date_modified( $context = 'view' ) {
417
-		return $this->get_prop( 'date_modified', $context );
416
+	public function get_date_modified($context = 'view') {
417
+		return $this->get_prop('date_modified', $context);
418 418
 	}
419 419
 
420 420
 	/**
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
 	 * @param  string $context View or edit context.
425 425
 	 * @return string
426 426
 	 */
427
-	public function get_modified_date( $context = 'view' ) {
428
-		return $this->get_date_modified( $context );
427
+	public function get_modified_date($context = 'view') {
428
+		return $this->get_date_modified($context);
429 429
     }
430 430
 
431 431
     /**
@@ -435,11 +435,11 @@  discard block
 block discarded – undo
435 435
 	 * @param  string $context View or edit context.
436 436
 	 * @return string
437 437
 	 */
438
-	public function get_date_modified_gmt( $context = 'view' ) {
439
-        $date = $this->get_date_modified( $context );
438
+	public function get_date_modified_gmt($context = 'view') {
439
+        $date = $this->get_date_modified($context);
440 440
 
441
-        if ( $date ) {
442
-            $date = get_gmt_from_date( $date );
441
+        if ($date) {
442
+            $date = get_gmt_from_date($date);
443 443
         }
444 444
 		return $date;
445 445
     }
@@ -451,8 +451,8 @@  discard block
 block discarded – undo
451 451
 	 * @param  string $context View or edit context.
452 452
 	 * @return string
453 453
 	 */
454
-	public function get_due_date( $context = 'view' ) {
455
-		return $this->get_prop( 'due_date', $context );
454
+	public function get_due_date($context = 'view') {
455
+		return $this->get_prop('due_date', $context);
456 456
     }
457 457
 
458 458
     /**
@@ -462,8 +462,8 @@  discard block
 block discarded – undo
462 462
 	 * @param  string $context View or edit context.
463 463
 	 * @return string
464 464
 	 */
465
-	public function get_date_due( $context = 'view' ) {
466
-		return $this->get_due_date( $context );
465
+	public function get_date_due($context = 'view') {
466
+		return $this->get_due_date($context);
467 467
     }
468 468
 
469 469
     /**
@@ -473,11 +473,11 @@  discard block
 block discarded – undo
473 473
 	 * @param  string $context View or edit context.
474 474
 	 * @return string
475 475
 	 */
476
-	public function get_due_date_gmt( $context = 'view' ) {
477
-        $date = $this->get_due_date( $context );
476
+	public function get_due_date_gmt($context = 'view') {
477
+        $date = $this->get_due_date($context);
478 478
 
479
-        if ( $date ) {
480
-            $date = get_gmt_from_date( $date );
479
+        if ($date) {
480
+            $date = get_gmt_from_date($date);
481 481
         }
482 482
 		return $date;
483 483
     }
@@ -489,8 +489,8 @@  discard block
 block discarded – undo
489 489
 	 * @param  string $context View or edit context.
490 490
 	 * @return string
491 491
 	 */
492
-	public function get_gmt_date_due( $context = 'view' ) {
493
-		return $this->get_due_date_gmt( $context );
492
+	public function get_gmt_date_due($context = 'view') {
493
+		return $this->get_due_date_gmt($context);
494 494
     }
495 495
 
496 496
     /**
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 	 * @param  string $context View or edit context.
501 501
 	 * @return string
502 502
 	 */
503
-	public function get_completed_date( $context = 'view' ) {
504
-		return $this->get_prop( 'completed_date', $context );
503
+	public function get_completed_date($context = 'view') {
504
+		return $this->get_prop('completed_date', $context);
505 505
     }
506 506
 
507 507
     /**
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
 	 * @param  string $context View or edit context.
512 512
 	 * @return string
513 513
 	 */
514
-	public function get_date_completed( $context = 'view' ) {
515
-		return $this->get_completed_date( $context );
514
+	public function get_date_completed($context = 'view') {
515
+		return $this->get_completed_date($context);
516 516
     }
517 517
 
518 518
     /**
@@ -522,11 +522,11 @@  discard block
 block discarded – undo
522 522
 	 * @param  string $context View or edit context.
523 523
 	 * @return string
524 524
 	 */
525
-	public function get_completed_date_gmt( $context = 'view' ) {
526
-        $date = $this->get_completed_date( $context );
525
+	public function get_completed_date_gmt($context = 'view') {
526
+        $date = $this->get_completed_date($context);
527 527
 
528
-        if ( $date ) {
529
-            $date = get_gmt_from_date( $date );
528
+        if ($date) {
529
+            $date = get_gmt_from_date($date);
530 530
         }
531 531
 		return $date;
532 532
     }
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
 	 * @param  string $context View or edit context.
539 539
 	 * @return string
540 540
 	 */
541
-	public function get_gmt_completed_date( $context = 'view' ) {
542
-		return $this->get_completed_date_gmt( $context );
541
+	public function get_gmt_completed_date($context = 'view') {
542
+		return $this->get_completed_date_gmt($context);
543 543
     }
544 544
 
545 545
     /**
@@ -549,12 +549,12 @@  discard block
 block discarded – undo
549 549
 	 * @param  string $context View or edit context.
550 550
 	 * @return string
551 551
 	 */
552
-	public function get_number( $context = 'view' ) {
553
-		$number = $this->get_prop( 'number', $context );
552
+	public function get_number($context = 'view') {
553
+		$number = $this->get_prop('number', $context);
554 554
 
555
-		if ( empty( $number ) ) {
555
+		if (empty($number)) {
556 556
 			$number = $this->generate_number();
557
-			$this->set_number( $this->generate_number() );
557
+			$this->set_number($this->generate_number());
558 558
 		}
559 559
 
560 560
 		return $number;
@@ -568,8 +568,8 @@  discard block
 block discarded – undo
568 568
 	public function maybe_set_number() {
569 569
         $number = $this->get_number();
570 570
 
571
-        if ( empty( $number ) || $this->get_id() == $number ) {
572
-			$this->set_number( $this->generate_number() );
571
+        if (empty($number) || $this->get_id() == $number) {
572
+			$this->set_number($this->generate_number());
573 573
         }
574 574
 
575 575
 	}
@@ -581,8 +581,8 @@  discard block
 block discarded – undo
581 581
 	 * @param  string $context View or edit context.
582 582
 	 * @return string
583 583
 	 */
584
-	public function get_key( $context = 'view' ) {
585
-        return $this->get_prop( 'key', $context );
584
+	public function get_key($context = 'view') {
585
+        return $this->get_prop('key', $context);
586 586
 	}
587 587
 
588 588
 	/**
@@ -593,9 +593,9 @@  discard block
 block discarded – undo
593 593
 	public function maybe_set_key() {
594 594
         $key = $this->get_key();
595 595
 
596
-        if ( empty( $key ) ) {
597
-            $key = $this->generate_key( $this->get_type() . '_' );
598
-            $this->set_key( $key );
596
+        if (empty($key)) {
597
+            $key = $this->generate_key($this->get_type() . '_');
598
+            $this->set_key($key);
599 599
         }
600 600
 
601 601
     }
@@ -607,8 +607,8 @@  discard block
 block discarded – undo
607 607
 	 * @param  string $context View or edit context.
608 608
 	 * @return string
609 609
 	 */
610
-	public function get_type( $context = 'view' ) {
611
-        return $this->get_prop( 'type', $context );
610
+	public function get_type($context = 'view') {
611
+        return $this->get_prop('type', $context);
612 612
 	}
613 613
 
614 614
 	/**
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 	 * @return string
619 619
 	 */
620 620
 	public function get_invoice_quote_type() {
621
-        return getpaid_get_post_type_label( $this->get_post_type(), false );
621
+        return getpaid_get_post_type_label($this->get_post_type(), false);
622 622
     }
623 623
 
624 624
     /**
@@ -628,8 +628,8 @@  discard block
 block discarded – undo
628 628
 	 * @param  string $context View or edit context.
629 629
 	 * @return string
630 630
 	 */
631
-	public function get_label( $context = 'view' ) {
632
-        return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
631
+	public function get_label($context = 'view') {
632
+        return getpaid_get_post_type_label($this->get_post_type($context), false);
633 633
 	}
634 634
 
635 635
 	/**
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
 	 * @param  string $context View or edit context.
640 640
 	 * @return string
641 641
 	 */
642
-	public function get_post_type( $context = 'view' ) {
643
-        return $this->get_prop( 'post_type', $context );
642
+	public function get_post_type($context = 'view') {
643
+        return $this->get_prop('post_type', $context);
644 644
     }
645 645
 
646 646
     /**
@@ -650,8 +650,8 @@  discard block
 block discarded – undo
650 650
 	 * @param  string $context View or edit context.
651 651
 	 * @return string
652 652
 	 */
653
-	public function get_mode( $context = 'view' ) {
654
-        return $this->get_prop( 'mode', $context );
653
+	public function get_mode($context = 'view') {
654
+        return $this->get_prop('mode', $context);
655 655
     }
656 656
 
657 657
     /**
@@ -661,13 +661,13 @@  discard block
 block discarded – undo
661 661
 	 * @param  string $context View or edit context.
662 662
 	 * @return string
663 663
 	 */
664
-	public function get_path( $context = 'view' ) {
665
-        $path   = $this->get_prop( 'path', $context );
664
+	public function get_path($context = 'view') {
665
+        $path = $this->get_prop('path', $context);
666 666
 		$prefix = $this->get_type();
667 667
 
668
-		if ( 0 !== strpos( $path, $prefix ) ) {
669
-			$path = sanitize_title(  $prefix . '-' . $this->get_id()  );
670
-			$this->set_path( $path );
668
+		if (0 !== strpos($path, $prefix)) {
669
+			$path = sanitize_title($prefix . '-' . $this->get_id());
670
+			$this->set_path($path);
671 671
 		}
672 672
 
673 673
 		return $path;
@@ -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_name( $context = 'view' ) {
684
-        return $this->get_prop( 'title', $context );
683
+	public function get_name($context = 'view') {
684
+        return $this->get_prop('title', $context);
685 685
     }
686 686
 
687 687
     /**
@@ -691,8 +691,8 @@  discard block
 block discarded – undo
691 691
 	 * @param  string $context View or edit context.
692 692
 	 * @return string
693 693
 	 */
694
-	public function get_title( $context = 'view' ) {
695
-		return $this->get_name( $context );
694
+	public function get_title($context = 'view') {
695
+		return $this->get_name($context);
696 696
     }
697 697
 
698 698
     /**
@@ -702,8 +702,8 @@  discard block
 block discarded – undo
702 702
 	 * @param  string $context View or edit context.
703 703
 	 * @return string
704 704
 	 */
705
-	public function get_description( $context = 'view' ) {
706
-		return $this->get_prop( 'description', $context );
705
+	public function get_description($context = 'view') {
706
+		return $this->get_prop('description', $context);
707 707
     }
708 708
 
709 709
     /**
@@ -713,8 +713,8 @@  discard block
 block discarded – undo
713 713
 	 * @param  string $context View or edit context.
714 714
 	 * @return string
715 715
 	 */
716
-	public function get_excerpt( $context = 'view' ) {
717
-		return $this->get_description( $context );
716
+	public function get_excerpt($context = 'view') {
717
+		return $this->get_description($context);
718 718
     }
719 719
 
720 720
     /**
@@ -724,8 +724,8 @@  discard block
 block discarded – undo
724 724
 	 * @param  string $context View or edit context.
725 725
 	 * @return string
726 726
 	 */
727
-	public function get_summary( $context = 'view' ) {
728
-		return $this->get_description( $context );
727
+	public function get_summary($context = 'view') {
728
+		return $this->get_description($context);
729 729
     }
730 730
 
731 731
     /**
@@ -735,25 +735,25 @@  discard block
 block discarded – undo
735 735
      * @param  string $context View or edit context.
736 736
 	 * @return array
737 737
 	 */
738
-    public function get_user_info( $context = 'view' ) {
738
+    public function get_user_info($context = 'view') {
739 739
 
740 740
         $user_info = array(
741
-            'user_id'    => $this->get_user_id( $context ),
742
-            'email'      => $this->get_email( $context ),
743
-            'first_name' => $this->get_first_name( $context ),
744
-            'last_name'  => $this->get_last_name( $context ),
745
-            'address'    => $this->get_address( $context ),
746
-            'phone'      => $this->get_phone( $context ),
747
-            'city'       => $this->get_city( $context ),
748
-            'country'    => $this->get_country( $context ),
749
-            'state'      => $this->get_state( $context ),
750
-            'zip'        => $this->get_zip( $context ),
751
-            'company'    => $this->get_company( $context ),
752
-            'vat_number' => $this->get_vat_number( $context ),
753
-            'discount'   => $this->get_discount_code( $context ),
741
+            'user_id'    => $this->get_user_id($context),
742
+            'email'      => $this->get_email($context),
743
+            'first_name' => $this->get_first_name($context),
744
+            'last_name'  => $this->get_last_name($context),
745
+            'address'    => $this->get_address($context),
746
+            'phone'      => $this->get_phone($context),
747
+            'city'       => $this->get_city($context),
748
+            'country'    => $this->get_country($context),
749
+            'state'      => $this->get_state($context),
750
+            'zip'        => $this->get_zip($context),
751
+            'company'    => $this->get_company($context),
752
+            'vat_number' => $this->get_vat_number($context),
753
+            'discount'   => $this->get_discount_code($context),
754 754
 		);
755 755
 
756
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
756
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
757 757
 
758 758
     }
759 759
 
@@ -764,8 +764,8 @@  discard block
 block discarded – undo
764 764
 	 * @param  string $context View or edit context.
765 765
 	 * @return int
766 766
 	 */
767
-	public function get_author( $context = 'view' ) {
768
-		return (int) $this->get_prop( 'author', $context );
767
+	public function get_author($context = 'view') {
768
+		return (int) $this->get_prop('author', $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 int
777 777
 	 */
778
-	public function get_user_id( $context = 'view' ) {
779
-		return $this->get_author( $context );
778
+	public function get_user_id($context = 'view') {
779
+		return $this->get_author($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 int
788 788
 	 */
789
-	public function get_customer_id( $context = 'view' ) {
790
-		return $this->get_author( $context );
789
+	public function get_customer_id($context = 'view') {
790
+		return $this->get_author($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 string
799 799
 	 */
800
-	public function get_ip( $context = 'view' ) {
801
-		return $this->get_prop( 'user_ip', $context );
800
+	public function get_ip($context = 'view') {
801
+		return $this->get_prop('user_ip', $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 string
810 810
 	 */
811
-	public function get_user_ip( $context = 'view' ) {
812
-		return $this->get_ip( $context );
811
+	public function get_user_ip($context = 'view') {
812
+		return $this->get_ip($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_customer_ip( $context = 'view' ) {
823
-		return $this->get_ip( $context );
822
+	public function get_customer_ip($context = 'view') {
823
+		return $this->get_ip($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 string
832 832
 	 */
833
-	public function get_first_name( $context = 'view' ) {
834
-		return $this->get_prop( 'first_name', $context );
833
+	public function get_first_name($context = 'view') {
834
+		return $this->get_prop('first_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 string
843 843
 	 */
844
-	public function get_user_first_name( $context = 'view' ) {
845
-		return $this->get_first_name( $context );
844
+	public function get_user_first_name($context = 'view') {
845
+		return $this->get_first_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_customer_first_name( $context = 'view' ) {
856
-		return $this->get_first_name( $context );
855
+	public function get_customer_first_name($context = 'view') {
856
+		return $this->get_first_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 string
865 865
 	 */
866
-	public function get_last_name( $context = 'view' ) {
867
-		return $this->get_prop( 'last_name', $context );
866
+	public function get_last_name($context = 'view') {
867
+		return $this->get_prop('last_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 string
876 876
 	 */
877
-	public function get_user_last_name( $context = 'view' ) {
878
-		return $this->get_last_name( $context );
877
+	public function get_user_last_name($context = 'view') {
878
+		return $this->get_last_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_customer_last_name( $context = 'view' ) {
889
-		return $this->get_last_name( $context );
888
+	public function get_customer_last_name($context = 'view') {
889
+		return $this->get_last_name($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 string
898 898
 	 */
899
-	public function get_full_name( $context = 'view' ) {
900
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
899
+	public function get_full_name($context = 'view') {
900
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($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 string
909 909
 	 */
910
-	public function get_user_full_name( $context = 'view' ) {
911
-		return $this->get_full_name( $context );
910
+	public function get_user_full_name($context = 'view') {
911
+		return $this->get_full_name($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 string
920 920
 	 */
921
-	public function get_customer_full_name( $context = 'view' ) {
922
-		return $this->get_full_name( $context );
921
+	public function get_customer_full_name($context = 'view') {
922
+		return $this->get_full_name($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_phone( $context = 'view' ) {
933
-		return $this->get_prop( 'phone', $context );
932
+	public function get_phone($context = 'view') {
933
+		return $this->get_prop('phone', $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_phone_number( $context = 'view' ) {
944
-		return $this->get_phone( $context );
943
+	public function get_phone_number($context = 'view') {
944
+		return $this->get_phone($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 string
953 953
 	 */
954
-	public function get_user_phone( $context = 'view' ) {
955
-		return $this->get_phone( $context );
954
+	public function get_user_phone($context = 'view') {
955
+		return $this->get_phone($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 string
964 964
 	 */
965
-	public function get_customer_phone( $context = 'view' ) {
966
-		return $this->get_phone( $context );
965
+	public function get_customer_phone($context = 'view') {
966
+		return $this->get_phone($context);
967 967
     }
968 968
 
969 969
     /**
@@ -973,8 +973,8 @@  discard block
 block discarded – undo
973 973
 	 * @param  string $context View or edit context.
974 974
 	 * @return string
975 975
 	 */
976
-	public function get_email( $context = 'view' ) {
977
-		return $this->get_prop( 'email', $context );
976
+	public function get_email($context = 'view') {
977
+		return $this->get_prop('email', $context);
978 978
     }
979 979
 
980 980
     /**
@@ -984,8 +984,8 @@  discard block
 block discarded – undo
984 984
 	 * @param  string $context View or edit context.
985 985
 	 * @return string
986 986
 	 */
987
-	public function get_email_address( $context = 'view' ) {
988
-		return $this->get_email( $context );
987
+	public function get_email_address($context = 'view') {
988
+		return $this->get_email($context);
989 989
     }
990 990
 
991 991
     /**
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
 	 * @param  string $context View or edit context.
996 996
 	 * @return string
997 997
 	 */
998
-	public function get_user_email( $context = 'view' ) {
999
-		return $this->get_email( $context );
998
+	public function get_user_email($context = 'view') {
999
+		return $this->get_email($context);
1000 1000
     }
1001 1001
 
1002 1002
     /**
@@ -1006,8 +1006,8 @@  discard block
 block discarded – undo
1006 1006
 	 * @param  string $context View or edit context.
1007 1007
 	 * @return string
1008 1008
 	 */
1009
-	public function get_customer_email( $context = 'view' ) {
1010
-		return $this->get_email( $context );
1009
+	public function get_customer_email($context = 'view') {
1010
+		return $this->get_email($context);
1011 1011
     }
1012 1012
 
1013 1013
     /**
@@ -1017,9 +1017,9 @@  discard block
 block discarded – undo
1017 1017
 	 * @param  string $context View or edit context.
1018 1018
 	 * @return string
1019 1019
 	 */
1020
-	public function get_country( $context = 'view' ) {
1021
-		$country = $this->get_prop( 'country', $context );
1022
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1020
+	public function get_country($context = 'view') {
1021
+		$country = $this->get_prop('country', $context);
1022
+		return empty($country) ? wpinv_get_default_country() : $country;
1023 1023
     }
1024 1024
 
1025 1025
     /**
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
 	 * @param  string $context View or edit context.
1030 1030
 	 * @return string
1031 1031
 	 */
1032
-	public function get_user_country( $context = 'view' ) {
1033
-		return $this->get_country( $context );
1032
+	public function get_user_country($context = 'view') {
1033
+		return $this->get_country($context);
1034 1034
     }
1035 1035
 
1036 1036
     /**
@@ -1040,8 +1040,8 @@  discard block
 block discarded – undo
1040 1040
 	 * @param  string $context View or edit context.
1041 1041
 	 * @return string
1042 1042
 	 */
1043
-	public function get_customer_country( $context = 'view' ) {
1044
-		return $this->get_country( $context );
1043
+	public function get_customer_country($context = 'view') {
1044
+		return $this->get_country($context);
1045 1045
     }
1046 1046
 
1047 1047
     /**
@@ -1051,9 +1051,9 @@  discard block
 block discarded – undo
1051 1051
 	 * @param  string $context View or edit context.
1052 1052
 	 * @return string
1053 1053
 	 */
1054
-	public function get_state( $context = 'view' ) {
1055
-		$state = $this->get_prop( 'state', $context );
1056
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1054
+	public function get_state($context = 'view') {
1055
+		$state = $this->get_prop('state', $context);
1056
+		return empty($state) ? wpinv_get_default_state() : $state;
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_user_state( $context = 'view' ) {
1067
-		return $this->get_state( $context );
1066
+	public function get_user_state($context = 'view') {
1067
+		return $this->get_state($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_customer_state( $context = 'view' ) {
1078
-		return $this->get_state( $context );
1077
+	public function get_customer_state($context = 'view') {
1078
+		return $this->get_state($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_city( $context = 'view' ) {
1089
-		return $this->get_prop( 'city', $context );
1088
+	public function get_city($context = 'view') {
1089
+		return $this->get_prop('city', $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_user_city( $context = 'view' ) {
1100
-		return $this->get_city( $context );
1099
+	public function get_user_city($context = 'view') {
1100
+		return $this->get_city($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_customer_city( $context = 'view' ) {
1111
-		return $this->get_city( $context );
1110
+	public function get_customer_city($context = 'view') {
1111
+		return $this->get_city($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_zip( $context = 'view' ) {
1122
-		return $this->get_prop( 'zip', $context );
1121
+	public function get_zip($context = 'view') {
1122
+		return $this->get_prop('zip', $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_user_zip( $context = 'view' ) {
1133
-		return $this->get_zip( $context );
1132
+	public function get_user_zip($context = 'view') {
1133
+		return $this->get_zip($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_customer_zip( $context = 'view' ) {
1144
-		return $this->get_zip( $context );
1143
+	public function get_customer_zip($context = 'view') {
1144
+		return $this->get_zip($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_company( $context = 'view' ) {
1155
-		return $this->get_prop( 'company', $context );
1154
+	public function get_company($context = 'view') {
1155
+		return $this->get_prop('company', $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_user_company( $context = 'view' ) {
1166
-		return $this->get_company( $context );
1165
+	public function get_user_company($context = 'view') {
1166
+		return $this->get_company($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_customer_company( $context = 'view' ) {
1177
-		return $this->get_company( $context );
1176
+	public function get_customer_company($context = 'view') {
1177
+		return $this->get_company($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_vat_number( $context = 'view' ) {
1188
-		return $this->get_prop( 'vat_number', $context );
1187
+	public function get_vat_number($context = 'view') {
1188
+		return $this->get_prop('vat_number', $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_user_vat_number( $context = 'view' ) {
1199
-		return $this->get_vat_number( $context );
1198
+	public function get_user_vat_number($context = 'view') {
1199
+		return $this->get_vat_number($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_customer_vat_number( $context = 'view' ) {
1210
-		return $this->get_vat_number( $context );
1209
+	public function get_customer_vat_number($context = 'view') {
1210
+		return $this->get_vat_number($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_vat_rate( $context = 'view' ) {
1221
-		return $this->get_prop( 'vat_rate', $context );
1220
+	public function get_vat_rate($context = 'view') {
1221
+		return $this->get_prop('vat_rate', $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_user_vat_rate( $context = 'view' ) {
1232
-		return $this->get_vat_rate( $context );
1231
+	public function get_user_vat_rate($context = 'view') {
1232
+		return $this->get_vat_rate($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 string
1241 1241
 	 */
1242
-	public function get_customer_vat_rate( $context = 'view' ) {
1243
-		return $this->get_vat_rate( $context );
1242
+	public function get_customer_vat_rate($context = 'view') {
1243
+		return $this->get_vat_rate($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 string
1252 1252
 	 */
1253
-	public function get_address( $context = 'view' ) {
1254
-		return $this->get_prop( 'address', $context );
1253
+	public function get_address($context = 'view') {
1254
+		return $this->get_prop('address', $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 string
1263 1263
 	 */
1264
-	public function get_user_address( $context = 'view' ) {
1265
-		return $this->get_address( $context );
1264
+	public function get_user_address($context = 'view') {
1265
+		return $this->get_address($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 string
1274 1274
 	 */
1275
-	public function get_customer_address( $context = 'view' ) {
1276
-		return $this->get_address( $context );
1275
+	public function get_customer_address($context = 'view') {
1276
+		return $this->get_address($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_is_viewed( $context = 'view' ) {
1287
-		return (bool) $this->get_prop( 'is_viewed', $context );
1286
+	public function get_is_viewed($context = 'view') {
1287
+		return (bool) $this->get_prop('is_viewed', $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_email_cc( $context = 'view' ) {
1298
-		return $this->get_prop( 'email_cc', $context );
1297
+	public function get_email_cc($context = 'view') {
1298
+		return $this->get_prop('email_cc', $context);
1299 1299
 	}
1300 1300
 
1301 1301
 	/**
@@ -1305,8 +1305,8 @@  discard block
 block discarded – undo
1305 1305
 	 * @param  string $context View or edit context.
1306 1306
 	 * @return bool
1307 1307
 	 */
1308
-	public function get_template( $context = 'view' ) {
1309
-		return $this->get_prop( 'template', $context );
1308
+	public function get_template($context = 'view') {
1309
+		return $this->get_prop('template', $context);
1310 1310
 	}
1311 1311
 
1312 1312
 	/**
@@ -1316,8 +1316,8 @@  discard block
 block discarded – undo
1316 1316
 	 * @param  string $context View or edit context.
1317 1317
 	 * @return bool
1318 1318
 	 */
1319
-	public function get_created_via( $context = 'view' ) {
1320
-		return $this->get_prop( 'created_via', $context );
1319
+	public function get_created_via($context = 'view') {
1320
+		return $this->get_prop('created_via', $context);
1321 1321
 	}
1322 1322
 
1323 1323
 	/**
@@ -1327,8 +1327,8 @@  discard block
 block discarded – undo
1327 1327
 	 * @param  string $context View or edit context.
1328 1328
 	 * @return bool
1329 1329
 	 */
1330
-	public function get_address_confirmed( $context = 'view' ) {
1331
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1330
+	public function get_address_confirmed($context = 'view') {
1331
+		return (bool) $this->get_prop('address_confirmed', $context);
1332 1332
     }
1333 1333
 
1334 1334
     /**
@@ -1338,8 +1338,8 @@  discard block
 block discarded – undo
1338 1338
 	 * @param  string $context View or edit context.
1339 1339
 	 * @return bool
1340 1340
 	 */
1341
-	public function get_user_address_confirmed( $context = 'view' ) {
1342
-		return $this->get_address_confirmed( $context );
1341
+	public function get_user_address_confirmed($context = 'view') {
1342
+		return $this->get_address_confirmed($context);
1343 1343
     }
1344 1344
 
1345 1345
     /**
@@ -1349,8 +1349,8 @@  discard block
 block discarded – undo
1349 1349
 	 * @param  string $context View or edit context.
1350 1350
 	 * @return bool
1351 1351
 	 */
1352
-	public function get_customer_address_confirmed( $context = 'view' ) {
1353
-		return $this->get_address_confirmed( $context );
1352
+	public function get_customer_address_confirmed($context = 'view') {
1353
+		return $this->get_address_confirmed($context);
1354 1354
     }
1355 1355
 
1356 1356
     /**
@@ -1360,12 +1360,12 @@  discard block
 block discarded – undo
1360 1360
 	 * @param  string $context View or edit context.
1361 1361
 	 * @return float
1362 1362
 	 */
1363
-	public function get_subtotal( $context = 'view' ) {
1364
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1363
+	public function get_subtotal($context = 'view') {
1364
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1365 1365
 
1366 1366
         // Backwards compatibility.
1367
-        if ( is_bool( $context ) && $context ) {
1368
-            return wpinv_price( $subtotal, $this->get_currency() );
1367
+        if (is_bool($context) && $context) {
1368
+            return wpinv_price($subtotal, $this->get_currency());
1369 1369
         }
1370 1370
 
1371 1371
         return $subtotal;
@@ -1378,8 +1378,8 @@  discard block
 block discarded – undo
1378 1378
 	 * @param  string $context View or edit context.
1379 1379
 	 * @return float
1380 1380
 	 */
1381
-	public function get_total_discount( $context = 'view' ) {
1382
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1381
+	public function get_total_discount($context = 'view') {
1382
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context)));
1383 1383
     }
1384 1384
 
1385 1385
     /**
@@ -1389,18 +1389,18 @@  discard block
 block discarded – undo
1389 1389
 	 * @param  string $context View or edit context.
1390 1390
 	 * @return float
1391 1391
 	 */
1392
-	public function get_total_tax( $context = 'view' ) {
1393
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1392
+	public function get_total_tax($context = 'view') {
1393
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context)));
1394 1394
 	}
1395 1395
 
1396 1396
 	/**
1397 1397
 	 * @deprecated
1398 1398
 	 */
1399
-	public function get_final_tax( $currency = false ) {
1399
+	public function get_final_tax($currency = false) {
1400 1400
 		$tax = $this->get_total_tax();
1401 1401
 
1402
-        if ( $currency ) {
1403
-			return wpinv_price( $tax, $this->get_currency() );
1402
+        if ($currency) {
1403
+			return wpinv_price($tax, $this->get_currency());
1404 1404
         }
1405 1405
 
1406 1406
         return $tax;
@@ -1413,8 +1413,8 @@  discard block
 block discarded – undo
1413 1413
 	 * @param  string $context View or edit context.
1414 1414
 	 * @return float
1415 1415
 	 */
1416
-	public function get_total_fees( $context = 'view' ) {
1417
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1416
+	public function get_total_fees($context = 'view') {
1417
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context)));
1418 1418
     }
1419 1419
 
1420 1420
     /**
@@ -1424,8 +1424,8 @@  discard block
 block discarded – undo
1424 1424
 	 * @param  string $context View or edit context.
1425 1425
 	 * @return float
1426 1426
 	 */
1427
-	public function get_fees_total( $context = 'view' ) {
1428
-		return $this->get_total_fees( $context );
1427
+	public function get_fees_total($context = 'view') {
1428
+		return $this->get_total_fees($context);
1429 1429
     }
1430 1430
 
1431 1431
     /**
@@ -1434,8 +1434,8 @@  discard block
 block discarded – undo
1434 1434
 	 * @since 1.0.19
1435 1435
      * @return float
1436 1436
 	 */
1437
-	public function get_total( $context = 'view' ) {
1438
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) );
1437
+	public function get_total($context = 'view') {
1438
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total', $context)));
1439 1439
 	}
1440 1440
 
1441 1441
 	/**
@@ -1447,20 +1447,20 @@  discard block
 block discarded – undo
1447 1447
 	public function get_non_recurring_total() {
1448 1448
 
1449 1449
 		$subtotal = 0;
1450
-		foreach ( $this->get_items() as $item ) {
1451
-			if ( ! $item->is_recurring() ) {
1450
+		foreach ($this->get_items() as $item) {
1451
+			if (!$item->is_recurring()) {
1452 1452
 				$subtotal += $item->get_sub_total();
1453 1453
 			}
1454 1454
 		}
1455 1455
 
1456
-		foreach ( $this->get_fees() as $fee ) {
1457
-			if ( empty( $fee['recurring_fee'] ) ) {
1458
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1456
+		foreach ($this->get_fees() as $fee) {
1457
+			if (empty($fee['recurring_fee'])) {
1458
+				$subtotal += wpinv_sanitize_amount($fee['initial_fee']);
1459 1459
 			}
1460 1460
 		}
1461 1461
 
1462
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1463
-        return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1462
+		$subtotal = wpinv_round_amount(wpinv_sanitize_amount($subtotal));
1463
+        return apply_filters('wpinv_get_non_recurring_invoice_total', $subtotal, $this);
1464 1464
 
1465 1465
     }
1466 1466
 
@@ -1483,7 +1483,7 @@  discard block
 block discarded – undo
1483 1483
 	 */
1484 1484
     public function get_initial_total() {
1485 1485
 
1486
-		if ( empty( $this->totals ) ) {
1486
+		if (empty($this->totals)) {
1487 1487
 			$this->recalculate_total();
1488 1488
 		}
1489 1489
 
@@ -1493,12 +1493,12 @@  discard block
 block discarded – undo
1493 1493
 		$subtotal = $this->totals['subtotal']['initial'];
1494 1494
 		$total    = $tax + $fee - $discount + $subtotal;
1495 1495
 
1496
-		if ( 0 > $total ) {
1496
+		if (0 > $total) {
1497 1497
 			$total = 0;
1498 1498
 		}
1499 1499
 
1500
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1501
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1500
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1501
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1502 1502
 	}
1503 1503
 
1504 1504
 	/**
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
 	 */
1511 1511
     public function get_recurring_total() {
1512 1512
 
1513
-		if ( empty( $this->totals ) ) {
1513
+		if (empty($this->totals)) {
1514 1514
 			$this->recalculate_total();
1515 1515
 		}
1516 1516
 
@@ -1520,12 +1520,12 @@  discard block
 block discarded – undo
1520 1520
 		$subtotal = $this->totals['subtotal']['recurring'];
1521 1521
 		$total    = $tax + $fee - $discount + $subtotal;
1522 1522
 
1523
-		if ( 0 > $total ) {
1523
+		if (0 > $total) {
1524 1524
 			$total = 0;
1525 1525
 		}
1526 1526
 
1527
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1528
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1527
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1528
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1529 1529
 	}
1530 1530
 
1531 1531
 	/**
@@ -1536,10 +1536,10 @@  discard block
 block discarded – undo
1536 1536
 	 * @param string $currency Whether to include the currency.
1537 1537
      * @return float|string
1538 1538
 	 */
1539
-    public function get_recurring_details( $field = '', $currency = false ) {
1539
+    public function get_recurring_details($field = '', $currency = false) {
1540 1540
 
1541 1541
 		// Maybe recalculate totals.
1542
-		if ( empty( $this->totals ) ) {
1542
+		if (empty($this->totals)) {
1543 1543
 			$this->recalculate_total();
1544 1544
 		}
1545 1545
 
@@ -1559,8 +1559,8 @@  discard block
 block discarded – undo
1559 1559
 			$currency
1560 1560
 		);
1561 1561
 
1562
-        if ( isset( $data[$field] ) ) {
1563
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1562
+        if (isset($data[$field])) {
1563
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1564 1564
         }
1565 1565
 
1566 1566
         return $data;
@@ -1573,8 +1573,8 @@  discard block
 block discarded – undo
1573 1573
 	 * @param  string $context View or edit context.
1574 1574
 	 * @return array
1575 1575
 	 */
1576
-	public function get_fees( $context = 'view' ) {
1577
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1576
+	public function get_fees($context = 'view') {
1577
+		return wpinv_parse_list($this->get_prop('fees', $context));
1578 1578
     }
1579 1579
 
1580 1580
     /**
@@ -1584,8 +1584,8 @@  discard block
 block discarded – undo
1584 1584
 	 * @param  string $context View or edit context.
1585 1585
 	 * @return array
1586 1586
 	 */
1587
-	public function get_discounts( $context = 'view' ) {
1588
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1587
+	public function get_discounts($context = 'view') {
1588
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1589 1589
     }
1590 1590
 
1591 1591
     /**
@@ -1595,8 +1595,8 @@  discard block
 block discarded – undo
1595 1595
 	 * @param  string $context View or edit context.
1596 1596
 	 * @return array
1597 1597
 	 */
1598
-	public function get_taxes( $context = 'view' ) {
1599
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1598
+	public function get_taxes($context = 'view') {
1599
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1600 1600
     }
1601 1601
 
1602 1602
     /**
@@ -1606,8 +1606,8 @@  discard block
 block discarded – undo
1606 1606
 	 * @param  string $context View or edit context.
1607 1607
 	 * @return GetPaid_Form_Item[]
1608 1608
 	 */
1609
-	public function get_items( $context = 'view' ) {
1610
-        return $this->get_prop( 'items', $context );
1609
+	public function get_items($context = 'view') {
1610
+        return $this->get_prop('items', $context);
1611 1611
 	}
1612 1612
 
1613 1613
 	/**
@@ -1617,7 +1617,7 @@  discard block
 block discarded – undo
1617 1617
 	 * @return string
1618 1618
 	 */
1619 1619
 	public function get_item_ids() {
1620
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1620
+		return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id'));
1621 1621
     }
1622 1622
 
1623 1623
     /**
@@ -1627,8 +1627,8 @@  discard block
 block discarded – undo
1627 1627
 	 * @param  string $context View or edit context.
1628 1628
 	 * @return int
1629 1629
 	 */
1630
-	public function get_payment_form( $context = 'view' ) {
1631
-		return intval( $this->get_prop( 'payment_form', $context ) );
1630
+	public function get_payment_form($context = 'view') {
1631
+		return intval($this->get_prop('payment_form', $context));
1632 1632
     }
1633 1633
 
1634 1634
     /**
@@ -1638,8 +1638,8 @@  discard block
 block discarded – undo
1638 1638
 	 * @param  string $context View or edit context.
1639 1639
 	 * @return string
1640 1640
 	 */
1641
-	public function get_submission_id( $context = 'view' ) {
1642
-		return $this->get_prop( 'submission_id', $context );
1641
+	public function get_submission_id($context = 'view') {
1642
+		return $this->get_prop('submission_id', $context);
1643 1643
     }
1644 1644
 
1645 1645
     /**
@@ -1649,8 +1649,8 @@  discard block
 block discarded – undo
1649 1649
 	 * @param  string $context View or edit context.
1650 1650
 	 * @return string
1651 1651
 	 */
1652
-	public function get_discount_code( $context = 'view' ) {
1653
-		return $this->get_prop( 'discount_code', $context );
1652
+	public function get_discount_code($context = 'view') {
1653
+		return $this->get_prop('discount_code', $context);
1654 1654
     }
1655 1655
 
1656 1656
     /**
@@ -1660,8 +1660,8 @@  discard block
 block discarded – undo
1660 1660
 	 * @param  string $context View or edit context.
1661 1661
 	 * @return string
1662 1662
 	 */
1663
-	public function get_gateway( $context = 'view' ) {
1664
-		return $this->get_prop( 'gateway', $context );
1663
+	public function get_gateway($context = 'view') {
1664
+		return $this->get_prop('gateway', $context);
1665 1665
     }
1666 1666
 
1667 1667
     /**
@@ -1671,8 +1671,8 @@  discard block
 block discarded – undo
1671 1671
 	 * @return string
1672 1672
 	 */
1673 1673
     public function get_gateway_title() {
1674
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1675
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1674
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1675
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1676 1676
     }
1677 1677
 
1678 1678
     /**
@@ -1682,8 +1682,8 @@  discard block
 block discarded – undo
1682 1682
 	 * @param  string $context View or edit context.
1683 1683
 	 * @return string
1684 1684
 	 */
1685
-	public function get_transaction_id( $context = 'view' ) {
1686
-		return $this->get_prop( 'transaction_id', $context );
1685
+	public function get_transaction_id($context = 'view') {
1686
+		return $this->get_prop('transaction_id', $context);
1687 1687
     }
1688 1688
 
1689 1689
     /**
@@ -1693,9 +1693,9 @@  discard block
 block discarded – undo
1693 1693
 	 * @param  string $context View or edit context.
1694 1694
 	 * @return string
1695 1695
 	 */
1696
-	public function get_currency( $context = 'view' ) {
1697
-        $currency = $this->get_prop( 'currency', $context );
1698
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1696
+	public function get_currency($context = 'view') {
1697
+        $currency = $this->get_prop('currency', $context);
1698
+        return empty($currency) ? wpinv_get_currency() : $currency;
1699 1699
     }
1700 1700
 
1701 1701
     /**
@@ -1705,8 +1705,8 @@  discard block
 block discarded – undo
1705 1705
 	 * @param  string $context View or edit context.
1706 1706
 	 * @return bool
1707 1707
 	 */
1708
-	public function get_disable_taxes( $context = 'view' ) {
1709
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1708
+	public function get_disable_taxes($context = 'view') {
1709
+        return (bool) $this->get_prop('disable_taxes', $context);
1710 1710
     }
1711 1711
 
1712 1712
     /**
@@ -1716,8 +1716,8 @@  discard block
 block discarded – undo
1716 1716
 	 * @param  string $context View or edit context.
1717 1717
 	 * @return int
1718 1718
 	 */
1719
-    public function get_subscription_id( $context = 'view' ) {
1720
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1719
+    public function get_subscription_id($context = 'view') {
1720
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1721 1721
 	}
1722 1722
 
1723 1723
 	/**
@@ -1727,12 +1727,12 @@  discard block
 block discarded – undo
1727 1727
 	 * @param  string $context View or edit context.
1728 1728
 	 * @return int
1729 1729
 	 */
1730
-    public function get_remote_subscription_id( $context = 'view' ) {
1731
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1730
+    public function get_remote_subscription_id($context = 'view') {
1731
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1732 1732
 
1733
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1733
+        if (empty($subscription_id) && $this->is_renewal()) {
1734 1734
             $parent = $this->get_parent();
1735
-            return $parent->get_remote_subscription_id( $context );
1735
+            return $parent->get_remote_subscription_id($context);
1736 1736
         }
1737 1737
 
1738 1738
         return $subscription_id;
@@ -1745,20 +1745,20 @@  discard block
 block discarded – undo
1745 1745
 	 * @param  string $context View or edit context.
1746 1746
 	 * @return array
1747 1747
 	 */
1748
-    public function get_payment_meta( $context = 'view' ) {
1748
+    public function get_payment_meta($context = 'view') {
1749 1749
 
1750 1750
         return array(
1751
-            'price'        => $this->get_total( $context ),
1752
-            'date'         => $this->get_date_created( $context ),
1753
-            'user_email'   => $this->get_email( $context ),
1754
-            'invoice_key'  => $this->get_key( $context ),
1755
-            'currency'     => $this->get_currency( $context ),
1756
-            'items'        => $this->get_items( $context ),
1757
-            'user_info'    => $this->get_user_info( $context ),
1751
+            'price'        => $this->get_total($context),
1752
+            'date'         => $this->get_date_created($context),
1753
+            'user_email'   => $this->get_email($context),
1754
+            'invoice_key'  => $this->get_key($context),
1755
+            'currency'     => $this->get_currency($context),
1756
+            'items'        => $this->get_items($context),
1757
+            'user_info'    => $this->get_user_info($context),
1758 1758
             'cart_details' => $this->get_cart_details(),
1759
-            'status'       => $this->get_status( $context ),
1760
-            'fees'         => $this->get_fees( $context ),
1761
-            'taxes'        => $this->get_taxes( $context ),
1759
+            'status'       => $this->get_status($context),
1760
+            'fees'         => $this->get_fees($context),
1761
+            'taxes'        => $this->get_taxes($context),
1762 1762
         );
1763 1763
 
1764 1764
     }
@@ -1773,9 +1773,9 @@  discard block
 block discarded – undo
1773 1773
         $items        = $this->get_items();
1774 1774
         $cart_details = array();
1775 1775
 
1776
-        foreach ( $items as $item ) {
1776
+        foreach ($items as $item) {
1777 1777
 			$item->invoice_id = $this->get_id();
1778
-            $cart_details[]   = $item->prepare_data_for_saving();
1778
+            $cart_details[] = $item->prepare_data_for_saving();
1779 1779
         }
1780 1780
 
1781 1781
         return $cart_details;
@@ -1786,11 +1786,11 @@  discard block
 block discarded – undo
1786 1786
 	 *
1787 1787
 	 * @return null|GetPaid_Form_Item|int
1788 1788
 	 */
1789
-	public function get_recurring( $object = false ) {
1789
+	public function get_recurring($object = false) {
1790 1790
 
1791 1791
 		// Are we returning an object?
1792
-        if ( $object ) {
1793
-            return $this->get_item( $this->recurring_item );
1792
+        if ($object) {
1793
+            return $this->get_item($this->recurring_item);
1794 1794
         }
1795 1795
 
1796 1796
         return $this->recurring_item;
@@ -1805,15 +1805,15 @@  discard block
 block discarded – undo
1805 1805
 	public function get_subscription_name() {
1806 1806
 
1807 1807
 		// Retrieve the recurring name
1808
-        $item = $this->get_recurring( true );
1808
+        $item = $this->get_recurring(true);
1809 1809
 
1810 1810
 		// Abort if it does not exist.
1811
-        if ( empty( $item ) ) {
1811
+        if (empty($item)) {
1812 1812
             return '';
1813 1813
         }
1814 1814
 
1815 1815
 		// Return the item name.
1816
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1816
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1817 1817
 	}
1818 1818
 
1819 1819
 	/**
@@ -1823,9 +1823,9 @@  discard block
 block discarded – undo
1823 1823
 	 * @return string
1824 1824
 	 */
1825 1825
 	public function get_view_url() {
1826
-        $invoice_url = get_permalink( $this->get_id() );
1827
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1828
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1826
+        $invoice_url = get_permalink($this->get_id());
1827
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1828
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1829 1829
 	}
1830 1830
 
1831 1831
 	/**
@@ -1834,25 +1834,25 @@  discard block
 block discarded – undo
1834 1834
 	 * @since 1.0.19
1835 1835
 	 * @return string
1836 1836
 	 */
1837
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1837
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1838 1838
 
1839 1839
 		// Retrieve the checkout url.
1840 1840
         $pay_url = wpinv_get_checkout_uri();
1841 1841
 
1842 1842
 		// Maybe force ssl.
1843
-        if ( is_ssl() ) {
1844
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1843
+        if (is_ssl()) {
1844
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1845 1845
         }
1846 1846
 
1847 1847
 		// Add the invoice key.
1848
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1848
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1849 1849
 
1850 1850
 		// (Maybe?) add a secret
1851
-        if ( $secret ) {
1852
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1851
+        if ($secret) {
1852
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1853 1853
         }
1854 1854
 
1855
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1855
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1856 1856
 	}
1857 1857
 	
1858 1858
 	/**
@@ -1867,14 +1867,14 @@  discard block
 block discarded – undo
1867 1867
         $receipt_url = wpinv_get_success_page_uri();
1868 1868
 
1869 1869
 		// Maybe force ssl.
1870
-        if ( is_ssl() ) {
1871
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1870
+        if (is_ssl()) {
1871
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1872 1872
         }
1873 1873
 
1874 1874
 		// Add the invoice key.
1875
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1875
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1876 1876
 
1877
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1877
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1878 1878
 	}
1879 1879
 	
1880 1880
 	/**
@@ -1887,7 +1887,7 @@  discard block
 block discarded – undo
1887 1887
 
1888 1888
 		$type   = $this->get_type();
1889 1889
 		$status = "wpi-$type-pending";
1890
-		return str_replace( '-invoice', '', $status );
1890
+		return str_replace('-invoice', '', $status);
1891 1891
 
1892 1892
 	}
1893 1893
 
@@ -1901,8 +1901,8 @@  discard block
 block discarded – undo
1901 1901
 	 * @param  string $context View or edit context.
1902 1902
 	 * @return mixed Value of the given invoice property (if set).
1903 1903
 	 */
1904
-	public function get( $key, $context = 'view' ) {
1905
-        return $this->get_prop( $key, $context );
1904
+	public function get($key, $context = 'view') {
1905
+        return $this->get_prop($key, $context);
1906 1906
 	}
1907 1907
 
1908 1908
     /*
@@ -1925,11 +1925,11 @@  discard block
 block discarded – undo
1925 1925
 	 * @param  mixed $value new value.
1926 1926
 	 * @return mixed Value of the given invoice property (if set).
1927 1927
 	 */
1928
-	public function set( $key, $value ) {
1928
+	public function set($key, $value) {
1929 1929
 
1930 1930
         $setter = "set_$key";
1931
-        if ( is_callable( array( $this, $setter ) ) ) {
1932
-            $this->{$setter}( $value );
1931
+        if (is_callable(array($this, $setter))) {
1932
+            $this->{$setter}($value);
1933 1933
         }
1934 1934
 
1935 1935
 	}
@@ -1943,45 +1943,45 @@  discard block
 block discarded – undo
1943 1943
 	 * @param bool   $manual_update Is this a manual status change?.
1944 1944
 	 * @return array details of change.
1945 1945
 	 */
1946
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1946
+	public function set_status($new_status, $note = '', $manual_update = false) {
1947 1947
 		$old_status = $this->get_status();
1948 1948
 
1949 1949
 		$statuses = $this->get_all_statuses();
1950 1950
 
1951
-		if ( isset( $statuses[ 'draft' ] ) ) {
1952
-			unset( $statuses[ 'draft' ] );
1951
+		if (isset($statuses['draft'])) {
1952
+			unset($statuses['draft']);
1953 1953
 		}
1954 1954
 
1955
-		$this->set_prop( 'status', $new_status );
1955
+		$this->set_prop('status', $new_status);
1956 1956
 
1957 1957
 		// If setting the status, ensure it's set to a valid status.
1958
-		if ( true === $this->object_read ) {
1958
+		if (true === $this->object_read) {
1959 1959
 
1960 1960
 			// Only allow valid new status.
1961
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1961
+			if (!array_key_exists($new_status, $statuses)) {
1962 1962
 				$new_status = $this->get_default_status();
1963 1963
 			}
1964 1964
 
1965 1965
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1966
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1966
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1967 1967
 				$old_status = $this->get_default_status();
1968 1968
 			}
1969 1969
 
1970 1970
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1971
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1971
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
1972 1972
 				$old_status = 'wpi-pending';
1973 1973
 			}
1974 1974
 
1975
-			if ( $old_status !== $new_status ) {
1975
+			if ($old_status !== $new_status) {
1976 1976
 				$this->status_transition = array(
1977
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1977
+					'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1978 1978
 					'to'     => $new_status,
1979 1979
 					'note'   => $note,
1980 1980
 					'manual' => (bool) $manual_update,
1981 1981
 				);
1982 1982
 
1983
-				if ( $manual_update ) {
1984
-					do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1983
+				if ($manual_update) {
1984
+					do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1985 1985
 				}
1986 1986
 
1987 1987
 				$this->maybe_set_date_paid();
@@ -2006,8 +2006,8 @@  discard block
 block discarded – undo
2006 2006
 	 */
2007 2007
 	public function maybe_set_date_paid() {
2008 2008
 
2009
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2010
-			$this->set_date_completed( current_time( 'mysql' ) );
2009
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
2010
+			$this->set_date_completed(current_time('mysql'));
2011 2011
 		}
2012 2012
 	}
2013 2013
 
@@ -2016,11 +2016,11 @@  discard block
 block discarded – undo
2016 2016
 	 *
2017 2017
 	 * @since 1.0.19
2018 2018
 	 */
2019
-	public function set_parent_id( $value ) {
2020
-		if ( $value && ( $value === $this->get_id() ) ) {
2019
+	public function set_parent_id($value) {
2020
+		if ($value && ($value === $this->get_id())) {
2021 2021
 			return;
2022 2022
 		}
2023
-		$this->set_prop( 'parent_id', absint( $value ) );
2023
+		$this->set_prop('parent_id', absint($value));
2024 2024
     }
2025 2025
 
2026 2026
     /**
@@ -2028,8 +2028,8 @@  discard block
 block discarded – undo
2028 2028
 	 *
2029 2029
 	 * @since 1.0.19
2030 2030
 	 */
2031
-	public function set_version( $value ) {
2032
-		$this->set_prop( 'version', $value );
2031
+	public function set_version($value) {
2032
+		$this->set_prop('version', $value);
2033 2033
     }
2034 2034
 
2035 2035
     /**
@@ -2039,15 +2039,15 @@  discard block
 block discarded – undo
2039 2039
 	 * @param string $value Value to set.
2040 2040
      * @return bool Whether or not the date was set.
2041 2041
 	 */
2042
-	public function set_date_created( $value ) {
2043
-        $date = strtotime( $value );
2042
+	public function set_date_created($value) {
2043
+        $date = strtotime($value);
2044 2044
 
2045
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2046
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
2045
+        if ($date && $value !== '0000-00-00 00:00:00') {
2046
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
2047 2047
             return true;
2048 2048
         }
2049 2049
 
2050
-		$this->set_prop( 'date_created', '' );
2050
+		$this->set_prop('date_created', '');
2051 2051
 		return false;
2052 2052
 
2053 2053
     }
@@ -2059,15 +2059,15 @@  discard block
 block discarded – undo
2059 2059
 	 * @param string $value Value to set.
2060 2060
      * @return bool Whether or not the date was set.
2061 2061
 	 */
2062
-	public function set_due_date( $value ) {
2063
-        $date = strtotime( $value );
2062
+	public function set_due_date($value) {
2063
+        $date = strtotime($value);
2064 2064
 
2065
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2066
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
2065
+        if ($date && $value !== '0000-00-00 00:00:00') {
2066
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
2067 2067
             return true;
2068 2068
         }
2069 2069
 
2070
-		$this->set_prop( 'due_date', '' );
2070
+		$this->set_prop('due_date', '');
2071 2071
         return false;
2072 2072
 
2073 2073
     }
@@ -2078,8 +2078,8 @@  discard block
 block discarded – undo
2078 2078
 	 * @since 1.0.19
2079 2079
 	 * @param  string $value New name.
2080 2080
 	 */
2081
-	public function set_date_due( $value ) {
2082
-		$this->set_due_date( $value );
2081
+	public function set_date_due($value) {
2082
+		$this->set_due_date($value);
2083 2083
     }
2084 2084
 
2085 2085
     /**
@@ -2089,15 +2089,15 @@  discard block
 block discarded – undo
2089 2089
 	 * @param string $value Value to set.
2090 2090
      * @return bool Whether or not the date was set.
2091 2091
 	 */
2092
-	public function set_completed_date( $value ) {
2093
-        $date = strtotime( $value );
2092
+	public function set_completed_date($value) {
2093
+        $date = strtotime($value);
2094 2094
 
2095
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
2096
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2095
+        if ($date && $value !== '0000-00-00 00:00:00') {
2096
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2097 2097
             return true;
2098 2098
         }
2099 2099
 
2100
-		$this->set_prop( 'completed_date', '' );
2100
+		$this->set_prop('completed_date', '');
2101 2101
         return false;
2102 2102
 
2103 2103
     }
@@ -2108,8 +2108,8 @@  discard block
 block discarded – undo
2108 2108
 	 * @since 1.0.19
2109 2109
 	 * @param  string $value New name.
2110 2110
 	 */
2111
-	public function set_date_completed( $value ) {
2112
-		$this->set_completed_date( $value );
2111
+	public function set_date_completed($value) {
2112
+		$this->set_completed_date($value);
2113 2113
     }
2114 2114
 
2115 2115
     /**
@@ -2119,15 +2119,15 @@  discard block
 block discarded – undo
2119 2119
 	 * @param string $value Value to set.
2120 2120
      * @return bool Whether or not the date was set.
2121 2121
 	 */
2122
-	public function set_date_modified( $value ) {
2123
-        $date = strtotime( $value );
2122
+	public function set_date_modified($value) {
2123
+        $date = strtotime($value);
2124 2124
 
2125
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2126
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2125
+        if ($date && $value !== '0000-00-00 00:00:00') {
2126
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2127 2127
             return true;
2128 2128
         }
2129 2129
 
2130
-		$this->set_prop( 'date_modified', '' );
2130
+		$this->set_prop('date_modified', '');
2131 2131
         return false;
2132 2132
 
2133 2133
     }
@@ -2138,9 +2138,9 @@  discard block
 block discarded – undo
2138 2138
 	 * @since 1.0.19
2139 2139
 	 * @param  string $value New number.
2140 2140
 	 */
2141
-	public function set_number( $value ) {
2142
-        $number = sanitize_text_field( $value );
2143
-		$this->set_prop( 'number', $number );
2141
+	public function set_number($value) {
2142
+        $number = sanitize_text_field($value);
2143
+		$this->set_prop('number', $number);
2144 2144
     }
2145 2145
 
2146 2146
     /**
@@ -2149,9 +2149,9 @@  discard block
 block discarded – undo
2149 2149
 	 * @since 1.0.19
2150 2150
 	 * @param  string $value Type.
2151 2151
 	 */
2152
-	public function set_type( $value ) {
2153
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2154
-		$this->set_prop( 'type', $type );
2152
+	public function set_type($value) {
2153
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2154
+		$this->set_prop('type', $type);
2155 2155
 	}
2156 2156
 
2157 2157
     /**
@@ -2160,10 +2160,10 @@  discard block
 block discarded – undo
2160 2160
 	 * @since 1.0.19
2161 2161
 	 * @param  string $value Post type.
2162 2162
 	 */
2163
-	public function set_post_type( $value ) {
2164
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2165
-			$this->set_type( $value );
2166
-            $this->set_prop( 'post_type', $value );
2163
+	public function set_post_type($value) {
2164
+        if (getpaid_is_invoice_post_type($value)) {
2165
+			$this->set_type($value);
2166
+            $this->set_prop('post_type', $value);
2167 2167
         }
2168 2168
     }
2169 2169
 
@@ -2173,9 +2173,9 @@  discard block
 block discarded – undo
2173 2173
 	 * @since 1.0.19
2174 2174
 	 * @param  string $value New key.
2175 2175
 	 */
2176
-	public function set_key( $value ) {
2177
-        $key = sanitize_text_field( $value );
2178
-		$this->set_prop( 'key', $key );
2176
+	public function set_key($value) {
2177
+        $key = sanitize_text_field($value);
2178
+		$this->set_prop('key', $key);
2179 2179
     }
2180 2180
 
2181 2181
     /**
@@ -2184,9 +2184,9 @@  discard block
 block discarded – undo
2184 2184
 	 * @since 1.0.19
2185 2185
 	 * @param  string $value mode.
2186 2186
 	 */
2187
-	public function set_mode( $value ) {
2188
-        if ( in_array( $value, array( 'live', 'test' ) ) ) {
2189
-            $this->set_prop( 'mode', $value );
2187
+	public function set_mode($value) {
2188
+        if (in_array($value, array('live', 'test'))) {
2189
+            $this->set_prop('mode', $value);
2190 2190
         }
2191 2191
     }
2192 2192
 
@@ -2196,8 +2196,8 @@  discard block
 block discarded – undo
2196 2196
 	 * @since 1.0.19
2197 2197
 	 * @param  string $value path.
2198 2198
 	 */
2199
-	public function set_path( $value ) {
2200
-        $this->set_prop( 'path', $value );
2199
+	public function set_path($value) {
2200
+        $this->set_prop('path', $value);
2201 2201
     }
2202 2202
 
2203 2203
     /**
@@ -2206,9 +2206,9 @@  discard block
 block discarded – undo
2206 2206
 	 * @since 1.0.19
2207 2207
 	 * @param  string $value New name.
2208 2208
 	 */
2209
-	public function set_name( $value ) {
2210
-        $name = sanitize_text_field( $value );
2211
-		$this->set_prop( 'name', $name );
2209
+	public function set_name($value) {
2210
+        $name = sanitize_text_field($value);
2211
+		$this->set_prop('name', $name);
2212 2212
     }
2213 2213
 
2214 2214
     /**
@@ -2217,8 +2217,8 @@  discard block
 block discarded – undo
2217 2217
 	 * @since 1.0.19
2218 2218
 	 * @param  string $value New name.
2219 2219
 	 */
2220
-	public function set_title( $value ) {
2221
-		$this->set_name( $value );
2220
+	public function set_title($value) {
2221
+		$this->set_name($value);
2222 2222
     }
2223 2223
 
2224 2224
     /**
@@ -2227,9 +2227,9 @@  discard block
 block discarded – undo
2227 2227
 	 * @since 1.0.19
2228 2228
 	 * @param  string $value New description.
2229 2229
 	 */
2230
-	public function set_description( $value ) {
2231
-        $description = wp_kses_post( $value );
2232
-		$this->set_prop( 'description', $description );
2230
+	public function set_description($value) {
2231
+        $description = wp_kses_post($value);
2232
+		$this->set_prop('description', $description);
2233 2233
     }
2234 2234
 
2235 2235
     /**
@@ -2238,8 +2238,8 @@  discard block
 block discarded – undo
2238 2238
 	 * @since 1.0.19
2239 2239
 	 * @param  string $value New description.
2240 2240
 	 */
2241
-	public function set_excerpt( $value ) {
2242
-		$this->set_description( $value );
2241
+	public function set_excerpt($value) {
2242
+		$this->set_description($value);
2243 2243
     }
2244 2244
 
2245 2245
     /**
@@ -2248,8 +2248,8 @@  discard block
 block discarded – undo
2248 2248
 	 * @since 1.0.19
2249 2249
 	 * @param  string $value New description.
2250 2250
 	 */
2251
-	public function set_summary( $value ) {
2252
-		$this->set_description( $value );
2251
+	public function set_summary($value) {
2252
+		$this->set_description($value);
2253 2253
     }
2254 2254
 
2255 2255
     /**
@@ -2258,12 +2258,12 @@  discard block
 block discarded – undo
2258 2258
 	 * @since 1.0.19
2259 2259
 	 * @param  int $value New author.
2260 2260
 	 */
2261
-	public function set_author( $value ) {
2262
-		$user = get_user_by( 'id', (int) $value );
2261
+	public function set_author($value) {
2262
+		$user = get_user_by('id', (int) $value);
2263 2263
 
2264
-		if ( $user && $user->ID ) {
2265
-			$this->set_prop( 'author', $user->ID );
2266
-			$this->set_prop( 'email', $user->user_email );
2264
+		if ($user && $user->ID) {
2265
+			$this->set_prop('author', $user->ID);
2266
+			$this->set_prop('email', $user->user_email);
2267 2267
 		}
2268 2268
 
2269 2269
     }
@@ -2274,8 +2274,8 @@  discard block
 block discarded – undo
2274 2274
 	 * @since 1.0.19
2275 2275
 	 * @param  int $value New user id.
2276 2276
 	 */
2277
-	public function set_user_id( $value ) {
2278
-		$this->set_author( $value );
2277
+	public function set_user_id($value) {
2278
+		$this->set_author($value);
2279 2279
     }
2280 2280
 
2281 2281
     /**
@@ -2284,8 +2284,8 @@  discard block
 block discarded – undo
2284 2284
 	 * @since 1.0.19
2285 2285
 	 * @param  int $value New user id.
2286 2286
 	 */
2287
-	public function set_customer_id( $value ) {
2288
-		$this->set_author( $value );
2287
+	public function set_customer_id($value) {
2288
+		$this->set_author($value);
2289 2289
     }
2290 2290
 
2291 2291
     /**
@@ -2294,8 +2294,8 @@  discard block
 block discarded – undo
2294 2294
 	 * @since 1.0.19
2295 2295
 	 * @param  string $value ip address.
2296 2296
 	 */
2297
-	public function set_ip( $value ) {
2298
-		$this->set_prop( 'ip', $value );
2297
+	public function set_ip($value) {
2298
+		$this->set_prop('ip', $value);
2299 2299
     }
2300 2300
 
2301 2301
     /**
@@ -2304,8 +2304,8 @@  discard block
 block discarded – undo
2304 2304
 	 * @since 1.0.19
2305 2305
 	 * @param  string $value ip address.
2306 2306
 	 */
2307
-	public function set_user_ip( $value ) {
2308
-		$this->set_ip( $value );
2307
+	public function set_user_ip($value) {
2308
+		$this->set_ip($value);
2309 2309
     }
2310 2310
 
2311 2311
     /**
@@ -2314,8 +2314,8 @@  discard block
 block discarded – undo
2314 2314
 	 * @since 1.0.19
2315 2315
 	 * @param  string $value first name.
2316 2316
 	 */
2317
-	public function set_first_name( $value ) {
2318
-		$this->set_prop( 'first_name', $value );
2317
+	public function set_first_name($value) {
2318
+		$this->set_prop('first_name', $value);
2319 2319
     }
2320 2320
 
2321 2321
     /**
@@ -2324,8 +2324,8 @@  discard block
 block discarded – undo
2324 2324
 	 * @since 1.0.19
2325 2325
 	 * @param  string $value first name.
2326 2326
 	 */
2327
-	public function set_user_first_name( $value ) {
2328
-		$this->set_first_name( $value );
2327
+	public function set_user_first_name($value) {
2328
+		$this->set_first_name($value);
2329 2329
     }
2330 2330
 
2331 2331
     /**
@@ -2334,8 +2334,8 @@  discard block
 block discarded – undo
2334 2334
 	 * @since 1.0.19
2335 2335
 	 * @param  string $value first name.
2336 2336
 	 */
2337
-	public function set_customer_first_name( $value ) {
2338
-		$this->set_first_name( $value );
2337
+	public function set_customer_first_name($value) {
2338
+		$this->set_first_name($value);
2339 2339
     }
2340 2340
 
2341 2341
     /**
@@ -2344,8 +2344,8 @@  discard block
 block discarded – undo
2344 2344
 	 * @since 1.0.19
2345 2345
 	 * @param  string $value last name.
2346 2346
 	 */
2347
-	public function set_last_name( $value ) {
2348
-		$this->set_prop( 'last_name', $value );
2347
+	public function set_last_name($value) {
2348
+		$this->set_prop('last_name', $value);
2349 2349
     }
2350 2350
 
2351 2351
     /**
@@ -2354,8 +2354,8 @@  discard block
 block discarded – undo
2354 2354
 	 * @since 1.0.19
2355 2355
 	 * @param  string $value last name.
2356 2356
 	 */
2357
-	public function set_user_last_name( $value ) {
2358
-		$this->set_last_name( $value );
2357
+	public function set_user_last_name($value) {
2358
+		$this->set_last_name($value);
2359 2359
     }
2360 2360
 
2361 2361
     /**
@@ -2364,8 +2364,8 @@  discard block
 block discarded – undo
2364 2364
 	 * @since 1.0.19
2365 2365
 	 * @param  string $value last name.
2366 2366
 	 */
2367
-	public function set_customer_last_name( $value ) {
2368
-		$this->set_last_name( $value );
2367
+	public function set_customer_last_name($value) {
2368
+		$this->set_last_name($value);
2369 2369
     }
2370 2370
 
2371 2371
     /**
@@ -2374,8 +2374,8 @@  discard block
 block discarded – undo
2374 2374
 	 * @since 1.0.19
2375 2375
 	 * @param  string $value phone.
2376 2376
 	 */
2377
-	public function set_phone( $value ) {
2378
-		$this->set_prop( 'phone', $value );
2377
+	public function set_phone($value) {
2378
+		$this->set_prop('phone', $value);
2379 2379
     }
2380 2380
 
2381 2381
     /**
@@ -2384,8 +2384,8 @@  discard block
 block discarded – undo
2384 2384
 	 * @since 1.0.19
2385 2385
 	 * @param  string $value phone.
2386 2386
 	 */
2387
-	public function set_user_phone( $value ) {
2388
-		$this->set_phone( $value );
2387
+	public function set_user_phone($value) {
2388
+		$this->set_phone($value);
2389 2389
     }
2390 2390
 
2391 2391
     /**
@@ -2394,8 +2394,8 @@  discard block
 block discarded – undo
2394 2394
 	 * @since 1.0.19
2395 2395
 	 * @param  string $value phone.
2396 2396
 	 */
2397
-	public function set_customer_phone( $value ) {
2398
-		$this->set_phone( $value );
2397
+	public function set_customer_phone($value) {
2398
+		$this->set_phone($value);
2399 2399
     }
2400 2400
 
2401 2401
     /**
@@ -2404,8 +2404,8 @@  discard block
 block discarded – undo
2404 2404
 	 * @since 1.0.19
2405 2405
 	 * @param  string $value phone.
2406 2406
 	 */
2407
-	public function set_phone_number( $value ) {
2408
-		$this->set_phone( $value );
2407
+	public function set_phone_number($value) {
2408
+		$this->set_phone($value);
2409 2409
     }
2410 2410
 
2411 2411
     /**
@@ -2414,8 +2414,8 @@  discard block
 block discarded – undo
2414 2414
 	 * @since 1.0.19
2415 2415
 	 * @param  string $value email address.
2416 2416
 	 */
2417
-	public function set_email( $value ) {
2418
-		$this->set_prop( 'email', $value );
2417
+	public function set_email($value) {
2418
+		$this->set_prop('email', $value);
2419 2419
     }
2420 2420
 
2421 2421
     /**
@@ -2424,8 +2424,8 @@  discard block
 block discarded – undo
2424 2424
 	 * @since 1.0.19
2425 2425
 	 * @param  string $value email address.
2426 2426
 	 */
2427
-	public function set_user_email( $value ) {
2428
-		$this->set_email( $value );
2427
+	public function set_user_email($value) {
2428
+		$this->set_email($value);
2429 2429
     }
2430 2430
 
2431 2431
     /**
@@ -2434,8 +2434,8 @@  discard block
 block discarded – undo
2434 2434
 	 * @since 1.0.19
2435 2435
 	 * @param  string $value email address.
2436 2436
 	 */
2437
-	public function set_email_address( $value ) {
2438
-		$this->set_email( $value );
2437
+	public function set_email_address($value) {
2438
+		$this->set_email($value);
2439 2439
     }
2440 2440
 
2441 2441
     /**
@@ -2444,8 +2444,8 @@  discard block
 block discarded – undo
2444 2444
 	 * @since 1.0.19
2445 2445
 	 * @param  string $value email address.
2446 2446
 	 */
2447
-	public function set_customer_email( $value ) {
2448
-		$this->set_email( $value );
2447
+	public function set_customer_email($value) {
2448
+		$this->set_email($value);
2449 2449
     }
2450 2450
 
2451 2451
     /**
@@ -2454,8 +2454,8 @@  discard block
 block discarded – undo
2454 2454
 	 * @since 1.0.19
2455 2455
 	 * @param  string $value country.
2456 2456
 	 */
2457
-	public function set_country( $value ) {
2458
-		$this->set_prop( 'country', $value );
2457
+	public function set_country($value) {
2458
+		$this->set_prop('country', $value);
2459 2459
     }
2460 2460
 
2461 2461
     /**
@@ -2464,8 +2464,8 @@  discard block
 block discarded – undo
2464 2464
 	 * @since 1.0.19
2465 2465
 	 * @param  string $value country.
2466 2466
 	 */
2467
-	public function set_user_country( $value ) {
2468
-		$this->set_country( $value );
2467
+	public function set_user_country($value) {
2468
+		$this->set_country($value);
2469 2469
     }
2470 2470
 
2471 2471
     /**
@@ -2474,8 +2474,8 @@  discard block
 block discarded – undo
2474 2474
 	 * @since 1.0.19
2475 2475
 	 * @param  string $value country.
2476 2476
 	 */
2477
-	public function set_customer_country( $value ) {
2478
-		$this->set_country( $value );
2477
+	public function set_customer_country($value) {
2478
+		$this->set_country($value);
2479 2479
     }
2480 2480
 
2481 2481
     /**
@@ -2484,8 +2484,8 @@  discard block
 block discarded – undo
2484 2484
 	 * @since 1.0.19
2485 2485
 	 * @param  string $value state.
2486 2486
 	 */
2487
-	public function set_state( $value ) {
2488
-		$this->set_prop( 'state', $value );
2487
+	public function set_state($value) {
2488
+		$this->set_prop('state', $value);
2489 2489
     }
2490 2490
 
2491 2491
     /**
@@ -2494,8 +2494,8 @@  discard block
 block discarded – undo
2494 2494
 	 * @since 1.0.19
2495 2495
 	 * @param  string $value state.
2496 2496
 	 */
2497
-	public function set_user_state( $value ) {
2498
-		$this->set_state( $value );
2497
+	public function set_user_state($value) {
2498
+		$this->set_state($value);
2499 2499
     }
2500 2500
 
2501 2501
     /**
@@ -2504,8 +2504,8 @@  discard block
 block discarded – undo
2504 2504
 	 * @since 1.0.19
2505 2505
 	 * @param  string $value state.
2506 2506
 	 */
2507
-	public function set_customer_state( $value ) {
2508
-		$this->set_state( $value );
2507
+	public function set_customer_state($value) {
2508
+		$this->set_state($value);
2509 2509
     }
2510 2510
 
2511 2511
     /**
@@ -2514,8 +2514,8 @@  discard block
 block discarded – undo
2514 2514
 	 * @since 1.0.19
2515 2515
 	 * @param  string $value city.
2516 2516
 	 */
2517
-	public function set_city( $value ) {
2518
-		$this->set_prop( 'city', $value );
2517
+	public function set_city($value) {
2518
+		$this->set_prop('city', $value);
2519 2519
     }
2520 2520
 
2521 2521
     /**
@@ -2524,8 +2524,8 @@  discard block
 block discarded – undo
2524 2524
 	 * @since 1.0.19
2525 2525
 	 * @param  string $value city.
2526 2526
 	 */
2527
-	public function set_user_city( $value ) {
2528
-		$this->set_city( $value );
2527
+	public function set_user_city($value) {
2528
+		$this->set_city($value);
2529 2529
     }
2530 2530
 
2531 2531
     /**
@@ -2534,8 +2534,8 @@  discard block
 block discarded – undo
2534 2534
 	 * @since 1.0.19
2535 2535
 	 * @param  string $value city.
2536 2536
 	 */
2537
-	public function set_customer_city( $value ) {
2538
-		$this->set_city( $value );
2537
+	public function set_customer_city($value) {
2538
+		$this->set_city($value);
2539 2539
     }
2540 2540
 
2541 2541
     /**
@@ -2544,8 +2544,8 @@  discard block
 block discarded – undo
2544 2544
 	 * @since 1.0.19
2545 2545
 	 * @param  string $value zip.
2546 2546
 	 */
2547
-	public function set_zip( $value ) {
2548
-		$this->set_prop( 'zip', $value );
2547
+	public function set_zip($value) {
2548
+		$this->set_prop('zip', $value);
2549 2549
     }
2550 2550
 
2551 2551
     /**
@@ -2554,8 +2554,8 @@  discard block
 block discarded – undo
2554 2554
 	 * @since 1.0.19
2555 2555
 	 * @param  string $value zip.
2556 2556
 	 */
2557
-	public function set_user_zip( $value ) {
2558
-		$this->set_zip( $value );
2557
+	public function set_user_zip($value) {
2558
+		$this->set_zip($value);
2559 2559
     }
2560 2560
 
2561 2561
     /**
@@ -2564,8 +2564,8 @@  discard block
 block discarded – undo
2564 2564
 	 * @since 1.0.19
2565 2565
 	 * @param  string $value zip.
2566 2566
 	 */
2567
-	public function set_customer_zip( $value ) {
2568
-		$this->set_zip( $value );
2567
+	public function set_customer_zip($value) {
2568
+		$this->set_zip($value);
2569 2569
     }
2570 2570
 
2571 2571
     /**
@@ -2574,8 +2574,8 @@  discard block
 block discarded – undo
2574 2574
 	 * @since 1.0.19
2575 2575
 	 * @param  string $value company.
2576 2576
 	 */
2577
-	public function set_company( $value ) {
2578
-		$this->set_prop( 'company', $value );
2577
+	public function set_company($value) {
2578
+		$this->set_prop('company', $value);
2579 2579
     }
2580 2580
 
2581 2581
     /**
@@ -2584,8 +2584,8 @@  discard block
 block discarded – undo
2584 2584
 	 * @since 1.0.19
2585 2585
 	 * @param  string $value company.
2586 2586
 	 */
2587
-	public function set_user_company( $value ) {
2588
-		$this->set_company( $value );
2587
+	public function set_user_company($value) {
2588
+		$this->set_company($value);
2589 2589
     }
2590 2590
 
2591 2591
     /**
@@ -2594,8 +2594,8 @@  discard block
 block discarded – undo
2594 2594
 	 * @since 1.0.19
2595 2595
 	 * @param  string $value company.
2596 2596
 	 */
2597
-	public function set_customer_company( $value ) {
2598
-		$this->set_company( $value );
2597
+	public function set_customer_company($value) {
2598
+		$this->set_company($value);
2599 2599
     }
2600 2600
 
2601 2601
     /**
@@ -2604,8 +2604,8 @@  discard block
 block discarded – undo
2604 2604
 	 * @since 1.0.19
2605 2605
 	 * @param  string $value var number.
2606 2606
 	 */
2607
-	public function set_vat_number( $value ) {
2608
-		$this->set_prop( 'vat_number', $value );
2607
+	public function set_vat_number($value) {
2608
+		$this->set_prop('vat_number', $value);
2609 2609
     }
2610 2610
 
2611 2611
     /**
@@ -2614,8 +2614,8 @@  discard block
 block discarded – undo
2614 2614
 	 * @since 1.0.19
2615 2615
 	 * @param  string $value var number.
2616 2616
 	 */
2617
-	public function set_user_vat_number( $value ) {
2618
-		$this->set_vat_number( $value );
2617
+	public function set_user_vat_number($value) {
2618
+		$this->set_vat_number($value);
2619 2619
     }
2620 2620
 
2621 2621
     /**
@@ -2624,8 +2624,8 @@  discard block
 block discarded – undo
2624 2624
 	 * @since 1.0.19
2625 2625
 	 * @param  string $value var number.
2626 2626
 	 */
2627
-	public function set_customer_vat_number( $value ) {
2628
-		$this->set_vat_number( $value );
2627
+	public function set_customer_vat_number($value) {
2628
+		$this->set_vat_number($value);
2629 2629
     }
2630 2630
 
2631 2631
     /**
@@ -2634,8 +2634,8 @@  discard block
 block discarded – undo
2634 2634
 	 * @since 1.0.19
2635 2635
 	 * @param  string $value var rate.
2636 2636
 	 */
2637
-	public function set_vat_rate( $value ) {
2638
-		$this->set_prop( 'vat_rate', $value );
2637
+	public function set_vat_rate($value) {
2638
+		$this->set_prop('vat_rate', $value);
2639 2639
     }
2640 2640
 
2641 2641
     /**
@@ -2644,8 +2644,8 @@  discard block
 block discarded – undo
2644 2644
 	 * @since 1.0.19
2645 2645
 	 * @param  string $value var number.
2646 2646
 	 */
2647
-	public function set_user_vat_rate( $value ) {
2648
-		$this->set_vat_rate( $value );
2647
+	public function set_user_vat_rate($value) {
2648
+		$this->set_vat_rate($value);
2649 2649
     }
2650 2650
 
2651 2651
     /**
@@ -2654,8 +2654,8 @@  discard block
 block discarded – undo
2654 2654
 	 * @since 1.0.19
2655 2655
 	 * @param  string $value var number.
2656 2656
 	 */
2657
-	public function set_customer_vat_rate( $value ) {
2658
-		$this->set_vat_rate( $value );
2657
+	public function set_customer_vat_rate($value) {
2658
+		$this->set_vat_rate($value);
2659 2659
     }
2660 2660
 
2661 2661
     /**
@@ -2664,8 +2664,8 @@  discard block
 block discarded – undo
2664 2664
 	 * @since 1.0.19
2665 2665
 	 * @param  string $value address.
2666 2666
 	 */
2667
-	public function set_address( $value ) {
2668
-		$this->set_prop( 'address', $value );
2667
+	public function set_address($value) {
2668
+		$this->set_prop('address', $value);
2669 2669
     }
2670 2670
 
2671 2671
     /**
@@ -2674,8 +2674,8 @@  discard block
 block discarded – undo
2674 2674
 	 * @since 1.0.19
2675 2675
 	 * @param  string $value address.
2676 2676
 	 */
2677
-	public function set_user_address( $value ) {
2678
-		$this->set_address( $value );
2677
+	public function set_user_address($value) {
2678
+		$this->set_address($value);
2679 2679
     }
2680 2680
 
2681 2681
     /**
@@ -2684,8 +2684,8 @@  discard block
 block discarded – undo
2684 2684
 	 * @since 1.0.19
2685 2685
 	 * @param  string $value address.
2686 2686
 	 */
2687
-	public function set_customer_address( $value ) {
2688
-		$this->set_address( $value );
2687
+	public function set_customer_address($value) {
2688
+		$this->set_address($value);
2689 2689
     }
2690 2690
 
2691 2691
     /**
@@ -2694,8 +2694,8 @@  discard block
 block discarded – undo
2694 2694
 	 * @since 1.0.19
2695 2695
 	 * @param  int|bool $value confirmed.
2696 2696
 	 */
2697
-	public function set_is_viewed( $value ) {
2698
-		$this->set_prop( 'is_viewed', $value );
2697
+	public function set_is_viewed($value) {
2698
+		$this->set_prop('is_viewed', $value);
2699 2699
 	}
2700 2700
 
2701 2701
 	/**
@@ -2704,8 +2704,8 @@  discard block
 block discarded – undo
2704 2704
 	 * @since 1.0.19
2705 2705
 	 * @param  string $value email recipients.
2706 2706
 	 */
2707
-	public function set_email_cc( $value ) {
2708
-		$this->set_prop( 'email_cc', $value );
2707
+	public function set_email_cc($value) {
2708
+		$this->set_prop('email_cc', $value);
2709 2709
 	}
2710 2710
 
2711 2711
 	/**
@@ -2714,9 +2714,9 @@  discard block
 block discarded – undo
2714 2714
 	 * @since 1.0.19
2715 2715
 	 * @param  string $value template.
2716 2716
 	 */
2717
-	public function set_template( $value ) {
2718
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2719
-			$this->set_prop( 'template', $value );
2717
+	public function set_template($value) {
2718
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2719
+			$this->set_prop('template', $value);
2720 2720
 		}
2721 2721
 	}
2722 2722
 
@@ -2727,8 +2727,8 @@  discard block
 block discarded – undo
2727 2727
 	 * @param  string $value source.
2728 2728
 	 * @deprecated
2729 2729
 	 */
2730
-	public function created_via( $value ) {
2731
-		$this->set_created_via( sanitize_text_field( $value ) );
2730
+	public function created_via($value) {
2731
+		$this->set_created_via(sanitize_text_field($value));
2732 2732
 	}
2733 2733
 
2734 2734
 	/**
@@ -2737,8 +2737,8 @@  discard block
 block discarded – undo
2737 2737
 	 * @since 1.0.19
2738 2738
 	 * @param  string $value source.
2739 2739
 	 */
2740
-	public function set_created_via( $value ) {
2741
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2740
+	public function set_created_via($value) {
2741
+		$this->set_prop('created_via', sanitize_text_field($value));
2742 2742
 	}
2743 2743
 
2744 2744
 	/**
@@ -2747,8 +2747,8 @@  discard block
 block discarded – undo
2747 2747
 	 * @since 1.0.19
2748 2748
 	 * @param  int|bool $value confirmed.
2749 2749
 	 */
2750
-	public function set_address_confirmed( $value ) {
2751
-		$this->set_prop( 'address_confirmed', $value );
2750
+	public function set_address_confirmed($value) {
2751
+		$this->set_prop('address_confirmed', $value);
2752 2752
     }
2753 2753
 
2754 2754
     /**
@@ -2757,8 +2757,8 @@  discard block
 block discarded – undo
2757 2757
 	 * @since 1.0.19
2758 2758
 	 * @param  int|bool $value confirmed.
2759 2759
 	 */
2760
-	public function set_user_address_confirmed( $value ) {
2761
-		$this->set_address_confirmed( $value );
2760
+	public function set_user_address_confirmed($value) {
2761
+		$this->set_address_confirmed($value);
2762 2762
     }
2763 2763
 
2764 2764
     /**
@@ -2767,8 +2767,8 @@  discard block
 block discarded – undo
2767 2767
 	 * @since 1.0.19
2768 2768
 	 * @param  int|bool $value confirmed.
2769 2769
 	 */
2770
-	public function set_customer_address_confirmed( $value ) {
2771
-		$this->set_address_confirmed( $value );
2770
+	public function set_customer_address_confirmed($value) {
2771
+		$this->set_address_confirmed($value);
2772 2772
     }
2773 2773
 
2774 2774
     /**
@@ -2777,8 +2777,8 @@  discard block
 block discarded – undo
2777 2777
 	 * @since 1.0.19
2778 2778
 	 * @param  float $value sub total.
2779 2779
 	 */
2780
-	public function set_subtotal( $value ) {
2781
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2780
+	public function set_subtotal($value) {
2781
+		$this->set_prop('subtotal', max(0, $value));
2782 2782
 	}
2783 2783
 
2784 2784
 	/**
@@ -2787,8 +2787,8 @@  discard block
 block discarded – undo
2787 2787
 	 * @since 1.0.19
2788 2788
 	 * @param  float $value sub total.
2789 2789
 	 */
2790
-	public function set_total( $value ) {
2791
-		$this->set_prop( 'total', max( 0, $value ) );
2790
+	public function set_total($value) {
2791
+		$this->set_prop('total', max(0, $value));
2792 2792
     }
2793 2793
 
2794 2794
     /**
@@ -2797,8 +2797,8 @@  discard block
 block discarded – undo
2797 2797
 	 * @since 1.0.19
2798 2798
 	 * @param  float $value discount total.
2799 2799
 	 */
2800
-	public function set_total_discount( $value ) {
2801
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2800
+	public function set_total_discount($value) {
2801
+		$this->set_prop('total_discount', max(0, $value));
2802 2802
     }
2803 2803
 
2804 2804
     /**
@@ -2807,8 +2807,8 @@  discard block
 block discarded – undo
2807 2807
 	 * @since 1.0.19
2808 2808
 	 * @param  float $value discount total.
2809 2809
 	 */
2810
-	public function set_discount( $value ) {
2811
-		$this->set_total_discount( $value );
2810
+	public function set_discount($value) {
2811
+		$this->set_total_discount($value);
2812 2812
     }
2813 2813
 
2814 2814
     /**
@@ -2817,8 +2817,8 @@  discard block
 block discarded – undo
2817 2817
 	 * @since 1.0.19
2818 2818
 	 * @param  float $value tax total.
2819 2819
 	 */
2820
-	public function set_total_tax( $value ) {
2821
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2820
+	public function set_total_tax($value) {
2821
+		$this->set_prop('total_tax', max(0, $value));
2822 2822
     }
2823 2823
 
2824 2824
     /**
@@ -2827,8 +2827,8 @@  discard block
 block discarded – undo
2827 2827
 	 * @since 1.0.19
2828 2828
 	 * @param  float $value tax total.
2829 2829
 	 */
2830
-	public function set_tax_total( $value ) {
2831
-		$this->set_total_tax( $value );
2830
+	public function set_tax_total($value) {
2831
+		$this->set_total_tax($value);
2832 2832
     }
2833 2833
 
2834 2834
     /**
@@ -2837,8 +2837,8 @@  discard block
 block discarded – undo
2837 2837
 	 * @since 1.0.19
2838 2838
 	 * @param  float $value fees total.
2839 2839
 	 */
2840
-	public function set_total_fees( $value ) {
2841
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2840
+	public function set_total_fees($value) {
2841
+		$this->set_prop('total_fees', max(0, $value));
2842 2842
     }
2843 2843
 
2844 2844
     /**
@@ -2847,8 +2847,8 @@  discard block
 block discarded – undo
2847 2847
 	 * @since 1.0.19
2848 2848
 	 * @param  float $value fees total.
2849 2849
 	 */
2850
-	public function set_fees_total( $value ) {
2851
-		$this->set_total_fees( $value );
2850
+	public function set_fees_total($value) {
2851
+		$this->set_total_fees($value);
2852 2852
     }
2853 2853
 
2854 2854
     /**
@@ -2857,13 +2857,13 @@  discard block
 block discarded – undo
2857 2857
 	 * @since 1.0.19
2858 2858
 	 * @param  array $value fees.
2859 2859
 	 */
2860
-	public function set_fees( $value ) {
2860
+	public function set_fees($value) {
2861 2861
 
2862
-		if ( ! is_array( $value ) ) {
2862
+		if (!is_array($value)) {
2863 2863
 			$value = array();
2864 2864
 		}
2865 2865
 
2866
-		$this->set_prop( 'fees', $value );
2866
+		$this->set_prop('fees', $value);
2867 2867
 
2868 2868
     }
2869 2869
 
@@ -2873,13 +2873,13 @@  discard block
 block discarded – undo
2873 2873
 	 * @since 1.0.19
2874 2874
 	 * @param  array $value taxes.
2875 2875
 	 */
2876
-	public function set_taxes( $value ) {
2876
+	public function set_taxes($value) {
2877 2877
 
2878
-		if ( ! is_array( $value ) ) {
2878
+		if (!is_array($value)) {
2879 2879
 			$value = array();
2880 2880
 		}
2881 2881
 
2882
-		$this->set_prop( 'taxes', $value );
2882
+		$this->set_prop('taxes', $value);
2883 2883
 
2884 2884
     }
2885 2885
 
@@ -2889,13 +2889,13 @@  discard block
 block discarded – undo
2889 2889
 	 * @since 1.0.19
2890 2890
 	 * @param  array $value discounts.
2891 2891
 	 */
2892
-	public function set_discounts( $value ) {
2892
+	public function set_discounts($value) {
2893 2893
 
2894
-		if ( ! is_array( $value ) ) {
2894
+		if (!is_array($value)) {
2895 2895
 			$value = array();
2896 2896
 		}
2897 2897
 
2898
-		$this->set_prop( 'discounts', $value );
2898
+		$this->set_prop('discounts', $value);
2899 2899
     }
2900 2900
 
2901 2901
     /**
@@ -2904,19 +2904,19 @@  discard block
 block discarded – undo
2904 2904
 	 * @since 1.0.19
2905 2905
 	 * @param  GetPaid_Form_Item[] $value items.
2906 2906
 	 */
2907
-	public function set_items( $value ) {
2907
+	public function set_items($value) {
2908 2908
 
2909 2909
         // Remove existing items.
2910
-        $this->set_prop( 'items', array() );
2910
+        $this->set_prop('items', array());
2911 2911
 		$this->recurring_item = null;
2912 2912
 
2913 2913
         // Ensure that we have an array.
2914
-        if ( ! is_array( $value ) ) {
2914
+        if (!is_array($value)) {
2915 2915
             return;
2916 2916
         }
2917 2917
 
2918
-        foreach ( $value as $item ) {
2919
-            $this->add_item( $item );
2918
+        foreach ($value as $item) {
2919
+            $this->add_item($item);
2920 2920
         }
2921 2921
 
2922 2922
     }
@@ -2927,8 +2927,8 @@  discard block
 block discarded – undo
2927 2927
 	 * @since 1.0.19
2928 2928
 	 * @param  int $value payment form.
2929 2929
 	 */
2930
-	public function set_payment_form( $value ) {
2931
-		$this->set_prop( 'payment_form', $value );
2930
+	public function set_payment_form($value) {
2931
+		$this->set_prop('payment_form', $value);
2932 2932
     }
2933 2933
 
2934 2934
     /**
@@ -2937,8 +2937,8 @@  discard block
 block discarded – undo
2937 2937
 	 * @since 1.0.19
2938 2938
 	 * @param  string $value submission id.
2939 2939
 	 */
2940
-	public function set_submission_id( $value ) {
2941
-		$this->set_prop( 'submission_id', $value );
2940
+	public function set_submission_id($value) {
2941
+		$this->set_prop('submission_id', $value);
2942 2942
     }
2943 2943
 
2944 2944
     /**
@@ -2947,8 +2947,8 @@  discard block
 block discarded – undo
2947 2947
 	 * @since 1.0.19
2948 2948
 	 * @param  string $value discount code.
2949 2949
 	 */
2950
-	public function set_discount_code( $value ) {
2951
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
2950
+	public function set_discount_code($value) {
2951
+		$this->set_prop('discount_code', sanitize_text_field($value));
2952 2952
     }
2953 2953
 
2954 2954
     /**
@@ -2957,8 +2957,8 @@  discard block
 block discarded – undo
2957 2957
 	 * @since 1.0.19
2958 2958
 	 * @param  string $value gateway.
2959 2959
 	 */
2960
-	public function set_gateway( $value ) {
2961
-		$this->set_prop( 'gateway', $value );
2960
+	public function set_gateway($value) {
2961
+		$this->set_prop('gateway', $value);
2962 2962
     }
2963 2963
 
2964 2964
     /**
@@ -2967,9 +2967,9 @@  discard block
 block discarded – undo
2967 2967
 	 * @since 1.0.19
2968 2968
 	 * @param  string $value transaction id.
2969 2969
 	 */
2970
-	public function set_transaction_id( $value ) {
2971
-		if ( ! empty( $value ) ) {
2972
-			$this->set_prop( 'transaction_id', $value );
2970
+	public function set_transaction_id($value) {
2971
+		if (!empty($value)) {
2972
+			$this->set_prop('transaction_id', $value);
2973 2973
 		}
2974 2974
     }
2975 2975
 
@@ -2979,8 +2979,8 @@  discard block
 block discarded – undo
2979 2979
 	 * @since 1.0.19
2980 2980
 	 * @param  string $value currency id.
2981 2981
 	 */
2982
-	public function set_currency( $value ) {
2983
-		$this->set_prop( 'currency', $value );
2982
+	public function set_currency($value) {
2983
+		$this->set_prop('currency', $value);
2984 2984
     }
2985 2985
 
2986 2986
 	/**
@@ -2989,8 +2989,8 @@  discard block
 block discarded – undo
2989 2989
 	 * @since 1.0.19
2990 2990
 	 * @param  bool $value value.
2991 2991
 	 */
2992
-	public function set_disable_taxes( $value ) {
2993
-		$this->set_prop( 'disable_taxes', (bool) $value );
2992
+	public function set_disable_taxes($value) {
2993
+		$this->set_prop('disable_taxes', (bool) $value);
2994 2994
 	}
2995 2995
 
2996 2996
     /**
@@ -2999,8 +2999,8 @@  discard block
 block discarded – undo
2999 2999
 	 * @since 1.0.19
3000 3000
 	 * @param  string $value subscription id.
3001 3001
 	 */
3002
-	public function set_subscription_id( $value ) {
3003
-		$this->set_prop( 'subscription_id', $value );
3002
+	public function set_subscription_id($value) {
3003
+		$this->set_prop('subscription_id', $value);
3004 3004
 	}
3005 3005
 	
3006 3006
 	/**
@@ -3009,8 +3009,8 @@  discard block
 block discarded – undo
3009 3009
 	 * @since 1.0.19
3010 3010
 	 * @param  string $value subscription id.
3011 3011
 	 */
3012
-	public function set_remote_subscription_id( $value ) {
3013
-		$this->set_prop( 'remote_subscription_id', $value );
3012
+	public function set_remote_subscription_id($value) {
3013
+		$this->set_prop('remote_subscription_id', $value);
3014 3014
     }
3015 3015
 
3016 3016
     /*
@@ -3027,28 +3027,28 @@  discard block
 block discarded – undo
3027 3027
      */
3028 3028
     public function is_parent() {
3029 3029
         $parent = $this->get_parent_id();
3030
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
3030
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
3031 3031
     }
3032 3032
 
3033 3033
     /**
3034 3034
      * Checks if this is a renewal invoice.
3035 3035
      */
3036 3036
     public function is_renewal() {
3037
-        return ! $this->is_parent();
3037
+        return !$this->is_parent();
3038 3038
     }
3039 3039
 
3040 3040
     /**
3041 3041
      * Checks if this is a recurring invoice.
3042 3042
      */
3043 3043
     public function is_recurring() {
3044
-        return $this->is_renewal() || ! empty( $this->recurring_item );
3044
+        return $this->is_renewal() || !empty($this->recurring_item);
3045 3045
     }
3046 3046
 
3047 3047
     /**
3048 3048
      * Checks if this is a taxable invoice.
3049 3049
      */
3050 3050
     public function is_taxable() {
3051
-        return ! $this->get_disable_taxes();
3051
+        return !$this->get_disable_taxes();
3052 3052
 	}
3053 3053
 
3054 3054
 	/**
@@ -3062,45 +3062,45 @@  discard block
 block discarded – undo
3062 3062
 	 * Checks to see if the invoice requires payment.
3063 3063
 	 */
3064 3064
 	public function is_free() {
3065
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3065
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
3066 3066
 
3067
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3067
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
3068 3068
 			$is_free = false;
3069 3069
 		}
3070 3070
 
3071
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3071
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
3072 3072
     }
3073 3073
 
3074 3074
     /**
3075 3075
      * Checks if the invoice is paid.
3076 3076
      */
3077 3077
     public function is_paid() {
3078
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3079
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3078
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
3079
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
3080 3080
 	}
3081 3081
 
3082 3082
 	/**
3083 3083
      * Checks if the invoice needs payment.
3084 3084
      */
3085 3085
 	public function needs_payment() {
3086
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3087
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3086
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
3087
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
3088 3088
     }
3089 3089
   
3090 3090
 	/**
3091 3091
      * Checks if the invoice is refunded.
3092 3092
      */
3093 3093
 	public function is_refunded() {
3094
-        $is_refunded = $this->has_status( 'wpi-refunded' );
3095
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3094
+        $is_refunded = $this->has_status('wpi-refunded');
3095
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
3096 3096
 	}
3097 3097
 
3098 3098
 	/**
3099 3099
      * Checks if the invoice is held.
3100 3100
      */
3101 3101
 	public function is_held() {
3102
-        $is_held = $this->has_status( 'wpi-onhold' );
3103
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3102
+        $is_held = $this->has_status('wpi-onhold');
3103
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
3104 3104
 	}
3105 3105
 
3106 3106
 	/**
@@ -3108,30 +3108,30 @@  discard block
 block discarded – undo
3108 3108
      */
3109 3109
 	public function is_due() {
3110 3110
 		$due_date = $this->get_due_date();
3111
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3111
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3112 3112
 	}
3113 3113
 
3114 3114
 	/**
3115 3115
      * Checks if the invoice is draft.
3116 3116
      */
3117 3117
 	public function is_draft() {
3118
-        return $this->has_status( 'draft, auto-draft' );
3118
+        return $this->has_status('draft, auto-draft');
3119 3119
 	}
3120 3120
 
3121 3121
     /**
3122 3122
      * Checks if the invoice has a given status.
3123 3123
      */
3124
-    public function has_status( $status ) {
3125
-        $status = wpinv_parse_list( $status );
3126
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3124
+    public function has_status($status) {
3125
+        $status = wpinv_parse_list($status);
3126
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3127 3127
 	}
3128 3128
 
3129 3129
 	/**
3130 3130
      * Checks if the invoice is of a given type.
3131 3131
      */
3132
-    public function is_type( $type ) {
3133
-        $type = wpinv_parse_list( $type );
3134
-        return in_array( $this->get_type(), $type );
3132
+    public function is_type($type) {
3133
+        $type = wpinv_parse_list($type);
3134
+        return in_array($this->get_type(), $type);
3135 3135
     }
3136 3136
 
3137 3137
     /**
@@ -3163,8 +3163,8 @@  discard block
 block discarded – undo
3163 3163
      *
3164 3164
      */
3165 3165
 	public function is_initial_free() {
3166
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3167
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3166
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3167
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3168 3168
     }
3169 3169
 	
3170 3170
 	/**
@@ -3174,11 +3174,11 @@  discard block
 block discarded – undo
3174 3174
     public function item_has_free_trial() {
3175 3175
 
3176 3176
         // Ensure we have a recurring item.
3177
-        if ( ! $this->is_recurring() ) {
3177
+        if (!$this->is_recurring()) {
3178 3178
             return false;
3179 3179
         }
3180 3180
 
3181
-        $item = $this->get_recurring( true );
3181
+        $item = $this->get_recurring(true);
3182 3182
         return $item->has_free_trial();
3183 3183
 	}
3184 3184
 
@@ -3186,7 +3186,7 @@  discard block
 block discarded – undo
3186 3186
      * Check if the free trial is a result of a discount.
3187 3187
      */
3188 3188
     public function is_free_trial_from_discount() {
3189
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3189
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3190 3190
 	}
3191 3191
 	
3192 3192
 	/**
@@ -3194,12 +3194,12 @@  discard block
 block discarded – undo
3194 3194
      */
3195 3195
     public function discount_first_payment_only() {
3196 3196
 
3197
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3198
-        if ( ! $discount->exists() || ! $this->is_recurring() ) {
3197
+		$discount = wpinv_get_discount_obj($this->get_discount_code());
3198
+        if (!$discount->exists() || !$this->is_recurring()) {
3199 3199
             return true;
3200 3200
         }
3201 3201
 
3202
-        return ! $discount->get_is_recurring();
3202
+        return !$discount->get_is_recurring();
3203 3203
     }
3204 3204
 
3205 3205
     /*
@@ -3217,23 +3217,23 @@  discard block
 block discarded – undo
3217 3217
      * @param GetPaid_Form_Item|array $item
3218 3218
      * @return WP_Error|Bool
3219 3219
      */
3220
-    public function add_item( $item ) {
3220
+    public function add_item($item) {
3221 3221
 
3222
-		if ( is_array( $item ) ) {
3223
-			$item = $this->process_array_item( $item );
3222
+		if (is_array($item)) {
3223
+			$item = $this->process_array_item($item);
3224 3224
 		}
3225 3225
 
3226
-		if ( is_numeric( $item ) ) {
3227
-			$item = new GetPaid_Form_Item( $item );
3226
+		if (is_numeric($item)) {
3227
+			$item = new GetPaid_Form_Item($item);
3228 3228
 		}
3229 3229
 
3230 3230
         // Make sure that it is available for purchase.
3231
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3232
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3231
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3232
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3233 3233
         }
3234 3234
 
3235 3235
         // Do we have a recurring item?
3236
-		if ( $item->is_recurring() ) {
3236
+		if ($item->is_recurring()) {
3237 3237
 			$this->recurring_item = $item->get_id();
3238 3238
         }
3239 3239
 
@@ -3241,7 +3241,7 @@  discard block
 block discarded – undo
3241 3241
         $item->invoice_id = (int) $this->get_id();
3242 3242
 
3243 3243
 		// Remove duplicates.
3244
-		$this->remove_item( $item->get_id() );
3244
+		$this->remove_item($item->get_id());
3245 3245
 
3246 3246
 		// Retrieve all items.
3247 3247
         $items   = $this->get_items();
@@ -3249,7 +3249,7 @@  discard block
 block discarded – undo
3249 3249
 		// Add new item.
3250 3250
         $items[] = $item;
3251 3251
 
3252
-        $this->set_prop( 'items', $items );
3252
+        $this->set_prop('items', $items);
3253 3253
 
3254 3254
 		return true;
3255 3255
 	}
@@ -3260,26 +3260,26 @@  discard block
 block discarded – undo
3260 3260
 	 * @since 1.0.19
3261 3261
 	 * @return GetPaid_Form_Item
3262 3262
 	 */
3263
-	protected function process_array_item( $array ) {
3263
+	protected function process_array_item($array) {
3264 3264
 
3265
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3266
-		$item    = new GetPaid_Form_Item( $item_id );
3265
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3266
+		$item    = new GetPaid_Form_Item($item_id);
3267 3267
 
3268 3268
 		// Set item data.
3269
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3270
-			if ( isset( $array[ "item_$key" ] ) ) {
3269
+		foreach (array('name', 'price', 'description') as $key) {
3270
+			if (isset($array["item_$key"])) {
3271 3271
 				$method = "set_$key";
3272
-				$item->$method( $array[ "item_$key" ] );
3272
+				$item->$method($array["item_$key"]);
3273 3273
 			}
3274 3274
 		}
3275 3275
 
3276
-		if ( isset( $array['quantity'] ) ) {
3277
-			$item->set_quantity( $array['quantity'] );
3276
+		if (isset($array['quantity'])) {
3277
+			$item->set_quantity($array['quantity']);
3278 3278
 		}
3279 3279
 
3280 3280
 		// Set item meta.
3281
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3282
-			$item->set_item_meta( $array['meta'] );
3281
+		if (isset($array['meta']) && is_array($array['meta'])) {
3282
+			$item->set_item_meta($array['meta']);
3283 3283
 		}
3284 3284
 
3285 3285
 		return $item;
@@ -3292,10 +3292,10 @@  discard block
 block discarded – undo
3292 3292
 	 * @since 1.0.19
3293 3293
 	 * @return GetPaid_Form_Item|null
3294 3294
 	 */
3295
-	public function get_item( $item_id ) {
3295
+	public function get_item($item_id) {
3296 3296
 
3297
-		foreach ( $this->get_items() as $item ) {
3298
-			if ( (int) $item_id == $item->get_id() ) {
3297
+		foreach ($this->get_items() as $item) {
3298
+			if ((int) $item_id == $item->get_id()) {
3299 3299
 				return $item;
3300 3300
 			}
3301 3301
 		}
@@ -3308,16 +3308,16 @@  discard block
 block discarded – undo
3308 3308
 	 *
3309 3309
 	 * @since 1.0.19
3310 3310
 	 */
3311
-	public function remove_item( $item_id ) {
3311
+	public function remove_item($item_id) {
3312 3312
 		$items   = $this->get_items();
3313 3313
 		$item_id = (int) $item_id;
3314 3314
 
3315
-		foreach ( $items as $index => $item ) {
3316
-			if ( (int) $item_id == $item->get_id() ) {
3317
-				unset( $items[ $index ] );
3318
-				$this->set_prop( 'items', $items );
3315
+		foreach ($items as $index => $item) {
3316
+			if ((int) $item_id == $item->get_id()) {
3317
+				unset($items[$index]);
3318
+				$this->set_prop('items', $items);
3319 3319
 
3320
-				if ( $item_id == $this->recurring_item ) {
3320
+				if ($item_id == $this->recurring_item) {
3321 3321
 					$this->recurring_item = null;
3322 3322
 				}
3323 3323
 
@@ -3332,11 +3332,11 @@  discard block
 block discarded – undo
3332 3332
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3333 3333
 	 * @since 1.0.19
3334 3334
 	 */
3335
-    public function add_fee( $fee ) {
3335
+    public function add_fee($fee) {
3336 3336
 
3337 3337
 		$fees                 = $this->get_fees();
3338
-		$fees[ $fee['name'] ] = $fee;
3339
-		$this->set_prop( 'fees', $fees );
3338
+		$fees[$fee['name']] = $fee;
3339
+		$this->set_prop('fees', $fees);
3340 3340
 
3341 3341
     }
3342 3342
 
@@ -3345,9 +3345,9 @@  discard block
 block discarded – undo
3345 3345
 	 *
3346 3346
 	 * @since 1.0.19
3347 3347
 	 */
3348
-	public function get_fee( $fee ) {
3348
+	public function get_fee($fee) {
3349 3349
         $fees = $this->get_fees();
3350
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3350
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3351 3351
     }
3352 3352
 
3353 3353
     /**
@@ -3355,11 +3355,11 @@  discard block
 block discarded – undo
3355 3355
 	 *
3356 3356
 	 * @since 1.0.19
3357 3357
 	 */
3358
-	public function remove_fee( $fee ) {
3358
+	public function remove_fee($fee) {
3359 3359
         $fees = $this->get_fees();
3360
-        if ( isset( $fees[ $fee ] ) ) {
3361
-            unset( $fees[ $fee ] );
3362
-            $this->set_prop( 'fees', $fees );
3360
+        if (isset($fees[$fee])) {
3361
+            unset($fees[$fee]);
3362
+            $this->set_prop('fees', $fees);
3363 3363
         }
3364 3364
     }
3365 3365
 
@@ -3369,11 +3369,11 @@  discard block
 block discarded – undo
3369 3369
 	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3370 3370
 	 * @since 1.0.19
3371 3371
 	 */
3372
-	public function add_discount( $discount ) {
3372
+	public function add_discount($discount) {
3373 3373
 
3374 3374
 		$discounts = $this->get_discounts();
3375
-		$discounts[ $discount['name'] ] = $discount;
3376
-		$this->set_prop( 'discounts', $discounts );
3375
+		$discounts[$discount['name']] = $discount;
3376
+		$this->set_prop('discounts', $discounts);
3377 3377
 
3378 3378
 	}
3379 3379
 
@@ -3383,15 +3383,15 @@  discard block
 block discarded – undo
3383 3383
 	 * @since 1.0.19
3384 3384
 	 * @return float
3385 3385
 	 */
3386
-	public function get_discount( $discount = false ) {
3386
+	public function get_discount($discount = false) {
3387 3387
 
3388 3388
 		// Backwards compatibilty.
3389
-		if ( empty( $discount ) ) {
3389
+		if (empty($discount)) {
3390 3390
 			return $this->get_total_discount();
3391 3391
 		}
3392 3392
 
3393 3393
         $discounts = $this->get_discounts();
3394
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3394
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3395 3395
     }
3396 3396
 
3397 3397
     /**
@@ -3399,15 +3399,15 @@  discard block
 block discarded – undo
3399 3399
 	 *
3400 3400
 	 * @since 1.0.19
3401 3401
 	 */
3402
-	public function remove_discount( $discount ) {
3402
+	public function remove_discount($discount) {
3403 3403
         $discounts = $this->get_discounts();
3404
-        if ( isset( $discounts[ $discount ] ) ) {
3405
-            unset( $discounts[ $discount ] );
3406
-            $this->set_prop( 'discounts', $discounts );
3404
+        if (isset($discounts[$discount])) {
3405
+            unset($discounts[$discount]);
3406
+            $this->set_prop('discounts', $discounts);
3407 3407
         }
3408 3408
 
3409
-		if ( 'discount_code' == $discount ) {
3410
-			foreach ( $this->get_items() as $item ) {
3409
+		if ('discount_code' == $discount) {
3410
+			foreach ($this->get_items() as $item) {
3411 3411
 				$item->item_discount           = 0;
3412 3412
 				$item->recurring_item_discount = 0;
3413 3413
 			}
@@ -3420,12 +3420,12 @@  discard block
 block discarded – undo
3420 3420
      *
3421 3421
      * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
3422 3422
      */
3423
-    public function add_tax( $tax ) {
3424
-        if ( $this->is_taxable() ) {
3423
+    public function add_tax($tax) {
3424
+        if ($this->is_taxable()) {
3425 3425
 
3426
-            $taxes                 = $this->get_taxes();
3427
-			$taxes[ $tax['name'] ] = $tax;
3428
-			$this->set_prop( 'taxes', $tax );
3426
+            $taxes = $this->get_taxes();
3427
+			$taxes[$tax['name']] = $tax;
3428
+			$this->set_prop('taxes', $tax);
3429 3429
 
3430 3430
         }
3431 3431
     }
@@ -3435,15 +3435,15 @@  discard block
 block discarded – undo
3435 3435
 	 *
3436 3436
 	 * @since 1.0.19
3437 3437
 	 */
3438
-	public function get_tax( $tax = null ) {
3438
+	public function get_tax($tax = null) {
3439 3439
 
3440 3440
 		// Backwards compatility.
3441
-		if ( empty( $tax ) ) {
3441
+		if (empty($tax)) {
3442 3442
 			return $this->get_total_tax();
3443 3443
 		}
3444 3444
 
3445 3445
         $taxes = $this->get_taxes();
3446
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3446
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3447 3447
     }
3448 3448
 
3449 3449
     /**
@@ -3451,11 +3451,11 @@  discard block
 block discarded – undo
3451 3451
 	 *
3452 3452
 	 * @since 1.0.19
3453 3453
 	 */
3454
-	public function remove_tax( $tax ) {
3454
+	public function remove_tax($tax) {
3455 3455
         $taxes = $this->get_taxes();
3456
-        if ( isset( $taxes[ $tax ] ) ) {
3457
-            unset( $taxes[ $tax ] );
3458
-            $this->set_prop( 'taxes', $taxes );
3456
+        if (isset($taxes[$tax])) {
3457
+            unset($taxes[$tax]);
3458
+            $this->set_prop('taxes', $taxes);
3459 3459
         }
3460 3460
     }
3461 3461
 
@@ -3466,22 +3466,22 @@  discard block
 block discarded – undo
3466 3466
 	 * @return float The recalculated subtotal
3467 3467
 	 */
3468 3468
 	public function recalculate_subtotal() {
3469
-        $items     = $this->get_items();
3469
+        $items = $this->get_items();
3470 3470
 		$subtotal  = 0;
3471 3471
 		$recurring = 0;
3472 3472
 
3473
-        foreach ( $items as $item ) {
3473
+        foreach ($items as $item) {
3474 3474
 			$subtotal  += $item->get_sub_total();
3475 3475
 			$recurring += $item->get_recurring_sub_total();
3476 3476
         }
3477 3477
 
3478
-		if ( wpinv_prices_include_tax() ) {
3479
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3480
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3478
+		if (wpinv_prices_include_tax()) {
3479
+			$subtotal  = max(0, $subtotal - $this->totals['tax']['initial']);
3480
+			$recurring = max(0, $recurring - $this->totals['tax']['recurring']);
3481 3481
 		}
3482 3482
 
3483 3483
 		$current = $this->is_renewal() ? $recurring : $subtotal;
3484
-		$this->set_subtotal( $current );
3484
+		$this->set_subtotal($current);
3485 3485
 
3486 3486
 		$this->totals['subtotal'] = array(
3487 3487
 			'initial'   => $subtotal,
@@ -3502,14 +3502,14 @@  discard block
 block discarded – undo
3502 3502
 		$discount  = 0;
3503 3503
 		$recurring = 0;
3504 3504
 
3505
-        foreach ( $discounts as $data ) {
3506
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3507
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3505
+        foreach ($discounts as $data) {
3506
+			$discount  += wpinv_sanitize_amount($data['initial_discount']);
3507
+			$recurring += wpinv_sanitize_amount($data['recurring_discount']);
3508 3508
 		}
3509 3509
 
3510 3510
 		$current = $this->is_renewal() ? $recurring : $discount;
3511 3511
 
3512
-		$this->set_total_discount( $current );
3512
+		$this->set_total_discount($current);
3513 3513
 
3514 3514
 		$this->totals['discount'] = array(
3515 3515
 			'initial'   => $discount,
@@ -3530,13 +3530,13 @@  discard block
 block discarded – undo
3530 3530
 
3531 3531
 		// Maybe disable taxes.
3532 3532
 		$vat_number = $this->get_vat_number();
3533
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3533
+		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number);
3534 3534
 
3535
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3535
+		if (wpinv_is_base_country($this->get_country()) && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) {
3536 3536
 			$skip_tax = false;
3537 3537
 		}
3538 3538
 
3539
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3539
+		if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) {
3540 3540
 
3541 3541
 			$this->totals['tax'] = array(
3542 3542
 				'initial'   => 0,
@@ -3545,38 +3545,38 @@  discard block
 block discarded – undo
3545 3545
 
3546 3546
 			$this->tax_rate = 0;
3547 3547
 
3548
-			$this->set_taxes( array() );
3548
+			$this->set_taxes(array());
3549 3549
 			$current = 0;
3550 3550
 		} else {
3551 3551
 
3552 3552
 			$item_taxes = array();
3553 3553
 
3554
-			foreach ( $this->get_items() as $item ) {
3555
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3556
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3557
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3558
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3559
-				foreach ( $taxes as $name => $amount ) {
3560
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3561
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3562
-
3563
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3564
-						$item_taxes[ $name ] = $tax;
3554
+			foreach ($this->get_items() as $item) {
3555
+				$rates    = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state());
3556
+				$rates    = getpaid_filter_item_tax_rates($item, $rates);
3557
+				$taxes    = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates);
3558
+				$r_taxes  = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates);
3559
+				foreach ($taxes as $name => $amount) {
3560
+					$recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0;
3561
+					$tax       = getpaid_prepare_item_tax($item, $name, $amount, $recurring);
3562
+
3563
+					if (!isset($item_taxes[$name])) {
3564
+						$item_taxes[$name] = $tax;
3565 3565
 						continue;
3566 3566
 					}
3567 3567
 
3568
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3569
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3568
+					$item_taxes[$name]['initial_tax']   += $tax['initial_tax'];
3569
+					$item_taxes[$name]['recurring_tax'] += $tax['recurring_tax'];
3570 3570
 
3571 3571
 				}
3572 3572
 
3573 3573
 			}
3574 3574
 
3575
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3576
-			$this->set_taxes( $item_taxes );
3575
+			$item_taxes = array_replace($this->get_taxes(), $item_taxes);
3576
+			$this->set_taxes($item_taxes);
3577 3577
 
3578
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3579
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3578
+			$initial_tax   = array_sum(wp_list_pluck($item_taxes, 'initial_tax'));
3579
+			$recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax'));
3580 3580
 
3581 3581
 			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3582 3582
 
@@ -3587,7 +3587,7 @@  discard block
 block discarded – undo
3587 3587
 
3588 3588
 		}
3589 3589
 
3590
-		$this->set_total_tax( $current );
3590
+		$this->set_total_tax($current);
3591 3591
 
3592 3592
 		return $current;
3593 3593
 
@@ -3604,20 +3604,20 @@  discard block
 block discarded – undo
3604 3604
 		$fee       = 0;
3605 3605
 		$recurring = 0;
3606 3606
 
3607
-        foreach ( $fees as $data ) {
3608
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3609
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3607
+        foreach ($fees as $data) {
3608
+			$fee       += wpinv_sanitize_amount($data['initial_fee']);
3609
+			$recurring += wpinv_sanitize_amount($data['recurring_fee']);
3610 3610
 		}
3611 3611
 
3612 3612
 		$current = $this->is_renewal() ? $recurring : $fee;
3613
-		$this->set_total_fees( $current );
3613
+		$this->set_total_fees($current);
3614 3614
 
3615 3615
 		$this->totals['fee'] = array(
3616 3616
 			'initial'   => $fee,
3617 3617
 			'recurring' => $recurring,
3618 3618
 		);
3619 3619
 
3620
-        $this->set_total_fees( $fee );
3620
+        $this->set_total_fees($fee);
3621 3621
         return $current;
3622 3622
     }
3623 3623
 
@@ -3632,7 +3632,7 @@  discard block
 block discarded – undo
3632 3632
         $this->recalculate_total_discount();
3633 3633
 		$this->recalculate_total_tax();
3634 3634
 		$this->recalculate_subtotal();
3635
-		$this->set_total( $this->get_total_tax() + $this->get_total_fees() + $this->get_subtotal() - $this->get_total_discount() );
3635
+		$this->set_total($this->get_total_tax() + $this->get_total_fees() + $this->get_subtotal() - $this->get_total_discount());
3636 3636
 		return $this->get_total();
3637 3637
 	}
3638 3638
 
@@ -3641,7 +3641,7 @@  discard block
 block discarded – undo
3641 3641
 	 */
3642 3642
     public function recalculate_totals() {
3643 3643
         $this->recalculate_total();
3644
-        $this->save( true );
3644
+        $this->save(true);
3645 3645
         return $this;
3646 3646
     }
3647 3647
 
@@ -3659,8 +3659,8 @@  discard block
 block discarded – undo
3659 3659
 	 * @return int|false The new note's ID on success, false on failure.
3660 3660
      *
3661 3661
      */
3662
-    public function add_system_note( $note ) {
3663
-		return $this->add_note( $note, false, false, true );
3662
+    public function add_system_note($note) {
3663
+		return $this->add_note($note, false, false, true);
3664 3664
 	}
3665 3665
 
3666 3666
     /**
@@ -3670,10 +3670,10 @@  discard block
 block discarded – undo
3670 3670
 	 * @return int|false The new note's ID on success, false on failure.
3671 3671
      *
3672 3672
      */
3673
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3673
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3674 3674
 
3675 3675
         // Bail if no note specified or this invoice is not yet saved.
3676
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3676
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3677 3677
             return false;
3678 3678
         }
3679 3679
 
@@ -3681,23 +3681,23 @@  discard block
 block discarded – undo
3681 3681
 		$author_email = '[email protected]';
3682 3682
 
3683 3683
 		// If this is an admin comment or it has been added by the user.
3684
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3685
-			$user         = get_user_by( 'id', get_current_user_id() );
3684
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3685
+			$user = get_user_by('id', get_current_user_id());
3686 3686
             $author       = $user->display_name;
3687 3687
             $author_email = $user->user_email;
3688 3688
 		}
3689 3689
 
3690
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3690
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3691 3691
 
3692 3692
 	}
3693 3693
 
3694 3694
 	/**
3695 3695
      * Generates a unique key for the invoice.
3696 3696
      */
3697
-    public function generate_key( $string = '' ) {
3698
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3697
+    public function generate_key($string = '') {
3698
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3699 3699
         return strtolower(
3700
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3700
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3701 3701
         );
3702 3702
     }
3703 3703
 
@@ -3707,11 +3707,11 @@  discard block
 block discarded – undo
3707 3707
     public function generate_number() {
3708 3708
         $number = $this->get_id();
3709 3709
 
3710
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3711
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3710
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3711
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3712 3712
         }
3713 3713
 
3714
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3714
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3715 3715
 
3716 3716
 	}
3717 3717
 
@@ -3724,55 +3724,55 @@  discard block
 block discarded – undo
3724 3724
 		// Reset status transition variable.
3725 3725
 		$this->status_transition = false;
3726 3726
 
3727
-		if ( $status_transition ) {
3727
+		if ($status_transition) {
3728 3728
 			try {
3729 3729
 
3730 3730
 				// Fire a hook for the status change.
3731
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3731
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3732 3732
 
3733 3733
 				// @deprecated this is deprecated and will be removed in the future.
3734
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3734
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3735 3735
 
3736
-				if ( ! empty( $status_transition['from'] ) ) {
3736
+				if (!empty($status_transition['from'])) {
3737 3737
 
3738 3738
 					/* translators: 1: old invoice status 2: new invoice status */
3739
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3739
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this));
3740 3740
 
3741 3741
 					// Fire another hook.
3742
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3743
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3742
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3743
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3744 3744
 
3745 3745
 					// @deprecated this is deprecated and will be removed in the future.
3746
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3746
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3747 3747
 
3748 3748
 					// Note the transition occurred.
3749
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3749
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']);
3750 3750
 
3751 3751
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3752 3752
 					if (
3753
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3754
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3753
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3754
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3755 3755
 					) {
3756
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3756
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3757 3757
 					}
3758 3758
 
3759 3759
 					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3760 3760
 					if (
3761
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3762
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3761
+						in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3762
+						&& in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3763 3763
 					) {
3764
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3764
+						do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition);
3765 3765
 					}
3766 3766
 				} else {
3767 3767
 					/* translators: %s: new invoice status */
3768
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3768
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this));
3769 3769
 
3770 3770
 					// Note the transition occurred.
3771
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3771
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3772 3772
 
3773 3773
 				}
3774
-			} catch ( Exception $e ) {
3775
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3774
+			} catch (Exception $e) {
3775
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3776 3776
 			}
3777 3777
 		}
3778 3778
 	}
@@ -3780,13 +3780,13 @@  discard block
 block discarded – undo
3780 3780
 	/**
3781 3781
 	 * Updates an invoice status.
3782 3782
 	 */
3783
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3783
+	public function update_status($new_status = false, $note = '', $manual = false) {
3784 3784
 
3785 3785
 		// Fires before updating a status.
3786
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3786
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3787 3787
 
3788 3788
 		// Update the status.
3789
-		$this->set_status( $new_status, $note, $manual );
3789
+		$this->set_status($new_status, $note, $manual);
3790 3790
 
3791 3791
 		// Save the order.
3792 3792
 		return $this->save();
@@ -3797,18 +3797,18 @@  discard block
 block discarded – undo
3797 3797
 	 * @deprecated
3798 3798
 	 */
3799 3799
 	public function refresh_item_ids() {
3800
-        $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3801
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3800
+        $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id')));
3801
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3802 3802
 	}
3803 3803
 
3804 3804
 	/**
3805 3805
 	 * @deprecated
3806 3806
 	 */
3807
-	public function update_items( $temp = false ) {
3807
+	public function update_items($temp = false) {
3808 3808
 
3809
-		$this->set_items( $this->get_items() );
3809
+		$this->set_items($this->get_items());
3810 3810
 
3811
-		if ( ! $temp ) {
3811
+		if (!$temp) {
3812 3812
 			$this->save();
3813 3813
 		}
3814 3814
 
@@ -3822,11 +3822,11 @@  discard block
 block discarded – undo
3822 3822
 
3823 3823
         $discount_code = $this->get_discount_code();
3824 3824
 
3825
-        if ( empty( $discount_code ) ) {
3825
+        if (empty($discount_code)) {
3826 3826
             return false;
3827 3827
         }
3828 3828
 
3829
-        $discount = wpinv_get_discount_obj( $discount_code );
3829
+        $discount = wpinv_get_discount_obj($discount_code);
3830 3830
 
3831 3831
         // Ensure it is active.
3832 3832
         return $discount->exists();
@@ -3837,7 +3837,7 @@  discard block
 block discarded – undo
3837 3837
 	 * Refunds an invoice.
3838 3838
 	 */
3839 3839
     public function refund() {
3840
-		$this->set_status( 'wpi-refunded' );
3840
+		$this->set_status('wpi-refunded');
3841 3841
         $this->save();
3842 3842
 	}
3843 3843
 
@@ -3846,53 +3846,53 @@  discard block
 block discarded – undo
3846 3846
 	 * 
3847 3847
 	 * @param string $transaction_id
3848 3848
 	 */
3849
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3849
+    public function mark_paid($transaction_id = null, $note = '') {
3850 3850
 
3851 3851
 		// Set the transaction id.
3852
-		if ( empty( $transaction_id ) ) {
3852
+		if (empty($transaction_id)) {
3853 3853
 			$transaction_id = $this->generate_key('trans_');
3854 3854
 		}
3855 3855
 
3856
-		if ( ! $this->get_transaction_id() ) {
3857
-			$this->set_transaction_id( $transaction_id );
3856
+		if (!$this->get_transaction_id()) {
3857
+			$this->set_transaction_id($transaction_id);
3858 3858
 		}
3859 3859
 
3860
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3860
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3861 3861
 			return $this->save();
3862 3862
 		}
3863 3863
 
3864 3864
 		// Set the completed date.
3865
-		$this->set_date_completed( current_time( 'mysql' ) );
3865
+		$this->set_date_completed(current_time('mysql'));
3866 3866
 
3867 3867
 		// Set the new status.
3868
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3869
-		if ( $this->is_renewal() ) {
3868
+		$gateway = sanitize_text_field($this->get_gateway_title());
3869
+		if ($this->is_renewal()) {
3870 3870
 
3871
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3872
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3871
+			$_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway);
3872
+			$_note = $_note . empty($note) ? '' : " ($note)";
3873 3873
 
3874
-			if ( 'none' == $this->get_gateway() ) {
3874
+			if ('none' == $this->get_gateway()) {
3875 3875
 				$_note = $note;
3876 3876
 			}
3877 3877
 
3878
-			$this->set_status( 'wpi-renewal', $_note );
3878
+			$this->set_status('wpi-renewal', $_note);
3879 3879
 
3880 3880
 		} else {
3881 3881
 
3882
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3883
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3882
+			$_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway);
3883
+			$_note = $_note . empty($note) ? '' : " ($note)";
3884 3884
 
3885
-			if ( 'none' == $this->get_gateway() ) {
3885
+			if ('none' == $this->get_gateway()) {
3886 3886
 				$_note = $note;
3887 3887
 			}
3888 3888
 
3889
-			$this->set_status( 'publish', $_note );
3889
+			$this->set_status('publish', $_note);
3890 3890
 
3891 3891
 		}
3892 3892
 
3893 3893
 		// Set checkout mode.
3894
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3895
-		$this->set_mode( $mode );
3894
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3895
+		$this->set_mode($mode);
3896 3896
 
3897 3897
 		// Save the invoice.
3898 3898
         $this->save();
@@ -3917,9 +3917,9 @@  discard block
 block discarded – undo
3917 3917
      * Clears the subscription's cache.
3918 3918
      */
3919 3919
     public function clear_cache() {
3920
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3921
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3922
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3920
+		wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
3921
+		wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
3922
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
3923 3923
 	}
3924 3924
 
3925 3925
 }
Please login to merge, or discard this patch.