Passed
Push — master ( 345b42...86cae5 )
by Brian
05:49
created
includes/user-functions.php 2 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
  */
72 72
 function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) {
73 73
 
74
-	if ( current_user_can( 'manage_options' ) ) {
75
-		return 'manage_options';
76
-	};
74
+    if ( current_user_can( 'manage_options' ) ) {
75
+        return 'manage_options';
76
+    };
77 77
 
78
-	return $capalibilty;
78
+    return $capalibilty;
79 79
 }
80 80
 
81 81
 /**
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
  * @return bool Whether the current user has the given capability.
99 99
  */
100 100
 function wpinv_current_user_can( $capability, $args = array() ) {
101
-	$can = wpinv_current_user_can_manage_invoicing();
101
+    $can = wpinv_current_user_can_manage_invoicing();
102 102
 
103
-	return apply_filters( 'getpaid_current_user_can', $can, $capability, $args );
103
+    return apply_filters( 'getpaid_current_user_can', $can, $capability, $args );
104 104
 }
105 105
 
106 106
 /**
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
     // Prepare user values.
115 115
     $prefix = preg_replace( '/\s+/', '', $prefix );
116 116
     $prefix = empty( $prefix ) ? $email : $prefix;
117
-	$args   = array(
118
-		'user_login' => wpinv_generate_user_name( $prefix ),
119
-		'user_pass'  => wp_generate_password(),
120
-		'user_email' => $email,
117
+    $args   = array(
118
+        'user_login' => wpinv_generate_user_name( $prefix ),
119
+        'user_pass'  => wp_generate_password(),
120
+        'user_email' => $email,
121 121
         'role'       => 'subscriber',
122 122
     );
123 123
 
@@ -134,16 +134,16 @@  discard block
 block discarded – undo
134 134
 function wpinv_generate_user_name( $prefix = '' ) {
135 135
 
136 136
     // If prefix is an email, retrieve the part before the email.
137
-	$prefix = strtok( $prefix, '@' );
137
+    $prefix = strtok( $prefix, '@' );
138 138
     $prefix = trim( $prefix, '.' );
139 139
 
140
-	// Sanitize the username.
141
-	$prefix = sanitize_user( $prefix, true );
140
+    // Sanitize the username.
141
+    $prefix = sanitize_user( $prefix, true );
142 142
 
143
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
144
-	if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
145
-		$prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
146
-	}
143
+    $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
144
+    if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
145
+        $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
146
+    }
147 147
 
148 148
     $username = $prefix;
149 149
     $postfix  = 2;
@@ -282,43 +282,43 @@  discard block
 block discarded – undo
282 282
 
283 283
                         $value = $customer->get( $key );
284 284
 
285
-					// Display the country.
286
-					if ( 'country' == $key ) {
287
-
288
-						aui()->select(
289
-							array(
290
-								'options'     => wpinv_get_country_list(),
291
-								'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
292
-								'id'          => 'wpinv-' . sanitize_html_class( $key ),
293
-								'value'       => sanitize_text_field( $value ),
294
-								'placeholder' => $label,
295
-								'label'       => wp_kses_post( $label ),
296
-								'label_type'  => 'vertical',
297
-								'class'       => 'getpaid-address-field',
285
+                    // Display the country.
286
+                    if ( 'country' == $key ) {
287
+
288
+                        aui()->select(
289
+                            array(
290
+                                'options'     => wpinv_get_country_list(),
291
+                                'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
292
+                                'id'          => 'wpinv-' . sanitize_html_class( $key ),
293
+                                'value'       => sanitize_text_field( $value ),
294
+                                'placeholder' => $label,
295
+                                'label'       => wp_kses_post( $label ),
296
+                                'label_type'  => 'vertical',
297
+                                'class'       => 'getpaid-address-field',
298 298
                             ),
299 299
                             true
300
-						);
300
+                        );
301 301
 
302
-					}
302
+                    }
303 303
 
304
-					// Display the state.
305
-					elseif ( 'state' == $key ) {
304
+                    // Display the state.
305
+                    elseif ( 'state' == $key ) {
306 306
 
307
-						getpaid_get_states_select_markup(
307
+                        getpaid_get_states_select_markup(
308 308
                             $customer->get( 'country' ),
309
-							$value,
310
-							$label,
311
-							$label,
312
-							'',
313
-							false,
314
-							'',
315
-							'getpaid_address[' . esc_attr( $key ) . ']',
309
+                            $value,
310
+                            $label,
311
+                            $label,
312
+                            '',
313
+                            false,
314
+                            '',
315
+                            'getpaid_address[' . esc_attr( $key ) . ']',
316 316
                             true
317
-						);
317
+                        );
318 318
 
319 319
                         } else {
320 320
 
321
-						aui()->input(
321
+                        aui()->input(
322 322
                             array(
323 323
                                 'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
324 324
                                 'id'          => 'wpinv-' . sanitize_html_class( $key ),
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
                                 'class'       => 'getpaid-address-field',
331 331
                             ),
332 332
                             true
333
-						);
333
+                        );
334 334
 
335 335
                         }
336 336
                     }
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 function getpaid_allowed_html() {
475 475
     $allowed_html = wp_kses_allowed_html( 'post' );
476 476
 
477
-	// form fields
477
+    // form fields
478 478
     $allowed_html['form'] = array(
479 479
         'action'         => true,
480 480
         'accept'         => true,
@@ -486,12 +486,12 @@  discard block
 block discarded – undo
486 486
     );
487 487
 
488 488
     // - input
489
-	$allowed_html['input'] = array(
490
-		'class'        => array(),
491
-		'id'           => array(),
492
-		'name'         => array(),
493
-		'value'        => array(),
494
-		'type'         => array(),
489
+    $allowed_html['input'] = array(
490
+        'class'        => array(),
491
+        'id'           => array(),
492
+        'name'         => array(),
493
+        'value'        => array(),
494
+        'type'         => array(),
495 495
         'placeholder'  => array(),
496 496
         'autocomplete' => array(),
497 497
         'autofocus'    => array(),
@@ -505,33 +505,33 @@  discard block
 block discarded – undo
505 505
         'max'          => array(),
506 506
         'step'         => array(),
507 507
         'size'         => array(),
508
-	);
508
+    );
509 509
 
510 510
     // - input
511
-	$allowed_html['textarea'] = array(
512
-		'class' => array(),
513
-		'id'    => array(),
514
-		'name'  => array(),
515
-		'value' => array(),
516
-	);
517
-
518
-	// select
519
-	$allowed_html['select'] = array(
520
-		'class'        => array(),
521
-		'id'           => array(),
522
-		'name'         => array(),
511
+    $allowed_html['textarea'] = array(
512
+        'class' => array(),
513
+        'id'    => array(),
514
+        'name'  => array(),
515
+        'value' => array(),
516
+    );
517
+
518
+    // select
519
+    $allowed_html['select'] = array(
520
+        'class'        => array(),
521
+        'id'           => array(),
522
+        'name'         => array(),
523 523
         'autocomplete' => array(),
524 524
         'multiple'     => array(),
525
-	);
525
+    );
526 526
 
527
-	// select options
528
-	$allowed_html['option'] = array(
529
-		'selected' => array(),
527
+    // select options
528
+    $allowed_html['option'] = array(
529
+        'selected' => array(),
530 530
         'disabled' => array(),
531 531
         'value'    => array(),
532
-	);
532
+    );
533 533
 
534
-	return $allowed_html;
534
+    return $allowed_html;
535 535
 
536 536
 }
537 537
 
Please login to merge, or discard this patch.
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package GetPaid
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves a customer.
@@ -14,19 +14,19 @@  discard block
 block discarded – undo
14 14
  * @param int|string|object|GetPaid_Customer $customer customer id, email or object.
15 15
  * @return GetPaid_Customer|null
16 16
  */
17
-function getpaid_get_customer( $customer ) {
17
+function getpaid_get_customer($customer) {
18 18
 
19
-    if ( empty( $customer ) ) {
19
+    if (empty($customer)) {
20 20
         return null;
21 21
     }
22 22
 
23 23
     // Retrieve the customer.
24
-    if ( ! is_a( $customer, 'GetPaid_Customer' ) ) {
25
-        $customer = new GetPaid_Customer( $customer );
24
+    if (!is_a($customer, 'GetPaid_Customer')) {
25
+        $customer = new GetPaid_Customer($customer);
26 26
     }
27 27
 
28 28
     // Check if it exists.
29
-    if ( $customer->exists() ) {
29
+    if ($customer->exists()) {
30 30
         return $customer;
31 31
     }
32 32
 
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
  * @return GetPaid_Customer|null
40 40
  * @since 1.0.0
41 41
  */
42
-function getpaid_get_customer_by_user_id( $user_id ) {
42
+function getpaid_get_customer_by_user_id($user_id) {
43 43
     return getpaid_get_customer(
44
-        GetPaid_Customer::get_customer_id_by( $user_id, 'user_id' )
44
+        GetPaid_Customer::get_customer_id_by($user_id, 'user_id')
45 45
     );
46 46
 }
47 47
 
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
  * @param array $args
54 54
  * @see wp_dropdown_users
55 55
  */
56
-function wpinv_dropdown_users( $args = '' ) {
56
+function wpinv_dropdown_users($args = '') {
57 57
 
58
-    if ( is_array( $args ) && ! empty( $args['show'] ) && 'display_name_with_email' == $args['show'] ) {
58
+    if (is_array($args) && !empty($args['show']) && 'display_name_with_email' == $args['show']) {
59 59
         $args['show'] = 'display_name_with_login';
60 60
     }
61 61
 
62
-    return wp_dropdown_users( $args );
62
+    return wp_dropdown_users($args);
63 63
 }
64 64
 
65 65
 /**
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
  * @return string capability to check against
70 70
  * @param string $capalibilty Optional. The alternative capability to check against.
71 71
  */
72
-function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) {
72
+function wpinv_get_capability($capalibilty = 'manage_invoicing') {
73 73
 
74
-	if ( current_user_can( 'manage_options' ) ) {
74
+	if (current_user_can('manage_options')) {
75 75
 		return 'manage_options';
76 76
 	};
77 77
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
  * @return bool
86 86
  */
87 87
 function wpinv_current_user_can_manage_invoicing() {
88
-    return current_user_can( wpinv_get_capability() );
88
+    return current_user_can(wpinv_get_capability());
89 89
 }
90 90
 
91 91
 /**
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
  * @param mixed  $args    Optional further parameters, typically starting with an object.
98 98
  * @return bool Whether the current user has the given capability.
99 99
  */
100
-function wpinv_current_user_can( $capability, $args = array() ) {
100
+function wpinv_current_user_can($capability, $args = array()) {
101 101
 	$can = wpinv_current_user_can_manage_invoicing();
102 102
 
103
-	return apply_filters( 'getpaid_current_user_can', $can, $capability, $args );
103
+	return apply_filters('getpaid_current_user_can', $can, $capability, $args);
104 104
 }
105 105
 
106 106
 /**
@@ -109,19 +109,19 @@  discard block
 block discarded – undo
109 109
  * @since 1.0.19
110 110
  * @return int|WP_Error
111 111
  */
112
-function wpinv_create_user( $email, $prefix = '' ) {
112
+function wpinv_create_user($email, $prefix = '') {
113 113
 
114 114
     // Prepare user values.
115
-    $prefix = preg_replace( '/\s+/', '', $prefix );
116
-    $prefix = empty( $prefix ) ? $email : $prefix;
117
-	$args   = array(
118
-		'user_login' => wpinv_generate_user_name( $prefix ),
115
+    $prefix = preg_replace('/\s+/', '', $prefix);
116
+    $prefix = empty($prefix) ? $email : $prefix;
117
+	$args = array(
118
+		'user_login' => wpinv_generate_user_name($prefix),
119 119
 		'user_pass'  => wp_generate_password(),
120 120
 		'user_email' => $email,
121 121
         'role'       => 'subscriber',
122 122
     );
123 123
 
124
-    return wp_insert_user( $args );
124
+    return wp_insert_user($args);
125 125
 
126 126
 }
127 127
 
@@ -131,26 +131,26 @@  discard block
 block discarded – undo
131 131
  * @since 1.0.19
132 132
  * @return bool|WP_User
133 133
  */
134
-function wpinv_generate_user_name( $prefix = '' ) {
134
+function wpinv_generate_user_name($prefix = '') {
135 135
 
136 136
     // If prefix is an email, retrieve the part before the email.
137
-	$prefix = strtok( $prefix, '@' );
138
-    $prefix = trim( $prefix, '.' );
137
+	$prefix = strtok($prefix, '@');
138
+    $prefix = trim($prefix, '.');
139 139
 
140 140
 	// Sanitize the username.
141
-	$prefix = sanitize_user( $prefix, true );
141
+	$prefix = sanitize_user($prefix, true);
142 142
 
143
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
144
-	if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
145
-		$prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
143
+	$illegal_logins = (array) apply_filters('illegal_user_logins', array());
144
+	if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) {
145
+		$prefix = 'gtp_' . zeroise(wp_rand(0, 9999), 4);
146 146
 	}
147 147
 
148 148
     $username = $prefix;
149 149
     $postfix  = 2;
150 150
 
151
-    while ( username_exists( $username ) ) {
151
+    while (username_exists($username)) {
152 152
         $username = "{$prefix}{$postfix}";
153
-        $postfix ++;
153
+        $postfix++;
154 154
     }
155 155
 
156 156
     return $username;
@@ -167,31 +167,31 @@  discard block
 block discarded – undo
167 167
     $tabs = array(
168 168
 
169 169
         'gp-invoices'      => array(
170
-            'label'   => __( 'Invoices', 'invoicing' ), // Name of the tab.
170
+            'label'   => __('Invoices', 'invoicing'), // Name of the tab.
171 171
             'content' => '[wpinv_history]', // Content of the tab. Or specify "callback" to provide a callback instead.
172 172
             'icon'    => 'fas fa-file-invoice', // Shown on some profile plugins.
173 173
         ),
174 174
 
175 175
         'gp-subscriptions' => array(
176
-            'label'   => __( 'Subscriptions', 'invoicing' ),
176
+            'label'   => __('Subscriptions', 'invoicing'),
177 177
             'content' => '[wpinv_subscriptions]',
178 178
             'icon'    => 'fas fa-redo',
179 179
         ),
180 180
 
181 181
         'gp-edit-address'  => array(
182
-            'label'    => __( 'Billing Address', 'invoicing' ),
182
+            'label'    => __('Billing Address', 'invoicing'),
183 183
             'callback' => 'getpaid_display_address_edit_tab',
184 184
             'icon'     => 'fas fa-credit-card',
185 185
         ),
186 186
 
187 187
     );
188 188
 
189
-    $tabs = apply_filters( 'getpaid_user_content_tabs', $tabs );
189
+    $tabs = apply_filters('getpaid_user_content_tabs', $tabs);
190 190
 
191 191
     // Make sure address editing is last on the list.
192
-    if ( isset( $tabs['gp-edit-address'] ) ) {
192
+    if (isset($tabs['gp-edit-address'])) {
193 193
         $address = $tabs['gp-edit-address'];
194
-        unset( $tabs['gp-edit-address'] );
194
+        unset($tabs['gp-edit-address']);
195 195
         $tabs['gp-edit-address'] = $address;
196 196
     }
197 197
 
@@ -205,19 +205,19 @@  discard block
 block discarded – undo
205 205
  * @param array $tab
206 206
  * @return array
207 207
  */
208
-function getpaid_prepare_user_content_tab( $tab ) {
208
+function getpaid_prepare_user_content_tab($tab) {
209 209
 
210
-    if ( ! empty( $tab['callback'] ) ) {
211
-        return call_user_func( $tab['callback'] );
210
+    if (!empty($tab['callback'])) {
211
+        return call_user_func($tab['callback']);
212 212
     }
213 213
 
214
-    if ( ! empty( $tab['content'] ) ) {
215
-        return convert_smilies( capital_P_dangit( wp_filter_content_tags( do_shortcode( shortcode_unautop( wpautop( wptexturize( do_blocks( $tab['content'] ) ) ) ) ) ) ) );
214
+    if (!empty($tab['content'])) {
215
+        return convert_smilies(capital_P_dangit(wp_filter_content_tags(do_shortcode(shortcode_unautop(wpautop(wptexturize(do_blocks($tab['content']))))))));
216 216
     }
217 217
 
218 218
     $notice = aui()->alert(
219 219
         array(
220
-            'content' => __( 'This tab has no content or content callback.', 'invoicing' ),
220
+            'content' => __('This tab has no content or content callback.', 'invoicing'),
221 221
             'type'    => 'error',
222 222
         )
223 223
     );
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
  * @param string $default
234 234
  * @return array
235 235
  */
236
-function getpaid_get_tab_url( $tab, $default ) {
236
+function getpaid_get_tab_url($tab, $default) {
237 237
     global $getpaid_tab_url;
238 238
 
239
-    if ( empty( $getpaid_tab_url ) ) {
239
+    if (empty($getpaid_tab_url)) {
240 240
         return $default;
241 241
     }
242 242
 
243
-    return sprintf( $getpaid_tab_url, $tab );
243
+    return sprintf($getpaid_tab_url, $tab);
244 244
 
245 245
 }
246 246
 
@@ -252,21 +252,21 @@  discard block
 block discarded – undo
252 252
  */
253 253
 function getpaid_display_address_edit_tab() {
254 254
 
255
-    if ( 0 === get_current_user_id() ) {
255
+    if (0 === get_current_user_id()) {
256 256
         return '<div class="bsui">' . aui()->alert(
257 257
             array(
258 258
                 'type'        => 'error',
259
-                'content'     => __( 'Your must be logged in to view this section', 'invoicing' ),
259
+                'content'     => __('Your must be logged in to view this section', 'invoicing'),
260 260
                 'dismissible' => false,
261 261
             )
262 262
         ) . '</div>';
263 263
     }
264 264
 
265
-    $customer = getpaid_get_customer_by_user_id( get_current_user_id() );
265
+    $customer = getpaid_get_customer_by_user_id(get_current_user_id());
266 266
 
267
-    if ( empty( $customer ) ) {
268
-        $customer = new GetPaid_Customer( 0 );
269
-        $customer->clone_user( get_current_user_id() );
267
+    if (empty($customer)) {
268
+        $customer = new GetPaid_Customer(0);
269
+        $customer->clone_user(get_current_user_id());
270 270
         $customer->save();
271 271
     }
272 272
 
@@ -278,21 +278,21 @@  discard block
 block discarded – undo
278 278
 
279 279
                 <?php
280 280
 
281
-                    foreach ( getpaid_user_address_fields() as $key => $label ) {
281
+                    foreach (getpaid_user_address_fields() as $key => $label) {
282 282
 
283
-                        $value = $customer->get( $key );
283
+                        $value = $customer->get($key);
284 284
 
285 285
 					// Display the country.
286
-					if ( 'country' == $key ) {
286
+					if ('country' == $key) {
287 287
 
288 288
 						aui()->select(
289 289
 							array(
290 290
 								'options'     => wpinv_get_country_list(),
291
-								'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
292
-								'id'          => 'wpinv-' . sanitize_html_class( $key ),
293
-								'value'       => sanitize_text_field( $value ),
291
+								'name'        => 'getpaid_address[' . esc_attr($key) . ']',
292
+								'id'          => 'wpinv-' . sanitize_html_class($key),
293
+								'value'       => sanitize_text_field($value),
294 294
 								'placeholder' => $label,
295
-								'label'       => wp_kses_post( $label ),
295
+								'label'       => wp_kses_post($label),
296 296
 								'label_type'  => 'vertical',
297 297
 								'class'       => 'getpaid-address-field',
298 298
                             ),
@@ -302,17 +302,17 @@  discard block
 block discarded – undo
302 302
 					}
303 303
 
304 304
 					// Display the state.
305
-					elseif ( 'state' == $key ) {
305
+					elseif ('state' == $key) {
306 306
 
307 307
 						getpaid_get_states_select_markup(
308
-                            $customer->get( 'country' ),
308
+                            $customer->get('country'),
309 309
 							$value,
310 310
 							$label,
311 311
 							$label,
312 312
 							'',
313 313
 							false,
314 314
 							'',
315
-							'getpaid_address[' . esc_attr( $key ) . ']',
315
+							'getpaid_address[' . esc_attr($key) . ']',
316 316
                             true
317 317
 						);
318 318
 
@@ -320,13 +320,13 @@  discard block
 block discarded – undo
320 320
 
321 321
 						aui()->input(
322 322
                             array(
323
-                                'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
324
-                                'id'          => 'wpinv-' . sanitize_html_class( $key ),
323
+                                'name'        => 'getpaid_address[' . esc_attr($key) . ']',
324
+                                'id'          => 'wpinv-' . sanitize_html_class($key),
325 325
                                 'placeholder' => $label,
326
-                                'label'       => wp_kses_post( $label ),
326
+                                'label'       => wp_kses_post($label),
327 327
                                 'label_type'  => 'vertical',
328 328
                                 'type'        => 'text',
329
-                                'value'       => sanitize_text_field( $value ),
329
+                                'value'       => sanitize_text_field($value),
330 330
                                 'class'       => 'getpaid-address-field',
331 331
                             ),
332 332
                             true
@@ -340,32 +340,32 @@  discard block
 block discarded – undo
340 340
                             'name'        => 'getpaid_address[email_cc]',
341 341
                             'id'          => 'wpinv-email_cc',
342 342
                             'placeholder' => '[email protected], [email protected]',
343
-                            'label'       => __( 'Other email addresses', 'invoicing' ),
343
+                            'label'       => __('Other email addresses', 'invoicing'),
344 344
                             'label_type'  => 'vertical',
345 345
                             'type'        => 'text',
346
-                            'value'       => sanitize_text_field( $customer->get( 'email_cc' ) ),
346
+                            'value'       => sanitize_text_field($customer->get('email_cc')),
347 347
                             'class'       => 'getpaid-address-field',
348
-                            'help_text'   => __( 'Optionally provide other email addresses where we should send payment notifications', 'invoicing' ),
348
+                            'help_text'   => __('Optionally provide other email addresses where we should send payment notifications', 'invoicing'),
349 349
                         ),
350 350
                         true
351 351
                     );
352 352
 
353
-                    do_action( 'getpaid_display_address_edit_tab' );
353
+                    do_action('getpaid_display_address_edit_tab');
354 354
 
355 355
                     aui()->input(
356 356
                         array(
357 357
                             'name'      => 'getpaid_profile_edit_submit_button',
358 358
                             'id'        => 'getpaid_profile_edit_submit_button',
359
-                            'value'     => __( 'Save Address', 'invoicing' ),
360
-                            'help_text' => __( 'New invoices will use this address as the billing address.', 'invoicing' ),
359
+                            'value'     => __('Save Address', 'invoicing'),
360
+                            'help_text' => __('New invoices will use this address as the billing address.', 'invoicing'),
361 361
                             'type'      => 'submit',
362 362
                             'class'     => 'btn btn-primary btn-block submit-button',
363 363
                         ),
364 364
                         true
365 365
                     );
366 366
 
367
-                    wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' );
368
-                    getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' );
367
+                    wp_nonce_field('getpaid-nonce', 'getpaid-nonce');
368
+                    getpaid_hidden_field('getpaid-action', 'edit_billing_details');
369 369
                 ?>
370 370
 
371 371
             </form>
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 
376 376
     return ob_get_clean();
377 377
 }
378
-add_shortcode( 'getpaid_edit_address', 'getpaid_display_address_edit_tab' );
378
+add_shortcode('getpaid_edit_address', 'getpaid_display_address_edit_tab');
379 379
 
380 380
 /**
381 381
  * Saves the billing address edit tab.
@@ -383,35 +383,35 @@  discard block
 block discarded – undo
383 383
  * @since 2.1.4
384 384
  * @param array $data
385 385
  */
386
-function getpaid_save_address_edit_tab( $data ) {
386
+function getpaid_save_address_edit_tab($data) {
387 387
 
388
-    if ( empty( $data['getpaid_address'] ) || ! is_array( $data['getpaid_address'] ) ) {
388
+    if (empty($data['getpaid_address']) || !is_array($data['getpaid_address'])) {
389 389
         return;
390 390
     }
391 391
 
392 392
     $data     = $data['getpaid_address'];
393
-    $customer = getpaid_get_customer_by_user_id( get_current_user_id() );
393
+    $customer = getpaid_get_customer_by_user_id(get_current_user_id());
394 394
 
395
-    if ( empty( $customer ) ) {
396
-        $customer = new GetPaid_Customer( 0 );
397
-        $customer->clone_user( get_current_user_id() );
395
+    if (empty($customer)) {
396
+        $customer = new GetPaid_Customer(0);
397
+        $customer->clone_user(get_current_user_id());
398 398
     }
399 399
 
400
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
400
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
401 401
 
402
-        if ( isset( $data[ $field ] ) ) {
403
-            $customer->set( $field, sanitize_text_field( $data[ $field ] ) );
402
+        if (isset($data[$field])) {
403
+            $customer->set($field, sanitize_text_field($data[$field]));
404 404
         }
405 405
     }
406 406
 
407
-    if ( isset( $data['email_cc'] ) ) {
408
-        $customer->set( 'email_cc', sanitize_text_field( $data['email_cc'] ) );
407
+    if (isset($data['email_cc'])) {
408
+        $customer->set('email_cc', sanitize_text_field($data['email_cc']));
409 409
     }
410 410
 
411 411
     $customer->save();
412
-    wpinv_set_error( 'address_updated' );
412
+    wpinv_set_error('address_updated');
413 413
 }
414
-add_action( 'getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab' );
414
+add_action('getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab');
415 415
 
416 416
 
417 417
 /*
@@ -429,27 +429,27 @@  discard block
 block discarded – undo
429 429
  * @param  array $tabs
430 430
  * @return array
431 431
  */
432
-function getpaid_filter_userswp_account_tabs( $tabs ) {
432
+function getpaid_filter_userswp_account_tabs($tabs) {
433 433
 
434 434
     // Abort if the integration is inactive.
435
-    if ( ! getpaid_is_userswp_integration_active() ) {
435
+    if (!getpaid_is_userswp_integration_active()) {
436 436
         return $tabs;
437 437
     }
438 438
 
439
-    $new_tabs   = array();
439
+    $new_tabs = array();
440 440
 
441
-    foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) {
441
+    foreach (getpaid_get_user_content_tabs() as $slug => $tab) {
442 442
 
443
-        $new_tabs[ $slug ] = array(
443
+        $new_tabs[$slug] = array(
444 444
             'title' => $tab['label'],
445 445
             'icon'  => $tab['icon'],
446 446
         );
447 447
 
448 448
     }
449 449
 
450
-    return array_merge( $tabs, $new_tabs );
450
+    return array_merge($tabs, $new_tabs);
451 451
 }
452
-add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' );
452
+add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs');
453 453
 
454 454
 /**
455 455
  * Display our UsersWP account tabs.
@@ -458,21 +458,21 @@  discard block
 block discarded – undo
458 458
  * @param  array $tabs
459 459
  * @return array
460 460
  */
461
-function getpaid_display_userswp_account_tabs( $tab ) {
461
+function getpaid_display_userswp_account_tabs($tab) {
462 462
     global $getpaid_tab_url;
463 463
 
464 464
     $our_tabs = getpaid_get_user_content_tabs();
465 465
 
466
-    if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) {
467
-        $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() );
468
-        echo wp_kses( getpaid_prepare_user_content_tab( $our_tabs[ $tab ] ), getpaid_allowed_html() );
466
+    if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) {
467
+        $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url());
468
+        echo wp_kses(getpaid_prepare_user_content_tab($our_tabs[$tab]), getpaid_allowed_html());
469 469
     }
470 470
 
471 471
 }
472
-add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' );
472
+add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs');
473 473
 
474 474
 function getpaid_allowed_html() {
475
-    $allowed_html = wp_kses_allowed_html( 'post' );
475
+    $allowed_html = wp_kses_allowed_html('post');
476 476
 
477 477
 	// form fields
478 478
     $allowed_html['form'] = array(
@@ -543,17 +543,17 @@  discard block
 block discarded – undo
543 543
  * @param  string $tab   Current tab.
544 544
  * @return string Title.
545 545
  */
546
-function getpaid_filter_userswp_account_title( $title, $tab ) {
546
+function getpaid_filter_userswp_account_title($title, $tab) {
547 547
 
548
-    $our_tabs   = getpaid_get_user_content_tabs();
548
+    $our_tabs = getpaid_get_user_content_tabs();
549 549
 
550
-    if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) {
551
-        return $our_tabs[ $tab ]['label'];
550
+    if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) {
551
+        return $our_tabs[$tab]['label'];
552 552
     }
553 553
 
554 554
     return $title;
555 555
 }
556
-add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 );
556
+add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2);
557 557
 
558 558
 /**
559 559
  * Registers the UsersWP integration settings.
@@ -562,26 +562,26 @@  discard block
 block discarded – undo
562 562
  * @param  array $settings An array of integration settings.
563 563
  * @return array
564 564
  */
565
-function getpaid_register_userswp_settings( $settings ) {
565
+function getpaid_register_userswp_settings($settings) {
566 566
 
567
-    if ( defined( 'USERSWP_PLUGIN_FILE' ) ) {
567
+    if (defined('USERSWP_PLUGIN_FILE')) {
568 568
 
569 569
         $settings[] = array(
570 570
 
571 571
             'id'       => 'userswp',
572
-            'label'    => __( 'UsersWP', 'invoicing' ),
572
+            'label'    => __('UsersWP', 'invoicing'),
573 573
             'settings' => array(
574 574
 
575 575
                 'userswp_settings' => array(
576 576
                     'id'   => 'userswp_settings',
577
-                    'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>',
577
+                    'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>',
578 578
                     'type' => 'header',
579 579
                 ),
580 580
 
581 581
                 'enable_userswp'   => array(
582 582
                     'id'   => 'enable_userswp',
583
-                    'name' => __( 'Enable Integration', 'invoicing' ),
584
-                    'desc' => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ),
583
+                    'name' => __('Enable Integration', 'invoicing'),
584
+                    'desc' => __('Display GetPaid items on UsersWP account page.', 'invoicing'),
585 585
                     'type' => 'checkbox',
586 586
                     'std'  => 1,
587 587
                 ),
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 
595 595
     return $settings;
596 596
 }
597
-add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' );
597
+add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings');
598 598
 
599 599
 /**
600 600
  * Ovewrites the invoices history page to UsersWP.
@@ -602,18 +602,18 @@  discard block
 block discarded – undo
602 602
  * @since  2.3.1
603 603
  * @return bool
604 604
  */
605
-function getpaid_userswp_overwrite_invoice_history_page( $url, $post_type ) {
605
+function getpaid_userswp_overwrite_invoice_history_page($url, $post_type) {
606 606
 
607 607
     $our_tabs = getpaid_get_user_content_tabs();
608 608
     $tab      = "gp-{$post_type}s";
609
-    if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) {
610
-        return add_query_arg( 'type', $tab, uwp_get_account_page_url() );
609
+    if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) {
610
+        return add_query_arg('type', $tab, uwp_get_account_page_url());
611 611
     }
612 612
 
613 613
     return $url;
614 614
 
615 615
 }
616
-add_filter( 'wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2 );
616
+add_filter('wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2);
617 617
 
618 618
 /**
619 619
  * Checks if the integration is enabled.
@@ -622,8 +622,8 @@  discard block
 block discarded – undo
622 622
  * @return bool
623 623
  */
624 624
 function getpaid_is_userswp_integration_active() {
625
-    $enabled = wpinv_get_option( 'enable_userswp', 1 );
626
-    return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled );
625
+    $enabled = wpinv_get_option('enable_userswp', 1);
626
+    return defined('USERSWP_PLUGIN_FILE') && !empty($enabled);
627 627
 }
628 628
 
629 629
 /*
@@ -641,26 +641,26 @@  discard block
 block discarded – undo
641 641
  * @param  array $settings An array of integration settings.
642 642
  * @return array
643 643
  */
644
-function getpaid_register_buddypress_settings( $settings ) {
644
+function getpaid_register_buddypress_settings($settings) {
645 645
 
646
-    if ( class_exists( 'BuddyPress' ) ) {
646
+    if (class_exists('BuddyPress')) {
647 647
 
648 648
         $settings[] = array(
649 649
 
650 650
             'id'       => 'buddypress',
651
-            'label'    => __( 'BuddyPress', 'invoicing' ),
651
+            'label'    => __('BuddyPress', 'invoicing'),
652 652
             'settings' => array(
653 653
 
654 654
                 'buddypress_settings' => array(
655 655
                     'id'   => 'buddypress_settings',
656
-                    'name' => '<h3>' . __( 'BuddyPress', 'invoicing' ) . '</h3>',
656
+                    'name' => '<h3>' . __('BuddyPress', 'invoicing') . '</h3>',
657 657
                     'type' => 'header',
658 658
                 ),
659 659
 
660 660
                 'enable_buddypress'   => array(
661 661
                     'id'   => 'enable_buddypress',
662
-                    'name' => __( 'Enable Integration', 'invoicing' ),
663
-                    'desc' => __( 'Display GetPaid items on BuddyPress account pages.', 'invoicing' ),
662
+                    'name' => __('Enable Integration', 'invoicing'),
663
+                    'desc' => __('Display GetPaid items on BuddyPress account pages.', 'invoicing'),
664 664
                     'type' => 'checkbox',
665 665
                     'std'  => 1,
666 666
                 ),
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 
674 674
     return $settings;
675 675
 }
676
-add_filter( 'getpaid_integration_settings', 'getpaid_register_buddypress_settings' );
676
+add_filter('getpaid_integration_settings', 'getpaid_register_buddypress_settings');
677 677
 
678 678
 /**
679 679
  * Checks if the integration is enabled.
@@ -682,8 +682,8 @@  discard block
 block discarded – undo
682 682
  * @return bool
683 683
  */
684 684
 function getpaid_is_buddypress_integration_active() {
685
-    $enabled = wpinv_get_option( 'enable_buddypress', 1 );
686
-    return class_exists( 'BuddyPress' ) && ! empty( $enabled );
685
+    $enabled = wpinv_get_option('enable_buddypress', 1);
686
+    return class_exists('BuddyPress') && !empty($enabled);
687 687
 }
688 688
 
689 689
 /**
@@ -694,13 +694,13 @@  discard block
 block discarded – undo
694 694
  */
695 695
 function getpaid_setup_buddypress_integration() {
696 696
 
697
-    if ( getpaid_is_buddypress_integration_active() ) {
697
+    if (getpaid_is_buddypress_integration_active()) {
698 698
         require_once WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php';
699 699
         buddypress()->getpaid = new BP_GetPaid_Component();
700 700
     }
701 701
 
702 702
 }
703
-add_action( 'bp_setup_components', 'getpaid_setup_buddypress_integration' );
703
+add_action('bp_setup_components', 'getpaid_setup_buddypress_integration');
704 704
 
705 705
 /**
706 706
  * Checks if a given user has purchased a given item.
@@ -709,10 +709,10 @@  discard block
 block discarded – undo
709 709
  * @param int $item_id The item id.
710 710
  * @return int The IDs of users who purchased the item.
711 711
  */
712
-function getpaid_user_ids_who_purchased_item( $item_id ) {
712
+function getpaid_user_ids_who_purchased_item($item_id) {
713 713
     global $wpdb;
714 714
 
715
-    if ( empty( $item_id ) ) {
715
+    if (empty($item_id)) {
716 716
         return false;
717 717
     }
718 718
 
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
         )
726 726
     );
727 727
 
728
-    return wp_parse_id_list( $ids );
728
+    return wp_parse_id_list($ids);
729 729
 }
730 730
 
731 731
 /**
@@ -734,10 +734,10 @@  discard block
 block discarded – undo
734 734
  * @since 2.6.17
735 735
  * @param int $user_id The user id.
736 736
  */
737
-function getpaid_has_user_purchased_item( $user_id, $item_id ) {
737
+function getpaid_has_user_purchased_item($user_id, $item_id) {
738 738
     global $wpdb;
739 739
 
740
-    if ( empty( $user_id ) ) {
740
+    if (empty($user_id)) {
741 741
         return false;
742 742
     }
743 743
 
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
         )
753 753
     );
754 754
 
755
-    return ! empty( $count );
755
+    return !empty($count);
756 756
 }
757 757
 
758 758
 /**
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
  * @since 2.6.17
762 762
  * @param int $user_id The user id.
763 763
  */
764
-function getpaid_get_user_total_spend( $user_id ) {
764
+function getpaid_get_user_total_spend($user_id) {
765 765
     $args = array(
766 766
         'data'           => array(
767 767
 
@@ -776,17 +776,17 @@  discard block
 block discarded – undo
776 776
 
777 777
             'author' => array(
778 778
                 'type'     => 'post_data',
779
-                'value'    => absint( $user_id ),
779
+                'value'    => absint($user_id),
780 780
                 'key'      => 'posts.post_author',
781 781
                 'operator' => '=',
782 782
             ),
783 783
 
784 784
         ),
785 785
         'query_type'     => 'get_var',
786
-        'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ),
786
+        'invoice_status' => array('wpi-renewal', 'wpi-processing', 'publish'),
787 787
     );
788 788
 
789
-    return wpinv_round_amount( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
789
+    return wpinv_round_amount(GetPaid_Reports_Helper::get_invoice_report_data($args));
790 790
 }
791 791
 
792 792
 /**
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
  * @since 2.6.17
796 796
  * @param int $user_id The user id.
797 797
  */
798
-function getpaid_count_user_invoices( $user_id ) {
798
+function getpaid_count_user_invoices($user_id) {
799 799
     $args = array(
800 800
         'data'           => array(
801 801
 
@@ -811,15 +811,15 @@  discard block
 block discarded – undo
811 811
 
812 812
             'author' => array(
813 813
                 'type'     => 'post_data',
814
-                'value'    => absint( $user_id ),
814
+                'value'    => absint($user_id),
815 815
                 'key'      => 'posts.post_author',
816 816
                 'operator' => '=',
817 817
             ),
818 818
 
819 819
         ),
820 820
         'query_type'     => 'get_var',
821
-        'invoice_status' => array_keys( wpinv_get_invoice_statuses() ),
821
+        'invoice_status' => array_keys(wpinv_get_invoice_statuses()),
822 822
     );
823 823
 
824
-    return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
824
+    return absint(GetPaid_Reports_Helper::get_invoice_report_data($args));
825 825
 }
Please login to merge, or discard this patch.
includes/wpinv-address-functions.php 1 patch
Spacing   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // MUST have WordPress.
10
-if ( ! defined( 'WPINC' ) ) {
10
+if (!defined('WPINC')) {
11 11
     exit;
12 12
 }
13 13
 
14 14
 
15 15
 function wpinv_get_default_country() {
16
-	$country = wpinv_get_option( 'default_country', 'UK' );
16
+	$country = wpinv_get_option('default_country', 'UK');
17 17
 
18
-	return apply_filters( 'wpinv_default_country', $country );
18
+	return apply_filters('wpinv_default_country', $country);
19 19
 }
20 20
 
21 21
 /**
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return string
25 25
  */
26
-function getpaid_get_ip_country( $ip_address = '' ) {
27
-    $country = GetPaid_Geolocation::geolocate_ip( $ip_address, true );
26
+function getpaid_get_ip_country($ip_address = '') {
27
+    $country = GetPaid_Geolocation::geolocate_ip($ip_address, true);
28 28
     return $country['country'];
29 29
 }
30 30
 
@@ -34,59 +34,59 @@  discard block
 block discarded – undo
34 34
  * @param string $country The country code to sanitize
35 35
  * @return array
36 36
  */
37
-function wpinv_sanitize_country( $country ) {
37
+function wpinv_sanitize_country($country) {
38 38
 
39 39
 	// Enure the country is specified
40
-    if ( empty( $country ) ) {
40
+    if (empty($country)) {
41 41
         $country = wpinv_get_default_country();
42 42
     }
43
-    return trim( wpinv_utf8_strtoupper( $country ) );
43
+    return trim(wpinv_utf8_strtoupper($country));
44 44
 
45 45
 }
46 46
 
47
-function wpinv_is_base_country( $country ) {
47
+function wpinv_is_base_country($country) {
48 48
     $base_country = wpinv_get_default_country();
49 49
 
50
-    if ( $base_country === 'UK' ) {
50
+    if ($base_country === 'UK') {
51 51
         $base_country = 'GB';
52 52
     }
53
-    if ( $country == 'UK' ) {
53
+    if ($country == 'UK') {
54 54
         $country = 'GB';
55 55
     }
56 56
 
57
-    return ( $country && $country === $base_country ) ? true : false;
57
+    return ($country && $country === $base_country) ? true : false;
58 58
 }
59 59
 
60
-function wpinv_country_name( $country_code = '' ) {
60
+function wpinv_country_name($country_code = '') {
61 61
     $countries = wpinv_get_country_list();
62 62
     $country_code = $country_code == 'UK' ? 'GB' : $country_code;
63
-    $country = isset( $countries[ $country_code ] ) ? $countries[ $country_code ] : $country_code;
63
+    $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code;
64 64
 
65
-    return apply_filters( 'wpinv_country_name', $country, $country_code );
65
+    return apply_filters('wpinv_country_name', $country, $country_code);
66 66
 }
67 67
 
68 68
 function wpinv_get_default_state() {
69
-	$state = wpinv_get_option( 'default_state', '' );
69
+	$state = wpinv_get_option('default_state', '');
70 70
 
71
-	return apply_filters( 'wpinv_default_state', $state );
71
+	return apply_filters('wpinv_default_state', $state);
72 72
 }
73 73
 
74
-function wpinv_state_name( $state_code = '', $country_code = '' ) {
74
+function wpinv_state_name($state_code = '', $country_code = '') {
75 75
     $state = $state_code;
76 76
 
77
-    if ( ! empty( $country_code ) ) {
78
-        $states = wpinv_get_country_states( $country_code );
77
+    if (!empty($country_code)) {
78
+        $states = wpinv_get_country_states($country_code);
79 79
 
80
-        $state = ! empty( $states ) && isset( $states[ $state_code ] ) ? $states[ $state_code ] : $state;
80
+        $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state;
81 81
     }
82 82
 
83
-    return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code );
83
+    return apply_filters('wpinv_state_name', $state, $state_code, $country_code);
84 84
 }
85 85
 
86 86
 function wpinv_store_address() {
87
-    $address = wpinv_get_option( 'store_address', '' );
87
+    $address = wpinv_get_option('store_address', '');
88 88
 
89
-    return apply_filters( 'wpinv_store_address', $address );
89
+    return apply_filters('wpinv_store_address', $address);
90 90
 }
91 91
 
92 92
 /**
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
  *
95 95
  * @param WPInv_Invoice $invoice
96 96
  */
97
-function getpaid_maybe_add_default_address( &$invoice ) {
97
+function getpaid_maybe_add_default_address(&$invoice) {
98 98
 
99 99
     $user_id = $invoice->get_user_id();
100 100
 
101 101
     // Abort if the invoice belongs to no one.
102
-    if ( empty( $user_id ) ) {
102
+    if (empty($user_id)) {
103 103
         return;
104 104
     }
105 105
 
106 106
     // Fill in defaults whenever necessary.
107
-    foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) {
107
+    foreach (wpinv_get_user_address($user_id) as $key => $value) {
108 108
 
109
-        if ( is_callable( $invoice, "get_$key" ) ) {
110
-            $current = call_user_func( array( $invoice, "get_$key" ) );
109
+        if (is_callable($invoice, "get_$key")) {
110
+            $current = call_user_func(array($invoice, "get_$key"));
111 111
 
112
-            if ( empty( $current ) ) {
112
+            if (empty($current)) {
113 113
                 $method = "set_$key";
114
-                $invoice->$method( $value );
114
+                $invoice->$method($value);
115 115
             }
116 116
 }
117 117
 }
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
     $address_fields = apply_filters(
129 129
         'getpaid_user_address_fields',
130 130
         array(
131
-            'first_name' => __( 'First Name', 'invoicing' ),
132
-            'last_name'  => __( 'Last Name', 'invoicing' ),
133
-            'address'    => __( 'Address', 'invoicing' ),
134
-            'city'       => __( 'City', 'invoicing' ),
135
-            'country'    => __( 'Country', 'invoicing' ),
136
-            'state'      => __( 'State', 'invoicing' ),
137
-            'zip'        => __( 'Zip/Postal Code', 'invoicing' ),
138
-            'phone'      => __( 'Phone Number', 'invoicing' ),
139
-            'company'    => __( 'Company', 'invoicing' ),
140
-            'company_id' => __( 'Company ID', 'invoicing' ),
141
-            'vat_number' => __( 'VAT Number', 'invoicing' ),
131
+            'first_name' => __('First Name', 'invoicing'),
132
+            'last_name'  => __('Last Name', 'invoicing'),
133
+            'address'    => __('Address', 'invoicing'),
134
+            'city'       => __('City', 'invoicing'),
135
+            'country'    => __('Country', 'invoicing'),
136
+            'state'      => __('State', 'invoicing'),
137
+            'zip'        => __('Zip/Postal Code', 'invoicing'),
138
+            'phone'      => __('Phone Number', 'invoicing'),
139
+            'company'    => __('Company', 'invoicing'),
140
+            'company_id' => __('Company ID', 'invoicing'),
141
+            'vat_number' => __('VAT Number', 'invoicing'),
142 142
         )
143 143
     );
144 144
 
145
-    if ( ! wpinv_use_taxes() && isset( $address_fields['vat_number'] ) && ! wp_doing_ajax() ) {
146
-        unset( $address_fields['vat_number'] );
145
+    if (!wpinv_use_taxes() && isset($address_fields['vat_number']) && !wp_doing_ajax()) {
146
+        unset($address_fields['vat_number']);
147 147
     }
148 148
 
149 149
     return $address_fields;
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
  *
155 155
  * @return bool
156 156
  */
157
-function getpaid_is_address_field_whitelisted( $key ) {
158
-    return array_key_exists( $key, getpaid_user_address_fields() );
157
+function getpaid_is_address_field_whitelisted($key) {
158
+    return array_key_exists($key, getpaid_user_address_fields());
159 159
 }
160 160
 
161 161
 /**
@@ -165,39 +165,39 @@  discard block
 block discarded – undo
165 165
  *
166 166
  * @param WPInv_Invoice $invoice
167 167
  */
168
-function getpaid_save_invoice_user_address( $invoice ) {
168
+function getpaid_save_invoice_user_address($invoice) {
169 169
 
170 170
     // Retrieve the invoice.
171
-    $invoice = wpinv_get_invoice( $invoice );
171
+    $invoice = wpinv_get_invoice($invoice);
172 172
 
173 173
     // Abort if it does not exist.
174
-    if ( empty( $invoice ) || $invoice->is_renewal() ) {
174
+    if (empty($invoice) || $invoice->is_renewal()) {
175 175
         return;
176 176
     }
177 177
 
178
-    $customer = getpaid_get_customer_by_user_id( $invoice->get_user_id() );
178
+    $customer = getpaid_get_customer_by_user_id($invoice->get_user_id());
179 179
 
180
-    if ( empty( $customer ) ) {
181
-        $customer = new GetPaid_Customer( 0 );
182
-        $customer->clone_user( $invoice->get_user_id() );
180
+    if (empty($customer)) {
181
+        $customer = new GetPaid_Customer(0);
182
+        $customer->clone_user($invoice->get_user_id());
183 183
     }
184 184
 
185
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
185
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
186 186
 
187
-        if ( is_callable( array( $invoice, "get_$field" ) ) ) {
188
-            $value = call_user_func( array( $invoice, "get_$field" ) );
187
+        if (is_callable(array($invoice, "get_$field"))) {
188
+            $value = call_user_func(array($invoice, "get_$field"));
189 189
 
190 190
             // Only save if it is not empty.
191
-            if ( ! empty( $value ) ) {
192
-                $customer->set( $field, sanitize_text_field( $value ) );
191
+            if (!empty($value)) {
192
+                $customer->set($field, sanitize_text_field($value));
193 193
             }
194 194
         }
195 195
     }
196 196
 
197 197
     $customer->save();
198 198
 }
199
-add_action( 'getpaid_new_invoice', 'getpaid_save_invoice_user_address' );
200
-add_action( 'getpaid_update_invoice', 'getpaid_save_invoice_user_address' );
199
+add_action('getpaid_new_invoice', 'getpaid_save_invoice_user_address');
200
+add_action('getpaid_update_invoice', 'getpaid_save_invoice_user_address');
201 201
 
202 202
 /**
203 203
  * Retrieves a saved user address.
@@ -205,36 +205,36 @@  discard block
 block discarded – undo
205 205
  * @param int $user_id The user id whose address we should get. Defaults to the current user id.
206 206
  * @return array
207 207
  */
208
-function wpinv_get_user_address( $user_id = 0 ) {
208
+function wpinv_get_user_address($user_id = 0) {
209 209
 
210 210
     // Prepare the user id.
211
-    $user_id   = empty( $user_id ) ? get_current_user_id() : $user_id;
212
-    $user_info = get_userdata( $user_id );
211
+    $user_id   = empty($user_id) ? get_current_user_id() : $user_id;
212
+    $user_info = get_userdata($user_id);
213 213
 
214 214
     // Abort if non exists.
215
-    if ( empty( $user_info ) ) {
215
+    if (empty($user_info)) {
216 216
         return array();
217 217
     }
218 218
 
219
-    $customer = getpaid_get_customer_by_user_id( $user_id );
219
+    $customer = getpaid_get_customer_by_user_id($user_id);
220 220
 
221
-    if ( empty( $customer ) ) {
222
-        $customer = new GetPaid_Customer( 0 );
223
-        $customer->clone_user( $user_id );
221
+    if (empty($customer)) {
222
+        $customer = new GetPaid_Customer(0);
223
+        $customer->clone_user($user_id);
224 224
     }
225 225
 
226 226
     // Prepare the address.
227 227
     $address = array(
228 228
         'user_id'      => $user_id,
229
-        'email'        => $customer->get( 'email' ),
229
+        'email'        => $customer->get('email'),
230 230
         'display_name' => $user_info->display_name,
231 231
     );
232 232
 
233
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
234
-        $address[ $field ] = $customer->get( $field );
233
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
234
+        $address[$field] = $customer->get($field);
235 235
     }
236 236
 
237
-    $address = array_filter( $address );
237
+    $address = array_filter($address);
238 238
 
239 239
     $defaults = array(
240 240
         'first_name' => $user_info->first_name,
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         'country'    => wpinv_get_default_country(),
244 244
     );
245 245
 
246
-    return getpaid_array_merge_if_empty( $address, $defaults );
246
+    return getpaid_array_merge_if_empty($address, $defaults);
247 247
 
248 248
 }
249 249
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
  * @return string|null
256 256
  * @deprecated
257 257
  */
258
-function getpaid_get_user_address_field( $user_id, $field ) {
258
+function getpaid_get_user_address_field($user_id, $field) {
259 259
 
260 260
     $prefixes = array(
261 261
         '_wpinv_',
@@ -263,15 +263,15 @@  discard block
 block discarded – undo
263 263
         '',
264 264
     );
265 265
 
266
-    foreach ( $prefixes as $prefix ) {
266
+    foreach ($prefixes as $prefix) {
267 267
 
268 268
         // Meta table.
269
-        $value = get_user_meta( $user_id, $prefix . $field, true );
269
+        $value = get_user_meta($user_id, $prefix . $field, true);
270 270
 
271 271
         // UWP table.
272
-        $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value;
272
+        $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value;
273 273
 
274
-        if ( ! empty( $value ) ) {
274
+        if (!empty($value)) {
275 275
             return $value;
276 276
         }
277 277
 }
@@ -287,16 +287,16 @@  discard block
 block discarded – undo
287 287
  * @param string $return What to return.
288 288
  * @return array
289 289
  */
290
-function wpinv_get_continents( $return = 'all' ) {
290
+function wpinv_get_continents($return = 'all') {
291 291
 
292
-    $continents = wpinv_get_data( 'continents' );
292
+    $continents = wpinv_get_data('continents');
293 293
 
294
-    switch ( $return ) {
294
+    switch ($return) {
295 295
         case 'name':
296
-            return wp_list_pluck( $continents, 'name' );
296
+            return wp_list_pluck($continents, 'name');
297 297
             break;
298 298
         case 'countries':
299
-            return wp_list_pluck( $continents, 'countries' );
299
+            return wp_list_pluck($continents, 'countries');
300 300
             break;
301 301
         default:
302 302
             return $continents;
@@ -312,12 +312,12 @@  discard block
 block discarded – undo
312 312
  * @param string $country Country code. If no code is specified, defaults to the default country.
313 313
  * @return string
314 314
  */
315
-function wpinv_get_continent_code_for_country( $country = false ) {
315
+function wpinv_get_continent_code_for_country($country = false) {
316 316
 
317
-    $country = wpinv_sanitize_country( $country );
317
+    $country = wpinv_sanitize_country($country);
318 318
 
319
-	foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
320
-		if ( false !== array_search( $country, $countries, true ) ) {
319
+	foreach (wpinv_get_continents('countries') as $continent_code => $countries) {
320
+		if (false !== array_search($country, $countries, true)) {
321 321
 			return $continent_code;
322 322
 		}
323 323
 	}
@@ -333,13 +333,13 @@  discard block
 block discarded – undo
333 333
  * @param string $country Country code. If no code is specified, defaults to the default country.
334 334
  * @return array
335 335
  */
336
-function wpinv_get_country_calling_code( $country = null ) {
336
+function wpinv_get_country_calling_code($country = null) {
337 337
 
338
-    $country = wpinv_sanitize_country( $country );
339
-    $codes   = wpinv_get_data( 'phone-codes' );
340
-    $code    = isset( $codes[ $country ] ) ? $codes[ $country ] : '';
338
+    $country = wpinv_sanitize_country($country);
339
+    $codes   = wpinv_get_data('phone-codes');
340
+    $code    = isset($codes[$country]) ? $codes[$country] : '';
341 341
 
342
-    if ( is_array( $code ) ) {
342
+    if (is_array($code)) {
343 343
         return $code[0];
344 344
     }
345 345
     return $code;
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
  * @param bool $first_empty Whether or not the first item in the list should be empty
353 353
  * @return array
354 354
  */
355
-function wpinv_get_country_list( $first_empty = false ) {
356
-    return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty );
355
+function wpinv_get_country_list($first_empty = false) {
356
+    return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty);
357 357
 }
358 358
 
359 359
 /**
@@ -363,22 +363,22 @@  discard block
 block discarded – undo
363 363
  * @param bool $first_empty Whether or not the first item in the list should be empty
364 364
  * @return array
365 365
  */
366
-function wpinv_get_country_states( $country = null, $first_empty = false ) {
366
+function wpinv_get_country_states($country = null, $first_empty = false) {
367 367
 
368 368
     // Prepare the country.
369
-    $country = wpinv_sanitize_country( $country );
369
+    $country = wpinv_sanitize_country($country);
370 370
 
371 371
     // Fetch all states.
372
-    $all_states = wpinv_get_data( 'states' );
372
+    $all_states = wpinv_get_data('states');
373 373
 
374 374
     // Fetch the specified country's states.
375
-    $states     = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array();
376
-    $states     = apply_filters( "wpinv_{$country}_states", $states );
377
-    $states     = apply_filters( 'wpinv_country_states', $states, $country );
375
+    $states     = isset($all_states[$country]) ? $all_states[$country] : array();
376
+    $states     = apply_filters("wpinv_{$country}_states", $states);
377
+    $states     = apply_filters('wpinv_country_states', $states, $country);
378 378
 
379
-    asort( $states );
379
+    asort($states);
380 380
 
381
-    return wpinv_maybe_add_empty_option( $states, $first_empty );
381
+    return wpinv_maybe_add_empty_option($states, $first_empty);
382 382
 }
383 383
 
384 384
 /**
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
  * @return array
389 389
  */
390 390
 function wpinv_get_us_states_list() {
391
-    return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) );
391
+    return apply_filters('wpinv_usa_states', wpinv_get_country_states('US'));
392 392
 }
393 393
 
394 394
 /**
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
  * @return array
399 399
  */
400 400
 function wpinv_get_canada_states_list() {
401
-    return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) );
401
+    return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA'));
402 402
 }
403 403
 
404 404
 /**
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
  * @return array
409 409
  */
410 410
 function wpinv_get_australia_states_list() {
411
-    return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) );
411
+    return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU'));
412 412
 }
413 413
 
414 414
 /**
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
  * @return array
419 419
  */
420 420
 function wpinv_get_bangladesh_states_list() {
421
-    return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) );
421
+    return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD'));
422 422
 }
423 423
 
424 424
 /**
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
  * @return array
429 429
  */
430 430
 function wpinv_get_brazil_states_list() {
431
-    return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) );
431
+    return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR'));
432 432
 }
433 433
 
434 434
 /**
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
  * @return array
439 439
  */
440 440
 function wpinv_get_bulgaria_states_list() {
441
-    return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) );
441
+    return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG'));
442 442
 }
443 443
 
444 444
 /**
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
  * @return array
449 449
  */
450 450
 function wpinv_get_hong_kong_states_list() {
451
-    return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) );
451
+    return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK'));
452 452
 }
453 453
 
454 454
 /**
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
  * @return array
459 459
  */
460 460
 function wpinv_get_hungary_states_list() {
461
-    return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) );
461
+    return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU'));
462 462
 }
463 463
 
464 464
 /**
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
  * @return array
469 469
  */
470 470
 function wpinv_get_japan_states_list() {
471
-    return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) );
471
+    return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP'));
472 472
 }
473 473
 
474 474
 /**
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
  * @return array
479 479
  */
480 480
 function wpinv_get_china_states_list() {
481
-    return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) );
481
+    return apply_filters('wpinv_china_states', wpinv_get_country_states('CN'));
482 482
 }
483 483
 
484 484
 /**
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
  * @return array
489 489
  */
490 490
 function wpinv_get_new_zealand_states_list() {
491
-    return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) );
491
+    return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ'));
492 492
 }
493 493
 
494 494
 /**
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
  * @return array
499 499
  */
500 500
 function wpinv_get_peru_states_list() {
501
-    return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) );
501
+    return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE'));
502 502
 }
503 503
 
504 504
 /**
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
  * @return array
509 509
  */
510 510
 function wpinv_get_indonesia_states_list() {
511
-    return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) );
511
+    return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID'));
512 512
 }
513 513
 
514 514
 /**
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
  * @return array
519 519
  */
520 520
 function wpinv_get_india_states_list() {
521
-    return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) );
521
+    return apply_filters('wpinv_india_states', wpinv_get_country_states('IN'));
522 522
 }
523 523
 
524 524
 /**
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
  * @return array
529 529
  */
530 530
 function wpinv_get_iran_states_list() {
531
-    return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) );
531
+    return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR'));
532 532
 }
533 533
 
534 534
 /**
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
  * @return array
539 539
  */
540 540
 function wpinv_get_italy_states_list() {
541
-    return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) );
541
+    return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT'));
542 542
 }
543 543
 
544 544
 /**
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
  * @return array
549 549
  */
550 550
 function wpinv_get_malaysia_states_list() {
551
-    return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) );
551
+    return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY'));
552 552
 }
553 553
 
554 554
 /**
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
  * @return array
559 559
  */
560 560
 function wpinv_get_mexico_states_list() {
561
-    return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) );
561
+    return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX'));
562 562
 }
563 563
 
564 564
 /**
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
  * @return array
569 569
  */
570 570
 function wpinv_get_nepal_states_list() {
571
-    return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) );
571
+    return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP'));
572 572
 }
573 573
 
574 574
 /**
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
  * @return array
579 579
  */
580 580
 function wpinv_get_south_africa_states_list() {
581
-    return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) );
581
+    return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA'));
582 582
 }
583 583
 
584 584
 /**
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
  * @return array
589 589
  */
590 590
 function wpinv_get_thailand_states_list() {
591
-    return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) );
591
+    return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH'));
592 592
 }
593 593
 
594 594
 /**
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
  * @return array
599 599
  */
600 600
 function wpinv_get_turkey_states_list() {
601
-    return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) );
601
+    return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR'));
602 602
 }
603 603
 
604 604
 /**
@@ -608,31 +608,31 @@  discard block
 block discarded – undo
608 608
  * @return array
609 609
  */
610 610
 function wpinv_get_spain_states_list() {
611
-    return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) );
611
+    return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES'));
612 612
 }
613 613
 
614 614
 function wpinv_get_states_field() {
615
-	if ( empty( $_POST['country'] ) ) {
615
+	if (empty($_POST['country'])) {
616 616
 		$_POST['country'] = wpinv_get_default_country();
617 617
 	}
618
-	$states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
618
+	$states = wpinv_get_country_states(sanitize_text_field($_POST['country']));
619 619
 
620
-	if ( ! empty( $states ) ) {
621
-		$sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
620
+	if (!empty($states)) {
621
+		$sanitized_field_name = sanitize_text_field($_POST['field_name']);
622 622
 
623
-        $class  = isset( $_POST['class'] ) ? esc_attr( sanitize_text_field( $_POST['class'] ) ) : '';
623
+        $class  = isset($_POST['class']) ? esc_attr(sanitize_text_field($_POST['class'])) : '';
624 624
         $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2";
625 625
 
626
-        $args  = array(
626
+        $args = array(
627 627
 			'name'             => $sanitized_field_name,
628 628
 			'id'               => $sanitized_field_name,
629
-			'class'            => implode( ' ', array_unique( explode( ' ', $class ) ) ),
630
-			'options'          => array_merge( array( '' => '' ), $states ),
629
+			'class'            => implode(' ', array_unique(explode(' ', $class))),
630
+			'options'          => array_merge(array('' => ''), $states),
631 631
 			'show_option_all'  => false,
632 632
 			'show_option_none' => false,
633 633
 		);
634 634
 
635
-		wpinv_html_select( $args );
635
+		wpinv_html_select($args);
636 636
 
637 637
 	} else {
638 638
 		echo 'nostates';
@@ -640,10 +640,10 @@  discard block
 block discarded – undo
640 640
 
641 641
 }
642 642
 
643
-function wpinv_default_billing_country( $country = '', $user_id = 0 ) {
644
-    $country = ! empty( $country ) ? $country : wpinv_get_default_country();
643
+function wpinv_default_billing_country($country = '', $user_id = 0) {
644
+    $country = !empty($country) ? $country : wpinv_get_default_country();
645 645
 
646
-    return apply_filters( 'wpinv_default_billing_country', $country, $user_id );
646
+    return apply_filters('wpinv_default_billing_country', $country, $user_id);
647 647
 }
648 648
 
649 649
 /**
@@ -705,9 +705,9 @@  discard block
 block discarded – undo
705 705
  * @see `wpinv_get_invoice_address_replacements`
706 706
  * @return string
707 707
  */
708
-function wpinv_get_full_address_format( $country = false ) {
708
+function wpinv_get_full_address_format($country = false) {
709 709
 
710
-    if ( empty( $country ) ) {
710
+    if (empty($country)) {
711 711
         $country = wpinv_get_default_country();
712 712
     }
713 713
 
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 	$formats = wpinv_get_address_formats();
716 716
 
717 717
 	// Get format for the specified country.
718
-	$format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
718
+	$format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default'];
719 719
 
720 720
     /**
721 721
 	 * Filters the address format to use on Invoices.
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 	 * @param string $format  The address format to use.
728 728
      * @param string $country The country who's address format is being retrieved.
729 729
 	 */
730
-    return apply_filters( 'wpinv_get_full_address_format', $format, $country );
730
+    return apply_filters('wpinv_get_full_address_format', $format, $country);
731 731
 }
732 732
 
733 733
 /**
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
  * @param array $billing_details customer's billing details
739 739
  * @return array
740 740
  */
741
-function wpinv_get_invoice_address_replacements( $billing_details ) {
741
+function wpinv_get_invoice_address_replacements($billing_details) {
742 742
 
743 743
     $default_args = array(
744 744
         'address'    => '',
@@ -751,15 +751,15 @@  discard block
 block discarded – undo
751 751
 		'company'    => '',
752 752
     );
753 753
 
754
-    $args    = map_deep( wp_parse_args( array_filter( $billing_details ), $default_args ), 'trim' );
754
+    $args    = map_deep(wp_parse_args(array_filter($billing_details), $default_args), 'trim');
755 755
     $state   = $args['state'];
756 756
     $country = $args['country'];
757 757
 
758 758
     // Handle full country name.
759
-    $full_country = empty( $country ) ? $country : wpinv_country_name( $country );
759
+    $full_country = empty($country) ? $country : wpinv_country_name($country);
760 760
 
761 761
     // Handle full state name.
762
-    $full_state   = ( $country && $state ) ? wpinv_state_name( $state, $country ) : $state;
762
+    $full_state   = ($country && $state) ? wpinv_state_name($state, $country) : $state;
763 763
 
764 764
     $args['postcode']    = $args['zip'];
765 765
     $args['name']        = $args['first_name'] . ' ' . $args['last_name'];
@@ -777,14 +777,14 @@  discard block
 block discarded – undo
777 777
 	 * @param array $replacements  The address replacements to use.
778 778
      * @param array $billing_details  The billing details to use.
779 779
 	 */
780
-    $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details );
780
+    $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details);
781 781
 
782 782
     $return = array();
783 783
 
784
-    foreach ( $replacements as $key => $value ) {
785
-        $value  = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : '';
786
-        $return[ '{{' . $key . '}}' ] = $value;
787
-        $return[ '{{' . $key . '_upper}}' ] = wpinv_utf8_strtoupper( $value );
784
+    foreach ($replacements as $key => $value) {
785
+        $value = is_scalar($value) ? trim(sanitize_text_field($value)) : '';
786
+        $return['{{' . $key . '}}'] = $value;
787
+        $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value);
788 788
     }
789 789
 
790 790
     return $return;
@@ -798,6 +798,6 @@  discard block
 block discarded – undo
798 798
  * @since 1.0.14
799 799
  * @return string
800 800
  */
801
-function wpinv_trim_formatted_address_line( $line ) {
802
-	return trim( $line, ', ' );
801
+function wpinv_trim_formatted_address_line($line) {
802
+	return trim($line, ', ');
803 803
 }
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin-profile.php 2 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -5,110 +5,110 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 if ( ! defined( 'ABSPATH' ) ) {
8
-	exit; // Exit if accessed directly
8
+    exit; // Exit if accessed directly
9 9
 }
10 10
 
11 11
 if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) :
12 12
 
13
-	/**
14
-	 * GetPaid_Admin_Profile Class.
15
-	 */
16
-	class GetPaid_Admin_Profile {
17
-
18
-		/**
19
-		 * Hook in tabs.
20
-		 */
21
-		public function __construct() {
22
-			add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
23
-			add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
24
-
25
-			add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) );
26
-			add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) );
27
-		}
28
-
29
-		/**
30
-		 * Get Address Fields for the edit user pages.
31
-		 *
32
-		 * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned
33
-		 */
34
-		public function get_customer_meta_fields() {
35
-
36
-			$show_fields = apply_filters(
37
-				'getpaid_customer_meta_fields',
38
-				array(
39
-					'billing' => array(
40
-						'title'  => __( 'Billing Details (GetPaid)', 'invoicing' ),
41
-						'fields' => array(
42
-							'_wpinv_first_name' => array(
43
-								'label'       => __( 'First name', 'invoicing' ),
44
-								'description' => '',
45
-							),
46
-							'_wpinv_last_name'  => array(
47
-								'label'       => __( 'Last name', 'invoicing' ),
48
-								'description' => '',
49
-							),
50
-							'_wpinv_company'    => array(
51
-								'label'       => __( 'Company', 'invoicing' ),
52
-								'description' => '',
53
-							),
54
-							'_wpinv_company_id' => array(
55
-								'label'       => __( 'Company ID', 'invoicing' ),
56
-								'description' => '',
57
-							),
58
-							'_wpinv_address'    => array(
59
-								'label'       => __( 'Address', 'invoicing' ),
60
-								'description' => '',
61
-							),
62
-							'_wpinv_city'       => array(
63
-								'label'       => __( 'City', 'invoicing' ),
64
-								'description' => '',
65
-							),
66
-							'_wpinv_zip'        => array(
67
-								'label'       => __( 'Postcode / ZIP', 'invoicing' ),
68
-								'description' => '',
69
-							),
70
-							'_wpinv_country'    => array(
71
-								'label'       => __( 'Country / Region', 'invoicing' ),
72
-								'description' => '',
73
-								'class'       => 'getpaid_js_field-country',
74
-								'type'        => 'select',
75
-								'options'     => array( '' => __( 'Select a country / region&hellip;', 'invoicing' ) ) + wpinv_get_country_list(),
76
-							),
77
-							'_wpinv_state'      => array(
78
-								'label'       => __( 'State / County', 'invoicing' ),
79
-								'description' => __( 'State / County or state code', 'invoicing' ),
80
-								'class'       => 'getpaid_js_field-state regular-text',
81
-							),
82
-							'_wpinv_phone'      => array(
83
-								'label'       => __( 'Phone', 'invoicing' ),
84
-								'description' => '',
85
-							),
86
-							'_wpinv_vat_number' => array(
87
-								'label'       => __( 'VAT Number', 'invoicing' ),
88
-								'description' => '',
89
-							),
90
-						),
91
-					),
92
-				)
93
-			);
94
-			return $show_fields;
95
-		}
96
-
97
-		/**
98
-		 * Show Address Fields on edit user pages.
99
-		 *
100
-		 * @param WP_User $user
101
-		 */
102
-		public function add_customer_meta_fields( $user ) {
103
-
104
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) {
105
-				return;
106
-			}
107
-
108
-			$show_fields = $this->get_customer_meta_fields();
109
-
110
-			foreach ( $show_fields as $fieldset_key => $fieldset ) :
111
-				?>
13
+    /**
14
+     * GetPaid_Admin_Profile Class.
15
+     */
16
+    class GetPaid_Admin_Profile {
17
+
18
+        /**
19
+         * Hook in tabs.
20
+         */
21
+        public function __construct() {
22
+            add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
23
+            add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
24
+
25
+            add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) );
26
+            add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) );
27
+        }
28
+
29
+        /**
30
+         * Get Address Fields for the edit user pages.
31
+         *
32
+         * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned
33
+         */
34
+        public function get_customer_meta_fields() {
35
+
36
+            $show_fields = apply_filters(
37
+                'getpaid_customer_meta_fields',
38
+                array(
39
+                    'billing' => array(
40
+                        'title'  => __( 'Billing Details (GetPaid)', 'invoicing' ),
41
+                        'fields' => array(
42
+                            '_wpinv_first_name' => array(
43
+                                'label'       => __( 'First name', 'invoicing' ),
44
+                                'description' => '',
45
+                            ),
46
+                            '_wpinv_last_name'  => array(
47
+                                'label'       => __( 'Last name', 'invoicing' ),
48
+                                'description' => '',
49
+                            ),
50
+                            '_wpinv_company'    => array(
51
+                                'label'       => __( 'Company', 'invoicing' ),
52
+                                'description' => '',
53
+                            ),
54
+                            '_wpinv_company_id' => array(
55
+                                'label'       => __( 'Company ID', 'invoicing' ),
56
+                                'description' => '',
57
+                            ),
58
+                            '_wpinv_address'    => array(
59
+                                'label'       => __( 'Address', 'invoicing' ),
60
+                                'description' => '',
61
+                            ),
62
+                            '_wpinv_city'       => array(
63
+                                'label'       => __( 'City', 'invoicing' ),
64
+                                'description' => '',
65
+                            ),
66
+                            '_wpinv_zip'        => array(
67
+                                'label'       => __( 'Postcode / ZIP', 'invoicing' ),
68
+                                'description' => '',
69
+                            ),
70
+                            '_wpinv_country'    => array(
71
+                                'label'       => __( 'Country / Region', 'invoicing' ),
72
+                                'description' => '',
73
+                                'class'       => 'getpaid_js_field-country',
74
+                                'type'        => 'select',
75
+                                'options'     => array( '' => __( 'Select a country / region&hellip;', 'invoicing' ) ) + wpinv_get_country_list(),
76
+                            ),
77
+                            '_wpinv_state'      => array(
78
+                                'label'       => __( 'State / County', 'invoicing' ),
79
+                                'description' => __( 'State / County or state code', 'invoicing' ),
80
+                                'class'       => 'getpaid_js_field-state regular-text',
81
+                            ),
82
+                            '_wpinv_phone'      => array(
83
+                                'label'       => __( 'Phone', 'invoicing' ),
84
+                                'description' => '',
85
+                            ),
86
+                            '_wpinv_vat_number' => array(
87
+                                'label'       => __( 'VAT Number', 'invoicing' ),
88
+                                'description' => '',
89
+                            ),
90
+                        ),
91
+                    ),
92
+                )
93
+            );
94
+            return $show_fields;
95
+        }
96
+
97
+        /**
98
+         * Show Address Fields on edit user pages.
99
+         *
100
+         * @param WP_User $user
101
+         */
102
+        public function add_customer_meta_fields( $user ) {
103
+
104
+            if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) {
105
+                return;
106
+            }
107
+
108
+            $show_fields = $this->get_customer_meta_fields();
109
+
110
+            foreach ( $show_fields as $fieldset_key => $fieldset ) :
111
+                ?>
112 112
 				<h2><?php echo esc_html( $fieldset['title'] ); ?></h2>
113 113
 				<table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>">
114 114
 					<?php foreach ( $fieldset['fields'] as $key => $field ) : ?>
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 								<?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?>
121 121
 									<select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;">
122 122
 										<?php
123
-											$selected = esc_attr( get_user_meta( $user->ID, $key, true ) );
124
-										foreach ( $field['options'] as $option_key => $option_value ) :
125
-											?>
123
+                                            $selected = esc_attr( get_user_meta( $user->ID, $key, true ) );
124
+                                        foreach ( $field['options'] as $option_key => $option_value ) :
125
+                                            ?>
126 126
 											<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option>
127 127
 										<?php endforeach; ?>
128 128
 									</select>
@@ -137,59 +137,59 @@  discard block
 block discarded – undo
137 137
 					<?php endforeach; ?>
138 138
 				</table>
139 139
 				<?php
140
-			endforeach;
141
-		}
142
-
143
-		/**
144
-		 * Save Address Fields on edit user pages.
145
-		 *
146
-		 * @param int $user_id User ID of the user being saved
147
-		 */
148
-		public function save_customer_meta_fields( $user_id ) {
149
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) {
150
-				return;
151
-			}
152
-
153
-			$save_fields = $this->get_customer_meta_fields();
154
-
155
-			$customer = getpaid_get_customer_by_user_id( get_current_user_id() );
156
-
157
-			if ( empty( $customer ) ) {
158
-				$customer = new GetPaid_Customer( 0 );
159
-				$customer->clone_user( get_current_user_id() );
160
-			}
161
-
162
-			foreach ( $save_fields as $fieldset ) {
163
-
164
-				foreach ( $fieldset['fields'] as $key => $field ) {
165
-
166
-					if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) {
167
-						$customer->set( $key, ! empty( $_POST[ $key ] ) );
168
-					} elseif ( isset( $_POST[ $key ] ) ) {
169
-						$customer->set( $key, wpinv_clean( $_POST[ $key ] ) );
170
-					}
171
-				}
172
-			}
173
-		}
174
-
175
-		/**
176
-		 * Get user meta for a given key, with fallbacks to core user info for pre-existing fields.
177
-		 *
178
-		 * @since 3.1.0
179
-		 * @param int    $user_id User ID of the user being edited
180
-		 * @param string $key     Key for user meta field
181
-		 * @return string
182
-		 */
183
-		protected function get_user_meta( $user_id, $key ) {
184
-			$value           = get_user_meta( $user_id, $key, true );
185
-			$existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' );
186
-			if ( ! $value && in_array( $key, $existing_fields ) ) {
187
-				$value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true );
188
-			}
189
-
190
-			return $value;
191
-		}
192
-	}
140
+            endforeach;
141
+        }
142
+
143
+        /**
144
+         * Save Address Fields on edit user pages.
145
+         *
146
+         * @param int $user_id User ID of the user being saved
147
+         */
148
+        public function save_customer_meta_fields( $user_id ) {
149
+            if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) {
150
+                return;
151
+            }
152
+
153
+            $save_fields = $this->get_customer_meta_fields();
154
+
155
+            $customer = getpaid_get_customer_by_user_id( get_current_user_id() );
156
+
157
+            if ( empty( $customer ) ) {
158
+                $customer = new GetPaid_Customer( 0 );
159
+                $customer->clone_user( get_current_user_id() );
160
+            }
161
+
162
+            foreach ( $save_fields as $fieldset ) {
163
+
164
+                foreach ( $fieldset['fields'] as $key => $field ) {
165
+
166
+                    if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) {
167
+                        $customer->set( $key, ! empty( $_POST[ $key ] ) );
168
+                    } elseif ( isset( $_POST[ $key ] ) ) {
169
+                        $customer->set( $key, wpinv_clean( $_POST[ $key ] ) );
170
+                    }
171
+                }
172
+            }
173
+        }
174
+
175
+        /**
176
+         * Get user meta for a given key, with fallbacks to core user info for pre-existing fields.
177
+         *
178
+         * @since 3.1.0
179
+         * @param int    $user_id User ID of the user being edited
180
+         * @param string $key     Key for user meta field
181
+         * @return string
182
+         */
183
+        protected function get_user_meta( $user_id, $key ) {
184
+            $value           = get_user_meta( $user_id, $key, true );
185
+            $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' );
186
+            if ( ! $value && in_array( $key, $existing_fields ) ) {
187
+                $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true );
188
+            }
189
+
190
+            return $value;
191
+        }
192
+    }
193 193
 
194 194
 endif;
195 195
 
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if (!defined('ABSPATH')) {
8 8
 	exit; // Exit if accessed directly
9 9
 }
10 10
 
11
-if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) :
11
+if (!class_exists('GetPaid_Admin_Profile', false)) :
12 12
 
13 13
 	/**
14 14
 	 * GetPaid_Admin_Profile Class.
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 		 * Hook in tabs.
20 20
 		 */
21 21
 		public function __construct() {
22
-			add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
23
-			add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
22
+			add_action('show_user_profile', array($this, 'add_customer_meta_fields'), 100);
23
+			add_action('edit_user_profile', array($this, 'add_customer_meta_fields'), 100);
24 24
 
25
-			add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) );
26
-			add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) );
25
+			add_action('personal_options_update', array($this, 'save_customer_meta_fields'));
26
+			add_action('edit_user_profile_update', array($this, 'save_customer_meta_fields'));
27 27
 		}
28 28
 
29 29
 		/**
@@ -37,54 +37,54 @@  discard block
 block discarded – undo
37 37
 				'getpaid_customer_meta_fields',
38 38
 				array(
39 39
 					'billing' => array(
40
-						'title'  => __( 'Billing Details (GetPaid)', 'invoicing' ),
40
+						'title'  => __('Billing Details (GetPaid)', 'invoicing'),
41 41
 						'fields' => array(
42 42
 							'_wpinv_first_name' => array(
43
-								'label'       => __( 'First name', 'invoicing' ),
43
+								'label'       => __('First name', 'invoicing'),
44 44
 								'description' => '',
45 45
 							),
46 46
 							'_wpinv_last_name'  => array(
47
-								'label'       => __( 'Last name', 'invoicing' ),
47
+								'label'       => __('Last name', 'invoicing'),
48 48
 								'description' => '',
49 49
 							),
50 50
 							'_wpinv_company'    => array(
51
-								'label'       => __( 'Company', 'invoicing' ),
51
+								'label'       => __('Company', 'invoicing'),
52 52
 								'description' => '',
53 53
 							),
54 54
 							'_wpinv_company_id' => array(
55
-								'label'       => __( 'Company ID', 'invoicing' ),
55
+								'label'       => __('Company ID', 'invoicing'),
56 56
 								'description' => '',
57 57
 							),
58 58
 							'_wpinv_address'    => array(
59
-								'label'       => __( 'Address', 'invoicing' ),
59
+								'label'       => __('Address', 'invoicing'),
60 60
 								'description' => '',
61 61
 							),
62 62
 							'_wpinv_city'       => array(
63
-								'label'       => __( 'City', 'invoicing' ),
63
+								'label'       => __('City', 'invoicing'),
64 64
 								'description' => '',
65 65
 							),
66 66
 							'_wpinv_zip'        => array(
67
-								'label'       => __( 'Postcode / ZIP', 'invoicing' ),
67
+								'label'       => __('Postcode / ZIP', 'invoicing'),
68 68
 								'description' => '',
69 69
 							),
70 70
 							'_wpinv_country'    => array(
71
-								'label'       => __( 'Country / Region', 'invoicing' ),
71
+								'label'       => __('Country / Region', 'invoicing'),
72 72
 								'description' => '',
73 73
 								'class'       => 'getpaid_js_field-country',
74 74
 								'type'        => 'select',
75
-								'options'     => array( '' => __( 'Select a country / region&hellip;', 'invoicing' ) ) + wpinv_get_country_list(),
75
+								'options'     => array('' => __('Select a country / region&hellip;', 'invoicing')) + wpinv_get_country_list(),
76 76
 							),
77 77
 							'_wpinv_state'      => array(
78
-								'label'       => __( 'State / County', 'invoicing' ),
79
-								'description' => __( 'State / County or state code', 'invoicing' ),
78
+								'label'       => __('State / County', 'invoicing'),
79
+								'description' => __('State / County or state code', 'invoicing'),
80 80
 								'class'       => 'getpaid_js_field-state regular-text',
81 81
 							),
82 82
 							'_wpinv_phone'      => array(
83
-								'label'       => __( 'Phone', 'invoicing' ),
83
+								'label'       => __('Phone', 'invoicing'),
84 84
 								'description' => '',
85 85
 							),
86 86
 							'_wpinv_vat_number' => array(
87
-								'label'       => __( 'VAT Number', 'invoicing' ),
87
+								'label'       => __('VAT Number', 'invoicing'),
88 88
 								'description' => '',
89 89
 							),
90 90
 						),
@@ -99,39 +99,39 @@  discard block
 block discarded – undo
99 99
 		 *
100 100
 		 * @param WP_User $user
101 101
 		 */
102
-		public function add_customer_meta_fields( $user ) {
102
+		public function add_customer_meta_fields($user) {
103 103
 
104
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) {
104
+			if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user->ID)) {
105 105
 				return;
106 106
 			}
107 107
 
108 108
 			$show_fields = $this->get_customer_meta_fields();
109 109
 
110
-			foreach ( $show_fields as $fieldset_key => $fieldset ) :
110
+			foreach ($show_fields as $fieldset_key => $fieldset) :
111 111
 				?>
112
-				<h2><?php echo esc_html( $fieldset['title'] ); ?></h2>
113
-				<table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>">
114
-					<?php foreach ( $fieldset['fields'] as $key => $field ) : ?>
112
+				<h2><?php echo esc_html($fieldset['title']); ?></h2>
113
+				<table class="form-table" id="<?php echo esc_attr('getpaid-fieldset-' . $fieldset_key); ?>">
114
+					<?php foreach ($fieldset['fields'] as $key => $field) : ?>
115 115
 						<tr>
116 116
 							<th>
117
-								<label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label>
117
+								<label for="<?php echo esc_attr($key); ?>"><?php echo esc_html($field['label']); ?></label>
118 118
 							</th>
119 119
 							<td>
120
-								<?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?>
121
-									<select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;">
120
+								<?php if (!empty($field['type']) && 'select' === $field['type']) : ?>
121
+									<select name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" class="<?php echo esc_attr($field['class']); ?> wpi_select2" style="width: 25em;">
122 122
 										<?php
123
-											$selected = esc_attr( get_user_meta( $user->ID, $key, true ) );
124
-										foreach ( $field['options'] as $option_key => $option_value ) :
123
+											$selected = esc_attr(get_user_meta($user->ID, $key, true));
124
+										foreach ($field['options'] as $option_key => $option_value) :
125 125
 											?>
126
-											<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option>
126
+											<option value="<?php echo esc_attr($option_key); ?>" <?php selected($selected, $option_key, true); ?>><?php echo esc_html($option_value); ?></option>
127 127
 										<?php endforeach; ?>
128 128
 									</select>
129
-								<?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?>
130
-									<input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) get_user_meta( $user->ID, $key, true ), 1, true ); ?> />
129
+								<?php elseif (!empty($field['type']) && 'checkbox' === $field['type']) : ?>
130
+									<input type="checkbox" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="1" class="<?php echo esc_attr($field['class']); ?>" <?php checked((int) get_user_meta($user->ID, $key, true), 1, true); ?> />
131 131
 								<?php else : ?>
132
-									<input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" />
132
+									<input type="text" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="<?php echo esc_attr($this->get_user_meta($user->ID, $key)); ?>" class="<?php echo (!empty($field['class']) ? esc_attr($field['class']) : 'regular-text'); ?>" />
133 133
 								<?php endif; ?>
134
-								<p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p>
134
+								<p class="description"><?php echo wp_kses_post($field['description']); ?></p>
135 135
 							</td>
136 136
 						</tr>
137 137
 					<?php endforeach; ?>
@@ -145,28 +145,28 @@  discard block
 block discarded – undo
145 145
 		 *
146 146
 		 * @param int $user_id User ID of the user being saved
147 147
 		 */
148
-		public function save_customer_meta_fields( $user_id ) {
149
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) {
148
+		public function save_customer_meta_fields($user_id) {
149
+			if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user_id)) {
150 150
 				return;
151 151
 			}
152 152
 
153 153
 			$save_fields = $this->get_customer_meta_fields();
154 154
 
155
-			$customer = getpaid_get_customer_by_user_id( get_current_user_id() );
155
+			$customer = getpaid_get_customer_by_user_id(get_current_user_id());
156 156
 
157
-			if ( empty( $customer ) ) {
158
-				$customer = new GetPaid_Customer( 0 );
159
-				$customer->clone_user( get_current_user_id() );
157
+			if (empty($customer)) {
158
+				$customer = new GetPaid_Customer(0);
159
+				$customer->clone_user(get_current_user_id());
160 160
 			}
161 161
 
162
-			foreach ( $save_fields as $fieldset ) {
162
+			foreach ($save_fields as $fieldset) {
163 163
 
164
-				foreach ( $fieldset['fields'] as $key => $field ) {
164
+				foreach ($fieldset['fields'] as $key => $field) {
165 165
 
166
-					if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) {
167
-						$customer->set( $key, ! empty( $_POST[ $key ] ) );
168
-					} elseif ( isset( $_POST[ $key ] ) ) {
169
-						$customer->set( $key, wpinv_clean( $_POST[ $key ] ) );
166
+					if (isset($field['type']) && 'checkbox' === $field['type']) {
167
+						$customer->set($key, !empty($_POST[$key]));
168
+					} elseif (isset($_POST[$key])) {
169
+						$customer->set($key, wpinv_clean($_POST[$key]));
170 170
 					}
171 171
 				}
172 172
 			}
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 		 * @param string $key     Key for user meta field
181 181
 		 * @return string
182 182
 		 */
183
-		protected function get_user_meta( $user_id, $key ) {
184
-			$value           = get_user_meta( $user_id, $key, true );
185
-			$existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' );
186
-			if ( ! $value && in_array( $key, $existing_fields ) ) {
187
-				$value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true );
183
+		protected function get_user_meta($user_id, $key) {
184
+			$value           = get_user_meta($user_id, $key, true);
185
+			$existing_fields = array('_wpinv_first_name', '_wpinv_last_name');
186
+			if (!$value && in_array($key, $existing_fields)) {
187
+				$value = get_user_meta($user_id, str_replace('_wpinv_', '', $key), true);
188 188
 			}
189 189
 
190 190
 			return $value;
Please login to merge, or discard this patch.
includes/admin/class-getpaid-installer.php 2 patches
Indentation   +441 added lines, -441 removed lines patch added patch discarded remove patch
@@ -20,402 +20,402 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class GetPaid_Installer {
22 22
 
23
-	/**
24
-	 * Upgrades the install.
25
-	 *
26
-	 * @param string $upgrade_from The current invoicing version.
27
-	 */
28
-	public function upgrade_db( $upgrade_from ) {
29
-
30
-		// Save the current invoicing version.
31
-		update_option( 'wpinv_version', WPINV_VERSION );
32
-
33
-		// Setup the invoice Custom Post Type.
34
-		GetPaid_Post_Types::register_post_types();
35
-
36
-		// Clear the permalinks
37
-		flush_rewrite_rules();
38
-
39
-		// Maybe create new/missing pages.
40
-		$this->create_pages();
41
-
42
-		// Maybe re(add) admin capabilities.
43
-		$this->add_capabilities();
44
-
45
-		// Maybe create the default payment form.
46
-		wpinv_get_default_payment_form();
47
-
48
-		// Create any missing database tables.
49
-		$method = "upgrade_from_$upgrade_from";
50
-
51
-		$installed = get_option( 'gepaid_installed_on' );
52
-
53
-		if ( empty( $installed ) ) {
54
-			update_option( 'gepaid_installed_on', time() );
55
-		}
56
-
57
-		if ( method_exists( $this, $method ) ) {
58
-			$this->$method();
59
-		}
60
-
61
-	}
62
-
63
-	/**
64
-	 * Do a fresh install.
65
-	 *
66
-	 */
67
-	public function upgrade_from_0() {
68
-
69
-		// Save default tax rates.
70
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
71
-	}
72
-
73
-	/**
74
-	 * Upgrade to 0.0.5
75
-	 *
76
-	 */
77
-	public function upgrade_from_004() {
78
-		global $wpdb;
79
-
80
-		// Invoices.
81
-		$results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
82
-		if ( ! empty( $results ) ) {
83
-			$wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
84
-
85
-			// Clean post cache
86
-			foreach ( $results as $row ) {
87
-				clean_post_cache( $row->ID );
88
-			}
89
-		}
90
-
91
-		// Item meta key changes
92
-		$query = 'SELECT DISTINCT post_id FROM ' . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
93
-		$results = $wpdb->get_results( $query );
94
-
95
-		if ( ! empty( $results ) ) {
96
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
97
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
98
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
99
-
100
-			foreach ( $results as $row ) {
101
-				clean_post_cache( $row->post_id );
102
-			}
103
-		}
104
-
105
-		$this->upgrade_from_118();
106
-	}
107
-
108
-	/**
109
-	 * Upgrade to version 2.0.0.
110
-	 *
111
-	 */
112
-	public function upgrade_from_118() {
113
-		$this->migrate_old_invoices();
114
-		$this->upgrade_from_279();
115
-	}
116
-
117
-	/**
118
-	 * Upgrade to version 2.0.0.
119
-	 *
120
-	 */
121
-	public function upgrade_from_279() {
122
-		$this->migrate_old_customers();
123
-	}
124
-
125
-	/**
126
-	 * Give administrators the capability to manage GetPaid.
127
-	 *
128
-	 */
129
-	public function add_capabilities() {
130
-		$GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
131
-	}
132
-
133
-	/**
134
-	 * Retreives GetPaid pages.
135
-	 *
136
-	 */
137
-	public static function get_pages() {
138
-
139
-		return apply_filters(
140
-			'wpinv_create_pages',
141
-			array(
142
-
143
-				// Checkout page.
144
-				'checkout_page'             => array(
145
-					'name'    => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
146
-					'title'   => _x( 'Checkout', 'Page title', 'invoicing' ),
147
-					'content' => '
23
+    /**
24
+     * Upgrades the install.
25
+     *
26
+     * @param string $upgrade_from The current invoicing version.
27
+     */
28
+    public function upgrade_db( $upgrade_from ) {
29
+
30
+        // Save the current invoicing version.
31
+        update_option( 'wpinv_version', WPINV_VERSION );
32
+
33
+        // Setup the invoice Custom Post Type.
34
+        GetPaid_Post_Types::register_post_types();
35
+
36
+        // Clear the permalinks
37
+        flush_rewrite_rules();
38
+
39
+        // Maybe create new/missing pages.
40
+        $this->create_pages();
41
+
42
+        // Maybe re(add) admin capabilities.
43
+        $this->add_capabilities();
44
+
45
+        // Maybe create the default payment form.
46
+        wpinv_get_default_payment_form();
47
+
48
+        // Create any missing database tables.
49
+        $method = "upgrade_from_$upgrade_from";
50
+
51
+        $installed = get_option( 'gepaid_installed_on' );
52
+
53
+        if ( empty( $installed ) ) {
54
+            update_option( 'gepaid_installed_on', time() );
55
+        }
56
+
57
+        if ( method_exists( $this, $method ) ) {
58
+            $this->$method();
59
+        }
60
+
61
+    }
62
+
63
+    /**
64
+     * Do a fresh install.
65
+     *
66
+     */
67
+    public function upgrade_from_0() {
68
+
69
+        // Save default tax rates.
70
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
71
+    }
72
+
73
+    /**
74
+     * Upgrade to 0.0.5
75
+     *
76
+     */
77
+    public function upgrade_from_004() {
78
+        global $wpdb;
79
+
80
+        // Invoices.
81
+        $results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
82
+        if ( ! empty( $results ) ) {
83
+            $wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
84
+
85
+            // Clean post cache
86
+            foreach ( $results as $row ) {
87
+                clean_post_cache( $row->ID );
88
+            }
89
+        }
90
+
91
+        // Item meta key changes
92
+        $query = 'SELECT DISTINCT post_id FROM ' . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
93
+        $results = $wpdb->get_results( $query );
94
+
95
+        if ( ! empty( $results ) ) {
96
+            $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
97
+            $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
98
+            $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
99
+
100
+            foreach ( $results as $row ) {
101
+                clean_post_cache( $row->post_id );
102
+            }
103
+        }
104
+
105
+        $this->upgrade_from_118();
106
+    }
107
+
108
+    /**
109
+     * Upgrade to version 2.0.0.
110
+     *
111
+     */
112
+    public function upgrade_from_118() {
113
+        $this->migrate_old_invoices();
114
+        $this->upgrade_from_279();
115
+    }
116
+
117
+    /**
118
+     * Upgrade to version 2.0.0.
119
+     *
120
+     */
121
+    public function upgrade_from_279() {
122
+        $this->migrate_old_customers();
123
+    }
124
+
125
+    /**
126
+     * Give administrators the capability to manage GetPaid.
127
+     *
128
+     */
129
+    public function add_capabilities() {
130
+        $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
131
+    }
132
+
133
+    /**
134
+     * Retreives GetPaid pages.
135
+     *
136
+     */
137
+    public static function get_pages() {
138
+
139
+        return apply_filters(
140
+            'wpinv_create_pages',
141
+            array(
142
+
143
+                // Checkout page.
144
+                'checkout_page'             => array(
145
+                    'name'    => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
146
+                    'title'   => _x( 'Checkout', 'Page title', 'invoicing' ),
147
+                    'content' => '
148 148
 						<!-- wp:shortcode -->
149 149
 						[wpinv_checkout]
150 150
 						<!-- /wp:shortcode -->
151 151
 					',
152
-					'parent'  => '',
153
-				),
154
-
155
-				// Invoice history page.
156
-				'invoice_history_page'      => array(
157
-					'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
158
-					'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
159
-					'content' => '
152
+                    'parent'  => '',
153
+                ),
154
+
155
+                // Invoice history page.
156
+                'invoice_history_page'      => array(
157
+                    'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
158
+                    'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
159
+                    'content' => '
160 160
 					<!-- wp:shortcode -->
161 161
 					[wpinv_history]
162 162
 					<!-- /wp:shortcode -->
163 163
 				',
164
-					'parent'  => '',
165
-				),
166
-
167
-				// Success page content.
168
-				'success_page'              => array(
169
-					'name'    => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
170
-					'title'   => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
171
-					'content' => '
164
+                    'parent'  => '',
165
+                ),
166
+
167
+                // Success page content.
168
+                'success_page'              => array(
169
+                    'name'    => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
170
+                    'title'   => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
171
+                    'content' => '
172 172
 					<!-- wp:shortcode -->
173 173
 					[wpinv_receipt]
174 174
 					<!-- /wp:shortcode -->
175 175
 				',
176
-					'parent'  => 'gp-checkout',
177
-				),
178
-
179
-				// Failure page content.
180
-				'failure_page'              => array(
181
-					'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
182
-					'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
183
-					'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
184
-					'parent'  => 'gp-checkout',
185
-				),
186
-
187
-				// Subscriptions history page.
188
-				'invoice_subscription_page' => array(
189
-					'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
190
-					'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
191
-					'content' => '
176
+                    'parent'  => 'gp-checkout',
177
+                ),
178
+
179
+                // Failure page content.
180
+                'failure_page'              => array(
181
+                    'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
182
+                    'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
183
+                    'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
184
+                    'parent'  => 'gp-checkout',
185
+                ),
186
+
187
+                // Subscriptions history page.
188
+                'invoice_subscription_page' => array(
189
+                    'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
190
+                    'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
191
+                    'content' => '
192 192
 					<!-- wp:shortcode -->
193 193
 					[wpinv_subscriptions]
194 194
 					<!-- /wp:shortcode -->
195 195
 				',
196
-					'parent'  => '',
197
-				),
198
-
199
-			)
200
-		);
201
-
202
-	}
203
-
204
-	/**
205
-	 * Re-create GetPaid pages.
206
-	 *
207
-	 */
208
-	public function create_pages() {
209
-
210
-		foreach ( self::get_pages() as $key => $page ) {
211
-			wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
212
-		}
213
-
214
-	}
215
-
216
-	/**
217
-	 * Migrates old invoices to new invoices.
218
-	 *
219
-	 */
220
-	public function migrate_old_invoices() {
221
-		global $wpdb;
222
-
223
-		$invoices_table      = $wpdb->prefix . 'getpaid_invoices';
224
-		$invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
225
-		$migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
226
-		$invoices            = array_unique(
227
-			get_posts(
228
-				array(
229
-					'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
230
-					'posts_per_page' => -1,
231
-					'fields'         => 'ids',
232
-					'post_status'    => array_keys( get_post_stati() ),
233
-					'exclude'        => (array) $migrated,
234
-				)
235
-			)
236
-		);
237
-
238
-		// Abort if we do not have any invoices.
239
-		if ( empty( $invoices ) ) {
240
-			return;
241
-		}
242
-
243
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php';
244
-
245
-		$invoice_rows = array();
246
-		foreach ( $invoices as $invoice ) {
247
-
248
-			$invoice = new WPInv_Legacy_Invoice( $invoice );
249
-
250
-			if ( empty( $invoice->ID ) ) {
251
-				return;
252
-			}
253
-
254
-			$fields = array(
255
-				'post_id'            => $invoice->ID,
256
-				'number'             => $invoice->get_number(),
257
-				'key'                => $invoice->get_key(),
258
-				'type'               => str_replace( 'wpi_', '', $invoice->post_type ),
259
-				'mode'               => $invoice->mode,
260
-				'user_ip'            => $invoice->get_ip(),
261
-				'first_name'         => $invoice->get_first_name(),
262
-				'last_name'          => $invoice->get_last_name(),
263
-				'address'            => $invoice->get_address(),
264
-				'city'               => $invoice->city,
265
-				'state'              => $invoice->state,
266
-				'country'            => $invoice->country,
267
-				'zip'                => $invoice->zip,
268
-				'adddress_confirmed' => (int) $invoice->adddress_confirmed,
269
-				'gateway'            => $invoice->get_gateway(),
270
-				'transaction_id'     => $invoice->get_transaction_id(),
271
-				'currency'           => $invoice->get_currency(),
272
-				'subtotal'           => $invoice->get_subtotal(),
273
-				'tax'                => $invoice->get_tax(),
274
-				'fees_total'         => $invoice->get_fees_total(),
275
-				'total'              => $invoice->get_total(),
276
-				'discount'           => $invoice->get_discount(),
277
-				'discount_code'      => $invoice->get_discount_code(),
278
-				'disable_taxes'      => $invoice->disable_taxes,
279
-				'due_date'           => $invoice->get_due_date(),
280
-				'completed_date'     => $invoice->get_completed_date(),
281
-				'company'            => $invoice->company,
282
-				'vat_number'         => $invoice->vat_number,
283
-				'vat_rate'           => $invoice->vat_rate,
284
-				'custom_meta'        => $invoice->payment_meta,
285
-			);
286
-
287
-			foreach ( $fields as $key => $val ) {
288
-				if ( is_null( $val ) ) {
289
-					$val = '';
290
-				}
291
-				$val = maybe_serialize( $val );
292
-				$fields[ $key ] = $wpdb->prepare( '%s', $val );
293
-			}
294
-
295
-			$fields = implode( ', ', $fields );
296
-			$invoice_rows[] = "($fields)";
297
-
298
-			$item_rows    = array();
299
-			$item_columns = array();
300
-			foreach ( $invoice->get_cart_details() as $details ) {
301
-				$fields = array(
302
-					'post_id'          => $invoice->ID,
303
-					'item_id'          => $details['id'],
304
-					'item_name'        => $details['name'],
305
-					'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
306
-					'vat_rate'         => $details['vat_rate'],
307
-					'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
308
-					'tax'              => $details['tax'],
309
-					'item_price'       => $details['item_price'],
310
-					'custom_price'     => $details['custom_price'],
311
-					'quantity'         => $details['quantity'],
312
-					'discount'         => $details['discount'],
313
-					'subtotal'         => $details['subtotal'],
314
-					'price'            => $details['price'],
315
-					'meta'             => $details['meta'],
316
-					'fees'             => $details['fees'],
317
-				);
318
-
319
-				$item_columns = array_keys( $fields );
320
-
321
-				foreach ( $fields as $key => $val ) {
322
-					if ( is_null( $val ) ) {
323
-						$val = '';
324
-					}
325
-					$val = maybe_serialize( $val );
326
-					$fields[ $key ] = $wpdb->prepare( '%s', $val );
327
-				}
328
-
329
-				$fields = implode( ', ', $fields );
330
-				$item_rows[] = "($fields)";
331
-			}
332
-
333
-			$item_rows    = implode( ', ', $item_rows );
334
-			$item_columns = implode( ', ', $item_columns );
335
-			$wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
336
-		}
337
-
338
-		if ( empty( $invoice_rows ) ) {
339
-			return;
340
-		}
341
-
342
-		$invoice_rows = implode( ', ', $invoice_rows );
343
-		$wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
344
-
345
-	}
346
-
347
-	/**
348
-	 * Migrates old customers to new table.
349
-	 *
350
-	 */
351
-	public function migrate_old_customers() {
352
-		global $wpdb;
353
-
354
-		// Fetch post_id from $wpdb->prefix . 'getpaid_invoices' where customer_id = 0 or null.
355
-		$invoice_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->prefix}getpaid_invoices WHERE customer_id = 0 OR customer_id IS NULL" );
356
-
357
-		foreach ( $invoice_ids as $invoice_id ) {
358
-			$invoice = wpinv_get_invoice( $invoice_id );
359
-
360
-			if ( empty( $invoice ) ) {
361
-				continue;
362
-			}
363
-
364
-			// Fetch customer from the user ID.
365
-			$user_id = $invoice->get_user_id();
366
-
367
-			if ( empty( $user_id ) ) {
368
-				continue;
369
-			}
370
-
371
-			$customer = getpaid_get_customer_by_user_id( $user_id );
372
-
373
-			// Create if not exists.
374
-			if ( empty( $customer ) ) {
375
-				$customer = new GetPaid_Customer( 0 );
376
-				$customer->clone_user( $user_id );
377
-				$customer->save();
378
-			}
379
-
380
-			$invoice->set_customer_id( $customer->get_id() );
381
-			$invoice->save();
382
-		}
383
-
384
-	}
385
-
386
-	/**
387
-	 * Migrates old invoices to new invoices.
388
-	 *
389
-	 */
390
-	public static function rename_gateways_label() {
391
-		global $wpdb;
392
-
393
-		foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
394
-
395
-			$wpdb->update(
396
-				$wpdb->prefix . 'getpaid_invoices',
397
-				array( 'gateway' => $gateway ),
398
-				array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
399
-				'%s',
400
-				'%s'
401
-			);
402
-
403
-		}
404
-	}
405
-
406
-	/**
407
-	 * Returns the DB schema.
408
-	 *
409
-	 */
410
-	public static function get_db_schema() {
411
-		global $wpdb;
412
-
413
-		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
414
-
415
-		$charset_collate = $wpdb->get_charset_collate();
196
+                    'parent'  => '',
197
+                ),
198
+
199
+            )
200
+        );
201
+
202
+    }
203
+
204
+    /**
205
+     * Re-create GetPaid pages.
206
+     *
207
+     */
208
+    public function create_pages() {
209
+
210
+        foreach ( self::get_pages() as $key => $page ) {
211
+            wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
212
+        }
213
+
214
+    }
215
+
216
+    /**
217
+     * Migrates old invoices to new invoices.
218
+     *
219
+     */
220
+    public function migrate_old_invoices() {
221
+        global $wpdb;
222
+
223
+        $invoices_table      = $wpdb->prefix . 'getpaid_invoices';
224
+        $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
225
+        $migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
226
+        $invoices            = array_unique(
227
+            get_posts(
228
+                array(
229
+                    'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
230
+                    'posts_per_page' => -1,
231
+                    'fields'         => 'ids',
232
+                    'post_status'    => array_keys( get_post_stati() ),
233
+                    'exclude'        => (array) $migrated,
234
+                )
235
+            )
236
+        );
237
+
238
+        // Abort if we do not have any invoices.
239
+        if ( empty( $invoices ) ) {
240
+            return;
241
+        }
242
+
243
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php';
244
+
245
+        $invoice_rows = array();
246
+        foreach ( $invoices as $invoice ) {
247
+
248
+            $invoice = new WPInv_Legacy_Invoice( $invoice );
249
+
250
+            if ( empty( $invoice->ID ) ) {
251
+                return;
252
+            }
253
+
254
+            $fields = array(
255
+                'post_id'            => $invoice->ID,
256
+                'number'             => $invoice->get_number(),
257
+                'key'                => $invoice->get_key(),
258
+                'type'               => str_replace( 'wpi_', '', $invoice->post_type ),
259
+                'mode'               => $invoice->mode,
260
+                'user_ip'            => $invoice->get_ip(),
261
+                'first_name'         => $invoice->get_first_name(),
262
+                'last_name'          => $invoice->get_last_name(),
263
+                'address'            => $invoice->get_address(),
264
+                'city'               => $invoice->city,
265
+                'state'              => $invoice->state,
266
+                'country'            => $invoice->country,
267
+                'zip'                => $invoice->zip,
268
+                'adddress_confirmed' => (int) $invoice->adddress_confirmed,
269
+                'gateway'            => $invoice->get_gateway(),
270
+                'transaction_id'     => $invoice->get_transaction_id(),
271
+                'currency'           => $invoice->get_currency(),
272
+                'subtotal'           => $invoice->get_subtotal(),
273
+                'tax'                => $invoice->get_tax(),
274
+                'fees_total'         => $invoice->get_fees_total(),
275
+                'total'              => $invoice->get_total(),
276
+                'discount'           => $invoice->get_discount(),
277
+                'discount_code'      => $invoice->get_discount_code(),
278
+                'disable_taxes'      => $invoice->disable_taxes,
279
+                'due_date'           => $invoice->get_due_date(),
280
+                'completed_date'     => $invoice->get_completed_date(),
281
+                'company'            => $invoice->company,
282
+                'vat_number'         => $invoice->vat_number,
283
+                'vat_rate'           => $invoice->vat_rate,
284
+                'custom_meta'        => $invoice->payment_meta,
285
+            );
286
+
287
+            foreach ( $fields as $key => $val ) {
288
+                if ( is_null( $val ) ) {
289
+                    $val = '';
290
+                }
291
+                $val = maybe_serialize( $val );
292
+                $fields[ $key ] = $wpdb->prepare( '%s', $val );
293
+            }
294
+
295
+            $fields = implode( ', ', $fields );
296
+            $invoice_rows[] = "($fields)";
297
+
298
+            $item_rows    = array();
299
+            $item_columns = array();
300
+            foreach ( $invoice->get_cart_details() as $details ) {
301
+                $fields = array(
302
+                    'post_id'          => $invoice->ID,
303
+                    'item_id'          => $details['id'],
304
+                    'item_name'        => $details['name'],
305
+                    'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
306
+                    'vat_rate'         => $details['vat_rate'],
307
+                    'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
308
+                    'tax'              => $details['tax'],
309
+                    'item_price'       => $details['item_price'],
310
+                    'custom_price'     => $details['custom_price'],
311
+                    'quantity'         => $details['quantity'],
312
+                    'discount'         => $details['discount'],
313
+                    'subtotal'         => $details['subtotal'],
314
+                    'price'            => $details['price'],
315
+                    'meta'             => $details['meta'],
316
+                    'fees'             => $details['fees'],
317
+                );
318
+
319
+                $item_columns = array_keys( $fields );
320
+
321
+                foreach ( $fields as $key => $val ) {
322
+                    if ( is_null( $val ) ) {
323
+                        $val = '';
324
+                    }
325
+                    $val = maybe_serialize( $val );
326
+                    $fields[ $key ] = $wpdb->prepare( '%s', $val );
327
+                }
328
+
329
+                $fields = implode( ', ', $fields );
330
+                $item_rows[] = "($fields)";
331
+            }
332
+
333
+            $item_rows    = implode( ', ', $item_rows );
334
+            $item_columns = implode( ', ', $item_columns );
335
+            $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
336
+        }
337
+
338
+        if ( empty( $invoice_rows ) ) {
339
+            return;
340
+        }
341
+
342
+        $invoice_rows = implode( ', ', $invoice_rows );
343
+        $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
344
+
345
+    }
346
+
347
+    /**
348
+     * Migrates old customers to new table.
349
+     *
350
+     */
351
+    public function migrate_old_customers() {
352
+        global $wpdb;
353
+
354
+        // Fetch post_id from $wpdb->prefix . 'getpaid_invoices' where customer_id = 0 or null.
355
+        $invoice_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->prefix}getpaid_invoices WHERE customer_id = 0 OR customer_id IS NULL" );
356
+
357
+        foreach ( $invoice_ids as $invoice_id ) {
358
+            $invoice = wpinv_get_invoice( $invoice_id );
359
+
360
+            if ( empty( $invoice ) ) {
361
+                continue;
362
+            }
363
+
364
+            // Fetch customer from the user ID.
365
+            $user_id = $invoice->get_user_id();
366
+
367
+            if ( empty( $user_id ) ) {
368
+                continue;
369
+            }
370
+
371
+            $customer = getpaid_get_customer_by_user_id( $user_id );
372
+
373
+            // Create if not exists.
374
+            if ( empty( $customer ) ) {
375
+                $customer = new GetPaid_Customer( 0 );
376
+                $customer->clone_user( $user_id );
377
+                $customer->save();
378
+            }
379
+
380
+            $invoice->set_customer_id( $customer->get_id() );
381
+            $invoice->save();
382
+        }
383
+
384
+    }
385
+
386
+    /**
387
+     * Migrates old invoices to new invoices.
388
+     *
389
+     */
390
+    public static function rename_gateways_label() {
391
+        global $wpdb;
392
+
393
+        foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
394
+
395
+            $wpdb->update(
396
+                $wpdb->prefix . 'getpaid_invoices',
397
+                array( 'gateway' => $gateway ),
398
+                array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
399
+                '%s',
400
+                '%s'
401
+            );
402
+
403
+        }
404
+    }
405
+
406
+    /**
407
+     * Returns the DB schema.
408
+     *
409
+     */
410
+    public static function get_db_schema() {
411
+        global $wpdb;
412
+
413
+        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
414
+
415
+        $charset_collate = $wpdb->get_charset_collate();
416 416
 
417
-		// Subscriptions.
418
-		$schema = "CREATE TABLE {$wpdb->prefix}wpinv_subscriptions (
417
+        // Subscriptions.
418
+        $schema = "CREATE TABLE {$wpdb->prefix}wpinv_subscriptions (
419 419
 			id bigint(20) unsigned NOT NULL auto_increment,
420 420
 			customer_id bigint(20) NOT NULL,
421 421
 			frequency int(11) NOT NULL DEFAULT '1',
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
 			KEY customer_and_status (customer_id, status)
439 439
 		  ) $charset_collate;";
440 440
 
441
-		// Invoices.
442
-		$schema .= "CREATE TABLE {$wpdb->prefix}getpaid_invoices (
441
+        // Invoices.
442
+        $schema .= "CREATE TABLE {$wpdb->prefix}getpaid_invoices (
443 443
 			post_id BIGINT(20) NOT NULL,
444 444
 			customer_id BIGINT(20) NOT NULL DEFAULT 0,
445 445
             `number` VARCHAR(100),
@@ -476,8 +476,8 @@  discard block
 block discarded – undo
476 476
 			KEY `key` (`key`)
477 477
 		  ) $charset_collate;";
478 478
 
479
-		// Invoice items.
480
-		$schema .= "CREATE TABLE {$wpdb->prefix}getpaid_invoice_items (
479
+        // Invoice items.
480
+        $schema .= "CREATE TABLE {$wpdb->prefix}getpaid_invoice_items (
481 481
 			ID BIGINT(20) NOT NULL AUTO_INCREMENT,
482 482
             post_id BIGINT(20) NOT NULL,
483 483
             item_id BIGINT(20) NOT NULL,
@@ -499,8 +499,8 @@  discard block
 block discarded – undo
499 499
 			KEY post_id (post_id)
500 500
 		  ) $charset_collate;";
501 501
 
502
-		// Customers.
503
-		$schema .= "CREATE TABLE {$wpdb->prefix}getpaid_customers (
502
+        // Customers.
503
+        $schema .= "CREATE TABLE {$wpdb->prefix}getpaid_customers (
504 504
 			id BIGINT(20) NOT NULL AUTO_INCREMENT,
505 505
 			user_id BIGINT(20) NOT NULL,
506 506
 			email VARCHAR(100) NOT NULL,
@@ -510,38 +510,38 @@  discard block
 block discarded – undo
510 510
 			purchase_count BIGINT(20) NOT NULL DEFAULT 0,
511 511
 			";
512 512
 
513
-		// Add address fields.
514
-		foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
513
+        // Add address fields.
514
+        foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
515 515
 
516
-			// Skip id, user_id and email.
517
-			if ( in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) {
518
-				continue;
519
-			}
516
+            // Skip id, user_id and email.
517
+            if ( in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) {
518
+                continue;
519
+            }
520 520
 
521
-			$field   = sanitize_key( $field );
522
-			$length  = 100;
523
-			$default = '';
521
+            $field   = sanitize_key( $field );
522
+            $length  = 100;
523
+            $default = '';
524 524
 
525
-			// Country.
526
-			if ( 'country' === $field ) {
527
-				$length  = 2;
528
-				$default = wpinv_get_default_country();
529
-			}
525
+            // Country.
526
+            if ( 'country' === $field ) {
527
+                $length  = 2;
528
+                $default = wpinv_get_default_country();
529
+            }
530 530
 
531
-			// State.
532
-			if ( 'state' === $field ) {
533
-				$default = wpinv_get_default_state();
534
-			}
531
+            // State.
532
+            if ( 'state' === $field ) {
533
+                $default = wpinv_get_default_state();
534
+            }
535 535
 
536
-			// Phone, zip.
537
-			if ( in_array( $field, array( 'phone', 'zip' ), true ) ) {
538
-				$length = 20;
539
-			}
536
+            // Phone, zip.
537
+            if ( in_array( $field, array( 'phone', 'zip' ), true ) ) {
538
+                $length = 20;
539
+            }
540 540
 
541
-			$schema .= "`$field` VARCHAR($length) NOT NULL DEFAULT '$default',";
542
-		}
541
+            $schema .= "`$field` VARCHAR($length) NOT NULL DEFAULT '$default',";
542
+        }
543 543
 
544
-		$schema .= "
544
+        $schema .= "
545 545
 			date_created DATETIME NOT NULL,
546 546
 			date_modified DATETIME NOT NULL,
547 547
 			uuid VARCHAR(100) NOT NULL,
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
 			KEY email (email)
551 551
 		  ) $charset_collate;";
552 552
 
553
-		// Customer meta.
554
-		$schema .= "CREATE TABLE {$wpdb->prefix}getpaid_customer_meta (
553
+        // Customer meta.
554
+        $schema .= "CREATE TABLE {$wpdb->prefix}getpaid_customer_meta (
555 555
 			meta_id BIGINT(20) NOT NULL AUTO_INCREMENT,
556 556
 			customer_id BIGINT(20) NOT NULL,
557 557
 			meta_key VARCHAR(255) NOT NULL,
@@ -561,41 +561,41 @@  discard block
 block discarded – undo
561 561
 			KEY meta_key (meta_key(191))
562 562
 		  ) $charset_collate;";
563 563
 
564
-		return $schema;
565
-	}
564
+        return $schema;
565
+    }
566 566
 
567
-	/**
568
-	 * Checks if the db schema is up to date.
569
-	 *
570
-	 * @return bool
571
-	 */
572
-	public static function is_db_schema_up_to_date() {
573
-		return md5( self::get_db_schema() ) === get_option( 'getpaid_db_schema' );
574
-	}
567
+    /**
568
+     * Checks if the db schema is up to date.
569
+     *
570
+     * @return bool
571
+     */
572
+    public static function is_db_schema_up_to_date() {
573
+        return md5( self::get_db_schema() ) === get_option( 'getpaid_db_schema' );
574
+    }
575 575
 
576
-	/**
577
-	 * Set up the database tables which the plugin needs to function.
578
-	 */
579
-	public static function create_db_tables() {
580
-		global $wpdb;
576
+    /**
577
+     * Set up the database tables which the plugin needs to function.
578
+     */
579
+    public static function create_db_tables() {
580
+        global $wpdb;
581 581
 
582
-		$wpdb->hide_errors();
582
+        $wpdb->hide_errors();
583 583
 
584
-		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
584
+        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
585 585
 
586
-		$schema = self::get_db_schema();
586
+        $schema = self::get_db_schema();
587 587
 
588
-		dbDelta( $schema );
588
+        dbDelta( $schema );
589 589
 
590
-		update_option( 'getpaid_db_schema', md5( self::get_db_schema() ) );
591
-	}
590
+        update_option( 'getpaid_db_schema', md5( self::get_db_schema() ) );
591
+    }
592 592
 
593
-	/**
594
-	 * Creates tables if schema is not up to date.
595
-	 */
596
-	public static function maybe_create_db_tables() {
597
-		if ( ! self::is_db_schema_up_to_date() ) {
598
-			self::create_db_tables();
599
-		}
600
-	}
593
+    /**
594
+     * Creates tables if schema is not up to date.
595
+     */
596
+    public static function maybe_create_db_tables() {
597
+        if ( ! self::is_db_schema_up_to_date() ) {
598
+            self::create_db_tables();
599
+        }
600
+    }
601 601
 }
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since   2.0.2
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * The main installer/updater class.
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @param string $upgrade_from The current invoicing version.
27 27
 	 */
28
-	public function upgrade_db( $upgrade_from ) {
28
+	public function upgrade_db($upgrade_from) {
29 29
 
30 30
 		// Save the current invoicing version.
31
-		update_option( 'wpinv_version', WPINV_VERSION );
31
+		update_option('wpinv_version', WPINV_VERSION);
32 32
 
33 33
 		// Setup the invoice Custom Post Type.
34 34
 		GetPaid_Post_Types::register_post_types();
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 		// Create any missing database tables.
49 49
 		$method = "upgrade_from_$upgrade_from";
50 50
 
51
-		$installed = get_option( 'gepaid_installed_on' );
51
+		$installed = get_option('gepaid_installed_on');
52 52
 
53
-		if ( empty( $installed ) ) {
54
-			update_option( 'gepaid_installed_on', time() );
53
+		if (empty($installed)) {
54
+			update_option('gepaid_installed_on', time());
55 55
 		}
56 56
 
57
-		if ( method_exists( $this, $method ) ) {
57
+		if (method_exists($this, $method)) {
58 58
 			$this->$method();
59 59
 		}
60 60
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	public function upgrade_from_0() {
68 68
 
69 69
 		// Save default tax rates.
70
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
70
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
71 71
 	}
72 72
 
73 73
 	/**
@@ -78,27 +78,27 @@  discard block
 block discarded – undo
78 78
 		global $wpdb;
79 79
 
80 80
 		// Invoices.
81
-		$results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
82
-		if ( ! empty( $results ) ) {
83
-			$wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
81
+		$results = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
82
+		if (!empty($results)) {
83
+			$wpdb->query("UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
84 84
 
85 85
 			// Clean post cache
86
-			foreach ( $results as $row ) {
87
-				clean_post_cache( $row->ID );
86
+			foreach ($results as $row) {
87
+				clean_post_cache($row->ID);
88 88
 			}
89 89
 		}
90 90
 
91 91
 		// Item meta key changes
92 92
 		$query = 'SELECT DISTINCT post_id FROM ' . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
93
-		$results = $wpdb->get_results( $query );
93
+		$results = $wpdb->get_results($query);
94 94
 
95
-		if ( ! empty( $results ) ) {
96
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
97
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
98
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
95
+		if (!empty($results)) {
96
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
97
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
98
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
99 99
 
100
-			foreach ( $results as $row ) {
101
-				clean_post_cache( $row->post_id );
100
+			foreach ($results as $row) {
101
+				clean_post_cache($row->post_id);
102 102
 			}
103 103
 		}
104 104
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 *
128 128
 	 */
129 129
 	public function add_capabilities() {
130
-		$GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
130
+		$GLOBALS['wp_roles']->add_cap('administrator', 'manage_invoicing');
131 131
 	}
132 132
 
133 133
 	/**
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 
143 143
 				// Checkout page.
144 144
 				'checkout_page'             => array(
145
-					'name'    => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
146
-					'title'   => _x( 'Checkout', 'Page title', 'invoicing' ),
145
+					'name'    => _x('gp-checkout', 'Page slug', 'invoicing'),
146
+					'title'   => _x('Checkout', 'Page title', 'invoicing'),
147 147
 					'content' => '
148 148
 						<!-- wp:shortcode -->
149 149
 						[wpinv_checkout]
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 
155 155
 				// Invoice history page.
156 156
 				'invoice_history_page'      => array(
157
-					'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
158
-					'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
157
+					'name'    => _x('gp-invoices', 'Page slug', 'invoicing'),
158
+					'title'   => _x('My Invoices', 'Page title', 'invoicing'),
159 159
 					'content' => '
160 160
 					<!-- wp:shortcode -->
161 161
 					[wpinv_history]
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 
167 167
 				// Success page content.
168 168
 				'success_page'              => array(
169
-					'name'    => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
170
-					'title'   => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
169
+					'name'    => _x('gp-receipt', 'Page slug', 'invoicing'),
170
+					'title'   => _x('Payment Confirmation', 'Page title', 'invoicing'),
171 171
 					'content' => '
172 172
 					<!-- wp:shortcode -->
173 173
 					[wpinv_receipt]
@@ -178,16 +178,16 @@  discard block
 block discarded – undo
178 178
 
179 179
 				// Failure page content.
180 180
 				'failure_page'              => array(
181
-					'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
182
-					'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
183
-					'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
181
+					'name'    => _x('gp-transaction-failed', 'Page slug', 'invoicing'),
182
+					'title'   => _x('Transaction Failed', 'Page title', 'invoicing'),
183
+					'content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'),
184 184
 					'parent'  => 'gp-checkout',
185 185
 				),
186 186
 
187 187
 				// Subscriptions history page.
188 188
 				'invoice_subscription_page' => array(
189
-					'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
190
-					'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
189
+					'name'    => _x('gp-subscriptions', 'Page slug', 'invoicing'),
190
+					'title'   => _x('My Subscriptions', 'Page title', 'invoicing'),
191 191
 					'content' => '
192 192
 					<!-- wp:shortcode -->
193 193
 					[wpinv_subscriptions]
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	public function create_pages() {
209 209
 
210
-		foreach ( self::get_pages() as $key => $page ) {
211
-			wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
210
+		foreach (self::get_pages() as $key => $page) {
211
+			wpinv_create_page(esc_sql($page['name']), $key, $page['title'], $page['content'], $page['parent']);
212 212
 		}
213 213
 
214 214
 	}
@@ -222,32 +222,32 @@  discard block
 block discarded – undo
222 222
 
223 223
 		$invoices_table      = $wpdb->prefix . 'getpaid_invoices';
224 224
 		$invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
225
-		$migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
225
+		$migrated            = $wpdb->get_col("SELECT post_id FROM $invoices_table");
226 226
 		$invoices            = array_unique(
227 227
 			get_posts(
228 228
 				array(
229
-					'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
229
+					'post_type'      => array('wpi_invoice', 'wpi_quote'),
230 230
 					'posts_per_page' => -1,
231 231
 					'fields'         => 'ids',
232
-					'post_status'    => array_keys( get_post_stati() ),
232
+					'post_status'    => array_keys(get_post_stati()),
233 233
 					'exclude'        => (array) $migrated,
234 234
 				)
235 235
 			)
236 236
 		);
237 237
 
238 238
 		// Abort if we do not have any invoices.
239
-		if ( empty( $invoices ) ) {
239
+		if (empty($invoices)) {
240 240
 			return;
241 241
 		}
242 242
 
243 243
 		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php';
244 244
 
245 245
 		$invoice_rows = array();
246
-		foreach ( $invoices as $invoice ) {
246
+		foreach ($invoices as $invoice) {
247 247
 
248
-			$invoice = new WPInv_Legacy_Invoice( $invoice );
248
+			$invoice = new WPInv_Legacy_Invoice($invoice);
249 249
 
250
-			if ( empty( $invoice->ID ) ) {
250
+			if (empty($invoice->ID)) {
251 251
 				return;
252 252
 			}
253 253
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 				'post_id'            => $invoice->ID,
256 256
 				'number'             => $invoice->get_number(),
257 257
 				'key'                => $invoice->get_key(),
258
-				'type'               => str_replace( 'wpi_', '', $invoice->post_type ),
258
+				'type'               => str_replace('wpi_', '', $invoice->post_type),
259 259
 				'mode'               => $invoice->mode,
260 260
 				'user_ip'            => $invoice->get_ip(),
261 261
 				'first_name'         => $invoice->get_first_name(),
@@ -284,27 +284,27 @@  discard block
 block discarded – undo
284 284
 				'custom_meta'        => $invoice->payment_meta,
285 285
 			);
286 286
 
287
-			foreach ( $fields as $key => $val ) {
288
-				if ( is_null( $val ) ) {
287
+			foreach ($fields as $key => $val) {
288
+				if (is_null($val)) {
289 289
 					$val = '';
290 290
 				}
291
-				$val = maybe_serialize( $val );
292
-				$fields[ $key ] = $wpdb->prepare( '%s', $val );
291
+				$val = maybe_serialize($val);
292
+				$fields[$key] = $wpdb->prepare('%s', $val);
293 293
 			}
294 294
 
295
-			$fields = implode( ', ', $fields );
295
+			$fields = implode(', ', $fields);
296 296
 			$invoice_rows[] = "($fields)";
297 297
 
298 298
 			$item_rows    = array();
299 299
 			$item_columns = array();
300
-			foreach ( $invoice->get_cart_details() as $details ) {
300
+			foreach ($invoice->get_cart_details() as $details) {
301 301
 				$fields = array(
302 302
 					'post_id'          => $invoice->ID,
303 303
 					'item_id'          => $details['id'],
304 304
 					'item_name'        => $details['name'],
305
-					'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
305
+					'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'],
306 306
 					'vat_rate'         => $details['vat_rate'],
307
-					'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
307
+					'vat_class'        => empty($details['vat_class']) ? '_standard' : $details['vat_class'],
308 308
 					'tax'              => $details['tax'],
309 309
 					'item_price'       => $details['item_price'],
310 310
 					'custom_price'     => $details['custom_price'],
@@ -316,31 +316,31 @@  discard block
 block discarded – undo
316 316
 					'fees'             => $details['fees'],
317 317
 				);
318 318
 
319
-				$item_columns = array_keys( $fields );
319
+				$item_columns = array_keys($fields);
320 320
 
321
-				foreach ( $fields as $key => $val ) {
322
-					if ( is_null( $val ) ) {
321
+				foreach ($fields as $key => $val) {
322
+					if (is_null($val)) {
323 323
 						$val = '';
324 324
 					}
325
-					$val = maybe_serialize( $val );
326
-					$fields[ $key ] = $wpdb->prepare( '%s', $val );
325
+					$val = maybe_serialize($val);
326
+					$fields[$key] = $wpdb->prepare('%s', $val);
327 327
 				}
328 328
 
329
-				$fields = implode( ', ', $fields );
329
+				$fields = implode(', ', $fields);
330 330
 				$item_rows[] = "($fields)";
331 331
 			}
332 332
 
333
-			$item_rows    = implode( ', ', $item_rows );
334
-			$item_columns = implode( ', ', $item_columns );
335
-			$wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
333
+			$item_rows    = implode(', ', $item_rows);
334
+			$item_columns = implode(', ', $item_columns);
335
+			$wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows");
336 336
 		}
337 337
 
338
-		if ( empty( $invoice_rows ) ) {
338
+		if (empty($invoice_rows)) {
339 339
 			return;
340 340
 		}
341 341
 
342
-		$invoice_rows = implode( ', ', $invoice_rows );
343
-		$wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
342
+		$invoice_rows = implode(', ', $invoice_rows);
343
+		$wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows");
344 344
 
345 345
 	}
346 346
 
@@ -352,32 +352,32 @@  discard block
 block discarded – undo
352 352
 		global $wpdb;
353 353
 
354 354
 		// Fetch post_id from $wpdb->prefix . 'getpaid_invoices' where customer_id = 0 or null.
355
-		$invoice_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->prefix}getpaid_invoices WHERE customer_id = 0 OR customer_id IS NULL" );
355
+		$invoice_ids = $wpdb->get_col("SELECT post_id FROM {$wpdb->prefix}getpaid_invoices WHERE customer_id = 0 OR customer_id IS NULL");
356 356
 
357
-		foreach ( $invoice_ids as $invoice_id ) {
358
-			$invoice = wpinv_get_invoice( $invoice_id );
357
+		foreach ($invoice_ids as $invoice_id) {
358
+			$invoice = wpinv_get_invoice($invoice_id);
359 359
 
360
-			if ( empty( $invoice ) ) {
360
+			if (empty($invoice)) {
361 361
 				continue;
362 362
 			}
363 363
 
364 364
 			// Fetch customer from the user ID.
365 365
 			$user_id = $invoice->get_user_id();
366 366
 
367
-			if ( empty( $user_id ) ) {
367
+			if (empty($user_id)) {
368 368
 				continue;
369 369
 			}
370 370
 
371
-			$customer = getpaid_get_customer_by_user_id( $user_id );
371
+			$customer = getpaid_get_customer_by_user_id($user_id);
372 372
 
373 373
 			// Create if not exists.
374
-			if ( empty( $customer ) ) {
375
-				$customer = new GetPaid_Customer( 0 );
376
-				$customer->clone_user( $user_id );
374
+			if (empty($customer)) {
375
+				$customer = new GetPaid_Customer(0);
376
+				$customer->clone_user($user_id);
377 377
 				$customer->save();
378 378
 			}
379 379
 
380
-			$invoice->set_customer_id( $customer->get_id() );
380
+			$invoice->set_customer_id($customer->get_id());
381 381
 			$invoice->save();
382 382
 		}
383 383
 
@@ -390,12 +390,12 @@  discard block
 block discarded – undo
390 390
 	public static function rename_gateways_label() {
391 391
 		global $wpdb;
392 392
 
393
-		foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
393
+		foreach (array_keys(wpinv_get_payment_gateways()) as $gateway) {
394 394
 
395 395
 			$wpdb->update(
396 396
 				$wpdb->prefix . 'getpaid_invoices',
397
-				array( 'gateway' => $gateway ),
398
-				array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
397
+				array('gateway' => $gateway),
398
+				array('gateway' => wpinv_get_gateway_admin_label($gateway)),
399 399
 				'%s',
400 400
 				'%s'
401 401
 			);
@@ -511,30 +511,30 @@  discard block
 block discarded – undo
511 511
 			";
512 512
 
513 513
 		// Add address fields.
514
-		foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
514
+		foreach (array_keys(getpaid_user_address_fields()) as $field) {
515 515
 
516 516
 			// Skip id, user_id and email.
517
-			if ( in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) {
517
+			if (in_array($field, array('id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid'), true)) {
518 518
 				continue;
519 519
 			}
520 520
 
521
-			$field   = sanitize_key( $field );
521
+			$field   = sanitize_key($field);
522 522
 			$length  = 100;
523 523
 			$default = '';
524 524
 
525 525
 			// Country.
526
-			if ( 'country' === $field ) {
526
+			if ('country' === $field) {
527 527
 				$length  = 2;
528 528
 				$default = wpinv_get_default_country();
529 529
 			}
530 530
 
531 531
 			// State.
532
-			if ( 'state' === $field ) {
532
+			if ('state' === $field) {
533 533
 				$default = wpinv_get_default_state();
534 534
 			}
535 535
 
536 536
 			// Phone, zip.
537
-			if ( in_array( $field, array( 'phone', 'zip' ), true ) ) {
537
+			if (in_array($field, array('phone', 'zip'), true)) {
538 538
 				$length = 20;
539 539
 			}
540 540
 
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	 * @return bool
571 571
 	 */
572 572
 	public static function is_db_schema_up_to_date() {
573
-		return md5( self::get_db_schema() ) === get_option( 'getpaid_db_schema' );
573
+		return md5(self::get_db_schema()) === get_option('getpaid_db_schema');
574 574
 	}
575 575
 
576 576
 	/**
@@ -585,16 +585,16 @@  discard block
 block discarded – undo
585 585
 
586 586
 		$schema = self::get_db_schema();
587 587
 
588
-		dbDelta( $schema );
588
+		dbDelta($schema);
589 589
 
590
-		update_option( 'getpaid_db_schema', md5( self::get_db_schema() ) );
590
+		update_option('getpaid_db_schema', md5(self::get_db_schema()));
591 591
 	}
592 592
 
593 593
 	/**
594 594
 	 * Creates tables if schema is not up to date.
595 595
 	 */
596 596
 	public static function maybe_create_db_tables() {
597
-		if ( ! self::is_db_schema_up_to_date() ) {
597
+		if (!self::is_db_schema_up_to_date()) {
598 598
 			self::create_db_tables();
599 599
 		}
600 600
 	}
Please login to merge, or discard this patch.
includes/admin/class-wpinv-customers-table.php 2 patches
Indentation   +316 added lines, -316 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 // Load WP_List_Table if not loaded
13 13
 if ( ! class_exists( 'WP_List_Table' ) ) {
14
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
14
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
15 15
 }
16 16
 
17 17
 /**
@@ -23,323 +23,323 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class WPInv_Customers_Table extends WP_List_Table {
25 25
 
26
-	/**
27
-	 * @var int Number of items per page
28
-	 * @since 1.0.19
29
-	 */
30
-	public $per_page = 10;
31
-
32
-	/**
33
-	 * @var int Number of items
34
-	 * @since 1.0.19
35
-	 */
36
-	public $total = 0;
37
-
38
-	/**
39
-	 * Get things started
40
-	 *
41
-	 * @since 1.0.19
42
-	 * @see WP_List_Table::__construct()
43
-	 */
44
-	public function __construct() {
45
-
46
-		// Set parent defaults
47
-		parent::__construct(
26
+    /**
27
+     * @var int Number of items per page
28
+     * @since 1.0.19
29
+     */
30
+    public $per_page = 10;
31
+
32
+    /**
33
+     * @var int Number of items
34
+     * @since 1.0.19
35
+     */
36
+    public $total = 0;
37
+
38
+    /**
39
+     * Get things started
40
+     *
41
+     * @since 1.0.19
42
+     * @see WP_List_Table::__construct()
43
+     */
44
+    public function __construct() {
45
+
46
+        // Set parent defaults
47
+        parent::__construct(
48 48
             array(
49
-				'singular' => 'id',
50
-				'plural'   => 'ids',
51
-				'ajax'     => false,
49
+                'singular' => 'id',
50
+                'plural'   => 'ids',
51
+                'ajax'     => false,
52 52
             )
53 53
         );
54 54
 
55
-	}
56
-
57
-	/**
58
-	 * Gets the name of the primary column.
59
-	 *
60
-	 * @since 1.0.19
61
-	 * @access protected
62
-	 *
63
-	 * @return string Name of the primary column.
64
-	 */
65
-	protected function get_primary_column_name() {
66
-		return 'name';
67
-	}
68
-
69
-	/**
70
-	 * This function renders most of the columns in the list table.
71
-	 *
72
-	 * @since 1.0.19
73
-	 *
74
-	 * @param WP_User $item
75
-	 * @param string $column_name The name of the column
76
-	 *
77
-	 * @return string Column Name
78
-	 */
79
-	public function column_default( $item, $column_name ) {
80
-		$value = esc_html( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) );
81
-		return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item );
82
-	}
83
-
84
-	/**
85
-	 * Displays the country column.
86
-	 *
87
-	 * @since 1.0.19
88
-	 *
89
-	 * @param WP_User $user
90
-	 *
91
-	 * @return string Column Name
92
-	 */
93
-	public function column_country( $user ) {
94
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
95
-		if ( $country ) {
96
-			$country = wpinv_country_name( $country );
97
-		}
98
-		return esc_html( $country );
99
-	}
100
-
101
-	/**
102
-	 * Displays the state column.
103
-	 *
104
-	 * @since 1.0.19
105
-	 *
106
-	 * @param WP_User $user
107
-	 *
108
-	 * @return string Column Name
109
-	 */
110
-	public function column_state( $user ) {
111
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
112
-		$state   = $user->_wpinv_state;
113
-		if ( $state ) {
114
-			$state = wpinv_state_name( $state, $country );
115
-		}
116
-
117
-		return esc_html( $state );
118
-	}
119
-
120
-	/**
121
-	 * Displays the signup column.
122
-	 *
123
-	 * @since 1.0.19
124
-	 *
125
-	 * @param WP_User $user
126
-	 *
127
-	 * @return string Column Name
128
-	 */
129
-	public function column_signup( $user ) {
130
-		return getpaid_format_date_value( $user->user_registered );
131
-	}
132
-
133
-	/**
134
-	 * Displays the total spent column.
135
-	 *
136
-	 * @since 1.0.19
137
-	 *
138
-	 * @param WP_User $user
139
-	 *
140
-	 * @return string Column Name
141
-	 */
142
-	public function column_total( $user ) {
143
-		return wpinv_price( $this->column_total_raw( $user ) );
144
-	}
145
-
146
-	/**
147
-	 * Displays the total spent column.
148
-	 *
149
-	 * @since 1.0.19
150
-	 *
151
-	 * @param WP_User $user
152
-	 *
153
-	 * @return float
154
-	 */
155
-	public function column_total_raw( $user ) {
156
-		return getpaid_get_user_total_spend( $user->ID );
157
-	}
158
-
159
-	/**
160
-	 * Displays the total spent column.
161
-	 *
162
-	 * @since 1.0.19
163
-	 *
164
-	 * @param WP_User $user
165
-	 *
166
-	 * @return string Column Name
167
-	 */
168
-	public function column_invoices( $user ) {
169
-		$value = getpaid_count_user_invoices( $user->ID );
170
-		$url   = add_query_arg( array( 'post_type' => 'wpi_invoice', 'author' => $user->ID ), admin_url( 'edit.php' ) );
171
-		return empty( $value ) ? '0' : '<a href="' . esc_url( $url ) . '">' . absint( $value ) . '</a>';
172
-
173
-	}
174
-
175
-	/**
176
-	 * Generates content for a single row of the table
177
-	 * @since 1.0.19
178
-	 *
179
-	 * @param int $item The user id.
180
-	 */
181
-	public function single_row( $item ) {
182
-		$item = get_user_by( 'id', $item );
183
-
184
-		if ( empty( $item ) ) {
185
-			return;
186
-		}
187
-
188
-		echo '<tr>';
189
-		$this->single_row_columns( $item );
190
-		echo '</tr>';
191
-	}
192
-
193
-	/**
194
-	 * Displays the customers name
195
-	 *
196
-	 * @param  WP_User $customer customer.
197
-	 * @return string
198
-	 */
199
-	public function column_name( $customer ) {
200
-
201
-		// Customer view URL.
202
-		$view_url    = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) );
203
-		$row_actions = $this->row_actions(
204
-			array(
205
-				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>',
206
-			)
207
-		);
208
-
209
-		// Get user's address.
210
-		$address = wpinv_get_user_address( $customer->ID );
211
-
212
-		// Customer email address.
213
-		$email       = sanitize_email( $customer->user_email );
214
-
215
-		// Customer's avatar.
216
-		$avatar = esc_url( get_avatar_url( $email ) );
217
-		$avatar = "<img src='$avatar' height='32' width='32'/>";
218
-
219
-		// Customer's name.
220
-		$name   = esc_html( "{$address['first_name']} {$address['last_name']}" );
221
-
222
-		if ( empty( trim( $name ) ) ) {
223
-			$name = esc_html( $address['display_name'] );
224
-		}
225
-
226
-		if ( ! empty( $name ) ) {
227
-			$name = "<div style='overflow: hidden;height: 18px;'>$name</div>";
228
-		}
229
-
230
-		$email = "<div class='row-title'><a href='$view_url'>$email</a></div>";
231
-
232
-		return "<div style='display: flex;'><div>$avatar</div><div style='margin-left: 10px;'>$name<strong>$email</strong>$row_actions</div></div>";
233
-
234
-	}
235
-
236
-	/**
237
-	 * Retrieve the table columns
238
-	 *
239
-	 * @since 1.0.19
240
-	 * @return array $columns Array of all the list table columns
241
-	 */
242
-	public function get_columns() {
243
-
244
-		$columns = array(
245
-			'name'     => __( 'Name', 'invoicing' ),
246
-			'country'  => __( 'Country', 'invoicing' ),
247
-			'state'    => __( 'State', 'invoicing' ),
248
-			'city'     => __( 'City', 'invoicing' ),
249
-			'zip'      => __( 'ZIP', 'invoicing' ),
250
-			'address'  => __( 'Address', 'invoicing' ),
251
-			'phone'    => __( 'Phone', 'invoicing' ),
252
-			'company'  => __( 'Company', 'invoicing' ),
253
-			'invoices' => __( 'Invoices', 'invoicing' ),
254
-			'total'    => __( 'Total Spend', 'invoicing' ),
255
-			'signup'   => __( 'Date created', 'invoicing' ),
256
-		);
257
-		return apply_filters( 'wpinv_customers_table_columns', $columns );
258
-
259
-	}
260
-
261
-	/**
262
-	 * Retrieve the current page number
263
-	 *
264
-	 * @since 1.0.19
265
-	 * @return int Current page number
266
-	 */
267
-	public function get_paged() {
268
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
269
-	}
270
-
271
-	/**
272
-	 * Returns bulk actions.
273
-	 *
274
-	 * @since 1.0.19
275
-	 * @return void
276
-	 */
277
-	public function bulk_actions( $which = '' ) {
278
-		return array();
279
-	}
280
-
281
-	/**
282
-	 *  Prepares the display query
283
-	 */
284
-	public function prepare_query() {
285
-		global $wpdb;
286
-
287
-		$post_types = '';
288
-
289
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
290
-			$post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type );
291
-		}
292
-
293
-		$post_types = rtrim( $post_types, ' OR' );
294
-
295
-		// Maybe search.
296
-		if ( ! empty( $_POST['s'] ) ) {
297
-			$users = get_users(
298
-				array(
299
-					'search'         => '*' . sanitize_text_field( urldecode( $_POST['s'] ) ) . '*',
300
-					'search_columns' => array( 'user_login', 'user_email', 'display_name' ),
301
-					'fields'         => 'ID',
302
-				)
303
-			);
304
-
305
-			$users      = implode( ', ', $users );
306
-			$post_types = "($post_types) AND ( post_author IN ( $users ) )";
307
-		}
308
-
309
-		// Users with invoices.
310
-    	$customers = $wpdb->get_col(
311
-			$wpdb->prepare(
312
-				"SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types LIMIT %d,%d",
313
-				$this->get_paged() * 10 - 10,
314
-				$this->per_page
315
-			)
316
-		);
317
-
318
-		$this->items = $customers;
319
-		$this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" );
320
-
321
-	}
322
-
323
-	/**
324
-	 * Setup the final data for the table
325
-	 *
326
-	 * @since 1.0.19
327
-	 * @return void
328
-	 */
329
-	public function prepare_items() {
330
-		$columns               = $this->get_columns();
331
-		$hidden                = array(); // No hidden columns
332
-		$sortable              = $this->get_sortable_columns();
333
-		$this->_column_headers = array( $columns, $hidden, $sortable );
334
-		$this->prepare_query();
335
-
336
-		$this->set_pagination_args(
337
-			array(
338
-				'total_items' => $this->total,
339
-				'per_page'    => $this->per_page,
340
-				'total_pages' => ceil( $this->total / $this->per_page ),
341
-			)
342
-		);
343
-
344
-	}
55
+    }
56
+
57
+    /**
58
+     * Gets the name of the primary column.
59
+     *
60
+     * @since 1.0.19
61
+     * @access protected
62
+     *
63
+     * @return string Name of the primary column.
64
+     */
65
+    protected function get_primary_column_name() {
66
+        return 'name';
67
+    }
68
+
69
+    /**
70
+     * This function renders most of the columns in the list table.
71
+     *
72
+     * @since 1.0.19
73
+     *
74
+     * @param WP_User $item
75
+     * @param string $column_name The name of the column
76
+     *
77
+     * @return string Column Name
78
+     */
79
+    public function column_default( $item, $column_name ) {
80
+        $value = esc_html( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) );
81
+        return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item );
82
+    }
83
+
84
+    /**
85
+     * Displays the country column.
86
+     *
87
+     * @since 1.0.19
88
+     *
89
+     * @param WP_User $user
90
+     *
91
+     * @return string Column Name
92
+     */
93
+    public function column_country( $user ) {
94
+        $country = wpinv_sanitize_country( $user->_wpinv_country );
95
+        if ( $country ) {
96
+            $country = wpinv_country_name( $country );
97
+        }
98
+        return esc_html( $country );
99
+    }
100
+
101
+    /**
102
+     * Displays the state column.
103
+     *
104
+     * @since 1.0.19
105
+     *
106
+     * @param WP_User $user
107
+     *
108
+     * @return string Column Name
109
+     */
110
+    public function column_state( $user ) {
111
+        $country = wpinv_sanitize_country( $user->_wpinv_country );
112
+        $state   = $user->_wpinv_state;
113
+        if ( $state ) {
114
+            $state = wpinv_state_name( $state, $country );
115
+        }
116
+
117
+        return esc_html( $state );
118
+    }
119
+
120
+    /**
121
+     * Displays the signup column.
122
+     *
123
+     * @since 1.0.19
124
+     *
125
+     * @param WP_User $user
126
+     *
127
+     * @return string Column Name
128
+     */
129
+    public function column_signup( $user ) {
130
+        return getpaid_format_date_value( $user->user_registered );
131
+    }
132
+
133
+    /**
134
+     * Displays the total spent column.
135
+     *
136
+     * @since 1.0.19
137
+     *
138
+     * @param WP_User $user
139
+     *
140
+     * @return string Column Name
141
+     */
142
+    public function column_total( $user ) {
143
+        return wpinv_price( $this->column_total_raw( $user ) );
144
+    }
145
+
146
+    /**
147
+     * Displays the total spent column.
148
+     *
149
+     * @since 1.0.19
150
+     *
151
+     * @param WP_User $user
152
+     *
153
+     * @return float
154
+     */
155
+    public function column_total_raw( $user ) {
156
+        return getpaid_get_user_total_spend( $user->ID );
157
+    }
158
+
159
+    /**
160
+     * Displays the total spent column.
161
+     *
162
+     * @since 1.0.19
163
+     *
164
+     * @param WP_User $user
165
+     *
166
+     * @return string Column Name
167
+     */
168
+    public function column_invoices( $user ) {
169
+        $value = getpaid_count_user_invoices( $user->ID );
170
+        $url   = add_query_arg( array( 'post_type' => 'wpi_invoice', 'author' => $user->ID ), admin_url( 'edit.php' ) );
171
+        return empty( $value ) ? '0' : '<a href="' . esc_url( $url ) . '">' . absint( $value ) . '</a>';
172
+
173
+    }
174
+
175
+    /**
176
+     * Generates content for a single row of the table
177
+     * @since 1.0.19
178
+     *
179
+     * @param int $item The user id.
180
+     */
181
+    public function single_row( $item ) {
182
+        $item = get_user_by( 'id', $item );
183
+
184
+        if ( empty( $item ) ) {
185
+            return;
186
+        }
187
+
188
+        echo '<tr>';
189
+        $this->single_row_columns( $item );
190
+        echo '</tr>';
191
+    }
192
+
193
+    /**
194
+     * Displays the customers name
195
+     *
196
+     * @param  WP_User $customer customer.
197
+     * @return string
198
+     */
199
+    public function column_name( $customer ) {
200
+
201
+        // Customer view URL.
202
+        $view_url    = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) );
203
+        $row_actions = $this->row_actions(
204
+            array(
205
+                'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>',
206
+            )
207
+        );
208
+
209
+        // Get user's address.
210
+        $address = wpinv_get_user_address( $customer->ID );
211
+
212
+        // Customer email address.
213
+        $email       = sanitize_email( $customer->user_email );
214
+
215
+        // Customer's avatar.
216
+        $avatar = esc_url( get_avatar_url( $email ) );
217
+        $avatar = "<img src='$avatar' height='32' width='32'/>";
218
+
219
+        // Customer's name.
220
+        $name   = esc_html( "{$address['first_name']} {$address['last_name']}" );
221
+
222
+        if ( empty( trim( $name ) ) ) {
223
+            $name = esc_html( $address['display_name'] );
224
+        }
225
+
226
+        if ( ! empty( $name ) ) {
227
+            $name = "<div style='overflow: hidden;height: 18px;'>$name</div>";
228
+        }
229
+
230
+        $email = "<div class='row-title'><a href='$view_url'>$email</a></div>";
231
+
232
+        return "<div style='display: flex;'><div>$avatar</div><div style='margin-left: 10px;'>$name<strong>$email</strong>$row_actions</div></div>";
233
+
234
+    }
235
+
236
+    /**
237
+     * Retrieve the table columns
238
+     *
239
+     * @since 1.0.19
240
+     * @return array $columns Array of all the list table columns
241
+     */
242
+    public function get_columns() {
243
+
244
+        $columns = array(
245
+            'name'     => __( 'Name', 'invoicing' ),
246
+            'country'  => __( 'Country', 'invoicing' ),
247
+            'state'    => __( 'State', 'invoicing' ),
248
+            'city'     => __( 'City', 'invoicing' ),
249
+            'zip'      => __( 'ZIP', 'invoicing' ),
250
+            'address'  => __( 'Address', 'invoicing' ),
251
+            'phone'    => __( 'Phone', 'invoicing' ),
252
+            'company'  => __( 'Company', 'invoicing' ),
253
+            'invoices' => __( 'Invoices', 'invoicing' ),
254
+            'total'    => __( 'Total Spend', 'invoicing' ),
255
+            'signup'   => __( 'Date created', 'invoicing' ),
256
+        );
257
+        return apply_filters( 'wpinv_customers_table_columns', $columns );
258
+
259
+    }
260
+
261
+    /**
262
+     * Retrieve the current page number
263
+     *
264
+     * @since 1.0.19
265
+     * @return int Current page number
266
+     */
267
+    public function get_paged() {
268
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
269
+    }
270
+
271
+    /**
272
+     * Returns bulk actions.
273
+     *
274
+     * @since 1.0.19
275
+     * @return void
276
+     */
277
+    public function bulk_actions( $which = '' ) {
278
+        return array();
279
+    }
280
+
281
+    /**
282
+     *  Prepares the display query
283
+     */
284
+    public function prepare_query() {
285
+        global $wpdb;
286
+
287
+        $post_types = '';
288
+
289
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
290
+            $post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type );
291
+        }
292
+
293
+        $post_types = rtrim( $post_types, ' OR' );
294
+
295
+        // Maybe search.
296
+        if ( ! empty( $_POST['s'] ) ) {
297
+            $users = get_users(
298
+                array(
299
+                    'search'         => '*' . sanitize_text_field( urldecode( $_POST['s'] ) ) . '*',
300
+                    'search_columns' => array( 'user_login', 'user_email', 'display_name' ),
301
+                    'fields'         => 'ID',
302
+                )
303
+            );
304
+
305
+            $users      = implode( ', ', $users );
306
+            $post_types = "($post_types) AND ( post_author IN ( $users ) )";
307
+        }
308
+
309
+        // Users with invoices.
310
+        $customers = $wpdb->get_col(
311
+            $wpdb->prepare(
312
+                "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types LIMIT %d,%d",
313
+                $this->get_paged() * 10 - 10,
314
+                $this->per_page
315
+            )
316
+        );
317
+
318
+        $this->items = $customers;
319
+        $this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" );
320
+
321
+    }
322
+
323
+    /**
324
+     * Setup the final data for the table
325
+     *
326
+     * @since 1.0.19
327
+     * @return void
328
+     */
329
+    public function prepare_items() {
330
+        $columns               = $this->get_columns();
331
+        $hidden                = array(); // No hidden columns
332
+        $sortable              = $this->get_sortable_columns();
333
+        $this->_column_headers = array( $columns, $hidden, $sortable );
334
+        $this->prepare_query();
335
+
336
+        $this->set_pagination_args(
337
+            array(
338
+                'total_items' => $this->total,
339
+                'per_page'    => $this->per_page,
340
+                'total_pages' => ceil( $this->total / $this->per_page ),
341
+            )
342
+        );
343
+
344
+    }
345 345
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 // Exit if accessed directly
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if (!defined('ABSPATH')) {
9 9
 exit;
10 10
 }
11 11
 
12 12
 // Load WP_List_Table if not loaded
13
-if ( ! class_exists( 'WP_List_Table' ) ) {
13
+if (!class_exists('WP_List_Table')) {
14 14
 	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
15 15
 }
16 16
 
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @return string Column Name
78 78
 	 */
79
-	public function column_default( $item, $column_name ) {
80
-		$value = esc_html( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) );
81
-		return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item );
79
+	public function column_default($item, $column_name) {
80
+		$value = esc_html(get_user_meta($item->ID, '_wpinv_' . $column_name, true));
81
+		return apply_filters('wpinv_customers_table_column' . $column_name, $value, $item);
82 82
 	}
83 83
 
84 84
 	/**
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return string Column Name
92 92
 	 */
93
-	public function column_country( $user ) {
94
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
95
-		if ( $country ) {
96
-			$country = wpinv_country_name( $country );
93
+	public function column_country($user) {
94
+		$country = wpinv_sanitize_country($user->_wpinv_country);
95
+		if ($country) {
96
+			$country = wpinv_country_name($country);
97 97
 		}
98
-		return esc_html( $country );
98
+		return esc_html($country);
99 99
 	}
100 100
 
101 101
 	/**
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @return string Column Name
109 109
 	 */
110
-	public function column_state( $user ) {
111
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
110
+	public function column_state($user) {
111
+		$country = wpinv_sanitize_country($user->_wpinv_country);
112 112
 		$state   = $user->_wpinv_state;
113
-		if ( $state ) {
114
-			$state = wpinv_state_name( $state, $country );
113
+		if ($state) {
114
+			$state = wpinv_state_name($state, $country);
115 115
 		}
116 116
 
117
-		return esc_html( $state );
117
+		return esc_html($state);
118 118
 	}
119 119
 
120 120
 	/**
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @return string Column Name
128 128
 	 */
129
-	public function column_signup( $user ) {
130
-		return getpaid_format_date_value( $user->user_registered );
129
+	public function column_signup($user) {
130
+		return getpaid_format_date_value($user->user_registered);
131 131
 	}
132 132
 
133 133
 	/**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 *
140 140
 	 * @return string Column Name
141 141
 	 */
142
-	public function column_total( $user ) {
143
-		return wpinv_price( $this->column_total_raw( $user ) );
142
+	public function column_total($user) {
143
+		return wpinv_price($this->column_total_raw($user));
144 144
 	}
145 145
 
146 146
 	/**
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @return float
154 154
 	 */
155
-	public function column_total_raw( $user ) {
156
-		return getpaid_get_user_total_spend( $user->ID );
155
+	public function column_total_raw($user) {
156
+		return getpaid_get_user_total_spend($user->ID);
157 157
 	}
158 158
 
159 159
 	/**
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 	 *
166 166
 	 * @return string Column Name
167 167
 	 */
168
-	public function column_invoices( $user ) {
169
-		$value = getpaid_count_user_invoices( $user->ID );
170
-		$url   = add_query_arg( array( 'post_type' => 'wpi_invoice', 'author' => $user->ID ), admin_url( 'edit.php' ) );
171
-		return empty( $value ) ? '0' : '<a href="' . esc_url( $url ) . '">' . absint( $value ) . '</a>';
168
+	public function column_invoices($user) {
169
+		$value = getpaid_count_user_invoices($user->ID);
170
+		$url   = add_query_arg(array('post_type' => 'wpi_invoice', 'author' => $user->ID), admin_url('edit.php'));
171
+		return empty($value) ? '0' : '<a href="' . esc_url($url) . '">' . absint($value) . '</a>';
172 172
 
173 173
 	}
174 174
 
@@ -178,15 +178,15 @@  discard block
 block discarded – undo
178 178
 	 *
179 179
 	 * @param int $item The user id.
180 180
 	 */
181
-	public function single_row( $item ) {
182
-		$item = get_user_by( 'id', $item );
181
+	public function single_row($item) {
182
+		$item = get_user_by('id', $item);
183 183
 
184
-		if ( empty( $item ) ) {
184
+		if (empty($item)) {
185 185
 			return;
186 186
 		}
187 187
 
188 188
 		echo '<tr>';
189
-		$this->single_row_columns( $item );
189
+		$this->single_row_columns($item);
190 190
 		echo '</tr>';
191 191
 	}
192 192
 
@@ -196,34 +196,34 @@  discard block
 block discarded – undo
196 196
 	 * @param  WP_User $customer customer.
197 197
 	 * @return string
198 198
 	 */
199
-	public function column_name( $customer ) {
199
+	public function column_name($customer) {
200 200
 
201 201
 		// Customer view URL.
202
-		$view_url    = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) );
202
+		$view_url    = esc_url(add_query_arg('user_id', $customer->ID, admin_url('user-edit.php')));
203 203
 		$row_actions = $this->row_actions(
204 204
 			array(
205
-				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>',
205
+				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __('Edit Details', 'invoicing') . '</a>',
206 206
 			)
207 207
 		);
208 208
 
209 209
 		// Get user's address.
210
-		$address = wpinv_get_user_address( $customer->ID );
210
+		$address = wpinv_get_user_address($customer->ID);
211 211
 
212 212
 		// Customer email address.
213
-		$email       = sanitize_email( $customer->user_email );
213
+		$email = sanitize_email($customer->user_email);
214 214
 
215 215
 		// Customer's avatar.
216
-		$avatar = esc_url( get_avatar_url( $email ) );
216
+		$avatar = esc_url(get_avatar_url($email));
217 217
 		$avatar = "<img src='$avatar' height='32' width='32'/>";
218 218
 
219 219
 		// Customer's name.
220
-		$name   = esc_html( "{$address['first_name']} {$address['last_name']}" );
220
+		$name   = esc_html("{$address['first_name']} {$address['last_name']}");
221 221
 
222
-		if ( empty( trim( $name ) ) ) {
223
-			$name = esc_html( $address['display_name'] );
222
+		if (empty(trim($name))) {
223
+			$name = esc_html($address['display_name']);
224 224
 		}
225 225
 
226
-		if ( ! empty( $name ) ) {
226
+		if (!empty($name)) {
227 227
 			$name = "<div style='overflow: hidden;height: 18px;'>$name</div>";
228 228
 		}
229 229
 
@@ -242,19 +242,19 @@  discard block
 block discarded – undo
242 242
 	public function get_columns() {
243 243
 
244 244
 		$columns = array(
245
-			'name'     => __( 'Name', 'invoicing' ),
246
-			'country'  => __( 'Country', 'invoicing' ),
247
-			'state'    => __( 'State', 'invoicing' ),
248
-			'city'     => __( 'City', 'invoicing' ),
249
-			'zip'      => __( 'ZIP', 'invoicing' ),
250
-			'address'  => __( 'Address', 'invoicing' ),
251
-			'phone'    => __( 'Phone', 'invoicing' ),
252
-			'company'  => __( 'Company', 'invoicing' ),
253
-			'invoices' => __( 'Invoices', 'invoicing' ),
254
-			'total'    => __( 'Total Spend', 'invoicing' ),
255
-			'signup'   => __( 'Date created', 'invoicing' ),
245
+			'name'     => __('Name', 'invoicing'),
246
+			'country'  => __('Country', 'invoicing'),
247
+			'state'    => __('State', 'invoicing'),
248
+			'city'     => __('City', 'invoicing'),
249
+			'zip'      => __('ZIP', 'invoicing'),
250
+			'address'  => __('Address', 'invoicing'),
251
+			'phone'    => __('Phone', 'invoicing'),
252
+			'company'  => __('Company', 'invoicing'),
253
+			'invoices' => __('Invoices', 'invoicing'),
254
+			'total'    => __('Total Spend', 'invoicing'),
255
+			'signup'   => __('Date created', 'invoicing'),
256 256
 		);
257
-		return apply_filters( 'wpinv_customers_table_columns', $columns );
257
+		return apply_filters('wpinv_customers_table_columns', $columns);
258 258
 
259 259
 	}
260 260
 
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 	 * @return int Current page number
266 266
 	 */
267 267
 	public function get_paged() {
268
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
268
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
269 269
 	}
270 270
 
271 271
 	/**
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	 * @since 1.0.19
275 275
 	 * @return void
276 276
 	 */
277
-	public function bulk_actions( $which = '' ) {
277
+	public function bulk_actions($which = '') {
278 278
 		return array();
279 279
 	}
280 280
 
@@ -286,23 +286,23 @@  discard block
 block discarded – undo
286 286
 
287 287
 		$post_types = '';
288 288
 
289
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
290
-			$post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type );
289
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
290
+			$post_types .= $wpdb->prepare('post_type=%s OR ', $post_type);
291 291
 		}
292 292
 
293
-		$post_types = rtrim( $post_types, ' OR' );
293
+		$post_types = rtrim($post_types, ' OR');
294 294
 
295 295
 		// Maybe search.
296
-		if ( ! empty( $_POST['s'] ) ) {
296
+		if (!empty($_POST['s'])) {
297 297
 			$users = get_users(
298 298
 				array(
299
-					'search'         => '*' . sanitize_text_field( urldecode( $_POST['s'] ) ) . '*',
300
-					'search_columns' => array( 'user_login', 'user_email', 'display_name' ),
299
+					'search'         => '*' . sanitize_text_field(urldecode($_POST['s'])) . '*',
300
+					'search_columns' => array('user_login', 'user_email', 'display_name'),
301 301
 					'fields'         => 'ID',
302 302
 				)
303 303
 			);
304 304
 
305
-			$users      = implode( ', ', $users );
305
+			$users      = implode(', ', $users);
306 306
 			$post_types = "($post_types) AND ( post_author IN ( $users ) )";
307 307
 		}
308 308
 
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 		);
317 317
 
318 318
 		$this->items = $customers;
319
-		$this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" );
319
+		$this->total = (int) $wpdb->get_var("SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types");
320 320
 
321 321
 	}
322 322
 
@@ -330,14 +330,14 @@  discard block
 block discarded – undo
330 330
 		$columns               = $this->get_columns();
331 331
 		$hidden                = array(); // No hidden columns
332 332
 		$sortable              = $this->get_sortable_columns();
333
-		$this->_column_headers = array( $columns, $hidden, $sortable );
333
+		$this->_column_headers = array($columns, $hidden, $sortable);
334 334
 		$this->prepare_query();
335 335
 
336 336
 		$this->set_pagination_args(
337 337
 			array(
338 338
 				'total_items' => $this->total,
339 339
 				'per_page'    => $this->per_page,
340
-				'total_pages' => ceil( $this->total / $this->per_page ),
340
+				'total_pages' => ceil($this->total / $this->per_page),
341 341
 			)
342 342
 		);
343 343
 
Please login to merge, or discard this patch.
includes/class-getpaid-customer.php 2 patches
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -15,67 +15,67 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class GetPaid_Customer extends GetPaid_Data {
17 17
 
18
-	/**
19
-	 * Which data store to load.
20
-	 *
21
-	 * @var string
22
-	 */
18
+    /**
19
+     * Which data store to load.
20
+     *
21
+     * @var string
22
+     */
23 23
     protected $data_store_name = 'customer';
24 24
 
25 25
     /**
26
-	 * This is the name of this object type.
27
-	 *
28
-	 * @var string
29
-	 */
30
-	protected $object_type = 'customer';
31
-
32
-	/**
33
-	 * Get the customer if ID is passed, otherwise the customer is new and empty.
34
-	 *
35
-	 * @param int|string|GetPaid_Customer $customer customer id, object, or email.
36
-	 */
37
-	public function __construct( $customer = 0 ) {
26
+     * This is the name of this object type.
27
+     *
28
+     * @var string
29
+     */
30
+    protected $object_type = 'customer';
31
+
32
+    /**
33
+     * Get the customer if ID is passed, otherwise the customer is new and empty.
34
+     *
35
+     * @param int|string|GetPaid_Customer $customer customer id, object, or email.
36
+     */
37
+    public function __construct( $customer = 0 ) {
38 38
 
39 39
         // Setup default customer data.
40 40
         $this->setup_default_data();
41 41
 
42
-		if ( is_numeric( $customer ) ) {
43
-			$this->set_id( $customer );
44
-		} elseif ( $customer instanceof self ) {
45
-			$this->set_id( $customer->get_id() );
46
-		} elseif ( is_string( $customer ) && $customer_id = self::get_customer_id_by( $customer, 'email' ) ) {
47
-			$this->set_id( $customer_id );
48
-		}
42
+        if ( is_numeric( $customer ) ) {
43
+            $this->set_id( $customer );
44
+        } elseif ( $customer instanceof self ) {
45
+            $this->set_id( $customer->get_id() );
46
+        } elseif ( is_string( $customer ) && $customer_id = self::get_customer_id_by( $customer, 'email' ) ) {
47
+            $this->set_id( $customer_id );
48
+        }
49 49
 
50 50
         // Load the datastore.
51
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
51
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
52 52
 
53
-		if ( $this->get_id() > 0 ) {
54
-			$this->data_store->read( $this );
53
+        if ( $this->get_id() > 0 ) {
54
+            $this->data_store->read( $this );
55 55
         }
56 56
 
57 57
         $this->set_object_read( true );
58
-	}
58
+    }
59 59
 
60 60
     /**
61
-	 * Sets up default customer data.
62
-	 */
63
-	private function setup_default_data() {
61
+     * Sets up default customer data.
62
+     */
63
+    private function setup_default_data() {
64 64
 
65 65
         $this->data = array(
66
-			'user_id'        => 0,
67
-			'email'          => '',
68
-			'email_cc'       => '',
69
-			'status'         => 'active',
70
-			'purchase_value' => 0,
71
-			'purchase_count' => 0,
72
-			'date_created'   => current_time( 'mysql' ),
73
-			'date_modified'  => current_time( 'mysql' ),
74
-			'uuid'           => wp_generate_uuid4(),
75
-		);
66
+            'user_id'        => 0,
67
+            'email'          => '',
68
+            'email_cc'       => '',
69
+            'status'         => 'active',
70
+            'purchase_value' => 0,
71
+            'purchase_count' => 0,
72
+            'date_created'   => current_time( 'mysql' ),
73
+            'date_modified'  => current_time( 'mysql' ),
74
+            'uuid'           => wp_generate_uuid4(),
75
+        );
76 76
 
77 77
         // Add address fields.
78
-		foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
78
+        foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
79 79
 
80 80
             if ( isset( $this->data[ $field ] ) ) {
81 81
                 continue;
@@ -93,22 +93,22 @@  discard block
 block discarded – undo
93 93
                 continue;
94 94
             }
95 95
 
96
-			$this->data[ $field ] = '';
97
-		}
96
+            $this->data[ $field ] = '';
97
+        }
98 98
 
99 99
         $this->default_data = $this->data;
100
-	}
101
-
102
-	/**
103
-	 * Given a customer email or user id, it returns a customer id.
104
-	 *
105
-	 * @static
106
-	 * @param string $value
107
-	 * @since 1.0.15
108
-	 * @return int
109
-	 */
110
-	public static function get_customer_id_by( $value, $by = 'email' ) {
111
-		global $wpdb;
100
+    }
101
+
102
+    /**
103
+     * Given a customer email or user id, it returns a customer id.
104
+     *
105
+     * @static
106
+     * @param string $value
107
+     * @since 1.0.15
108
+     * @return int
109
+     */
110
+    public static function get_customer_id_by( $value, $by = 'email' ) {
111
+        global $wpdb;
112 112
 
113 113
         // Prepare value.
114 114
         if ( 'email' === $by ) {
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
             return 0;
124 124
         }
125 125
 
126
-		// Maybe retrieve from the cache.
126
+        // Maybe retrieve from the cache.
127 127
         $cache_key   = 'getpaid_customer_ids_by_' . $by;
128
-		$customer_id = wp_cache_get( $value, $cache_key );
129
-		if ( false !== $customer_id ) {
130
-			return $customer_id;
131
-		}
128
+        $customer_id = wp_cache_get( $value, $cache_key );
129
+        if ( false !== $customer_id ) {
130
+            return $customer_id;
131
+        }
132 132
 
133 133
         if ( 'email' === $by ) {
134 134
             $customer_id = (int) $wpdb->get_var(
@@ -140,23 +140,23 @@  discard block
 block discarded – undo
140 140
             );
141 141
         }
142 142
 
143
-		// Update the cache with our data
144
-		wp_cache_set( $value, $customer_id, $cache_key );
143
+        // Update the cache with our data
144
+        wp_cache_set( $value, $customer_id, $cache_key );
145 145
 
146
-		return $customer_id;
146
+        return $customer_id;
147 147
 
148
-	}
148
+    }
149 149
 
150
-	/**
150
+    /**
151 151
      * Clears the customer's cache.
152 152
      */
153 153
     public function clear_cache() {
154 154
         wp_cache_delete( $this->get( 'email' ), 'getpaid_customer_ids_by_email' );
155 155
         wp_cache_delete( $this->get( 'user_id' ), 'getpaid_customer_ids_by_user_id' );
156
-		wp_cache_delete( $this->get_id(), 'getpaid_customers' );
157
-	}
156
+        wp_cache_delete( $this->get_id(), 'getpaid_customers' );
157
+    }
158 158
 
159
-	/*
159
+    /*
160 160
 	|--------------------------------------------------------------------------
161 161
 	| CRUD methods
162 162
 	|--------------------------------------------------------------------------
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
             return call_user_func( array( $this, 'get_' . $key ), $context );
188 188
         }
189 189
 
190
-		return $this->get_prop( $key, $context );
190
+        return $this->get_prop( $key, $context );
191 191
 
192 192
     }
193 193
 
194
-	/*
194
+    /*
195 195
 	|--------------------------------------------------------------------------
196 196
 	| Setters
197 197
 	|--------------------------------------------------------------------------
@@ -214,114 +214,114 @@  discard block
 block discarded – undo
214 214
             return call_user_func( array( $this, 'set_' . $key ), $value );
215 215
         }
216 216
 
217
-		return $this->set_prop( $key, $value );
217
+        return $this->set_prop( $key, $value );
218 218
 
219 219
     }
220 220
 
221
-	/**
222
-	 * Sets customer status.
223
-	 *
224
-	 * @since 1.0.0
225
-	 * @param  string $status New status.
226
-	 */
227
-	public function set_status( $status ) {
228
-
229
-		if ( in_array( $status, array( 'active', 'inactive', 'blocked' ), true ) ) {
230
-			return $this->set_prop( 'status', $status );
231
-		}
232
-
233
-		$this->set_prop( 'status', 'inactive' );
234
-	}
235
-
236
-	/**
237
-	 * Sets the purchase value.
238
-	 *
239
-	 * @since 1.0.0
240
-	 * @param float $purchase_value.
241
-	 */
242
-	public function set_purchase_value( $purchase_value ) {
243
-		$this->set_prop( 'purchase_value', (float) $purchase_value );
244
-	}
221
+    /**
222
+     * Sets customer status.
223
+     *
224
+     * @since 1.0.0
225
+     * @param  string $status New status.
226
+     */
227
+    public function set_status( $status ) {
228
+
229
+        if ( in_array( $status, array( 'active', 'inactive', 'blocked' ), true ) ) {
230
+            return $this->set_prop( 'status', $status );
231
+        }
232
+
233
+        $this->set_prop( 'status', 'inactive' );
234
+    }
235
+
236
+    /**
237
+     * Sets the purchase value.
238
+     *
239
+     * @since 1.0.0
240
+     * @param float $purchase_value.
241
+     */
242
+    public function set_purchase_value( $purchase_value ) {
243
+        $this->set_prop( 'purchase_value', (float) $purchase_value );
244
+    }
245 245
 
246 246
     /**
247
-	 * Sets the purchase count.
248
-	 *
249
-	 * @since 1.0.0
250
-	 * @param int $purchase_count.
251
-	 */
252
-	public function set_purchase_count( $purchase_count ) {
253
-		$this->set_prop( 'purchase_count', absint( $purchase_count ) );
254
-	}
247
+     * Sets the purchase count.
248
+     *
249
+     * @since 1.0.0
250
+     * @param int $purchase_count.
251
+     */
252
+    public function set_purchase_count( $purchase_count ) {
253
+        $this->set_prop( 'purchase_count', absint( $purchase_count ) );
254
+    }
255 255
 
256 256
     /**
257
-	 * Sets the user id.
258
-	 *
259
-	 * @since 1.0.0
260
-	 * @param int $user_id.
261
-	 */
262
-	public function set_user_id( $user_id ) {
263
-		$this->set_prop( 'user_id', absint( $user_id ) );
264
-	}
257
+     * Sets the user id.
258
+     *
259
+     * @since 1.0.0
260
+     * @param int $user_id.
261
+     */
262
+    public function set_user_id( $user_id ) {
263
+        $this->set_prop( 'user_id', absint( $user_id ) );
264
+    }
265 265
 
266 266
     /**
267
-	 * Sets the email.
268
-	 *
269
-	 * @since 1.0.0
270
-	 * @param string $email.
271
-	 */
272
-	public function set_email( $email ) {
267
+     * Sets the email.
268
+     *
269
+     * @since 1.0.0
270
+     * @param string $email.
271
+     */
272
+    public function set_email( $email ) {
273 273
         $email = is_string( $email ) ? sanitize_email( $email ) : '';
274
-		$this->set_prop( 'email', $email );
275
-	}
274
+        $this->set_prop( 'email', $email );
275
+    }
276 276
 
277 277
     /**
278
-	 * Sets the email cc.
279
-	 *
280
-	 * @since 1.0.0
281
-	 * @param string $email_cc.
282
-	 */
283
-	public function set_email_cc( $email_cc ) {
278
+     * Sets the email cc.
279
+     *
280
+     * @since 1.0.0
281
+     * @param string $email_cc.
282
+     */
283
+    public function set_email_cc( $email_cc ) {
284 284
         $email_cc = implode( ', ', wp_parse_list( $email_cc ) );
285
-		$this->set_prop( 'email_cc', $email_cc );
286
-	}
285
+        $this->set_prop( 'email_cc', $email_cc );
286
+    }
287 287
 
288 288
     /**
289
-	 * Sets the created date.
290
-	 *
291
-	 * @since 1.0.0
292
-	 * @param  string $date_created date created.
293
-	 */
294
-	public function set_date_created( $date_created ) {
289
+     * Sets the created date.
290
+     *
291
+     * @since 1.0.0
292
+     * @param  string $date_created date created.
293
+     */
294
+    public function set_date_created( $date_created ) {
295 295
 
296
-		$date = strtotime( $date_created );
296
+        $date = strtotime( $date_created );
297 297
 
298 298
         if ( $date && $date_created !== '0000-00-00 00:00:00'  && $date_created !== '0000-00-00 00:00' ) {
299 299
             $this->set_prop( 'date_created', gmdate( 'Y-m-d H:i:s', $date ) );
300 300
             return;
301
-		}
301
+        }
302 302
 
303
-		$this->set_prop( 'date_created', null );
304
-	}
303
+        $this->set_prop( 'date_created', null );
304
+    }
305 305
 
306 306
     /**
307
-	 * Sets the created date.
308
-	 *
309
-	 * @since 1.0.0
310
-	 * @param  string $date_modified date created.
311
-	 */
312
-	public function set_date_modified( $date_modified ) {
307
+     * Sets the created date.
308
+     *
309
+     * @since 1.0.0
310
+     * @param  string $date_modified date created.
311
+     */
312
+    public function set_date_modified( $date_modified ) {
313 313
 
314
-		$date = strtotime( $date_modified );
314
+        $date = strtotime( $date_modified );
315 315
 
316 316
         if ( $date && $date_modified !== '0000-00-00 00:00:00'  && $date_modified !== '0000-00-00 00:00' ) {
317 317
             $this->set_prop( 'date_modified', gmdate( 'Y-m-d H:i:s', $date ) );
318 318
             return;
319
-		}
319
+        }
320 320
 
321
-		$this->set_prop( 'date_modified', null );
322
-	}
321
+        $this->set_prop( 'date_modified', null );
322
+    }
323 323
 
324
-	/*
324
+    /*
325 325
 	|--------------------------------------------------------------------------
326 326
 	| Additional methods
327 327
 	|--------------------------------------------------------------------------
@@ -330,12 +330,12 @@  discard block
 block discarded – undo
330 330
 	|
331 331
 	*/
332 332
 
333
-	/**
334
-	 * Saves the customer.
335
-	 *
336
-	 * @since 1.0.0
337
-	 */
338
-	public function save() {
333
+    /**
334
+     * Saves the customer.
335
+     *
336
+     * @since 1.0.0
337
+     */
338
+    public function save() {
339 339
 
340 340
         $maybe_set = array(
341 341
             'uuid'         => wp_generate_uuid4(),
@@ -352,23 +352,23 @@  discard block
 block discarded – undo
352 352
 
353 353
         $this->set( 'date_modified', current_time( 'mysql' ) );
354 354
 
355
-		return parent::save();
356
-	}
355
+        return parent::save();
356
+    }
357 357
 
358 358
     /**
359
-	 * Helper method to clone a customer from a user ID.
360
-	 *
361
-	 * @since 1.0.0
362
-	 * @param int $user_id.
363
-	 */
364
-	public function clone_user( $user_id ) {
359
+     * Helper method to clone a customer from a user ID.
360
+     *
361
+     * @since 1.0.0
362
+     * @param int $user_id.
363
+     */
364
+    public function clone_user( $user_id ) {
365 365
         $user = get_userdata( $user_id );
366 366
 
367 367
         if ( empty( $user ) ) {
368 368
             return;
369 369
         }
370 370
 
371
-		$this->set_user_id( $user->ID );
371
+        $this->set_user_id( $user->ID );
372 372
         $this->set_email( $user->user_email );
373 373
         $this->set_purchase_value( getpaid_get_user_total_spend( $user->ID ) );
374 374
         $this->set_purchase_count( getpaid_count_user_invoices( $user->ID ) );
@@ -397,18 +397,18 @@  discard block
 block discarded – undo
397 397
                     continue;
398 398
                 }
399 399
             }
400
-		}
401
-	}
400
+        }
401
+    }
402 402
 
403 403
     /**
404
-	 * Helper method to migrate an existing user ID to the new customers table.
405
-	 *
406
-	 * @since 1.0.0
407
-	 * @param int $user_id.
408
-	 */
409
-	public function migrate_from_user( $user_id ) {
404
+     * Helper method to migrate an existing user ID to the new customers table.
405
+     *
406
+     * @since 1.0.0
407
+     * @param int $user_id.
408
+     */
409
+    public function migrate_from_user( $user_id ) {
410 410
         $this->clone_user( $user_id );
411 411
         do_action( 'getpaid_customer_migrated_from_user', $this, $user_id );
412 412
         $this->save();
413
-	}
413
+    }
414 414
 }
Please login to merge, or discard this patch.
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @since   1.0.15
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * Customer class.
@@ -34,27 +34,27 @@  discard block
 block discarded – undo
34 34
 	 *
35 35
 	 * @param int|string|GetPaid_Customer $customer customer id, object, or email.
36 36
 	 */
37
-	public function __construct( $customer = 0 ) {
37
+	public function __construct($customer = 0) {
38 38
 
39 39
         // Setup default customer data.
40 40
         $this->setup_default_data();
41 41
 
42
-		if ( is_numeric( $customer ) ) {
43
-			$this->set_id( $customer );
44
-		} elseif ( $customer instanceof self ) {
45
-			$this->set_id( $customer->get_id() );
46
-		} elseif ( is_string( $customer ) && $customer_id = self::get_customer_id_by( $customer, 'email' ) ) {
47
-			$this->set_id( $customer_id );
42
+		if (is_numeric($customer)) {
43
+			$this->set_id($customer);
44
+		} elseif ($customer instanceof self) {
45
+			$this->set_id($customer->get_id());
46
+		} elseif (is_string($customer) && $customer_id = self::get_customer_id_by($customer, 'email')) {
47
+			$this->set_id($customer_id);
48 48
 		}
49 49
 
50 50
         // Load the datastore.
51
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
51
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
52 52
 
53
-		if ( $this->get_id() > 0 ) {
54
-			$this->data_store->read( $this );
53
+		if ($this->get_id() > 0) {
54
+			$this->data_store->read($this);
55 55
         }
56 56
 
57
-        $this->set_object_read( true );
57
+        $this->set_object_read(true);
58 58
 	}
59 59
 
60 60
     /**
@@ -69,31 +69,31 @@  discard block
 block discarded – undo
69 69
 			'status'         => 'active',
70 70
 			'purchase_value' => 0,
71 71
 			'purchase_count' => 0,
72
-			'date_created'   => current_time( 'mysql' ),
73
-			'date_modified'  => current_time( 'mysql' ),
72
+			'date_created'   => current_time('mysql'),
73
+			'date_modified'  => current_time('mysql'),
74 74
 			'uuid'           => wp_generate_uuid4(),
75 75
 		);
76 76
 
77 77
         // Add address fields.
78
-		foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
78
+		foreach (array_keys(getpaid_user_address_fields()) as $field) {
79 79
 
80
-            if ( isset( $this->data[ $field ] ) ) {
80
+            if (isset($this->data[$field])) {
81 81
                 continue;
82 82
             }
83 83
 
84 84
             // Country.
85
-            if ( 'country' === $field ) {
86
-                $this->data[ $field ] = wpinv_get_default_country();
85
+            if ('country' === $field) {
86
+                $this->data[$field] = wpinv_get_default_country();
87 87
                 continue;
88 88
             }
89 89
 
90 90
             // State.
91
-            if ( 'state' === $field ) {
92
-                $this->data[ $field ] = wpinv_get_default_state();
91
+            if ('state' === $field) {
92
+                $this->data[$field] = wpinv_get_default_state();
93 93
                 continue;
94 94
             }
95 95
 
96
-			$this->data[ $field ] = '';
96
+			$this->data[$field] = '';
97 97
 		}
98 98
 
99 99
         $this->default_data = $this->data;
@@ -107,41 +107,41 @@  discard block
 block discarded – undo
107 107
 	 * @since 1.0.15
108 108
 	 * @return int
109 109
 	 */
110
-	public static function get_customer_id_by( $value, $by = 'email' ) {
110
+	public static function get_customer_id_by($value, $by = 'email') {
111 111
 		global $wpdb;
112 112
 
113 113
         // Prepare value.
114
-        if ( 'email' === $by ) {
115
-            $value = sanitize_email( $value );
116
-        } elseif ( 'user_id' === $by ) {
117
-            $value = absint( $value );
114
+        if ('email' === $by) {
115
+            $value = sanitize_email($value);
116
+        } elseif ('user_id' === $by) {
117
+            $value = absint($value);
118 118
         } else {
119 119
             return 0;
120 120
         }
121 121
 
122
-        if ( empty( $value ) ) {
122
+        if (empty($value)) {
123 123
             return 0;
124 124
         }
125 125
 
126 126
 		// Maybe retrieve from the cache.
127
-        $cache_key   = 'getpaid_customer_ids_by_' . $by;
128
-		$customer_id = wp_cache_get( $value, $cache_key );
129
-		if ( false !== $customer_id ) {
127
+        $cache_key = 'getpaid_customer_ids_by_' . $by;
128
+		$customer_id = wp_cache_get($value, $cache_key);
129
+		if (false !== $customer_id) {
130 130
 			return $customer_id;
131 131
 		}
132 132
 
133
-        if ( 'email' === $by ) {
133
+        if ('email' === $by) {
134 134
             $customer_id = (int) $wpdb->get_var(
135
-                $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}getpaid_customers WHERE email=%s LIMIT 1", $value )
135
+                $wpdb->prepare("SELECT id FROM {$wpdb->prefix}getpaid_customers WHERE email=%s LIMIT 1", $value)
136 136
             );
137
-        } elseif ( 'user_id' === $by ) {
137
+        } elseif ('user_id' === $by) {
138 138
             $customer_id = (int) $wpdb->get_var(
139
-                $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}getpaid_customers WHERE user_id=%d LIMIT 1", $value )
139
+                $wpdb->prepare("SELECT id FROM {$wpdb->prefix}getpaid_customers WHERE user_id=%d LIMIT 1", $value)
140 140
             );
141 141
         }
142 142
 
143 143
 		// Update the cache with our data
144
-		wp_cache_set( $value, $customer_id, $cache_key );
144
+		wp_cache_set($value, $customer_id, $cache_key);
145 145
 
146 146
 		return $customer_id;
147 147
 
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
      * Clears the customer's cache.
152 152
      */
153 153
     public function clear_cache() {
154
-        wp_cache_delete( $this->get( 'email' ), 'getpaid_customer_ids_by_email' );
155
-        wp_cache_delete( $this->get( 'user_id' ), 'getpaid_customer_ids_by_user_id' );
156
-		wp_cache_delete( $this->get_id(), 'getpaid_customers' );
154
+        wp_cache_delete($this->get('email'), 'getpaid_customer_ids_by_email');
155
+        wp_cache_delete($this->get('user_id'), 'getpaid_customer_ids_by_user_id');
156
+		wp_cache_delete($this->get_id(), 'getpaid_customers');
157 157
 	}
158 158
 
159 159
 	/*
@@ -177,17 +177,17 @@  discard block
 block discarded – undo
177 177
      * @param  string $key The key to fetch.
178 178
      * @param  string $context View or edit context.
179 179
      */
180
-    public function get( $key, $context = 'view' ) {
180
+    public function get($key, $context = 'view') {
181 181
 
182 182
         // Maybe strip _wpinv_ prefix from key.
183
-        $key = str_replace( '_wpinv_', '', $key );
183
+        $key = str_replace('_wpinv_', '', $key);
184 184
 
185 185
         // Check if we have a helper method for that.
186
-        if ( method_exists( $this, 'get_' . $key ) ) {
187
-            return call_user_func( array( $this, 'get_' . $key ), $context );
186
+        if (method_exists($this, 'get_' . $key)) {
187
+            return call_user_func(array($this, 'get_' . $key), $context);
188 188
         }
189 189
 
190
-		return $this->get_prop( $key, $context );
190
+		return $this->get_prop($key, $context);
191 191
 
192 192
     }
193 193
 
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
      * @param string $key The key to fetch.
208 208
      * @param mixed $value The new value.
209 209
      */
210
-    public function set( $key, $value ) {
210
+    public function set($key, $value) {
211 211
 
212 212
         // Check if we have a helper method for that.
213
-        if ( method_exists( $this, 'set_' . $key ) ) {
214
-            return call_user_func( array( $this, 'set_' . $key ), $value );
213
+        if (method_exists($this, 'set_' . $key)) {
214
+            return call_user_func(array($this, 'set_' . $key), $value);
215 215
         }
216 216
 
217
-		return $this->set_prop( $key, $value );
217
+		return $this->set_prop($key, $value);
218 218
 
219 219
     }
220 220
 
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
 	 * @since 1.0.0
225 225
 	 * @param  string $status New status.
226 226
 	 */
227
-	public function set_status( $status ) {
227
+	public function set_status($status) {
228 228
 
229
-		if ( in_array( $status, array( 'active', 'inactive', 'blocked' ), true ) ) {
230
-			return $this->set_prop( 'status', $status );
229
+		if (in_array($status, array('active', 'inactive', 'blocked'), true)) {
230
+			return $this->set_prop('status', $status);
231 231
 		}
232 232
 
233
-		$this->set_prop( 'status', 'inactive' );
233
+		$this->set_prop('status', 'inactive');
234 234
 	}
235 235
 
236 236
 	/**
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 	 * @since 1.0.0
240 240
 	 * @param float $purchase_value.
241 241
 	 */
242
-	public function set_purchase_value( $purchase_value ) {
243
-		$this->set_prop( 'purchase_value', (float) $purchase_value );
242
+	public function set_purchase_value($purchase_value) {
243
+		$this->set_prop('purchase_value', (float) $purchase_value);
244 244
 	}
245 245
 
246 246
     /**
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 	 * @since 1.0.0
250 250
 	 * @param int $purchase_count.
251 251
 	 */
252
-	public function set_purchase_count( $purchase_count ) {
253
-		$this->set_prop( 'purchase_count', absint( $purchase_count ) );
252
+	public function set_purchase_count($purchase_count) {
253
+		$this->set_prop('purchase_count', absint($purchase_count));
254 254
 	}
255 255
 
256 256
     /**
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 * @since 1.0.0
260 260
 	 * @param int $user_id.
261 261
 	 */
262
-	public function set_user_id( $user_id ) {
263
-		$this->set_prop( 'user_id', absint( $user_id ) );
262
+	public function set_user_id($user_id) {
263
+		$this->set_prop('user_id', absint($user_id));
264 264
 	}
265 265
 
266 266
     /**
@@ -269,9 +269,9 @@  discard block
 block discarded – undo
269 269
 	 * @since 1.0.0
270 270
 	 * @param string $email.
271 271
 	 */
272
-	public function set_email( $email ) {
273
-        $email = is_string( $email ) ? sanitize_email( $email ) : '';
274
-		$this->set_prop( 'email', $email );
272
+	public function set_email($email) {
273
+        $email = is_string($email) ? sanitize_email($email) : '';
274
+		$this->set_prop('email', $email);
275 275
 	}
276 276
 
277 277
     /**
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
 	 * @since 1.0.0
281 281
 	 * @param string $email_cc.
282 282
 	 */
283
-	public function set_email_cc( $email_cc ) {
284
-        $email_cc = implode( ', ', wp_parse_list( $email_cc ) );
285
-		$this->set_prop( 'email_cc', $email_cc );
283
+	public function set_email_cc($email_cc) {
284
+        $email_cc = implode(', ', wp_parse_list($email_cc));
285
+		$this->set_prop('email_cc', $email_cc);
286 286
 	}
287 287
 
288 288
     /**
@@ -291,16 +291,16 @@  discard block
 block discarded – undo
291 291
 	 * @since 1.0.0
292 292
 	 * @param  string $date_created date created.
293 293
 	 */
294
-	public function set_date_created( $date_created ) {
294
+	public function set_date_created($date_created) {
295 295
 
296
-		$date = strtotime( $date_created );
296
+		$date = strtotime($date_created);
297 297
 
298
-        if ( $date && $date_created !== '0000-00-00 00:00:00'  && $date_created !== '0000-00-00 00:00' ) {
299
-            $this->set_prop( 'date_created', gmdate( 'Y-m-d H:i:s', $date ) );
298
+        if ($date && $date_created !== '0000-00-00 00:00:00' && $date_created !== '0000-00-00 00:00') {
299
+            $this->set_prop('date_created', gmdate('Y-m-d H:i:s', $date));
300 300
             return;
301 301
 		}
302 302
 
303
-		$this->set_prop( 'date_created', null );
303
+		$this->set_prop('date_created', null);
304 304
 	}
305 305
 
306 306
     /**
@@ -309,16 +309,16 @@  discard block
 block discarded – undo
309 309
 	 * @since 1.0.0
310 310
 	 * @param  string $date_modified date created.
311 311
 	 */
312
-	public function set_date_modified( $date_modified ) {
312
+	public function set_date_modified($date_modified) {
313 313
 
314
-		$date = strtotime( $date_modified );
314
+		$date = strtotime($date_modified);
315 315
 
316
-        if ( $date && $date_modified !== '0000-00-00 00:00:00'  && $date_modified !== '0000-00-00 00:00' ) {
317
-            $this->set_prop( 'date_modified', gmdate( 'Y-m-d H:i:s', $date ) );
316
+        if ($date && $date_modified !== '0000-00-00 00:00:00' && $date_modified !== '0000-00-00 00:00') {
317
+            $this->set_prop('date_modified', gmdate('Y-m-d H:i:s', $date));
318 318
             return;
319 319
 		}
320 320
 
321
-		$this->set_prop( 'date_modified', null );
321
+		$this->set_prop('date_modified', null);
322 322
 	}
323 323
 
324 324
 	/*
@@ -339,18 +339,18 @@  discard block
 block discarded – undo
339 339
 
340 340
         $maybe_set = array(
341 341
             'uuid'         => wp_generate_uuid4(),
342
-            'date_created' => current_time( 'mysql' ),
342
+            'date_created' => current_time('mysql'),
343 343
         );
344 344
 
345
-        foreach ( $maybe_set as $key => $value ) {
346
-            $current_value = $this->get( $key );
345
+        foreach ($maybe_set as $key => $value) {
346
+            $current_value = $this->get($key);
347 347
 
348
-            if ( empty( $current_value ) ) {
349
-                $this->set( $key, $value );
348
+            if (empty($current_value)) {
349
+                $this->set($key, $value);
350 350
             }
351 351
         }
352 352
 
353
-        $this->set( 'date_modified', current_time( 'mysql' ) );
353
+        $this->set('date_modified', current_time('mysql'));
354 354
 
355 355
 		return parent::save();
356 356
 	}
@@ -361,19 +361,19 @@  discard block
 block discarded – undo
361 361
 	 * @since 1.0.0
362 362
 	 * @param int $user_id.
363 363
 	 */
364
-	public function clone_user( $user_id ) {
365
-        $user = get_userdata( $user_id );
364
+	public function clone_user($user_id) {
365
+        $user = get_userdata($user_id);
366 366
 
367
-        if ( empty( $user ) ) {
367
+        if (empty($user)) {
368 368
             return;
369 369
         }
370 370
 
371
-		$this->set_user_id( $user->ID );
372
-        $this->set_email( $user->user_email );
373
-        $this->set_purchase_value( getpaid_get_user_total_spend( $user->ID ) );
374
-        $this->set_purchase_count( getpaid_count_user_invoices( $user->ID ) );
375
-        $this->set( 'first_name', $user->first_name );
376
-        $this->set( 'last_name', $user->last_name );
371
+		$this->set_user_id($user->ID);
372
+        $this->set_email($user->user_email);
373
+        $this->set_purchase_value(getpaid_get_user_total_spend($user->ID));
374
+        $this->set_purchase_count(getpaid_count_user_invoices($user->ID));
375
+        $this->set('first_name', $user->first_name);
376
+        $this->set('last_name', $user->last_name);
377 377
 
378 378
         // Fetch extra data from WC or old GetPaid.
379 379
         $prefixes = array(
@@ -382,18 +382,18 @@  discard block
 block discarded – undo
382 382
             '',
383 383
         );
384 384
 
385
-        foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
385
+        foreach (array_keys(getpaid_user_address_fields()) as $field) {
386 386
 
387
-            foreach ( $prefixes as $prefix ) {
387
+            foreach ($prefixes as $prefix) {
388 388
 
389 389
                 // Meta table.
390
-                $value = get_user_meta( $user_id, $prefix . $field, true );
390
+                $value = get_user_meta($user_id, $prefix . $field, true);
391 391
 
392 392
                 // UWP table.
393
-                $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value;
393
+                $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value;
394 394
 
395
-                if ( ! empty( $value ) ) {
396
-                    $this->set( $field, $value );
395
+                if (!empty($value)) {
396
+                    $this->set($field, $value);
397 397
                     continue;
398 398
                 }
399 399
             }
@@ -406,9 +406,9 @@  discard block
 block discarded – undo
406 406
 	 * @since 1.0.0
407 407
 	 * @param int $user_id.
408 408
 	 */
409
-	public function migrate_from_user( $user_id ) {
410
-        $this->clone_user( $user_id );
411
-        do_action( 'getpaid_customer_migrated_from_user', $this, $user_id );
409
+	public function migrate_from_user($user_id) {
410
+        $this->clone_user($user_id);
411
+        do_action('getpaid_customer_migrated_from_user', $this, $user_id);
412 412
         $this->save();
413 413
 	}
414 414
 }
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2662 added lines, -2662 removed lines patch added patch discarded remove patch
@@ -14,31 +14,31 @@  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
-		'customer_id'            => 0,
39
-		'status'                 => 'wpi-pending',
40
-		'version'                => '',
41
-		'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
+        'customer_id'            => 0,
39
+        'status'                 => 'wpi-pending',
40
+        'version'                => '',
41
+        'date_created'           => null,
42 42
         'date_modified'          => null,
43 43
         'due_date'               => null,
44 44
         'completed_date'         => null,
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
         'state'                  => null,
62 62
         'zip'                    => null,
63 63
         'company'                => null,
64
-		'company_id'             => null,
64
+        'company_id'             => null,
65 65
         'vat_number'             => null,
66 66
         'vat_rate'               => null,
67 67
         'address'                => null,
68 68
         'address_confirmed'      => false,
69 69
         'shipping'               => null,
70
-		'subtotal'               => 0,
70
+        'subtotal'               => 0,
71 71
         'total_discount'         => 0,
72 72
         'total_tax'              => 0,
73
-		'total_fees'             => 0,
74
-		'total'                  => 0,
73
+        'total_fees'             => 0,
74
+        'total'                  => 0,
75 75
         'fees'                   => array(),
76 76
         'discounts'              => array(),
77 77
         'taxes'                  => array(),
@@ -83,22 +83,22 @@  discard block
 block discarded – undo
83 83
         'transaction_id'         => '',
84 84
         'currency'               => '',
85 85
         'disable_taxes'          => false,
86
-		'subscription_id'        => null,
87
-		'remote_subscription_id' => null,
88
-		'is_viewed'              => false,
89
-		'email_cc'               => '',
90
-		'template'               => 'quantity', // hours, amount only
91
-		'created_via'            => null,
86
+        'subscription_id'        => null,
87
+        'remote_subscription_id' => null,
88
+        'is_viewed'              => false,
89
+        'email_cc'               => '',
90
+        'template'               => 'quantity', // hours, amount only
91
+        'created_via'            => null,
92 92
     );
93 93
 
94 94
     /**
95
-	 * Stores meta in cache for future reads.
96
-	 *
97
-	 * A group must be set to to enable caching.
98
-	 *
99
-	 * @var string
100
-	 */
101
-	protected $cache_group = 'getpaid_invoices';
95
+     * Stores meta in cache for future reads.
96
+     *
97
+     * A group must be set to to enable caching.
98
+     *
99
+     * @var string
100
+     */
101
+    protected $cache_group = 'getpaid_invoices';
102 102
 
103 103
     /**
104 104
      * Stores a reference to the original WP_Post object
@@ -112,110 +112,110 @@  discard block
 block discarded – undo
112 112
      *
113 113
      * @var int
114 114
      */
115
-	protected $recurring_item = null;
115
+    protected $recurring_item = null;
116 116
 
117
-	/**
117
+    /**
118 118
      * Stores an array of item totals.
119
-	 *
120
-	 * e.g $totals['discount'] = array(
121
-	 *      'initial'   => 10,
122
-	 *      'recurring' => 10,
123
-	 * )
119
+     *
120
+     * e.g $totals['discount'] = array(
121
+     *      'initial'   => 10,
122
+     *      'recurring' => 10,
123
+     * )
124 124
      *
125 125
      * @var array
126 126
      */
127
-	protected $totals = array();
127
+    protected $totals = array();
128 128
 
129
-	/**
129
+    /**
130 130
      * Tax rate.
131
-	 *
131
+     *
132 132
      * @var float
133 133
      */
134
-	protected $tax_rate = 0;
134
+    protected $tax_rate = 0;
135 135
 
136
-	/**
137
-	 * Stores the status transition information.
138
-	 *
139
-	 * @since 1.0.19
140
-	 * @var bool|array
141
-	 */
142
-	protected $status_transition = false;
136
+    /**
137
+     * Stores the status transition information.
138
+     *
139
+     * @since 1.0.19
140
+     * @var bool|array
141
+     */
142
+    protected $status_transition = false;
143 143
 
144 144
     /**
145
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
146
-	 *
147
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
148
-	 */
145
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
146
+     *
147
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
148
+     */
149 149
     public function __construct( $invoice = 0 ) {
150 150
 
151 151
         parent::__construct( $invoice );
152 152
 
153
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
154
-			$this->set_id( (int) $invoice );
155
-		} elseif ( $invoice instanceof self ) {
156
-			$this->set_id( $invoice->get_id() );
157
-		} elseif ( ! empty( $invoice->ID ) ) {
158
-			$this->set_id( $invoice->ID );
159
-		} elseif ( is_array( $invoice ) ) {
160
-			$this->set_props( $invoice );
161
-
162
-			if ( isset( $invoice['ID'] ) ) {
163
-				$this->set_id( $invoice['ID'] );
164
-			}
153
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
154
+            $this->set_id( (int) $invoice );
155
+        } elseif ( $invoice instanceof self ) {
156
+            $this->set_id( $invoice->get_id() );
157
+        } elseif ( ! empty( $invoice->ID ) ) {
158
+            $this->set_id( $invoice->ID );
159
+        } elseif ( is_array( $invoice ) ) {
160
+            $this->set_props( $invoice );
161
+
162
+            if ( isset( $invoice['ID'] ) ) {
163
+                $this->set_id( $invoice['ID'] );
164
+            }
165 165
 } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
166
-			$this->set_id( $invoice_id );
167
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
168
-			$this->set_id( $invoice_id );
169
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
170
-			$this->set_id( $invoice_id );
171
-		} else {
172
-			$this->set_object_read( true );
173
-		}
166
+            $this->set_id( $invoice_id );
167
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
168
+            $this->set_id( $invoice_id );
169
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
170
+            $this->set_id( $invoice_id );
171
+        } else {
172
+            $this->set_object_read( true );
173
+        }
174 174
 
175 175
         // Load the datastore.
176
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
176
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
177 177
 
178
-		if ( $this->get_id() > 0 ) {
178
+        if ( $this->get_id() > 0 ) {
179 179
             $this->post = get_post( $this->get_id() );
180 180
             $this->ID   = $this->get_id();
181
-			$this->data_store->read( $this );
181
+            $this->data_store->read( $this );
182 182
         }
183 183
 
184 184
     }
185 185
 
186 186
     /**
187
-	 * Given an invoice key/number, it returns its id.
188
-	 *
189
-	 *
190
-	 * @static
191
-	 * @param string $value The invoice key or number
192
-	 * @param string $field Either key, transaction_id or number.
193
-	 * @since 1.0.15
194
-	 * @return int
195
-	 */
196
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
187
+     * Given an invoice key/number, it returns its id.
188
+     *
189
+     *
190
+     * @static
191
+     * @param string $value The invoice key or number
192
+     * @param string $field Either key, transaction_id or number.
193
+     * @since 1.0.15
194
+     * @return int
195
+     */
196
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
197 197
         global $wpdb;
198 198
 
199
-		// Trim the value.
200
-		$value = trim( $value );
199
+        // Trim the value.
200
+        $value = trim( $value );
201 201
 
202
-		if ( empty( $value ) ) {
203
-			return 0;
204
-		}
202
+        if ( empty( $value ) ) {
203
+            return 0;
204
+        }
205 205
 
206 206
         // Valid fields.
207 207
         $fields = array( 'key', 'number', 'transaction_id' );
208 208
 
209
-		// Ensure a field has been passed.
210
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
211
-			return 0;
212
-		}
209
+        // Ensure a field has been passed.
210
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
211
+            return 0;
212
+        }
213 213
 
214
-		// Maybe retrieve from the cache.
215
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
-		if ( false !== $invoice_id ) {
217
-			return $invoice_id;
218
-		}
214
+        // Maybe retrieve from the cache.
215
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
+        if ( false !== $invoice_id ) {
217
+            return $invoice_id;
218
+        }
219 219
 
220 220
         // Fetch from the db.
221 221
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
224 224
         );
225 225
 
226
-		// Update the cache with our data
227
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
226
+        // Update the cache with our data
227
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
228 228
 
229
-		return $invoice_id;
229
+        return $invoice_id;
230 230
     }
231 231
 
232 232
     /**
@@ -252,83 +252,83 @@  discard block
 block discarded – undo
252 252
     */
253 253
 
254 254
     /**
255
-	 * Get parent invoice ID.
256
-	 *
257
-	 * @since 1.0.19
258
-	 * @param  string $context View or edit context.
259
-	 * @return int
260
-	 */
261
-	public function get_parent_id( $context = 'view' ) {
262
-		return (int) $this->get_prop( 'parent_id', $context );
255
+     * Get parent invoice ID.
256
+     *
257
+     * @since 1.0.19
258
+     * @param  string $context View or edit context.
259
+     * @return int
260
+     */
261
+    public function get_parent_id( $context = 'view' ) {
262
+        return (int) $this->get_prop( 'parent_id', $context );
263 263
     }
264 264
 
265 265
     /**
266
-	 * Get parent invoice.
267
-	 *
268
-	 * @since 1.0.19
269
-	 * @return WPInv_Invoice
270
-	 */
266
+     * Get parent invoice.
267
+     *
268
+     * @since 1.0.19
269
+     * @return WPInv_Invoice
270
+     */
271 271
     public function get_parent_payment() {
272 272
         return new WPInv_Invoice( $this->get_parent_id() );
273 273
     }
274 274
 
275 275
     /**
276
-	 * Alias for self::get_parent_payment().
277
-	 *
278
-	 * @since 1.0.19
279
-	 * @return WPInv_Invoice
280
-	 */
276
+     * Alias for self::get_parent_payment().
277
+     *
278
+     * @since 1.0.19
279
+     * @return WPInv_Invoice
280
+     */
281 281
     public function get_parent() {
282 282
         return $this->get_parent_payment();
283 283
     }
284 284
 
285 285
     /**
286
-	 * Get invoice status.
287
-	 *
288
-	 * @since 1.0.19
289
-	 * @param  string $context View or edit context.
290
-	 * @return string
291
-	 */
292
-	public function get_status( $context = 'view' ) {
293
-		return $this->get_prop( 'status', $context );
294
-	}
286
+     * Get invoice status.
287
+     *
288
+     * @since 1.0.19
289
+     * @param  string $context View or edit context.
290
+     * @return string
291
+     */
292
+    public function get_status( $context = 'view' ) {
293
+        return $this->get_prop( 'status', $context );
294
+    }
295 295
 
296
-	/**
297
-	 * Retrieves an array of possible invoice statuses.
298
-	 *
299
-	 * @since 1.0.19
300
-	 * @return array
301
-	 */
302
-	public function get_all_statuses() {
303
-		return wpinv_get_invoice_statuses( true, true, $this );
296
+    /**
297
+     * Retrieves an array of possible invoice statuses.
298
+     *
299
+     * @since 1.0.19
300
+     * @return array
301
+     */
302
+    public function get_all_statuses() {
303
+        return wpinv_get_invoice_statuses( true, true, $this );
304 304
     }
305 305
 
306 306
     /**
307
-	 * Get invoice status nice name.
308
-	 *
309
-	 * @since 1.0.19
310
-	 * @return string
311
-	 */
307
+     * Get invoice status nice name.
308
+     *
309
+     * @since 1.0.19
310
+     * @return string
311
+     */
312 312
     public function get_status_nicename() {
313
-		$statuses = $this->get_all_statuses();
313
+        $statuses = $this->get_all_statuses();
314 314
 
315 315
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
316 316
 
317 317
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
318 318
     }
319 319
 
320
-	/**
321
-	 * Retrieves the invoice status class
322
-	 *
323
-	 * @since  1.0.19
324
-	 * @return string
325
-	 */
326
-	public function get_status_class() {
327
-		$statuses = getpaid_get_invoice_status_classes();
328
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark';
329
-	}
320
+    /**
321
+     * Retrieves the invoice status class
322
+     *
323
+     * @since  1.0.19
324
+     * @return string
325
+     */
326
+    public function get_status_class() {
327
+        $statuses = getpaid_get_invoice_status_classes();
328
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark';
329
+    }
330 330
 
331
-	/**
331
+    /**
332 332
      * Retrieves the invoice status label html
333 333
      *
334 334
      * @since  1.0.0
@@ -336,263 +336,263 @@  discard block
 block discarded – undo
336 336
      */
337 337
     public function get_status_label_html() {
338 338
 
339
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
340
-		$status       = sanitize_html_class( $this->get_status() );
341
-		$class        = esc_attr( $this->get_status_class() );
342
-
343
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
344
-	}
345
-
346
-    /**
347
-	 * Get plugin version when the invoice was created.
348
-	 *
349
-	 * @since 1.0.19
350
-	 * @param  string $context View or edit context.
351
-	 * @return string
352
-	 */
353
-	public function get_version( $context = 'view' ) {
354
-		return $this->get_prop( 'version', $context );
355
-	}
356
-
357
-	/**
358
-	 * @deprecated
359
-	 */
360
-	public function get_invoice_date( $format = true ) {
361
-		$date      = getpaid_format_date( $this->get_date_completed() );
362
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
363
-		$formatted = getpaid_format_date( $date );
364
-
365
-		if ( $format ) {
366
-			return $formatted;
367
-		}
368
-
369
-		return empty( $formatted ) ? '' : $date;
370
-
371
-    }
372
-
373
-    /**
374
-	 * Get date when the invoice was created.
375
-	 *
376
-	 * @since 1.0.19
377
-	 * @param  string $context View or edit context.
378
-	 * @return string
379
-	 */
380
-	public function get_date_created( $context = 'view' ) {
381
-		return $this->get_prop( 'date_created', $context );
382
-	}
383
-
384
-	/**
385
-	 * Alias for self::get_date_created().
386
-	 *
387
-	 * @since 1.0.19
388
-	 * @param  string $context View or edit context.
389
-	 * @return string
390
-	 */
391
-	public function get_created_date( $context = 'view' ) {
392
-		return $this->get_date_created( $context );
393
-    }
394
-
395
-    /**
396
-	 * Get GMT date when the invoice was created.
397
-	 *
398
-	 * @since 1.0.19
399
-	 * @param  string $context View or edit context.
400
-	 * @return string
401
-	 */
402
-	public function get_date_created_gmt( $context = 'view' ) {
339
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
340
+        $status       = sanitize_html_class( $this->get_status() );
341
+        $class        = esc_attr( $this->get_status_class() );
342
+
343
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
344
+    }
345
+
346
+    /**
347
+     * Get plugin version when the invoice was created.
348
+     *
349
+     * @since 1.0.19
350
+     * @param  string $context View or edit context.
351
+     * @return string
352
+     */
353
+    public function get_version( $context = 'view' ) {
354
+        return $this->get_prop( 'version', $context );
355
+    }
356
+
357
+    /**
358
+     * @deprecated
359
+     */
360
+    public function get_invoice_date( $format = true ) {
361
+        $date      = getpaid_format_date( $this->get_date_completed() );
362
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
363
+        $formatted = getpaid_format_date( $date );
364
+
365
+        if ( $format ) {
366
+            return $formatted;
367
+        }
368
+
369
+        return empty( $formatted ) ? '' : $date;
370
+
371
+    }
372
+
373
+    /**
374
+     * Get date when the invoice was created.
375
+     *
376
+     * @since 1.0.19
377
+     * @param  string $context View or edit context.
378
+     * @return string
379
+     */
380
+    public function get_date_created( $context = 'view' ) {
381
+        return $this->get_prop( 'date_created', $context );
382
+    }
383
+
384
+    /**
385
+     * Alias for self::get_date_created().
386
+     *
387
+     * @since 1.0.19
388
+     * @param  string $context View or edit context.
389
+     * @return string
390
+     */
391
+    public function get_created_date( $context = 'view' ) {
392
+        return $this->get_date_created( $context );
393
+    }
394
+
395
+    /**
396
+     * Get GMT date when the invoice was created.
397
+     *
398
+     * @since 1.0.19
399
+     * @param  string $context View or edit context.
400
+     * @return string
401
+     */
402
+    public function get_date_created_gmt( $context = 'view' ) {
403 403
         $date = $this->get_date_created( $context );
404 404
 
405 405
         if ( $date ) {
406 406
             $date = get_gmt_from_date( $date );
407 407
         }
408
-		return $date;
408
+        return $date;
409 409
     }
410 410
 
411 411
     /**
412
-	 * Get date when the invoice was last modified.
413
-	 *
414
-	 * @since 1.0.19
415
-	 * @param  string $context View or edit context.
416
-	 * @return string
417
-	 */
418
-	public function get_date_modified( $context = 'view' ) {
419
-		return $this->get_prop( 'date_modified', $context );
420
-	}
412
+     * Get date when the invoice was last modified.
413
+     *
414
+     * @since 1.0.19
415
+     * @param  string $context View or edit context.
416
+     * @return string
417
+     */
418
+    public function get_date_modified( $context = 'view' ) {
419
+        return $this->get_prop( 'date_modified', $context );
420
+    }
421 421
 
422
-	/**
423
-	 * Alias for self::get_date_modified().
424
-	 *
425
-	 * @since 1.0.19
426
-	 * @param  string $context View or edit context.
427
-	 * @return string
428
-	 */
429
-	public function get_modified_date( $context = 'view' ) {
430
-		return $this->get_date_modified( $context );
422
+    /**
423
+     * Alias for self::get_date_modified().
424
+     *
425
+     * @since 1.0.19
426
+     * @param  string $context View or edit context.
427
+     * @return string
428
+     */
429
+    public function get_modified_date( $context = 'view' ) {
430
+        return $this->get_date_modified( $context );
431 431
     }
432 432
 
433 433
     /**
434
-	 * Get GMT date when the invoice was last modified.
435
-	 *
436
-	 * @since 1.0.19
437
-	 * @param  string $context View or edit context.
438
-	 * @return string
439
-	 */
440
-	public function get_date_modified_gmt( $context = 'view' ) {
434
+     * Get GMT date when the invoice was last modified.
435
+     *
436
+     * @since 1.0.19
437
+     * @param  string $context View or edit context.
438
+     * @return string
439
+     */
440
+    public function get_date_modified_gmt( $context = 'view' ) {
441 441
         $date = $this->get_date_modified( $context );
442 442
 
443 443
         if ( $date ) {
444 444
             $date = get_gmt_from_date( $date );
445 445
         }
446
-		return $date;
446
+        return $date;
447 447
     }
448 448
 
449 449
     /**
450
-	 * Get the invoice due date.
451
-	 *
452
-	 * @since 1.0.19
453
-	 * @param  string $context View or edit context.
454
-	 * @return string
455
-	 */
456
-	public function get_due_date( $context = 'view' ) {
457
-		return $this->get_prop( 'due_date', $context );
450
+     * Get the invoice due date.
451
+     *
452
+     * @since 1.0.19
453
+     * @param  string $context View or edit context.
454
+     * @return string
455
+     */
456
+    public function get_due_date( $context = 'view' ) {
457
+        return $this->get_prop( 'due_date', $context );
458 458
     }
459 459
 
460 460
     /**
461
-	 * Alias for self::get_due_date().
462
-	 *
463
-	 * @since 1.0.19
464
-	 * @param  string $context View or edit context.
465
-	 * @return string
466
-	 */
467
-	public function get_date_due( $context = 'view' ) {
468
-		return $this->get_due_date( $context );
461
+     * Alias for self::get_due_date().
462
+     *
463
+     * @since 1.0.19
464
+     * @param  string $context View or edit context.
465
+     * @return string
466
+     */
467
+    public function get_date_due( $context = 'view' ) {
468
+        return $this->get_due_date( $context );
469 469
     }
470 470
 
471 471
     /**
472
-	 * Get the invoice GMT due date.
473
-	 *
474
-	 * @since 1.0.19
475
-	 * @param  string $context View or edit context.
476
-	 * @return string
477
-	 */
478
-	public function get_due_date_gmt( $context = 'view' ) {
472
+     * Get the invoice GMT due date.
473
+     *
474
+     * @since 1.0.19
475
+     * @param  string $context View or edit context.
476
+     * @return string
477
+     */
478
+    public function get_due_date_gmt( $context = 'view' ) {
479 479
         $date = $this->get_due_date( $context );
480 480
 
481 481
         if ( $date ) {
482 482
             $date = get_gmt_from_date( $date );
483 483
         }
484
-		return $date;
484
+        return $date;
485 485
     }
486 486
 
487 487
     /**
488
-	 * Alias for self::get_due_date_gmt().
489
-	 *
490
-	 * @since 1.0.19
491
-	 * @param  string $context View or edit context.
492
-	 * @return string
493
-	 */
494
-	public function get_gmt_date_due( $context = 'view' ) {
495
-		return $this->get_due_date_gmt( $context );
488
+     * Alias for self::get_due_date_gmt().
489
+     *
490
+     * @since 1.0.19
491
+     * @param  string $context View or edit context.
492
+     * @return string
493
+     */
494
+    public function get_gmt_date_due( $context = 'view' ) {
495
+        return $this->get_due_date_gmt( $context );
496 496
     }
497 497
 
498 498
     /**
499
-	 * Get date when the invoice was completed.
500
-	 *
501
-	 * @since 1.0.19
502
-	 * @param  string $context View or edit context.
503
-	 * @return string
504
-	 */
505
-	public function get_completed_date( $context = 'view' ) {
506
-		return $this->get_prop( 'completed_date', $context );
499
+     * Get date when the invoice was completed.
500
+     *
501
+     * @since 1.0.19
502
+     * @param  string $context View or edit context.
503
+     * @return string
504
+     */
505
+    public function get_completed_date( $context = 'view' ) {
506
+        return $this->get_prop( 'completed_date', $context );
507 507
     }
508 508
 
509 509
     /**
510
-	 * Alias for self::get_completed_date().
511
-	 *
512
-	 * @since 1.0.19
513
-	 * @param  string $context View or edit context.
514
-	 * @return string
515
-	 */
516
-	public function get_date_completed( $context = 'view' ) {
517
-		return $this->get_completed_date( $context );
510
+     * Alias for self::get_completed_date().
511
+     *
512
+     * @since 1.0.19
513
+     * @param  string $context View or edit context.
514
+     * @return string
515
+     */
516
+    public function get_date_completed( $context = 'view' ) {
517
+        return $this->get_completed_date( $context );
518 518
     }
519 519
 
520 520
     /**
521
-	 * Get GMT date when the invoice was was completed.
522
-	 *
523
-	 * @since 1.0.19
524
-	 * @param  string $context View or edit context.
525
-	 * @return string
526
-	 */
527
-	public function get_completed_date_gmt( $context = 'view' ) {
521
+     * Get GMT date when the invoice was was completed.
522
+     *
523
+     * @since 1.0.19
524
+     * @param  string $context View or edit context.
525
+     * @return string
526
+     */
527
+    public function get_completed_date_gmt( $context = 'view' ) {
528 528
         $date = $this->get_completed_date( $context );
529 529
 
530 530
         if ( $date ) {
531 531
             $date = get_gmt_from_date( $date );
532 532
         }
533
-		return $date;
533
+        return $date;
534 534
     }
535 535
 
536 536
     /**
537
-	 * Alias for self::get_completed_date_gmt().
538
-	 *
539
-	 * @since 1.0.19
540
-	 * @param  string $context View or edit context.
541
-	 * @return string
542
-	 */
543
-	public function get_gmt_completed_date( $context = 'view' ) {
544
-		return $this->get_completed_date_gmt( $context );
537
+     * Alias for self::get_completed_date_gmt().
538
+     *
539
+     * @since 1.0.19
540
+     * @param  string $context View or edit context.
541
+     * @return string
542
+     */
543
+    public function get_gmt_completed_date( $context = 'view' ) {
544
+        return $this->get_completed_date_gmt( $context );
545 545
     }
546 546
 
547 547
     /**
548
-	 * Get the invoice number.
549
-	 *
550
-	 * @since 1.0.19
551
-	 * @param  string $context View or edit context.
552
-	 * @return string
553
-	 */
554
-	public function get_number( $context = 'view' ) {
555
-		$number = $this->get_prop( 'number', $context );
548
+     * Get the invoice number.
549
+     *
550
+     * @since 1.0.19
551
+     * @param  string $context View or edit context.
552
+     * @return string
553
+     */
554
+    public function get_number( $context = 'view' ) {
555
+        $number = $this->get_prop( 'number', $context );
556 556
 
557
-		if ( empty( $number ) ) {
558
-			$number = $this->generate_number();
559
-			$this->set_number( $this->generate_number() );
560
-		}
557
+        if ( empty( $number ) ) {
558
+            $number = $this->generate_number();
559
+            $this->set_number( $this->generate_number() );
560
+        }
561 561
 
562
-		return $number;
562
+        return $number;
563 563
     }
564 564
 
565
-	/**
566
-	 * Set the invoice number.
567
-	 *
568
-	 * @since 1.0.19
569
-	 */
570
-	public function maybe_set_number() {
565
+    /**
566
+     * Set the invoice number.
567
+     *
568
+     * @since 1.0.19
569
+     */
570
+    public function maybe_set_number() {
571 571
         $number = $this->get_number();
572 572
 
573 573
         if ( empty( $number ) || $this->get_id() == $number ) {
574
-			$this->set_number( $this->generate_number() );
574
+            $this->set_number( $this->generate_number() );
575 575
         }
576 576
 
577
-	}
577
+    }
578 578
 
579 579
     /**
580
-	 * Get the invoice key.
581
-	 *
582
-	 * @since 1.0.19
583
-	 * @param  string $context View or edit context.
584
-	 * @return string
585
-	 */
586
-	public function get_key( $context = 'view' ) {
580
+     * Get the invoice key.
581
+     *
582
+     * @since 1.0.19
583
+     * @param  string $context View or edit context.
584
+     * @return string
585
+     */
586
+    public function get_key( $context = 'view' ) {
587 587
         return $this->get_prop( 'key', $context );
588
-	}
589
-
590
-	/**
591
-	 * Set the invoice key.
592
-	 *
593
-	 * @since 1.0.19
594
-	 */
595
-	public function maybe_set_key() {
588
+    }
589
+
590
+    /**
591
+     * Set the invoice key.
592
+     *
593
+     * @since 1.0.19
594
+     */
595
+    public function maybe_set_key() {
596 596
         $key = $this->get_key();
597 597
 
598 598
         if ( empty( $key ) ) {
@@ -603,140 +603,140 @@  discard block
 block discarded – undo
603 603
     }
604 604
 
605 605
     /**
606
-	 * Get the invoice type.
607
-	 *
608
-	 * @since 1.0.19
609
-	 * @param  string $context View or edit context.
610
-	 * @return string
611
-	 */
612
-	public function get_type( $context = 'view' ) {
606
+     * Get the invoice type.
607
+     *
608
+     * @since 1.0.19
609
+     * @param  string $context View or edit context.
610
+     * @return string
611
+     */
612
+    public function get_type( $context = 'view' ) {
613 613
         return $this->get_prop( 'type', $context );
614
-	}
615
-
616
-	/**
617
-	 * Returns the post type name.
618
-	 *
619
-	 * @since 1.0.19
620
-	 * @return string
621
-	 */
622
-	public function get_invoice_quote_type() {
614
+    }
615
+
616
+    /**
617
+     * Returns the post type name.
618
+     *
619
+     * @since 1.0.19
620
+     * @return string
621
+     */
622
+    public function get_invoice_quote_type() {
623 623
         return getpaid_get_post_type_label( $this->get_post_type(), false );
624 624
     }
625 625
 
626 626
     /**
627
-	 * Get the invoice post type label.
628
-	 *
629
-	 * @since 1.0.19
630
-	 * @param  string $context View or edit context.
631
-	 * @return string
632
-	 */
633
-	public function get_label( $context = 'view' ) {
627
+     * Get the invoice post type label.
628
+     *
629
+     * @since 1.0.19
630
+     * @param  string $context View or edit context.
631
+     * @return string
632
+     */
633
+    public function get_label( $context = 'view' ) {
634 634
         return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
635
-	}
636
-
637
-	/**
638
-	 * Get the invoice post type.
639
-	 *
640
-	 * @since 1.0.19
641
-	 * @param  string $context View or edit context.
642
-	 * @return string
643
-	 */
644
-	public function get_post_type( $context = 'view' ) {
635
+    }
636
+
637
+    /**
638
+     * Get the invoice post type.
639
+     *
640
+     * @since 1.0.19
641
+     * @param  string $context View or edit context.
642
+     * @return string
643
+     */
644
+    public function get_post_type( $context = 'view' ) {
645 645
         return $this->get_prop( 'post_type', $context );
646 646
     }
647 647
 
648 648
     /**
649
-	 * Get the invoice mode.
650
-	 *
651
-	 * @since 1.0.19
652
-	 * @param  string $context View or edit context.
653
-	 * @return string
654
-	 */
655
-	public function get_mode( $context = 'view' ) {
649
+     * Get the invoice mode.
650
+     *
651
+     * @since 1.0.19
652
+     * @param  string $context View or edit context.
653
+     * @return string
654
+     */
655
+    public function get_mode( $context = 'view' ) {
656 656
         return $this->get_prop( 'mode', $context );
657 657
     }
658 658
 
659 659
     /**
660
-	 * Get the invoice path.
661
-	 *
662
-	 * @since 1.0.19
663
-	 * @param  string $context View or edit context.
664
-	 * @return string
665
-	 */
666
-	public function get_path( $context = 'view' ) {
660
+     * Get the invoice path.
661
+     *
662
+     * @since 1.0.19
663
+     * @param  string $context View or edit context.
664
+     * @return string
665
+     */
666
+    public function get_path( $context = 'view' ) {
667 667
         $path   = $this->get_prop( 'path', $context );
668
-		$prefix = $this->get_type();
668
+        $prefix = $this->get_type();
669 669
 
670
-		if ( 0 !== strpos( $path, $prefix ) ) {
671
-			$path = sanitize_title( $prefix . '-' . $this->get_id() );
672
-			$this->set_path( $path );
673
-		}
670
+        if ( 0 !== strpos( $path, $prefix ) ) {
671
+            $path = sanitize_title( $prefix . '-' . $this->get_id() );
672
+            $this->set_path( $path );
673
+        }
674 674
 
675
-		return $path;
675
+        return $path;
676 676
     }
677 677
 
678 678
     /**
679
-	 * Get the invoice name/title.
680
-	 *
681
-	 * @since 1.0.19
682
-	 * @param  string $context View or edit context.
683
-	 * @return string
684
-	 */
685
-	public function get_name( $context = 'view' ) {
679
+     * Get the invoice name/title.
680
+     *
681
+     * @since 1.0.19
682
+     * @param  string $context View or edit context.
683
+     * @return string
684
+     */
685
+    public function get_name( $context = 'view' ) {
686 686
         return $this->get_prop( 'title', $context );
687 687
     }
688 688
 
689 689
     /**
690
-	 * Alias of self::get_name().
691
-	 *
692
-	 * @since 1.0.19
693
-	 * @param  string $context View or edit context.
694
-	 * @return string
695
-	 */
696
-	public function get_title( $context = 'view' ) {
697
-		return $this->get_name( $context );
690
+     * Alias of self::get_name().
691
+     *
692
+     * @since 1.0.19
693
+     * @param  string $context View or edit context.
694
+     * @return string
695
+     */
696
+    public function get_title( $context = 'view' ) {
697
+        return $this->get_name( $context );
698 698
     }
699 699
 
700 700
     /**
701
-	 * Get the invoice description.
702
-	 *
703
-	 * @since 1.0.19
704
-	 * @param  string $context View or edit context.
705
-	 * @return string
706
-	 */
707
-	public function get_description( $context = 'view' ) {
708
-		return $this->get_prop( 'description', $context );
701
+     * Get the invoice description.
702
+     *
703
+     * @since 1.0.19
704
+     * @param  string $context View or edit context.
705
+     * @return string
706
+     */
707
+    public function get_description( $context = 'view' ) {
708
+        return $this->get_prop( 'description', $context );
709 709
     }
710 710
 
711 711
     /**
712
-	 * Alias of self::get_description().
713
-	 *
714
-	 * @since 1.0.19
715
-	 * @param  string $context View or edit context.
716
-	 * @return string
717
-	 */
718
-	public function get_excerpt( $context = 'view' ) {
719
-		return $this->get_description( $context );
712
+     * Alias of self::get_description().
713
+     *
714
+     * @since 1.0.19
715
+     * @param  string $context View or edit context.
716
+     * @return string
717
+     */
718
+    public function get_excerpt( $context = 'view' ) {
719
+        return $this->get_description( $context );
720 720
     }
721 721
 
722 722
     /**
723
-	 * Alias of self::get_description().
724
-	 *
725
-	 * @since 1.0.19
726
-	 * @param  string $context View or edit context.
727
-	 * @return string
728
-	 */
729
-	public function get_summary( $context = 'view' ) {
730
-		return $this->get_description( $context );
723
+     * Alias of self::get_description().
724
+     *
725
+     * @since 1.0.19
726
+     * @param  string $context View or edit context.
727
+     * @return string
728
+     */
729
+    public function get_summary( $context = 'view' ) {
730
+        return $this->get_description( $context );
731 731
     }
732 732
 
733 733
     /**
734
-	 * Returns the user info.
735
-	 *
736
-	 * @since 1.0.19
734
+     * Returns the user info.
735
+     *
736
+     * @since 1.0.19
737 737
      * @param  string $context View or edit context.
738
-	 * @return array
739
-	 */
738
+     * @return array
739
+     */
740 740
     public function get_user_info( $context = 'view' ) {
741 741
 
742 742
         $user_info = array(
@@ -751,683 +751,683 @@  discard block
 block discarded – undo
751 751
             'state'      => $this->get_state( $context ),
752 752
             'zip'        => $this->get_zip( $context ),
753 753
             'company'    => $this->get_company( $context ),
754
-			'company_id' => $this->get_company_id( $context ),
754
+            'company_id' => $this->get_company_id( $context ),
755 755
             'vat_number' => $this->get_vat_number( $context ),
756 756
             'discount'   => $this->get_discount_code( $context ),
757
-		);
757
+        );
758 758
 
759
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
759
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
760 760
 
761 761
     }
762 762
 
763 763
     /**
764
-	 * Get the user id.
765
-	 *
766
-	 * @since 1.0.19
767
-	 * @param  string $context View or edit context.
768
-	 * @return int
769
-	 */
770
-	public function get_author( $context = 'view' ) {
771
-		return (int) $this->get_prop( 'author', $context );
764
+     * Get the user id.
765
+     *
766
+     * @since 1.0.19
767
+     * @param  string $context View or edit context.
768
+     * @return int
769
+     */
770
+    public function get_author( $context = 'view' ) {
771
+        return (int) $this->get_prop( 'author', $context );
772 772
     }
773 773
 
774 774
     /**
775
-	 * Alias of self::get_author().
776
-	 *
777
-	 * @since 1.0.19
778
-	 * @param  string $context View or edit context.
779
-	 * @return int
780
-	 */
781
-	public function get_user_id( $context = 'view' ) {
782
-		return $this->get_author( $context );
775
+     * Alias of self::get_author().
776
+     *
777
+     * @since 1.0.19
778
+     * @param  string $context View or edit context.
779
+     * @return int
780
+     */
781
+    public function get_user_id( $context = 'view' ) {
782
+        return $this->get_author( $context );
783 783
     }
784 784
 
785
-     /**
786
-	 * Get customer ID.
787
-	 *
788
-	 * @since 1.0.19
789
-	 * @param  string $context View or edit context.
790
-	 * @return int
791
-	 */
792
-	public function get_customer_id( $context = 'view' ) {
793
-		return (int) $this->get_prop( 'customer_id', $context );
785
+        /**
786
+         * Get customer ID.
787
+         *
788
+         * @since 1.0.19
789
+         * @param  string $context View or edit context.
790
+         * @return int
791
+         */
792
+    public function get_customer_id( $context = 'view' ) {
793
+        return (int) $this->get_prop( 'customer_id', $context );
794 794
     }
795 795
 
796 796
     /**
797
-	 * Get the customer's ip.
798
-	 *
799
-	 * @since 1.0.19
800
-	 * @param  string $context View or edit context.
801
-	 * @return string
802
-	 */
803
-	public function get_ip( $context = 'view' ) {
804
-		return $this->get_prop( 'user_ip', $context );
797
+     * Get the customer's ip.
798
+     *
799
+     * @since 1.0.19
800
+     * @param  string $context View or edit context.
801
+     * @return string
802
+     */
803
+    public function get_ip( $context = 'view' ) {
804
+        return $this->get_prop( 'user_ip', $context );
805 805
     }
806 806
 
807 807
     /**
808
-	 * Alias of self::get_ip().
809
-	 *
810
-	 * @since 1.0.19
811
-	 * @param  string $context View or edit context.
812
-	 * @return string
813
-	 */
814
-	public function get_user_ip( $context = 'view' ) {
815
-		return $this->get_ip( $context );
808
+     * Alias of self::get_ip().
809
+     *
810
+     * @since 1.0.19
811
+     * @param  string $context View or edit context.
812
+     * @return string
813
+     */
814
+    public function get_user_ip( $context = 'view' ) {
815
+        return $this->get_ip( $context );
816 816
     }
817 817
 
818
-     /**
819
-	 * Alias of self::get_ip().
820
-	 *
821
-	 * @since 1.0.19
822
-	 * @param  string $context View or edit context.
823
-	 * @return string
824
-	 */
825
-	public function get_customer_ip( $context = 'view' ) {
826
-		return $this->get_ip( $context );
818
+        /**
819
+         * Alias of self::get_ip().
820
+         *
821
+         * @since 1.0.19
822
+         * @param  string $context View or edit context.
823
+         * @return string
824
+         */
825
+    public function get_customer_ip( $context = 'view' ) {
826
+        return $this->get_ip( $context );
827 827
     }
828 828
 
829 829
     /**
830
-	 * Get the customer's first name.
831
-	 *
832
-	 * @since 1.0.19
833
-	 * @param  string $context View or edit context.
834
-	 * @return string
835
-	 */
836
-	public function get_first_name( $context = 'view' ) {
837
-		return $this->get_prop( 'first_name', $context );
830
+     * Get the customer's first name.
831
+     *
832
+     * @since 1.0.19
833
+     * @param  string $context View or edit context.
834
+     * @return string
835
+     */
836
+    public function get_first_name( $context = 'view' ) {
837
+        return $this->get_prop( 'first_name', $context );
838 838
     }
839 839
 
840 840
     /**
841
-	 * Alias of self::get_first_name().
842
-	 *
843
-	 * @since 1.0.19
844
-	 * @param  string $context View or edit context.
845
-	 * @return string
846
-	 */
847
-	public function get_user_first_name( $context = 'view' ) {
848
-		return $this->get_first_name( $context );
841
+     * Alias of self::get_first_name().
842
+     *
843
+     * @since 1.0.19
844
+     * @param  string $context View or edit context.
845
+     * @return string
846
+     */
847
+    public function get_user_first_name( $context = 'view' ) {
848
+        return $this->get_first_name( $context );
849 849
     }
850 850
 
851
-     /**
852
-	 * Alias of self::get_first_name().
853
-	 *
854
-	 * @since 1.0.19
855
-	 * @param  string $context View or edit context.
856
-	 * @return string
857
-	 */
858
-	public function get_customer_first_name( $context = 'view' ) {
859
-		return $this->get_first_name( $context );
851
+        /**
852
+         * Alias of self::get_first_name().
853
+         *
854
+         * @since 1.0.19
855
+         * @param  string $context View or edit context.
856
+         * @return string
857
+         */
858
+    public function get_customer_first_name( $context = 'view' ) {
859
+        return $this->get_first_name( $context );
860 860
     }
861 861
 
862 862
     /**
863
-	 * Get the customer's last name.
864
-	 *
865
-	 * @since 1.0.19
866
-	 * @param  string $context View or edit context.
867
-	 * @return string
868
-	 */
869
-	public function get_last_name( $context = 'view' ) {
870
-		return $this->get_prop( 'last_name', $context );
863
+     * Get the customer's last name.
864
+     *
865
+     * @since 1.0.19
866
+     * @param  string $context View or edit context.
867
+     * @return string
868
+     */
869
+    public function get_last_name( $context = 'view' ) {
870
+        return $this->get_prop( 'last_name', $context );
871 871
     }
872 872
 
873 873
     /**
874
-	 * Alias of self::get_last_name().
875
-	 *
876
-	 * @since 1.0.19
877
-	 * @param  string $context View or edit context.
878
-	 * @return string
879
-	 */
880
-	public function get_user_last_name( $context = 'view' ) {
881
-		return $this->get_last_name( $context );
874
+     * Alias of self::get_last_name().
875
+     *
876
+     * @since 1.0.19
877
+     * @param  string $context View or edit context.
878
+     * @return string
879
+     */
880
+    public function get_user_last_name( $context = 'view' ) {
881
+        return $this->get_last_name( $context );
882 882
     }
883 883
 
884 884
     /**
885
-	 * Alias of self::get_last_name().
886
-	 *
887
-	 * @since 1.0.19
888
-	 * @param  string $context View or edit context.
889
-	 * @return string
890
-	 */
891
-	public function get_customer_last_name( $context = 'view' ) {
892
-		return $this->get_last_name( $context );
885
+     * Alias of self::get_last_name().
886
+     *
887
+     * @since 1.0.19
888
+     * @param  string $context View or edit context.
889
+     * @return string
890
+     */
891
+    public function get_customer_last_name( $context = 'view' ) {
892
+        return $this->get_last_name( $context );
893 893
     }
894 894
 
895 895
     /**
896
-	 * Get the customer's full name.
897
-	 *
898
-	 * @since 1.0.19
899
-	 * @param  string $context View or edit context.
900
-	 * @return string
901
-	 */
902
-	public function get_full_name( $context = 'view' ) {
903
-		$name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
896
+     * Get the customer's full name.
897
+     *
898
+     * @since 1.0.19
899
+     * @param  string $context View or edit context.
900
+     * @return string
901
+     */
902
+    public function get_full_name( $context = 'view' ) {
903
+        $name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
904 904
 
905
-		if ( ! $name ) {
906
-			$user = get_userdata( $this->get_author( $context ) );
905
+        if ( ! $name ) {
906
+            $user = get_userdata( $this->get_author( $context ) );
907 907
 
908
-			if ( $user ) {
909
-				$name = $user->display_name;
910
-			}
911
-		}
908
+            if ( $user ) {
909
+                $name = $user->display_name;
910
+            }
911
+        }
912 912
 
913
-		if ( ! $name ) {
914
-			$name = $this->get_email( $context );
915
-		}
913
+        if ( ! $name ) {
914
+            $name = $this->get_email( $context );
915
+        }
916 916
 
917
-		return apply_filters( 'wpinv_invoice_user_full_name', $name, $this );
917
+        return apply_filters( 'wpinv_invoice_user_full_name', $name, $this );
918 918
     }
919 919
 
920 920
     /**
921
-	 * Alias of self::get_full_name().
922
-	 *
923
-	 * @since 1.0.19
924
-	 * @param  string $context View or edit context.
925
-	 * @return string
926
-	 */
927
-	public function get_user_full_name( $context = 'view' ) {
928
-		return $this->get_full_name( $context );
921
+     * Alias of self::get_full_name().
922
+     *
923
+     * @since 1.0.19
924
+     * @param  string $context View or edit context.
925
+     * @return string
926
+     */
927
+    public function get_user_full_name( $context = 'view' ) {
928
+        return $this->get_full_name( $context );
929 929
     }
930 930
 
931 931
     /**
932
-	 * Alias of self::get_full_name().
933
-	 *
934
-	 * @since 1.0.19
935
-	 * @param  string $context View or edit context.
936
-	 * @return string
937
-	 */
938
-	public function get_customer_full_name( $context = 'view' ) {
939
-		return $this->get_full_name( $context );
932
+     * Alias of self::get_full_name().
933
+     *
934
+     * @since 1.0.19
935
+     * @param  string $context View or edit context.
936
+     * @return string
937
+     */
938
+    public function get_customer_full_name( $context = 'view' ) {
939
+        return $this->get_full_name( $context );
940 940
     }
941 941
 
942 942
     /**
943
-	 * Get the customer's phone number.
944
-	 *
945
-	 * @since 1.0.19
946
-	 * @param  string $context View or edit context.
947
-	 * @return string
948
-	 */
949
-	public function get_phone( $context = 'view' ) {
950
-		return $this->get_prop( 'phone', $context );
943
+     * Get the customer's phone number.
944
+     *
945
+     * @since 1.0.19
946
+     * @param  string $context View or edit context.
947
+     * @return string
948
+     */
949
+    public function get_phone( $context = 'view' ) {
950
+        return $this->get_prop( 'phone', $context );
951 951
     }
952 952
 
953 953
     /**
954
-	 * Alias of self::get_phone().
955
-	 *
956
-	 * @since 1.0.19
957
-	 * @param  string $context View or edit context.
958
-	 * @return string
959
-	 */
960
-	public function get_phone_number( $context = 'view' ) {
961
-		return $this->get_phone( $context );
954
+     * Alias of self::get_phone().
955
+     *
956
+     * @since 1.0.19
957
+     * @param  string $context View or edit context.
958
+     * @return string
959
+     */
960
+    public function get_phone_number( $context = 'view' ) {
961
+        return $this->get_phone( $context );
962 962
     }
963 963
 
964 964
     /**
965
-	 * Alias of self::get_phone().
966
-	 *
967
-	 * @since 1.0.19
968
-	 * @param  string $context View or edit context.
969
-	 * @return string
970
-	 */
971
-	public function get_user_phone( $context = 'view' ) {
972
-		return $this->get_phone( $context );
965
+     * Alias of self::get_phone().
966
+     *
967
+     * @since 1.0.19
968
+     * @param  string $context View or edit context.
969
+     * @return string
970
+     */
971
+    public function get_user_phone( $context = 'view' ) {
972
+        return $this->get_phone( $context );
973 973
     }
974 974
 
975 975
     /**
976
-	 * Alias of self::get_phone().
977
-	 *
978
-	 * @since 1.0.19
979
-	 * @param  string $context View or edit context.
980
-	 * @return string
981
-	 */
982
-	public function get_customer_phone( $context = 'view' ) {
983
-		return $this->get_phone( $context );
976
+     * Alias of self::get_phone().
977
+     *
978
+     * @since 1.0.19
979
+     * @param  string $context View or edit context.
980
+     * @return string
981
+     */
982
+    public function get_customer_phone( $context = 'view' ) {
983
+        return $this->get_phone( $context );
984 984
     }
985 985
 
986 986
     /**
987
-	 * Get the customer's email address.
988
-	 *
989
-	 * @since 1.0.19
990
-	 * @param  string $context View or edit context.
991
-	 * @return string
992
-	 */
993
-	public function get_email( $context = 'view' ) {
994
-		return $this->get_prop( 'email', $context );
987
+     * Get the customer's email address.
988
+     *
989
+     * @since 1.0.19
990
+     * @param  string $context View or edit context.
991
+     * @return string
992
+     */
993
+    public function get_email( $context = 'view' ) {
994
+        return $this->get_prop( 'email', $context );
995 995
     }
996 996
 
997 997
     /**
998
-	 * Alias of self::get_email().
999
-	 *
1000
-	 * @since 1.0.19
1001
-	 * @param  string $context View or edit context.
1002
-	 * @return string
1003
-	 */
1004
-	public function get_email_address( $context = 'view' ) {
1005
-		return $this->get_email( $context );
998
+     * Alias of self::get_email().
999
+     *
1000
+     * @since 1.0.19
1001
+     * @param  string $context View or edit context.
1002
+     * @return string
1003
+     */
1004
+    public function get_email_address( $context = 'view' ) {
1005
+        return $this->get_email( $context );
1006 1006
     }
1007 1007
 
1008 1008
     /**
1009
-	 * Alias of self::get_email().
1010
-	 *
1011
-	 * @since 1.0.19
1012
-	 * @param  string $context View or edit context.
1013
-	 * @return string
1014
-	 */
1015
-	public function get_user_email( $context = 'view' ) {
1016
-		return $this->get_email( $context );
1009
+     * Alias of self::get_email().
1010
+     *
1011
+     * @since 1.0.19
1012
+     * @param  string $context View or edit context.
1013
+     * @return string
1014
+     */
1015
+    public function get_user_email( $context = 'view' ) {
1016
+        return $this->get_email( $context );
1017 1017
     }
1018 1018
 
1019 1019
     /**
1020
-	 * Alias of self::get_email().
1021
-	 *
1022
-	 * @since 1.0.19
1023
-	 * @param  string $context View or edit context.
1024
-	 * @return string
1025
-	 */
1026
-	public function get_customer_email( $context = 'view' ) {
1027
-		return $this->get_email( $context );
1020
+     * Alias of self::get_email().
1021
+     *
1022
+     * @since 1.0.19
1023
+     * @param  string $context View or edit context.
1024
+     * @return string
1025
+     */
1026
+    public function get_customer_email( $context = 'view' ) {
1027
+        return $this->get_email( $context );
1028 1028
     }
1029 1029
 
1030 1030
     /**
1031
-	 * Get the customer's country.
1032
-	 *
1033
-	 * @since 1.0.19
1034
-	 * @param  string $context View or edit context.
1035
-	 * @return string
1036
-	 */
1037
-	public function get_country( $context = 'view' ) {
1038
-		$country = $this->get_prop( 'country', $context );
1039
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1031
+     * Get the customer's country.
1032
+     *
1033
+     * @since 1.0.19
1034
+     * @param  string $context View or edit context.
1035
+     * @return string
1036
+     */
1037
+    public function get_country( $context = 'view' ) {
1038
+        $country = $this->get_prop( 'country', $context );
1039
+        return empty( $country ) ? wpinv_get_default_country() : $country;
1040 1040
     }
1041 1041
 
1042 1042
     /**
1043
-	 * Alias of self::get_country().
1044
-	 *
1045
-	 * @since 1.0.19
1046
-	 * @param  string $context View or edit context.
1047
-	 * @return string
1048
-	 */
1049
-	public function get_user_country( $context = 'view' ) {
1050
-		return $this->get_country( $context );
1043
+     * Alias of self::get_country().
1044
+     *
1045
+     * @since 1.0.19
1046
+     * @param  string $context View or edit context.
1047
+     * @return string
1048
+     */
1049
+    public function get_user_country( $context = 'view' ) {
1050
+        return $this->get_country( $context );
1051 1051
     }
1052 1052
 
1053 1053
     /**
1054
-	 * Alias of self::get_country().
1055
-	 *
1056
-	 * @since 1.0.19
1057
-	 * @param  string $context View or edit context.
1058
-	 * @return string
1059
-	 */
1060
-	public function get_customer_country( $context = 'view' ) {
1061
-		return $this->get_country( $context );
1054
+     * Alias of self::get_country().
1055
+     *
1056
+     * @since 1.0.19
1057
+     * @param  string $context View or edit context.
1058
+     * @return string
1059
+     */
1060
+    public function get_customer_country( $context = 'view' ) {
1061
+        return $this->get_country( $context );
1062 1062
     }
1063 1063
 
1064 1064
     /**
1065
-	 * Get the customer's state.
1066
-	 *
1067
-	 * @since 1.0.19
1068
-	 * @param  string $context View or edit context.
1069
-	 * @return string
1070
-	 */
1071
-	public function get_state( $context = 'view' ) {
1072
-		$state = $this->get_prop( 'state', $context );
1073
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1065
+     * Get the customer's state.
1066
+     *
1067
+     * @since 1.0.19
1068
+     * @param  string $context View or edit context.
1069
+     * @return string
1070
+     */
1071
+    public function get_state( $context = 'view' ) {
1072
+        $state = $this->get_prop( 'state', $context );
1073
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1074 1074
     }
1075 1075
 
1076 1076
     /**
1077
-	 * Alias of self::get_state().
1078
-	 *
1079
-	 * @since 1.0.19
1080
-	 * @param  string $context View or edit context.
1081
-	 * @return string
1082
-	 */
1083
-	public function get_user_state( $context = 'view' ) {
1084
-		return $this->get_state( $context );
1077
+     * Alias of self::get_state().
1078
+     *
1079
+     * @since 1.0.19
1080
+     * @param  string $context View or edit context.
1081
+     * @return string
1082
+     */
1083
+    public function get_user_state( $context = 'view' ) {
1084
+        return $this->get_state( $context );
1085 1085
     }
1086 1086
 
1087 1087
     /**
1088
-	 * Alias of self::get_state().
1089
-	 *
1090
-	 * @since 1.0.19
1091
-	 * @param  string $context View or edit context.
1092
-	 * @return string
1093
-	 */
1094
-	public function get_customer_state( $context = 'view' ) {
1095
-		return $this->get_state( $context );
1088
+     * Alias of self::get_state().
1089
+     *
1090
+     * @since 1.0.19
1091
+     * @param  string $context View or edit context.
1092
+     * @return string
1093
+     */
1094
+    public function get_customer_state( $context = 'view' ) {
1095
+        return $this->get_state( $context );
1096 1096
     }
1097 1097
 
1098 1098
     /**
1099
-	 * Get the customer's city.
1100
-	 *
1101
-	 * @since 1.0.19
1102
-	 * @param  string $context View or edit context.
1103
-	 * @return string
1104
-	 */
1105
-	public function get_city( $context = 'view' ) {
1106
-		return $this->get_prop( 'city', $context );
1099
+     * Get the customer's city.
1100
+     *
1101
+     * @since 1.0.19
1102
+     * @param  string $context View or edit context.
1103
+     * @return string
1104
+     */
1105
+    public function get_city( $context = 'view' ) {
1106
+        return $this->get_prop( 'city', $context );
1107 1107
     }
1108 1108
 
1109 1109
     /**
1110
-	 * Alias of self::get_city().
1111
-	 *
1112
-	 * @since 1.0.19
1113
-	 * @param  string $context View or edit context.
1114
-	 * @return string
1115
-	 */
1116
-	public function get_user_city( $context = 'view' ) {
1117
-		return $this->get_city( $context );
1110
+     * Alias of self::get_city().
1111
+     *
1112
+     * @since 1.0.19
1113
+     * @param  string $context View or edit context.
1114
+     * @return string
1115
+     */
1116
+    public function get_user_city( $context = 'view' ) {
1117
+        return $this->get_city( $context );
1118 1118
     }
1119 1119
 
1120 1120
     /**
1121
-	 * Alias of self::get_city().
1122
-	 *
1123
-	 * @since 1.0.19
1124
-	 * @param  string $context View or edit context.
1125
-	 * @return string
1126
-	 */
1127
-	public function get_customer_city( $context = 'view' ) {
1128
-		return $this->get_city( $context );
1121
+     * Alias of self::get_city().
1122
+     *
1123
+     * @since 1.0.19
1124
+     * @param  string $context View or edit context.
1125
+     * @return string
1126
+     */
1127
+    public function get_customer_city( $context = 'view' ) {
1128
+        return $this->get_city( $context );
1129 1129
     }
1130 1130
 
1131 1131
     /**
1132
-	 * Get the customer's zip.
1133
-	 *
1134
-	 * @since 1.0.19
1135
-	 * @param  string $context View or edit context.
1136
-	 * @return string
1137
-	 */
1138
-	public function get_zip( $context = 'view' ) {
1139
-		return $this->get_prop( 'zip', $context );
1132
+     * Get the customer's zip.
1133
+     *
1134
+     * @since 1.0.19
1135
+     * @param  string $context View or edit context.
1136
+     * @return string
1137
+     */
1138
+    public function get_zip( $context = 'view' ) {
1139
+        return $this->get_prop( 'zip', $context );
1140 1140
     }
1141 1141
 
1142 1142
     /**
1143
-	 * Alias of self::get_zip().
1144
-	 *
1145
-	 * @since 1.0.19
1146
-	 * @param  string $context View or edit context.
1147
-	 * @return string
1148
-	 */
1149
-	public function get_user_zip( $context = 'view' ) {
1150
-		return $this->get_zip( $context );
1143
+     * Alias of self::get_zip().
1144
+     *
1145
+     * @since 1.0.19
1146
+     * @param  string $context View or edit context.
1147
+     * @return string
1148
+     */
1149
+    public function get_user_zip( $context = 'view' ) {
1150
+        return $this->get_zip( $context );
1151 1151
     }
1152 1152
 
1153 1153
     /**
1154
-	 * Alias of self::get_zip().
1155
-	 *
1156
-	 * @since 1.0.19
1157
-	 * @param  string $context View or edit context.
1158
-	 * @return string
1159
-	 */
1160
-	public function get_customer_zip( $context = 'view' ) {
1161
-		return $this->get_zip( $context );
1154
+     * Alias of self::get_zip().
1155
+     *
1156
+     * @since 1.0.19
1157
+     * @param  string $context View or edit context.
1158
+     * @return string
1159
+     */
1160
+    public function get_customer_zip( $context = 'view' ) {
1161
+        return $this->get_zip( $context );
1162 1162
     }
1163 1163
 
1164 1164
     /**
1165
-	 * Get the customer's company.
1166
-	 *
1167
-	 * @since 1.0.19
1168
-	 * @param  string $context View or edit context.
1169
-	 * @return string
1170
-	 */
1171
-	public function get_company( $context = 'view' ) {
1172
-		return $this->get_prop( 'company', $context );
1165
+     * Get the customer's company.
1166
+     *
1167
+     * @since 1.0.19
1168
+     * @param  string $context View or edit context.
1169
+     * @return string
1170
+     */
1171
+    public function get_company( $context = 'view' ) {
1172
+        return $this->get_prop( 'company', $context );
1173 1173
     }
1174 1174
 
1175 1175
     /**
1176
-	 * Alias of self::get_company().
1177
-	 *
1178
-	 * @since 1.0.19
1179
-	 * @param  string $context View or edit context.
1180
-	 * @return string
1181
-	 */
1182
-	public function get_user_company( $context = 'view' ) {
1183
-		return $this->get_company( $context );
1176
+     * Alias of self::get_company().
1177
+     *
1178
+     * @since 1.0.19
1179
+     * @param  string $context View or edit context.
1180
+     * @return string
1181
+     */
1182
+    public function get_user_company( $context = 'view' ) {
1183
+        return $this->get_company( $context );
1184
+    }
1185
+
1186
+    /**
1187
+     * Alias of self::get_company().
1188
+     *
1189
+     * @since 1.0.19
1190
+     * @param  string $context View or edit context.
1191
+     * @return string
1192
+     */
1193
+    public function get_customer_company( $context = 'view' ) {
1194
+        return $this->get_company( $context );
1184 1195
     }
1185 1196
 
1186 1197
     /**
1187
-	 * Alias of self::get_company().
1188
-	 *
1189
-	 * @since 1.0.19
1190
-	 * @param  string $context View or edit context.
1191
-	 * @return string
1192
-	 */
1193
-	public function get_customer_company( $context = 'view' ) {
1194
-		return $this->get_company( $context );
1198
+     * Get the customer's company id.
1199
+     *
1200
+     * @since 1.0.19
1201
+     * @param  string $context View or edit context.
1202
+     * @return string
1203
+     */
1204
+    public function get_company_id( $context = 'view' ) {
1205
+        return $this->get_prop( 'company_id', $context );
1206
+    }
1207
+
1208
+    /**
1209
+     * Get the customer's vat number.
1210
+     *
1211
+     * @since 1.0.19
1212
+     * @param  string $context View or edit context.
1213
+     * @return string
1214
+     */
1215
+    public function get_vat_number( $context = 'view' ) {
1216
+        return $this->get_prop( 'vat_number', $context );
1195 1217
     }
1196 1218
 
1197
-	/**
1198
-	 * Get the customer's company id.
1199
-	 *
1200
-	 * @since 1.0.19
1201
-	 * @param  string $context View or edit context.
1202
-	 * @return string
1203
-	 */
1204
-	public function get_company_id( $context = 'view' ) {
1205
-		return $this->get_prop( 'company_id', $context );
1219
+    /**
1220
+     * Alias of self::get_vat_number().
1221
+     *
1222
+     * @since 1.0.19
1223
+     * @param  string $context View or edit context.
1224
+     * @return string
1225
+     */
1226
+    public function get_user_vat_number( $context = 'view' ) {
1227
+        return $this->get_vat_number( $context );
1206 1228
     }
1207 1229
 
1208 1230
     /**
1209
-	 * Get the customer's vat number.
1210
-	 *
1211
-	 * @since 1.0.19
1212
-	 * @param  string $context View or edit context.
1213
-	 * @return string
1214
-	 */
1215
-	public function get_vat_number( $context = 'view' ) {
1216
-		return $this->get_prop( 'vat_number', $context );
1231
+     * Alias of self::get_vat_number().
1232
+     *
1233
+     * @since 1.0.19
1234
+     * @param  string $context View or edit context.
1235
+     * @return string
1236
+     */
1237
+    public function get_customer_vat_number( $context = 'view' ) {
1238
+        return $this->get_vat_number( $context );
1217 1239
     }
1218 1240
 
1219 1241
     /**
1220
-	 * Alias of self::get_vat_number().
1221
-	 *
1222
-	 * @since 1.0.19
1223
-	 * @param  string $context View or edit context.
1224
-	 * @return string
1225
-	 */
1226
-	public function get_user_vat_number( $context = 'view' ) {
1227
-		return $this->get_vat_number( $context );
1242
+     * Get the customer's vat rate.
1243
+     *
1244
+     * @since 1.0.19
1245
+     * @param  string $context View or edit context.
1246
+     * @return string
1247
+     */
1248
+    public function get_vat_rate( $context = 'view' ) {
1249
+        return $this->get_prop( 'vat_rate', $context );
1228 1250
     }
1229 1251
 
1230 1252
     /**
1231
-	 * Alias of self::get_vat_number().
1232
-	 *
1233
-	 * @since 1.0.19
1234
-	 * @param  string $context View or edit context.
1235
-	 * @return string
1236
-	 */
1237
-	public function get_customer_vat_number( $context = 'view' ) {
1238
-		return $this->get_vat_number( $context );
1253
+     * Alias of self::get_vat_rate().
1254
+     *
1255
+     * @since 1.0.19
1256
+     * @param  string $context View or edit context.
1257
+     * @return string
1258
+     */
1259
+    public function get_user_vat_rate( $context = 'view' ) {
1260
+        return $this->get_vat_rate( $context );
1239 1261
     }
1240 1262
 
1241
-    /**
1242
-	 * Get the customer's vat rate.
1243
-	 *
1244
-	 * @since 1.0.19
1245
-	 * @param  string $context View or edit context.
1246
-	 * @return string
1247
-	 */
1248
-	public function get_vat_rate( $context = 'view' ) {
1249
-		return $this->get_prop( 'vat_rate', $context );
1250
-    }
1251
-
1252
-    /**
1253
-	 * Alias of self::get_vat_rate().
1254
-	 *
1255
-	 * @since 1.0.19
1256
-	 * @param  string $context View or edit context.
1257
-	 * @return string
1258
-	 */
1259
-	public function get_user_vat_rate( $context = 'view' ) {
1260
-		return $this->get_vat_rate( $context );
1261
-    }
1262
-
1263
-    /**
1264
-	 * Alias of self::get_vat_rate().
1265
-	 *
1266
-	 * @since 1.0.19
1267
-	 * @param  string $context View or edit context.
1268
-	 * @return string
1269
-	 */
1270
-	public function get_customer_vat_rate( $context = 'view' ) {
1271
-		return $this->get_vat_rate( $context );
1272
-    }
1273
-
1274
-    /**
1275
-	 * Get the customer's address.
1276
-	 *
1277
-	 * @since 1.0.19
1278
-	 * @param  string $context View or edit context.
1279
-	 * @return string
1280
-	 */
1281
-	public function get_address( $context = 'view' ) {
1282
-		return $this->get_prop( 'address', $context );
1283
-    }
1284
-
1285
-    /**
1286
-	 * Alias of self::get_address().
1287
-	 *
1288
-	 * @since 1.0.19
1289
-	 * @param  string $context View or edit context.
1290
-	 * @return string
1291
-	 */
1292
-	public function get_user_address( $context = 'view' ) {
1293
-		return $this->get_address( $context );
1294
-    }
1295
-
1296
-    /**
1297
-	 * Alias of self::get_address().
1298
-	 *
1299
-	 * @since 1.0.19
1300
-	 * @param  string $context View or edit context.
1301
-	 * @return string
1302
-	 */
1303
-	public function get_customer_address( $context = 'view' ) {
1304
-		return $this->get_address( $context );
1305
-    }
1306
-
1307
-    /**
1308
-	 * Get whether the customer has viewed the invoice or not.
1309
-	 *
1310
-	 * @since 1.0.19
1311
-	 * @param  string $context View or edit context.
1312
-	 * @return bool
1313
-	 */
1314
-	public function get_is_viewed( $context = 'view' ) {
1315
-		return (bool) $this->get_prop( 'is_viewed', $context );
1316
-	}
1317
-
1318
-	/**
1319
-	 * Get other recipients for invoice communications.
1320
-	 *
1321
-	 * @since 1.0.19
1322
-	 * @param  string $context View or edit context.
1323
-	 * @return bool
1324
-	 */
1325
-	public function get_email_cc( $context = 'view' ) {
1326
-		return $this->get_prop( 'email_cc', $context );
1327
-	}
1328
-
1329
-	/**
1330
-	 * Get invoice template.
1331
-	 *
1332
-	 * @since 1.0.19
1333
-	 * @param  string $context View or edit context.
1334
-	 * @return bool
1335
-	 */
1336
-	public function get_template( $context = 'view' ) {
1337
-		return $this->get_prop( 'template', $context );
1338
-	}
1339
-
1340
-	/**
1341
-	 * Get invoice source.
1342
-	 *
1343
-	 * @since 1.0.19
1344
-	 * @param  string $context View or edit context.
1345
-	 * @return bool
1346
-	 */
1347
-	public function get_created_via( $context = 'view' ) {
1348
-		return $this->get_prop( 'created_via', $context );
1349
-	}
1350
-
1351
-	/**
1352
-	 * Get whether the customer has confirmed their address.
1353
-	 *
1354
-	 * @since 1.0.19
1355
-	 * @param  string $context View or edit context.
1356
-	 * @return bool
1357
-	 */
1358
-	public function get_address_confirmed( $context = 'view' ) {
1359
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1360
-    }
1361
-
1362
-    /**
1363
-	 * Alias of self::get_address_confirmed().
1364
-	 *
1365
-	 * @since 1.0.19
1366
-	 * @param  string $context View or edit context.
1367
-	 * @return bool
1368
-	 */
1369
-	public function get_user_address_confirmed( $context = 'view' ) {
1370
-		return $this->get_address_confirmed( $context );
1371
-    }
1372
-
1373
-    /**
1374
-	 * Alias of self::get_address().
1375
-	 *
1376
-	 * @since 1.0.19
1377
-	 * @param  string $context View or edit context.
1378
-	 * @return bool
1379
-	 */
1380
-	public function get_customer_address_confirmed( $context = 'view' ) {
1381
-		return $this->get_address_confirmed( $context );
1382
-    }
1383
-
1384
-	/**
1385
-	 * Get the shipping address.
1386
-	 *
1387
-	 * @since 1.0.19
1388
-	 * @return array|false
1389
-	 */
1390
-	public function get_shipping_address() {
1391
-
1392
-		$shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1393
-		return is_array( $shipping_address ) ? $shipping_address : false;
1394
-    }
1395
-
1396
-	/**
1397
-	 * Check if the invoice has a shipping address.
1398
-	 */
1399
-	public function has_shipping_address() {
1400
-		return false !== $this->get_shipping_address();
1401
-    }
1402
-
1403
-	/**
1404
-	 * Get the shipping amount.
1405
-	 *
1406
-	 * @since 1.0.19
1407
-	 * @param  string $context View or edit context.
1408
-	 * @return float
1409
-	 */
1410
-	public function get_shipping( $context = 'view' ) {
1411
-
1412
-		if ( $context = 'view' ) {
1413
-			return floatval( $this->get_prop( 'shipping', $context ) );
1414
-		}
1415
-
1416
-		return $this->get_prop( 'shipping', $context );
1417
-    }
1418
-
1419
-	public function has_shipping() {
1420
-		return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' );
1421
-    }
1422
-
1423
-    /**
1424
-	 * Get the invoice subtotal.
1425
-	 *
1426
-	 * @since 1.0.19
1427
-	 * @param  string $context View or edit context.
1428
-	 * @return float
1429
-	 */
1430
-	public function get_subtotal( $context = 'view' ) {
1263
+    /**
1264
+     * Alias of self::get_vat_rate().
1265
+     *
1266
+     * @since 1.0.19
1267
+     * @param  string $context View or edit context.
1268
+     * @return string
1269
+     */
1270
+    public function get_customer_vat_rate( $context = 'view' ) {
1271
+        return $this->get_vat_rate( $context );
1272
+    }
1273
+
1274
+    /**
1275
+     * Get the customer's address.
1276
+     *
1277
+     * @since 1.0.19
1278
+     * @param  string $context View or edit context.
1279
+     * @return string
1280
+     */
1281
+    public function get_address( $context = 'view' ) {
1282
+        return $this->get_prop( 'address', $context );
1283
+    }
1284
+
1285
+    /**
1286
+     * Alias of self::get_address().
1287
+     *
1288
+     * @since 1.0.19
1289
+     * @param  string $context View or edit context.
1290
+     * @return string
1291
+     */
1292
+    public function get_user_address( $context = 'view' ) {
1293
+        return $this->get_address( $context );
1294
+    }
1295
+
1296
+    /**
1297
+     * Alias of self::get_address().
1298
+     *
1299
+     * @since 1.0.19
1300
+     * @param  string $context View or edit context.
1301
+     * @return string
1302
+     */
1303
+    public function get_customer_address( $context = 'view' ) {
1304
+        return $this->get_address( $context );
1305
+    }
1306
+
1307
+    /**
1308
+     * Get whether the customer has viewed the invoice or not.
1309
+     *
1310
+     * @since 1.0.19
1311
+     * @param  string $context View or edit context.
1312
+     * @return bool
1313
+     */
1314
+    public function get_is_viewed( $context = 'view' ) {
1315
+        return (bool) $this->get_prop( 'is_viewed', $context );
1316
+    }
1317
+
1318
+    /**
1319
+     * Get other recipients for invoice communications.
1320
+     *
1321
+     * @since 1.0.19
1322
+     * @param  string $context View or edit context.
1323
+     * @return bool
1324
+     */
1325
+    public function get_email_cc( $context = 'view' ) {
1326
+        return $this->get_prop( 'email_cc', $context );
1327
+    }
1328
+
1329
+    /**
1330
+     * Get invoice template.
1331
+     *
1332
+     * @since 1.0.19
1333
+     * @param  string $context View or edit context.
1334
+     * @return bool
1335
+     */
1336
+    public function get_template( $context = 'view' ) {
1337
+        return $this->get_prop( 'template', $context );
1338
+    }
1339
+
1340
+    /**
1341
+     * Get invoice source.
1342
+     *
1343
+     * @since 1.0.19
1344
+     * @param  string $context View or edit context.
1345
+     * @return bool
1346
+     */
1347
+    public function get_created_via( $context = 'view' ) {
1348
+        return $this->get_prop( 'created_via', $context );
1349
+    }
1350
+
1351
+    /**
1352
+     * Get whether the customer has confirmed their address.
1353
+     *
1354
+     * @since 1.0.19
1355
+     * @param  string $context View or edit context.
1356
+     * @return bool
1357
+     */
1358
+    public function get_address_confirmed( $context = 'view' ) {
1359
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1360
+    }
1361
+
1362
+    /**
1363
+     * Alias of self::get_address_confirmed().
1364
+     *
1365
+     * @since 1.0.19
1366
+     * @param  string $context View or edit context.
1367
+     * @return bool
1368
+     */
1369
+    public function get_user_address_confirmed( $context = 'view' ) {
1370
+        return $this->get_address_confirmed( $context );
1371
+    }
1372
+
1373
+    /**
1374
+     * Alias of self::get_address().
1375
+     *
1376
+     * @since 1.0.19
1377
+     * @param  string $context View or edit context.
1378
+     * @return bool
1379
+     */
1380
+    public function get_customer_address_confirmed( $context = 'view' ) {
1381
+        return $this->get_address_confirmed( $context );
1382
+    }
1383
+
1384
+    /**
1385
+     * Get the shipping address.
1386
+     *
1387
+     * @since 1.0.19
1388
+     * @return array|false
1389
+     */
1390
+    public function get_shipping_address() {
1391
+
1392
+        $shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1393
+        return is_array( $shipping_address ) ? $shipping_address : false;
1394
+    }
1395
+
1396
+    /**
1397
+     * Check if the invoice has a shipping address.
1398
+     */
1399
+    public function has_shipping_address() {
1400
+        return false !== $this->get_shipping_address();
1401
+    }
1402
+
1403
+    /**
1404
+     * Get the shipping amount.
1405
+     *
1406
+     * @since 1.0.19
1407
+     * @param  string $context View or edit context.
1408
+     * @return float
1409
+     */
1410
+    public function get_shipping( $context = 'view' ) {
1411
+
1412
+        if ( $context = 'view' ) {
1413
+            return floatval( $this->get_prop( 'shipping', $context ) );
1414
+        }
1415
+
1416
+        return $this->get_prop( 'shipping', $context );
1417
+    }
1418
+
1419
+    public function has_shipping() {
1420
+        return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' );
1421
+    }
1422
+
1423
+    /**
1424
+     * Get the invoice subtotal.
1425
+     *
1426
+     * @since 1.0.19
1427
+     * @param  string $context View or edit context.
1428
+     * @return float
1429
+     */
1430
+    public function get_subtotal( $context = 'view' ) {
1431 1431
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1432 1432
 
1433 1433
         // Backwards compatibility.
@@ -1439,198 +1439,198 @@  discard block
 block discarded – undo
1439 1439
     }
1440 1440
 
1441 1441
     /**
1442
-	 * Get the invoice discount total.
1443
-	 *
1444
-	 * @since 1.0.19
1445
-	 * @param  string $context View or edit context.
1446
-	 * @return float
1447
-	 */
1448
-	public function get_total_discount( $context = 'view' ) {
1449
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1442
+     * Get the invoice discount total.
1443
+     *
1444
+     * @since 1.0.19
1445
+     * @param  string $context View or edit context.
1446
+     * @return float
1447
+     */
1448
+    public function get_total_discount( $context = 'view' ) {
1449
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1450 1450
     }
1451 1451
 
1452 1452
     /**
1453
-	 * Get the invoice tax total.
1454
-	 *
1455
-	 * @since 1.0.19
1456
-	 * @param  string $context View or edit context.
1457
-	 * @return float
1458
-	 */
1459
-	public function get_total_tax( $context = 'view' ) {
1460
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1461
-	}
1453
+     * Get the invoice tax total.
1454
+     *
1455
+     * @since 1.0.19
1456
+     * @param  string $context View or edit context.
1457
+     * @return float
1458
+     */
1459
+    public function get_total_tax( $context = 'view' ) {
1460
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1461
+    }
1462 1462
 
1463
-	/**
1464
-	 * @deprecated
1465
-	 */
1466
-	public function get_final_tax( $currency = false ) {
1467
-		$tax = $this->get_total_tax();
1463
+    /**
1464
+     * @deprecated
1465
+     */
1466
+    public function get_final_tax( $currency = false ) {
1467
+        $tax = $this->get_total_tax();
1468 1468
 
1469 1469
         if ( $currency ) {
1470
-			return wpinv_price( $tax, $this->get_currency() );
1470
+            return wpinv_price( $tax, $this->get_currency() );
1471 1471
         }
1472 1472
 
1473 1473
         return $tax;
1474 1474
     }
1475 1475
 
1476 1476
     /**
1477
-	 * Get the invoice fees total.
1478
-	 *
1479
-	 * @since 1.0.19
1480
-	 * @param  string $context View or edit context.
1481
-	 * @return float
1482
-	 */
1483
-	public function get_total_fees( $context = 'view' ) {
1484
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1477
+     * Get the invoice fees total.
1478
+     *
1479
+     * @since 1.0.19
1480
+     * @param  string $context View or edit context.
1481
+     * @return float
1482
+     */
1483
+    public function get_total_fees( $context = 'view' ) {
1484
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1485
+    }
1486
+
1487
+    /**
1488
+     * Alias for self::get_total_fees().
1489
+     *
1490
+     * @since 1.0.19
1491
+     * @param  string $context View or edit context.
1492
+     * @return float
1493
+     */
1494
+    public function get_fees_total( $context = 'view' ) {
1495
+        return $this->get_total_fees( $context );
1485 1496
     }
1486 1497
 
1487 1498
     /**
1488
-	 * Alias for self::get_total_fees().
1489
-	 *
1490
-	 * @since 1.0.19
1491
-	 * @param  string $context View or edit context.
1492
-	 * @return float
1493
-	 */
1494
-	public function get_fees_total( $context = 'view' ) {
1495
-		return $this->get_total_fees( $context );
1499
+     * Get the invoice total.
1500
+     *
1501
+     * @since 1.0.19
1502
+     * @return float
1503
+     */
1504
+    public function get_total( $context = 'view' ) {
1505
+        $total = $this->get_prop( 'total', $context );
1506
+
1507
+        if ( $this->has_shipping() && $context == 'view' ) {
1508
+            $total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1509
+        }
1510
+
1511
+        return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1496 1512
     }
1497 1513
 
1498 1514
     /**
1499
-	 * Get the invoice total.
1500
-	 *
1501
-	 * @since 1.0.19
1515
+     * Retrieves the non-recurring total of items.
1516
+     *
1517
+     * @since 2.3.0
1502 1518
      * @return float
1503
-	 */
1504
-	public function get_total( $context = 'view' ) {
1505
-		$total = $this->get_prop( 'total', $context );
1506
-
1507
-		if ( $this->has_shipping() && $context == 'view' ) {
1508
-			$total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1509
-		}
1510
-
1511
-		return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1512
-	}
1513
-
1514
-	/**
1515
-	 * Retrieves the non-recurring total of items.
1516
-	 *
1517
-	 * @since 2.3.0
1518
-	 * @return float
1519
-	 */
1520
-	public function get_non_recurring_total() {
1521
-
1522
-		$subtotal = 0;
1523
-		foreach ( $this->get_items() as $item ) {
1524
-			if ( ! $item->is_recurring() ) {
1525
-				$subtotal += $item->get_sub_total();
1526
-			}
1527
-		}
1528
-
1529
-		foreach ( $this->get_fees() as $fee ) {
1530
-			if ( empty( $fee['recurring_fee'] ) ) {
1531
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1532
-			}
1533
-		}
1534
-
1535
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1519
+     */
1520
+    public function get_non_recurring_total() {
1521
+
1522
+        $subtotal = 0;
1523
+        foreach ( $this->get_items() as $item ) {
1524
+            if ( ! $item->is_recurring() ) {
1525
+                $subtotal += $item->get_sub_total();
1526
+            }
1527
+        }
1528
+
1529
+        foreach ( $this->get_fees() as $fee ) {
1530
+            if ( empty( $fee['recurring_fee'] ) ) {
1531
+                $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1532
+            }
1533
+        }
1534
+
1535
+        $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1536 1536
         return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1537 1537
 
1538 1538
     }
1539 1539
 
1540
-	/**
1541
-	 * Get the invoice totals.
1542
-	 *
1543
-	 * @since 1.0.19
1540
+    /**
1541
+     * Get the invoice totals.
1542
+     *
1543
+     * @since 1.0.19
1544 1544
      * @return array
1545
-	 */
1546
-	public function get_totals() {
1547
-		return $this->totals;
1545
+     */
1546
+    public function get_totals() {
1547
+        return $this->totals;
1548 1548
     }
1549 1549
 
1550 1550
     /**
1551
-	 * Get the initial invoice total.
1552
-	 *
1553
-	 * @since 1.0.19
1551
+     * Get the initial invoice total.
1552
+     *
1553
+     * @since 1.0.19
1554 1554
      * @param  string $context View or edit context.
1555 1555
      * @return float
1556
-	 */
1556
+     */
1557 1557
     public function get_initial_total() {
1558 1558
 
1559
-		if ( empty( $this->totals ) ) {
1560
-			$this->recalculate_total();
1561
-		}
1559
+        if ( empty( $this->totals ) ) {
1560
+            $this->recalculate_total();
1561
+        }
1562 1562
 
1563
-		$tax      = $this->totals['tax']['initial'];
1564
-		$fee      = $this->totals['fee']['initial'];
1565
-		$discount = $this->totals['discount']['initial'];
1566
-		$subtotal = $this->totals['subtotal']['initial'];
1567
-		$total    = $tax + $fee - $discount + $subtotal;
1563
+        $tax      = $this->totals['tax']['initial'];
1564
+        $fee      = $this->totals['fee']['initial'];
1565
+        $discount = $this->totals['discount']['initial'];
1566
+        $subtotal = $this->totals['subtotal']['initial'];
1567
+        $total    = $tax + $fee - $discount + $subtotal;
1568 1568
 
1569
-		if ( 0 > $total ) {
1570
-			$total = 0;
1571
-		}
1569
+        if ( 0 > $total ) {
1570
+            $total = 0;
1571
+        }
1572 1572
 
1573
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1573
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1574 1574
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1575
-	}
1575
+    }
1576 1576
 
1577
-	/**
1578
-	 * Get the recurring invoice total.
1579
-	 *
1580
-	 * @since 1.0.19
1577
+    /**
1578
+     * Get the recurring invoice total.
1579
+     *
1580
+     * @since 1.0.19
1581 1581
      * @param  string $context View or edit context.
1582 1582
      * @return float
1583
-	 */
1583
+     */
1584 1584
     public function get_recurring_total() {
1585 1585
 
1586
-		if ( empty( $this->totals ) ) {
1587
-			$this->recalculate_total();
1588
-		}
1586
+        if ( empty( $this->totals ) ) {
1587
+            $this->recalculate_total();
1588
+        }
1589 1589
 
1590
-		$tax      = $this->totals['tax']['recurring'];
1591
-		$fee      = $this->totals['fee']['recurring'];
1592
-		$discount = $this->totals['discount']['recurring'];
1593
-		$subtotal = $this->totals['subtotal']['recurring'];
1594
-		$total    = $tax + $fee - $discount + $subtotal;
1590
+        $tax      = $this->totals['tax']['recurring'];
1591
+        $fee      = $this->totals['fee']['recurring'];
1592
+        $discount = $this->totals['discount']['recurring'];
1593
+        $subtotal = $this->totals['subtotal']['recurring'];
1594
+        $total    = $tax + $fee - $discount + $subtotal;
1595 1595
 
1596
-		if ( 0 > $total ) {
1597
-			$total = 0;
1598
-		}
1596
+        if ( 0 > $total ) {
1597
+            $total = 0;
1598
+        }
1599 1599
 
1600
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1600
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1601 1601
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1602
-	}
1602
+    }
1603 1603
 
1604
-	/**
1605
-	 * Returns recurring payment details.
1606
-	 *
1607
-	 * @since 1.0.19
1604
+    /**
1605
+     * Returns recurring payment details.
1606
+     *
1607
+     * @since 1.0.19
1608 1608
      * @param  string $field Optionally provide a field to return.
1609
-	 * @param string $currency Whether to include the currency.
1609
+     * @param string $currency Whether to include the currency.
1610 1610
      * @return float|string
1611
-	 */
1611
+     */
1612 1612
     public function get_recurring_details( $field = '', $currency = false ) {
1613 1613
 
1614
-		// Maybe recalculate totals.
1615
-		if ( empty( $this->totals ) ) {
1616
-			$this->recalculate_total();
1617
-		}
1614
+        // Maybe recalculate totals.
1615
+        if ( empty( $this->totals ) ) {
1616
+            $this->recalculate_total();
1617
+        }
1618 1618
 
1619
-		// Prepare recurring totals.
1619
+        // Prepare recurring totals.
1620 1620
         $data = apply_filters(
1621
-			'wpinv_get_invoice_recurring_details',
1622
-			array(
1623
-				'cart_details' => $this->get_cart_details(),
1624
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1625
-				'discount'     => $this->totals['discount']['recurring'],
1626
-				'tax'          => $this->totals['tax']['recurring'],
1627
-				'fee'          => $this->totals['fee']['recurring'],
1628
-				'total'        => $this->get_recurring_total(),
1629
-			),
1630
-			$this,
1631
-			$field,
1632
-			$currency
1633
-		);
1621
+            'wpinv_get_invoice_recurring_details',
1622
+            array(
1623
+                'cart_details' => $this->get_cart_details(),
1624
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1625
+                'discount'     => $this->totals['discount']['recurring'],
1626
+                'tax'          => $this->totals['tax']['recurring'],
1627
+                'fee'          => $this->totals['fee']['recurring'],
1628
+                'total'        => $this->get_recurring_total(),
1629
+            ),
1630
+            $this,
1631
+            $field,
1632
+            $currency
1633
+        );
1634 1634
 
1635 1635
         if ( isset( $data[ $field ] ) ) {
1636 1636
             return ( $currency ? wpinv_price( $data[ $field ], $this->get_currency() ) : $data[ $field ] );
@@ -1640,166 +1640,166 @@  discard block
 block discarded – undo
1640 1640
     }
1641 1641
 
1642 1642
     /**
1643
-	 * Get the invoice fees.
1644
-	 *
1645
-	 * @since 1.0.19
1646
-	 * @param  string $context View or edit context.
1647
-	 * @return array
1648
-	 */
1649
-	public function get_fees( $context = 'view' ) {
1650
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1643
+     * Get the invoice fees.
1644
+     *
1645
+     * @since 1.0.19
1646
+     * @param  string $context View or edit context.
1647
+     * @return array
1648
+     */
1649
+    public function get_fees( $context = 'view' ) {
1650
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1651 1651
     }
1652 1652
 
1653 1653
     /**
1654
-	 * Get the invoice discounts.
1655
-	 *
1656
-	 * @since 1.0.19
1657
-	 * @param  string $context View or edit context.
1658
-	 * @return array
1659
-	 */
1660
-	public function get_discounts( $context = 'view' ) {
1661
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1654
+     * Get the invoice discounts.
1655
+     *
1656
+     * @since 1.0.19
1657
+     * @param  string $context View or edit context.
1658
+     * @return array
1659
+     */
1660
+    public function get_discounts( $context = 'view' ) {
1661
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1662 1662
     }
1663 1663
 
1664 1664
     /**
1665
-	 * Get the invoice taxes.
1666
-	 *
1667
-	 * @since 1.0.19
1668
-	 * @param  string $context View or edit context.
1669
-	 * @return array
1670
-	 */
1671
-	public function get_taxes( $context = 'view' ) {
1672
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1665
+     * Get the invoice taxes.
1666
+     *
1667
+     * @since 1.0.19
1668
+     * @param  string $context View or edit context.
1669
+     * @return array
1670
+     */
1671
+    public function get_taxes( $context = 'view' ) {
1672
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1673 1673
     }
1674 1674
 
1675 1675
     /**
1676
-	 * Get the invoice items.
1677
-	 *
1678
-	 * @since 1.0.19
1679
-	 * @param  string $context View or edit context.
1680
-	 * @return GetPaid_Form_Item[]
1681
-	 */
1682
-	public function get_items( $context = 'view' ) {
1676
+     * Get the invoice items.
1677
+     *
1678
+     * @since 1.0.19
1679
+     * @param  string $context View or edit context.
1680
+     * @return GetPaid_Form_Item[]
1681
+     */
1682
+    public function get_items( $context = 'view' ) {
1683 1683
         return $this->get_prop( 'items', $context );
1684
-	}
1684
+    }
1685 1685
 
1686
-	/**
1687
-	 * Get the invoice item ids.
1688
-	 *
1689
-	 * @since 1.0.19
1690
-	 * @return string
1691
-	 */
1692
-	public function get_item_ids() {
1693
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1686
+    /**
1687
+     * Get the invoice item ids.
1688
+     *
1689
+     * @since 1.0.19
1690
+     * @return string
1691
+     */
1692
+    public function get_item_ids() {
1693
+        return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1694 1694
     }
1695 1695
 
1696 1696
     /**
1697
-	 * Get the invoice's payment form.
1698
-	 *
1699
-	 * @since 1.0.19
1700
-	 * @param  string $context View or edit context.
1701
-	 * @return int
1702
-	 */
1703
-	public function get_payment_form( $context = 'view' ) {
1704
-		return intval( $this->get_prop( 'payment_form', $context ) );
1697
+     * Get the invoice's payment form.
1698
+     *
1699
+     * @since 1.0.19
1700
+     * @param  string $context View or edit context.
1701
+     * @return int
1702
+     */
1703
+    public function get_payment_form( $context = 'view' ) {
1704
+        return intval( $this->get_prop( 'payment_form', $context ) );
1705 1705
     }
1706 1706
 
1707 1707
     /**
1708
-	 * Get the invoice's submission id.
1709
-	 *
1710
-	 * @since 1.0.19
1711
-	 * @param  string $context View or edit context.
1712
-	 * @return string
1713
-	 */
1714
-	public function get_submission_id( $context = 'view' ) {
1715
-		return $this->get_prop( 'submission_id', $context );
1708
+     * Get the invoice's submission id.
1709
+     *
1710
+     * @since 1.0.19
1711
+     * @param  string $context View or edit context.
1712
+     * @return string
1713
+     */
1714
+    public function get_submission_id( $context = 'view' ) {
1715
+        return $this->get_prop( 'submission_id', $context );
1716 1716
     }
1717 1717
 
1718 1718
     /**
1719
-	 * Get the invoice's discount code.
1720
-	 *
1721
-	 * @since 1.0.19
1722
-	 * @param  string $context View or edit context.
1723
-	 * @return string
1724
-	 */
1725
-	public function get_discount_code( $context = 'view' ) {
1726
-		return $this->get_prop( 'discount_code', $context );
1719
+     * Get the invoice's discount code.
1720
+     *
1721
+     * @since 1.0.19
1722
+     * @param  string $context View or edit context.
1723
+     * @return string
1724
+     */
1725
+    public function get_discount_code( $context = 'view' ) {
1726
+        return $this->get_prop( 'discount_code', $context );
1727 1727
     }
1728 1728
 
1729 1729
     /**
1730
-	 * Get the invoice's gateway.
1731
-	 *
1732
-	 * @since 1.0.19
1733
-	 * @param  string $context View or edit context.
1734
-	 * @return string
1735
-	 */
1736
-	public function get_gateway( $context = 'view' ) {
1737
-		return $this->get_prop( 'gateway', $context );
1730
+     * Get the invoice's gateway.
1731
+     *
1732
+     * @since 1.0.19
1733
+     * @param  string $context View or edit context.
1734
+     * @return string
1735
+     */
1736
+    public function get_gateway( $context = 'view' ) {
1737
+        return $this->get_prop( 'gateway', $context );
1738 1738
     }
1739 1739
 
1740 1740
     /**
1741
-	 * Get the invoice's gateway display title.
1742
-	 *
1743
-	 * @since 1.0.19
1744
-	 * @return string
1745
-	 */
1741
+     * Get the invoice's gateway display title.
1742
+     *
1743
+     * @since 1.0.19
1744
+     * @return string
1745
+     */
1746 1746
     public function get_gateway_title() {
1747 1747
         $title = wpinv_get_gateway_checkout_label( $this->get_gateway() );
1748 1748
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1749 1749
     }
1750 1750
 
1751 1751
     /**
1752
-	 * Get the invoice's transaction id.
1753
-	 *
1754
-	 * @since 1.0.19
1755
-	 * @param  string $context View or edit context.
1756
-	 * @return string
1757
-	 */
1758
-	public function get_transaction_id( $context = 'view' ) {
1759
-		return $this->get_prop( 'transaction_id', $context );
1752
+     * Get the invoice's transaction id.
1753
+     *
1754
+     * @since 1.0.19
1755
+     * @param  string $context View or edit context.
1756
+     * @return string
1757
+     */
1758
+    public function get_transaction_id( $context = 'view' ) {
1759
+        return $this->get_prop( 'transaction_id', $context );
1760 1760
     }
1761 1761
 
1762 1762
     /**
1763
-	 * Get the invoice's currency.
1764
-	 *
1765
-	 * @since 1.0.19
1766
-	 * @param  string $context View or edit context.
1767
-	 * @return string
1768
-	 */
1769
-	public function get_currency( $context = 'view' ) {
1763
+     * Get the invoice's currency.
1764
+     *
1765
+     * @since 1.0.19
1766
+     * @param  string $context View or edit context.
1767
+     * @return string
1768
+     */
1769
+    public function get_currency( $context = 'view' ) {
1770 1770
         $currency = $this->get_prop( 'currency', $context );
1771 1771
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1772 1772
     }
1773 1773
 
1774 1774
     /**
1775
-	 * Checks if we are charging taxes for this invoice.
1776
-	 *
1777
-	 * @since 1.0.19
1778
-	 * @param  string $context View or edit context.
1779
-	 * @return bool
1780
-	 */
1781
-	public function get_disable_taxes( $context = 'view' ) {
1775
+     * Checks if we are charging taxes for this invoice.
1776
+     *
1777
+     * @since 1.0.19
1778
+     * @param  string $context View or edit context.
1779
+     * @return bool
1780
+     */
1781
+    public function get_disable_taxes( $context = 'view' ) {
1782 1782
         return (bool) $this->get_prop( 'disable_taxes', $context );
1783 1783
     }
1784 1784
 
1785 1785
     /**
1786
-	 * Retrieves the subscription id for an invoice.
1787
-	 *
1788
-	 * @since 1.0.19
1789
-	 * @param  string $context View or edit context.
1790
-	 * @return int
1791
-	 */
1786
+     * Retrieves the subscription id for an invoice.
1787
+     *
1788
+     * @since 1.0.19
1789
+     * @param  string $context View or edit context.
1790
+     * @return int
1791
+     */
1792 1792
     public function get_subscription_id( $context = 'view' ) {
1793
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1794
-	}
1795
-
1796
-	/**
1797
-	 * Retrieves the remote subscription id for an invoice.
1798
-	 *
1799
-	 * @since 1.0.19
1800
-	 * @param  string $context View or edit context.
1801
-	 * @return int
1802
-	 */
1793
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1794
+    }
1795
+
1796
+    /**
1797
+     * Retrieves the remote subscription id for an invoice.
1798
+     *
1799
+     * @since 1.0.19
1800
+     * @param  string $context View or edit context.
1801
+     * @return int
1802
+     */
1803 1803
     public function get_remote_subscription_id( $context = 'view' ) {
1804 1804
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1805 1805
 
@@ -1812,12 +1812,12 @@  discard block
 block discarded – undo
1812 1812
     }
1813 1813
 
1814 1814
     /**
1815
-	 * Retrieves the payment meta for an invoice.
1816
-	 *
1817
-	 * @since 1.0.19
1818
-	 * @param  string $context View or edit context.
1819
-	 * @return array
1820
-	 */
1815
+     * Retrieves the payment meta for an invoice.
1816
+     *
1817
+     * @since 1.0.19
1818
+     * @param  string $context View or edit context.
1819
+     * @return array
1820
+     */
1821 1821
     public function get_payment_meta( $context = 'view' ) {
1822 1822
 
1823 1823
         return array(
@@ -1837,31 +1837,31 @@  discard block
 block discarded – undo
1837 1837
     }
1838 1838
 
1839 1839
     /**
1840
-	 * Retrieves the cart details for an invoice.
1841
-	 *
1842
-	 * @since 1.0.19
1843
-	 * @return array
1844
-	 */
1840
+     * Retrieves the cart details for an invoice.
1841
+     *
1842
+     * @since 1.0.19
1843
+     * @return array
1844
+     */
1845 1845
     public function get_cart_details() {
1846 1846
         $items        = $this->get_items();
1847 1847
         $cart_details = array();
1848 1848
 
1849 1849
         foreach ( $items as $item ) {
1850
-			$item->invoice_id = $this->get_id();
1850
+            $item->invoice_id = $this->get_id();
1851 1851
             $cart_details[]   = $item->prepare_data_for_saving();
1852 1852
         }
1853 1853
 
1854 1854
         return $cart_details;
1855
-	}
1855
+    }
1856 1856
 
1857
-	/**
1858
-	 * Retrieves the recurring item.
1859
-	 *
1860
-	 * @return null|GetPaid_Form_Item|int
1861
-	 */
1862
-	public function get_recurring( $object = false ) {
1857
+    /**
1858
+     * Retrieves the recurring item.
1859
+     *
1860
+     * @return null|GetPaid_Form_Item|int
1861
+     */
1862
+    public function get_recurring( $object = false ) {
1863 1863
 
1864
-		// Are we returning an object?
1864
+        // Are we returning an object?
1865 1865
         if ( $object ) {
1866 1866
             return $this->get_item( $this->recurring_item );
1867 1867
         }
@@ -1869,130 +1869,130 @@  discard block
 block discarded – undo
1869 1869
         return $this->recurring_item;
1870 1870
     }
1871 1871
 
1872
-	/**
1873
-	 * Retrieves the subscription name.
1874
-	 *
1875
-	 * @since 1.0.19
1876
-	 * @return string
1877
-	 */
1878
-	public function get_subscription_name() {
1872
+    /**
1873
+     * Retrieves the subscription name.
1874
+     *
1875
+     * @since 1.0.19
1876
+     * @return string
1877
+     */
1878
+    public function get_subscription_name() {
1879 1879
 
1880
-		// Retrieve the recurring name
1880
+        // Retrieve the recurring name
1881 1881
         $item = $this->get_recurring( true );
1882 1882
 
1883
-		// Abort if it does not exist.
1883
+        // Abort if it does not exist.
1884 1884
         if ( empty( $item ) ) {
1885 1885
             return '';
1886 1886
         }
1887 1887
 
1888
-		// Return the item name.
1888
+        // Return the item name.
1889 1889
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1890
-	}
1891
-
1892
-	/**
1893
-	 * Retrieves the view url.
1894
-	 *
1895
-	 * @since 1.0.19
1896
-	 * @return string
1897
-	 */
1898
-	public function get_view_url() {
1890
+    }
1891
+
1892
+    /**
1893
+     * Retrieves the view url.
1894
+     *
1895
+     * @since 1.0.19
1896
+     * @return string
1897
+     */
1898
+    public function get_view_url() {
1899 1899
         $invoice_url = get_permalink( $this->get_id() );
1900
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1900
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1901 1901
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1902
-	}
1902
+    }
1903 1903
 
1904
-	/**
1905
-	 * Retrieves the payment url.
1906
-	 *
1907
-	 * @since 1.0.19
1908
-	 * @return string
1909
-	 */
1910
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1904
+    /**
1905
+     * Retrieves the payment url.
1906
+     *
1907
+     * @since 1.0.19
1908
+     * @return string
1909
+     */
1910
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1911 1911
 
1912
-		// Retrieve the checkout url.
1912
+        // Retrieve the checkout url.
1913 1913
         $pay_url = wpinv_get_checkout_uri();
1914 1914
 
1915
-		// Maybe force ssl.
1915
+        // Maybe force ssl.
1916 1916
         if ( is_ssl() ) {
1917 1917
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1918 1918
         }
1919 1919
 
1920
-		// Add the invoice key.
1921
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1920
+        // Add the invoice key.
1921
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1922 1922
 
1923
-		// (Maybe?) add a secret
1923
+        // (Maybe?) add a secret
1924 1924
         if ( $secret ) {
1925 1925
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1926 1926
         }
1927 1927
 
1928 1928
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1929
-	}
1929
+    }
1930 1930
 
1931
-	/**
1932
-	 * Retrieves the receipt url.
1933
-	 *
1934
-	 * @since 1.0.19
1935
-	 * @return string
1936
-	 */
1937
-	public function get_receipt_url() {
1931
+    /**
1932
+     * Retrieves the receipt url.
1933
+     *
1934
+     * @since 1.0.19
1935
+     * @return string
1936
+     */
1937
+    public function get_receipt_url() {
1938 1938
 
1939
-		// Retrieve the checkout url.
1939
+        // Retrieve the checkout url.
1940 1940
         $receipt_url = wpinv_get_success_page_uri();
1941 1941
 
1942
-		// Maybe force ssl.
1942
+        // Maybe force ssl.
1943 1943
         if ( is_ssl() ) {
1944 1944
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1945 1945
         }
1946 1946
 
1947
-		// Add the invoice key.
1948
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1947
+        // Add the invoice key.
1948
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1949 1949
 
1950 1950
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1951
-	}
1952
-
1953
-	/**
1954
-	 * Retrieves the remote transaction url.
1955
-	 *
1956
-	 * @since 1.6.0
1957
-	 * @return string
1958
-	 */
1959
-	public function get_transaction_url() {
1960
-		return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1961
-	}
1962
-
1963
-	/**
1964
-	 * Retrieves the default status.
1965
-	 *
1966
-	 * @since 1.0.19
1967
-	 * @return string
1968
-	 */
1969
-	public function get_default_status() {
1970
-
1971
-		$type   = $this->get_type();
1972
-		$status = "wpi-$type-pending";
1973
-		return str_replace( '-invoice', '', $status );
1974
-
1975
-	}
1976
-
1977
-    /**
1978
-	 * Magic method for accessing invoice properties.
1979
-	 *
1980
-	 * @since 1.0.15
1981
-	 * @access public
1982
-	 *
1983
-	 * @param string $key Discount data to retrieve
1984
-	 * @param  string $context View or edit context.
1985
-	 * @return mixed Value of the given invoice property (if set).
1986
-	 */
1987
-	public function get( $key, $context = 'view' ) {
1988
-		$method = "get_$key";
1989
-
1990
-		if ( is_callable( array( $this, $method ) ) ) {
1991
-			return $this->$method( $context );
1992
-		}
1951
+    }
1952
+
1953
+    /**
1954
+     * Retrieves the remote transaction url.
1955
+     *
1956
+     * @since 1.6.0
1957
+     * @return string
1958
+     */
1959
+    public function get_transaction_url() {
1960
+        return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1961
+    }
1962
+
1963
+    /**
1964
+     * Retrieves the default status.
1965
+     *
1966
+     * @since 1.0.19
1967
+     * @return string
1968
+     */
1969
+    public function get_default_status() {
1970
+
1971
+        $type   = $this->get_type();
1972
+        $status = "wpi-$type-pending";
1973
+        return str_replace( '-invoice', '', $status );
1974
+
1975
+    }
1976
+
1977
+    /**
1978
+     * Magic method for accessing invoice properties.
1979
+     *
1980
+     * @since 1.0.15
1981
+     * @access public
1982
+     *
1983
+     * @param string $key Discount data to retrieve
1984
+     * @param  string $context View or edit context.
1985
+     * @return mixed Value of the given invoice property (if set).
1986
+     */
1987
+    public function get( $key, $context = 'view' ) {
1988
+        $method = "get_$key";
1989
+
1990
+        if ( is_callable( array( $this, $method ) ) ) {
1991
+            return $this->$method( $context );
1992
+        }
1993 1993
 
1994 1994
         return $this->get_prop( $key, $context );
1995
-	}
1995
+    }
1996 1996
 
1997 1997
     /*
1998 1998
 	|--------------------------------------------------------------------------
@@ -2005,129 +2005,129 @@  discard block
 block discarded – undo
2005 2005
     */
2006 2006
 
2007 2007
     /**
2008
-	 * Magic method for setting invoice properties.
2009
-	 *
2010
-	 * @since 1.0.19
2011
-	 * @access public
2012
-	 *
2013
-	 * @param string $key Discount data to retrieve
2014
-	 * @param  mixed $value new value.
2015
-	 * @return mixed Value of the given invoice property (if set).
2016
-	 */
2017
-	public function set( $key, $value ) {
2008
+     * Magic method for setting invoice properties.
2009
+     *
2010
+     * @since 1.0.19
2011
+     * @access public
2012
+     *
2013
+     * @param string $key Discount data to retrieve
2014
+     * @param  mixed $value new value.
2015
+     * @return mixed Value of the given invoice property (if set).
2016
+     */
2017
+    public function set( $key, $value ) {
2018 2018
 
2019 2019
         $setter = "set_$key";
2020 2020
         if ( is_callable( array( $this, $setter ) ) ) {
2021 2021
             $this->{$setter}( $value );
2022 2022
         }
2023 2023
 
2024
-	}
2025
-
2026
-	/**
2027
-	 * Sets item status.
2028
-	 *
2029
-	 * @since 1.0.19
2030
-	 * @param string $new_status    New status.
2031
-	 * @param string $note          Optional note to add.
2032
-	 * @param bool   $manual_update Is this a manual status change?.
2033
-	 * @return array details of change.
2034
-	 */
2035
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
2036
-		$old_status = $this->get_status();
2037
-
2038
-		$statuses = $this->get_all_statuses();
2039
-
2040
-		if ( isset( $statuses['draft'] ) ) {
2041
-			unset( $statuses['draft'] );
2042
-		}
2043
-
2044
-		$this->set_prop( 'status', $new_status );
2045
-
2046
-		// If setting the status, ensure it's set to a valid status.
2047
-		if ( true === $this->object_read ) {
2048
-
2049
-			// Only allow valid new status.
2050
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
2051
-				$new_status = $this->get_default_status();
2052
-			}
2053
-
2054
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2055
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2056
-				$old_status = $this->get_default_status();
2057
-			}
2058
-
2059
-			// Paid - Renewal (i.e when duplicating a parent invoice )
2060
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2061
-				$old_status = 'wpi-pending';
2062
-			}
2063
-
2064
-			if ( $old_status !== $new_status ) {
2065
-				$this->status_transition = array(
2066
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2067
-					'to'     => $new_status,
2068
-					'note'   => $note,
2069
-					'manual' => (bool) $manual_update,
2070
-				);
2071
-
2072
-				if ( $manual_update ) {
2073
-					do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status );
2074
-				}
2075
-
2076
-				$this->maybe_set_date_paid();
2077
-
2078
-			}
2079
-		}
2080
-
2081
-		return array(
2082
-			'from' => $old_status,
2083
-			'to'   => $new_status,
2084
-		);
2085
-	}
2086
-
2087
-	/**
2088
-	 * Maybe set date paid.
2089
-	 *
2090
-	 * Sets the date paid variable when transitioning to the payment complete
2091
-	 * order status.
2092
-	 *
2093
-	 * @since 1.0.19
2094
-	 */
2095
-	public function maybe_set_date_paid() {
2096
-
2097
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2098
-			$this->set_date_completed( current_time( 'mysql' ) );
2099
-		}
2100
-	}
2101
-
2102
-    /**
2103
-	 * Set parent invoice ID.
2104
-	 *
2105
-	 * @since 1.0.19
2106
-	 */
2107
-	public function set_parent_id( $value ) {
2108
-		if ( $value && ( $value === $this->get_id() ) ) {
2109
-			return;
2110
-		}
2111
-		$this->set_prop( 'parent_id', absint( $value ) );
2112
-    }
2113
-
2114
-    /**
2115
-	 * Set plugin version when the invoice was created.
2116
-	 *
2117
-	 * @since 1.0.19
2118
-	 */
2119
-	public function set_version( $value ) {
2120
-		$this->set_prop( 'version', $value );
2121
-    }
2122
-
2123
-    /**
2124
-	 * Set date when the invoice was created.
2125
-	 *
2126
-	 * @since 1.0.19
2127
-	 * @param string $value Value to set.
2024
+    }
2025
+
2026
+    /**
2027
+     * Sets item status.
2028
+     *
2029
+     * @since 1.0.19
2030
+     * @param string $new_status    New status.
2031
+     * @param string $note          Optional note to add.
2032
+     * @param bool   $manual_update Is this a manual status change?.
2033
+     * @return array details of change.
2034
+     */
2035
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
2036
+        $old_status = $this->get_status();
2037
+
2038
+        $statuses = $this->get_all_statuses();
2039
+
2040
+        if ( isset( $statuses['draft'] ) ) {
2041
+            unset( $statuses['draft'] );
2042
+        }
2043
+
2044
+        $this->set_prop( 'status', $new_status );
2045
+
2046
+        // If setting the status, ensure it's set to a valid status.
2047
+        if ( true === $this->object_read ) {
2048
+
2049
+            // Only allow valid new status.
2050
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
2051
+                $new_status = $this->get_default_status();
2052
+            }
2053
+
2054
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2055
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2056
+                $old_status = $this->get_default_status();
2057
+            }
2058
+
2059
+            // Paid - Renewal (i.e when duplicating a parent invoice )
2060
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2061
+                $old_status = 'wpi-pending';
2062
+            }
2063
+
2064
+            if ( $old_status !== $new_status ) {
2065
+                $this->status_transition = array(
2066
+                    'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2067
+                    'to'     => $new_status,
2068
+                    'note'   => $note,
2069
+                    'manual' => (bool) $manual_update,
2070
+                );
2071
+
2072
+                if ( $manual_update ) {
2073
+                    do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status );
2074
+                }
2075
+
2076
+                $this->maybe_set_date_paid();
2077
+
2078
+            }
2079
+        }
2080
+
2081
+        return array(
2082
+            'from' => $old_status,
2083
+            'to'   => $new_status,
2084
+        );
2085
+    }
2086
+
2087
+    /**
2088
+     * Maybe set date paid.
2089
+     *
2090
+     * Sets the date paid variable when transitioning to the payment complete
2091
+     * order status.
2092
+     *
2093
+     * @since 1.0.19
2094
+     */
2095
+    public function maybe_set_date_paid() {
2096
+
2097
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2098
+            $this->set_date_completed( current_time( 'mysql' ) );
2099
+        }
2100
+    }
2101
+
2102
+    /**
2103
+     * Set parent invoice ID.
2104
+     *
2105
+     * @since 1.0.19
2106
+     */
2107
+    public function set_parent_id( $value ) {
2108
+        if ( $value && ( $value === $this->get_id() ) ) {
2109
+            return;
2110
+        }
2111
+        $this->set_prop( 'parent_id', absint( $value ) );
2112
+    }
2113
+
2114
+    /**
2115
+     * Set plugin version when the invoice was created.
2116
+     *
2117
+     * @since 1.0.19
2118
+     */
2119
+    public function set_version( $value ) {
2120
+        $this->set_prop( 'version', $value );
2121
+    }
2122
+
2123
+    /**
2124
+     * Set date when the invoice was created.
2125
+     *
2126
+     * @since 1.0.19
2127
+     * @param string $value Value to set.
2128 2128
      * @return bool Whether or not the date was set.
2129
-	 */
2130
-	public function set_date_created( $value ) {
2129
+     */
2130
+    public function set_date_created( $value ) {
2131 2131
         $date = strtotime( $value );
2132 2132
 
2133 2133
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2135,19 +2135,19 @@  discard block
 block discarded – undo
2135 2135
             return true;
2136 2136
         }
2137 2137
 
2138
-		$this->set_prop( 'date_created', '' );
2139
-		return false;
2138
+        $this->set_prop( 'date_created', '' );
2139
+        return false;
2140 2140
 
2141 2141
     }
2142 2142
 
2143 2143
     /**
2144
-	 * Set date invoice due date.
2145
-	 *
2146
-	 * @since 1.0.19
2147
-	 * @param string $value Value to set.
2144
+     * Set date invoice due date.
2145
+     *
2146
+     * @since 1.0.19
2147
+     * @param string $value Value to set.
2148 2148
      * @return bool Whether or not the date was set.
2149
-	 */
2150
-	public function set_due_date( $value ) {
2149
+     */
2150
+    public function set_due_date( $value ) {
2151 2151
         $date = strtotime( $value );
2152 2152
 
2153 2153
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2155,29 +2155,29 @@  discard block
 block discarded – undo
2155 2155
             return true;
2156 2156
         }
2157 2157
 
2158
-		$this->set_prop( 'due_date', '' );
2158
+        $this->set_prop( 'due_date', '' );
2159 2159
         return false;
2160 2160
 
2161 2161
     }
2162 2162
 
2163 2163
     /**
2164
-	 * Alias of self::set_due_date().
2165
-	 *
2166
-	 * @since 1.0.19
2167
-	 * @param  string $value New name.
2168
-	 */
2169
-	public function set_date_due( $value ) {
2170
-		$this->set_due_date( $value );
2164
+     * Alias of self::set_due_date().
2165
+     *
2166
+     * @since 1.0.19
2167
+     * @param  string $value New name.
2168
+     */
2169
+    public function set_date_due( $value ) {
2170
+        $this->set_due_date( $value );
2171 2171
     }
2172 2172
 
2173 2173
     /**
2174
-	 * Set date invoice was completed.
2175
-	 *
2176
-	 * @since 1.0.19
2177
-	 * @param string $value Value to set.
2174
+     * Set date invoice was completed.
2175
+     *
2176
+     * @since 1.0.19
2177
+     * @param string $value Value to set.
2178 2178
      * @return bool Whether or not the date was set.
2179
-	 */
2180
-	public function set_completed_date( $value ) {
2179
+     */
2180
+    public function set_completed_date( $value ) {
2181 2181
         $date = strtotime( $value );
2182 2182
 
2183 2183
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2185,29 +2185,29 @@  discard block
 block discarded – undo
2185 2185
             return true;
2186 2186
         }
2187 2187
 
2188
-		$this->set_prop( 'completed_date', '' );
2188
+        $this->set_prop( 'completed_date', '' );
2189 2189
         return false;
2190 2190
 
2191 2191
     }
2192 2192
 
2193 2193
     /**
2194
-	 * Alias of self::set_completed_date().
2195
-	 *
2196
-	 * @since 1.0.19
2197
-	 * @param  string $value New name.
2198
-	 */
2199
-	public function set_date_completed( $value ) {
2200
-		$this->set_completed_date( $value );
2194
+     * Alias of self::set_completed_date().
2195
+     *
2196
+     * @since 1.0.19
2197
+     * @param  string $value New name.
2198
+     */
2199
+    public function set_date_completed( $value ) {
2200
+        $this->set_completed_date( $value );
2201 2201
     }
2202 2202
 
2203 2203
     /**
2204
-	 * Set date when the invoice was last modified.
2205
-	 *
2206
-	 * @since 1.0.19
2207
-	 * @param string $value Value to set.
2204
+     * Set date when the invoice was last modified.
2205
+     *
2206
+     * @since 1.0.19
2207
+     * @param string $value Value to set.
2208 2208
      * @return bool Whether or not the date was set.
2209
-	 */
2210
-	public function set_date_modified( $value ) {
2209
+     */
2210
+    public function set_date_modified( $value ) {
2211 2211
         $date = strtotime( $value );
2212 2212
 
2213 2213
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2215,813 +2215,813 @@  discard block
 block discarded – undo
2215 2215
             return true;
2216 2216
         }
2217 2217
 
2218
-		$this->set_prop( 'date_modified', '' );
2218
+        $this->set_prop( 'date_modified', '' );
2219 2219
         return false;
2220 2220
 
2221 2221
     }
2222 2222
 
2223 2223
     /**
2224
-	 * Set the invoice number.
2225
-	 *
2226
-	 * @since 1.0.19
2227
-	 * @param  string $value New number.
2228
-	 */
2229
-	public function set_number( $value ) {
2224
+     * Set the invoice number.
2225
+     *
2226
+     * @since 1.0.19
2227
+     * @param  string $value New number.
2228
+     */
2229
+    public function set_number( $value ) {
2230 2230
         $number = sanitize_text_field( $value );
2231
-		$this->set_prop( 'number', $number );
2231
+        $this->set_prop( 'number', $number );
2232 2232
     }
2233 2233
 
2234 2234
     /**
2235
-	 * Set the invoice type.
2236
-	 *
2237
-	 * @since 1.0.19
2238
-	 * @param  string $value Type.
2239
-	 */
2240
-	public function set_type( $value ) {
2235
+     * Set the invoice type.
2236
+     *
2237
+     * @since 1.0.19
2238
+     * @param  string $value Type.
2239
+     */
2240
+    public function set_type( $value ) {
2241 2241
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2242
-		$this->set_prop( 'type', $type );
2243
-	}
2242
+        $this->set_prop( 'type', $type );
2243
+    }
2244 2244
 
2245 2245
     /**
2246
-	 * Set the invoice post type.
2247
-	 *
2248
-	 * @since 1.0.19
2249
-	 * @param  string $value Post type.
2250
-	 */
2251
-	public function set_post_type( $value ) {
2246
+     * Set the invoice post type.
2247
+     *
2248
+     * @since 1.0.19
2249
+     * @param  string $value Post type.
2250
+     */
2251
+    public function set_post_type( $value ) {
2252 2252
         if ( getpaid_is_invoice_post_type( $value ) ) {
2253
-			$this->set_type( $value );
2253
+            $this->set_type( $value );
2254 2254
             $this->set_prop( 'post_type', $value );
2255 2255
         }
2256 2256
     }
2257 2257
 
2258 2258
     /**
2259
-	 * Set the invoice key.
2260
-	 *
2261
-	 * @since 1.0.19
2262
-	 * @param  string $value New key.
2263
-	 */
2264
-	public function set_key( $value ) {
2259
+     * Set the invoice key.
2260
+     *
2261
+     * @since 1.0.19
2262
+     * @param  string $value New key.
2263
+     */
2264
+    public function set_key( $value ) {
2265 2265
         $key = sanitize_text_field( $value );
2266
-		$this->set_prop( 'key', $key );
2266
+        $this->set_prop( 'key', $key );
2267 2267
     }
2268 2268
 
2269 2269
     /**
2270
-	 * Set the invoice mode.
2271
-	 *
2272
-	 * @since 1.0.19
2273
-	 * @param  string $value mode.
2274
-	 */
2275
-	public function set_mode( $value ) {
2270
+     * Set the invoice mode.
2271
+     *
2272
+     * @since 1.0.19
2273
+     * @param  string $value mode.
2274
+     */
2275
+    public function set_mode( $value ) {
2276 2276
         if ( in_array( $value, array( 'live', 'test' ) ) ) {
2277 2277
             $this->set_prop( 'mode', $value );
2278 2278
         }
2279 2279
     }
2280 2280
 
2281 2281
     /**
2282
-	 * Set the invoice path.
2283
-	 *
2284
-	 * @since 1.0.19
2285
-	 * @param  string $value path.
2286
-	 */
2287
-	public function set_path( $value ) {
2282
+     * Set the invoice path.
2283
+     *
2284
+     * @since 1.0.19
2285
+     * @param  string $value path.
2286
+     */
2287
+    public function set_path( $value ) {
2288 2288
         $this->set_prop( 'path', $value );
2289 2289
     }
2290 2290
 
2291 2291
     /**
2292
-	 * Set the invoice name.
2293
-	 *
2294
-	 * @since 1.0.19
2295
-	 * @param  string $value New name.
2296
-	 */
2297
-	public function set_name( $value ) {
2292
+     * Set the invoice name.
2293
+     *
2294
+     * @since 1.0.19
2295
+     * @param  string $value New name.
2296
+     */
2297
+    public function set_name( $value ) {
2298 2298
         $name = sanitize_text_field( $value );
2299
-		$this->set_prop( 'name', $name );
2299
+        $this->set_prop( 'name', $name );
2300 2300
     }
2301 2301
 
2302 2302
     /**
2303
-	 * Alias of self::set_name().
2304
-	 *
2305
-	 * @since 1.0.19
2306
-	 * @param  string $value New name.
2307
-	 */
2308
-	public function set_title( $value ) {
2309
-		$this->set_name( $value );
2303
+     * Alias of self::set_name().
2304
+     *
2305
+     * @since 1.0.19
2306
+     * @param  string $value New name.
2307
+     */
2308
+    public function set_title( $value ) {
2309
+        $this->set_name( $value );
2310 2310
     }
2311 2311
 
2312 2312
     /**
2313
-	 * Set the invoice description.
2314
-	 *
2315
-	 * @since 1.0.19
2316
-	 * @param  string $value New description.
2317
-	 */
2318
-	public function set_description( $value ) {
2313
+     * Set the invoice description.
2314
+     *
2315
+     * @since 1.0.19
2316
+     * @param  string $value New description.
2317
+     */
2318
+    public function set_description( $value ) {
2319 2319
         $description = wp_kses_post( $value );
2320
-		$this->set_prop( 'description', $description );
2320
+        $this->set_prop( 'description', $description );
2321
+    }
2322
+
2323
+    /**
2324
+     * Alias of self::set_description().
2325
+     *
2326
+     * @since 1.0.19
2327
+     * @param  string $value New description.
2328
+     */
2329
+    public function set_excerpt( $value ) {
2330
+        $this->set_description( $value );
2331
+    }
2332
+
2333
+    /**
2334
+     * Alias of self::set_description().
2335
+     *
2336
+     * @since 1.0.19
2337
+     * @param  string $value New description.
2338
+     */
2339
+    public function set_summary( $value ) {
2340
+        $this->set_description( $value );
2341
+    }
2342
+
2343
+    /**
2344
+     * Set the receiver of the invoice.
2345
+     *
2346
+     * @since 1.0.19
2347
+     * @param  int $value New author.
2348
+     */
2349
+    public function set_author( $value ) {
2350
+        $user = get_user_by( 'id', (int) $value );
2351
+
2352
+        if ( $user && $user->ID ) {
2353
+            $this->set_prop( 'author', $user->ID );
2354
+            $this->set_prop( 'email', $user->user_email );
2355
+        }
2356
+
2357
+    }
2358
+
2359
+    /**
2360
+     * Alias of self::set_author().
2361
+     *
2362
+     * @since 1.0.19
2363
+     * @param  int $value New user id.
2364
+     */
2365
+    public function set_user_id( $value ) {
2366
+        $this->set_author( $value );
2367
+    }
2368
+
2369
+    /**
2370
+     * Sets the customer ID.
2371
+     *
2372
+     * @since 1.0.19
2373
+     * @param  int $value New user id.
2374
+     */
2375
+    public function set_customer_id( $value ) {
2376
+        $this->set_prop( 'customer_id', (int) $value );
2377
+    }
2378
+
2379
+    /**
2380
+     * Set the customer's ip.
2381
+     *
2382
+     * @since 1.0.19
2383
+     * @param  string $value ip address.
2384
+     */
2385
+    public function set_ip( $value ) {
2386
+        $this->set_prop( 'ip', $value );
2387
+    }
2388
+
2389
+    /**
2390
+     * Alias of self::set_ip().
2391
+     *
2392
+     * @since 1.0.19
2393
+     * @param  string $value ip address.
2394
+     */
2395
+    public function set_user_ip( $value ) {
2396
+        $this->set_ip( $value );
2397
+    }
2398
+
2399
+    /**
2400
+     * Set the customer's first name.
2401
+     *
2402
+     * @since 1.0.19
2403
+     * @param  string $value first name.
2404
+     */
2405
+    public function set_first_name( $value ) {
2406
+        $this->set_prop( 'first_name', $value );
2407
+    }
2408
+
2409
+    /**
2410
+     * Alias of self::set_first_name().
2411
+     *
2412
+     * @since 1.0.19
2413
+     * @param  string $value first name.
2414
+     */
2415
+    public function set_user_first_name( $value ) {
2416
+        $this->set_first_name( $value );
2417
+    }
2418
+
2419
+    /**
2420
+     * Alias of self::set_first_name().
2421
+     *
2422
+     * @since 1.0.19
2423
+     * @param  string $value first name.
2424
+     */
2425
+    public function set_customer_first_name( $value ) {
2426
+        $this->set_first_name( $value );
2427
+    }
2428
+
2429
+    /**
2430
+     * Set the customer's last name.
2431
+     *
2432
+     * @since 1.0.19
2433
+     * @param  string $value last name.
2434
+     */
2435
+    public function set_last_name( $value ) {
2436
+        $this->set_prop( 'last_name', $value );
2437
+    }
2438
+
2439
+    /**
2440
+     * Alias of self::set_last_name().
2441
+     *
2442
+     * @since 1.0.19
2443
+     * @param  string $value last name.
2444
+     */
2445
+    public function set_user_last_name( $value ) {
2446
+        $this->set_last_name( $value );
2447
+    }
2448
+
2449
+    /**
2450
+     * Alias of self::set_last_name().
2451
+     *
2452
+     * @since 1.0.19
2453
+     * @param  string $value last name.
2454
+     */
2455
+    public function set_customer_last_name( $value ) {
2456
+        $this->set_last_name( $value );
2457
+    }
2458
+
2459
+    /**
2460
+     * Set the customer's phone number.
2461
+     *
2462
+     * @since 1.0.19
2463
+     * @param  string $value phone.
2464
+     */
2465
+    public function set_phone( $value ) {
2466
+        $this->set_prop( 'phone', $value );
2321 2467
     }
2322 2468
 
2323 2469
     /**
2324
-	 * Alias of self::set_description().
2325
-	 *
2326
-	 * @since 1.0.19
2327
-	 * @param  string $value New description.
2328
-	 */
2329
-	public function set_excerpt( $value ) {
2330
-		$this->set_description( $value );
2470
+     * Alias of self::set_phone().
2471
+     *
2472
+     * @since 1.0.19
2473
+     * @param  string $value phone.
2474
+     */
2475
+    public function set_user_phone( $value ) {
2476
+        $this->set_phone( $value );
2331 2477
     }
2332 2478
 
2333 2479
     /**
2334
-	 * Alias of self::set_description().
2335
-	 *
2336
-	 * @since 1.0.19
2337
-	 * @param  string $value New description.
2338
-	 */
2339
-	public function set_summary( $value ) {
2340
-		$this->set_description( $value );
2480
+     * Alias of self::set_phone().
2481
+     *
2482
+     * @since 1.0.19
2483
+     * @param  string $value phone.
2484
+     */
2485
+    public function set_customer_phone( $value ) {
2486
+        $this->set_phone( $value );
2341 2487
     }
2342 2488
 
2343 2489
     /**
2344
-	 * Set the receiver of the invoice.
2345
-	 *
2346
-	 * @since 1.0.19
2347
-	 * @param  int $value New author.
2348
-	 */
2349
-	public function set_author( $value ) {
2350
-		$user = get_user_by( 'id', (int) $value );
2490
+     * Alias of self::set_phone().
2491
+     *
2492
+     * @since 1.0.19
2493
+     * @param  string $value phone.
2494
+     */
2495
+    public function set_phone_number( $value ) {
2496
+        $this->set_phone( $value );
2497
+    }
2351 2498
 
2352
-		if ( $user && $user->ID ) {
2353
-			$this->set_prop( 'author', $user->ID );
2354
-			$this->set_prop( 'email', $user->user_email );
2355
-		}
2499
+    /**
2500
+     * Set the customer's email address.
2501
+     *
2502
+     * @since 1.0.19
2503
+     * @param  string $value email address.
2504
+     */
2505
+    public function set_email( $value ) {
2506
+        $this->set_prop( 'email', $value );
2507
+    }
2356 2508
 
2509
+    /**
2510
+     * Alias of self::set_email().
2511
+     *
2512
+     * @since 1.0.19
2513
+     * @param  string $value email address.
2514
+     */
2515
+    public function set_user_email( $value ) {
2516
+        $this->set_email( $value );
2357 2517
     }
2358 2518
 
2359 2519
     /**
2360
-	 * Alias of self::set_author().
2361
-	 *
2362
-	 * @since 1.0.19
2363
-	 * @param  int $value New user id.
2364
-	 */
2365
-	public function set_user_id( $value ) {
2366
-		$this->set_author( $value );
2520
+     * Alias of self::set_email().
2521
+     *
2522
+     * @since 1.0.19
2523
+     * @param  string $value email address.
2524
+     */
2525
+    public function set_email_address( $value ) {
2526
+        $this->set_email( $value );
2367 2527
     }
2368 2528
 
2369 2529
     /**
2370
-	 * Sets the customer ID.
2371
-	 *
2372
-	 * @since 1.0.19
2373
-	 * @param  int $value New user id.
2374
-	 */
2375
-	public function set_customer_id( $value ) {
2376
-		$this->set_prop( 'customer_id', (int) $value );
2530
+     * Alias of self::set_email().
2531
+     *
2532
+     * @since 1.0.19
2533
+     * @param  string $value email address.
2534
+     */
2535
+    public function set_customer_email( $value ) {
2536
+        $this->set_email( $value );
2377 2537
     }
2378 2538
 
2379 2539
     /**
2380
-	 * Set the customer's ip.
2381
-	 *
2382
-	 * @since 1.0.19
2383
-	 * @param  string $value ip address.
2384
-	 */
2385
-	public function set_ip( $value ) {
2386
-		$this->set_prop( 'ip', $value );
2540
+     * Set the customer's country.
2541
+     *
2542
+     * @since 1.0.19
2543
+     * @param  string $value country.
2544
+     */
2545
+    public function set_country( $value ) {
2546
+        $this->set_prop( 'country', $value );
2387 2547
     }
2388 2548
 
2389 2549
     /**
2390
-	 * Alias of self::set_ip().
2391
-	 *
2392
-	 * @since 1.0.19
2393
-	 * @param  string $value ip address.
2394
-	 */
2395
-	public function set_user_ip( $value ) {
2396
-		$this->set_ip( $value );
2550
+     * Alias of self::set_country().
2551
+     *
2552
+     * @since 1.0.19
2553
+     * @param  string $value country.
2554
+     */
2555
+    public function set_user_country( $value ) {
2556
+        $this->set_country( $value );
2397 2557
     }
2398 2558
 
2399 2559
     /**
2400
-	 * Set the customer's first name.
2401
-	 *
2402
-	 * @since 1.0.19
2403
-	 * @param  string $value first name.
2404
-	 */
2405
-	public function set_first_name( $value ) {
2406
-		$this->set_prop( 'first_name', $value );
2560
+     * Alias of self::set_country().
2561
+     *
2562
+     * @since 1.0.19
2563
+     * @param  string $value country.
2564
+     */
2565
+    public function set_customer_country( $value ) {
2566
+        $this->set_country( $value );
2407 2567
     }
2408 2568
 
2409 2569
     /**
2410
-	 * Alias of self::set_first_name().
2411
-	 *
2412
-	 * @since 1.0.19
2413
-	 * @param  string $value first name.
2414
-	 */
2415
-	public function set_user_first_name( $value ) {
2416
-		$this->set_first_name( $value );
2570
+     * Set the customer's state.
2571
+     *
2572
+     * @since 1.0.19
2573
+     * @param  string $value state.
2574
+     */
2575
+    public function set_state( $value ) {
2576
+        $this->set_prop( 'state', $value );
2417 2577
     }
2418 2578
 
2419 2579
     /**
2420
-	 * Alias of self::set_first_name().
2421
-	 *
2422
-	 * @since 1.0.19
2423
-	 * @param  string $value first name.
2424
-	 */
2425
-	public function set_customer_first_name( $value ) {
2426
-		$this->set_first_name( $value );
2580
+     * Alias of self::set_state().
2581
+     *
2582
+     * @since 1.0.19
2583
+     * @param  string $value state.
2584
+     */
2585
+    public function set_user_state( $value ) {
2586
+        $this->set_state( $value );
2427 2587
     }
2428 2588
 
2429 2589
     /**
2430
-	 * Set the customer's last name.
2431
-	 *
2432
-	 * @since 1.0.19
2433
-	 * @param  string $value last name.
2434
-	 */
2435
-	public function set_last_name( $value ) {
2436
-		$this->set_prop( 'last_name', $value );
2590
+     * Alias of self::set_state().
2591
+     *
2592
+     * @since 1.0.19
2593
+     * @param  string $value state.
2594
+     */
2595
+    public function set_customer_state( $value ) {
2596
+        $this->set_state( $value );
2437 2597
     }
2438 2598
 
2439 2599
     /**
2440
-	 * Alias of self::set_last_name().
2441
-	 *
2442
-	 * @since 1.0.19
2443
-	 * @param  string $value last name.
2444
-	 */
2445
-	public function set_user_last_name( $value ) {
2446
-		$this->set_last_name( $value );
2600
+     * Set the customer's city.
2601
+     *
2602
+     * @since 1.0.19
2603
+     * @param  string $value city.
2604
+     */
2605
+    public function set_city( $value ) {
2606
+        $this->set_prop( 'city', $value );
2447 2607
     }
2448 2608
 
2449 2609
     /**
2450
-	 * Alias of self::set_last_name().
2451
-	 *
2452
-	 * @since 1.0.19
2453
-	 * @param  string $value last name.
2454
-	 */
2455
-	public function set_customer_last_name( $value ) {
2456
-		$this->set_last_name( $value );
2610
+     * Alias of self::set_city().
2611
+     *
2612
+     * @since 1.0.19
2613
+     * @param  string $value city.
2614
+     */
2615
+    public function set_user_city( $value ) {
2616
+        $this->set_city( $value );
2457 2617
     }
2458 2618
 
2459 2619
     /**
2460
-	 * Set the customer's phone number.
2461
-	 *
2462
-	 * @since 1.0.19
2463
-	 * @param  string $value phone.
2464
-	 */
2465
-	public function set_phone( $value ) {
2466
-		$this->set_prop( 'phone', $value );
2620
+     * Alias of self::set_city().
2621
+     *
2622
+     * @since 1.0.19
2623
+     * @param  string $value city.
2624
+     */
2625
+    public function set_customer_city( $value ) {
2626
+        $this->set_city( $value );
2467 2627
     }
2468 2628
 
2469 2629
     /**
2470
-	 * Alias of self::set_phone().
2471
-	 *
2472
-	 * @since 1.0.19
2473
-	 * @param  string $value phone.
2474
-	 */
2475
-	public function set_user_phone( $value ) {
2476
-		$this->set_phone( $value );
2630
+     * Set the customer's zip code.
2631
+     *
2632
+     * @since 1.0.19
2633
+     * @param  string $value zip.
2634
+     */
2635
+    public function set_zip( $value ) {
2636
+        $this->set_prop( 'zip', $value );
2477 2637
     }
2478 2638
 
2479 2639
     /**
2480
-	 * Alias of self::set_phone().
2481
-	 *
2482
-	 * @since 1.0.19
2483
-	 * @param  string $value phone.
2484
-	 */
2485
-	public function set_customer_phone( $value ) {
2486
-		$this->set_phone( $value );
2640
+     * Alias of self::set_zip().
2641
+     *
2642
+     * @since 1.0.19
2643
+     * @param  string $value zip.
2644
+     */
2645
+    public function set_user_zip( $value ) {
2646
+        $this->set_zip( $value );
2487 2647
     }
2488 2648
 
2489 2649
     /**
2490
-	 * Alias of self::set_phone().
2491
-	 *
2492
-	 * @since 1.0.19
2493
-	 * @param  string $value phone.
2494
-	 */
2495
-	public function set_phone_number( $value ) {
2496
-		$this->set_phone( $value );
2650
+     * Alias of self::set_zip().
2651
+     *
2652
+     * @since 1.0.19
2653
+     * @param  string $value zip.
2654
+     */
2655
+    public function set_customer_zip( $value ) {
2656
+        $this->set_zip( $value );
2497 2657
     }
2498 2658
 
2499 2659
     /**
2500
-	 * Set the customer's email address.
2501
-	 *
2502
-	 * @since 1.0.19
2503
-	 * @param  string $value email address.
2504
-	 */
2505
-	public function set_email( $value ) {
2506
-		$this->set_prop( 'email', $value );
2660
+     * Set the customer's company.
2661
+     *
2662
+     * @since 1.0.19
2663
+     * @param  string $value company.
2664
+     */
2665
+    public function set_company( $value ) {
2666
+        $this->set_prop( 'company', $value );
2507 2667
     }
2508 2668
 
2509 2669
     /**
2510
-	 * Alias of self::set_email().
2511
-	 *
2512
-	 * @since 1.0.19
2513
-	 * @param  string $value email address.
2514
-	 */
2515
-	public function set_user_email( $value ) {
2516
-		$this->set_email( $value );
2670
+     * Alias of self::set_company().
2671
+     *
2672
+     * @since 1.0.19
2673
+     * @param  string $value company.
2674
+     */
2675
+    public function set_user_company( $value ) {
2676
+        $this->set_company( $value );
2517 2677
     }
2518 2678
 
2519 2679
     /**
2520
-	 * Alias of self::set_email().
2521
-	 *
2522
-	 * @since 1.0.19
2523
-	 * @param  string $value email address.
2524
-	 */
2525
-	public function set_email_address( $value ) {
2526
-		$this->set_email( $value );
2680
+     * Alias of self::set_company().
2681
+     *
2682
+     * @since 1.0.19
2683
+     * @param  string $value company.
2684
+     */
2685
+    public function set_customer_company( $value ) {
2686
+        $this->set_company( $value );
2527 2687
     }
2528 2688
 
2529 2689
     /**
2530
-	 * Alias of self::set_email().
2531
-	 *
2532
-	 * @since 1.0.19
2533
-	 * @param  string $value email address.
2534
-	 */
2535
-	public function set_customer_email( $value ) {
2536
-		$this->set_email( $value );
2690
+     * Set the customer's company id.
2691
+     *
2692
+     * @since 1.0.19
2693
+     * @param  string $value company id.
2694
+     */
2695
+    public function set_company_id( $value ) {
2696
+        $this->set_prop( 'company_id', $value );
2537 2697
     }
2538 2698
 
2539 2699
     /**
2540
-	 * Set the customer's country.
2541
-	 *
2542
-	 * @since 1.0.19
2543
-	 * @param  string $value country.
2544
-	 */
2545
-	public function set_country( $value ) {
2546
-		$this->set_prop( 'country', $value );
2700
+     * Set the customer's var number.
2701
+     *
2702
+     * @since 1.0.19
2703
+     * @param  string $value var number.
2704
+     */
2705
+    public function set_vat_number( $value ) {
2706
+        $this->set_prop( 'vat_number', $value );
2547 2707
     }
2548 2708
 
2549 2709
     /**
2550
-	 * Alias of self::set_country().
2551
-	 *
2552
-	 * @since 1.0.19
2553
-	 * @param  string $value country.
2554
-	 */
2555
-	public function set_user_country( $value ) {
2556
-		$this->set_country( $value );
2710
+     * Alias of self::set_vat_number().
2711
+     *
2712
+     * @since 1.0.19
2713
+     * @param  string $value var number.
2714
+     */
2715
+    public function set_user_vat_number( $value ) {
2716
+        $this->set_vat_number( $value );
2557 2717
     }
2558 2718
 
2559 2719
     /**
2560
-	 * Alias of self::set_country().
2561
-	 *
2562
-	 * @since 1.0.19
2563
-	 * @param  string $value country.
2564
-	 */
2565
-	public function set_customer_country( $value ) {
2566
-		$this->set_country( $value );
2720
+     * Alias of self::set_vat_number().
2721
+     *
2722
+     * @since 1.0.19
2723
+     * @param  string $value var number.
2724
+     */
2725
+    public function set_customer_vat_number( $value ) {
2726
+        $this->set_vat_number( $value );
2567 2727
     }
2568 2728
 
2569 2729
     /**
2570
-	 * Set the customer's state.
2571
-	 *
2572
-	 * @since 1.0.19
2573
-	 * @param  string $value state.
2574
-	 */
2575
-	public function set_state( $value ) {
2576
-		$this->set_prop( 'state', $value );
2730
+     * Set the customer's vat rate.
2731
+     *
2732
+     * @since 1.0.19
2733
+     * @param  string $value var rate.
2734
+     */
2735
+    public function set_vat_rate( $value ) {
2736
+        $this->set_prop( 'vat_rate', $value );
2577 2737
     }
2578 2738
 
2579 2739
     /**
2580
-	 * Alias of self::set_state().
2581
-	 *
2582
-	 * @since 1.0.19
2583
-	 * @param  string $value state.
2584
-	 */
2585
-	public function set_user_state( $value ) {
2586
-		$this->set_state( $value );
2740
+     * Alias of self::set_vat_rate().
2741
+     *
2742
+     * @since 1.0.19
2743
+     * @param  string $value var number.
2744
+     */
2745
+    public function set_user_vat_rate( $value ) {
2746
+        $this->set_vat_rate( $value );
2587 2747
     }
2588 2748
 
2589 2749
     /**
2590
-	 * Alias of self::set_state().
2591
-	 *
2592
-	 * @since 1.0.19
2593
-	 * @param  string $value state.
2594
-	 */
2595
-	public function set_customer_state( $value ) {
2596
-		$this->set_state( $value );
2750
+     * Alias of self::set_vat_rate().
2751
+     *
2752
+     * @since 1.0.19
2753
+     * @param  string $value var number.
2754
+     */
2755
+    public function set_customer_vat_rate( $value ) {
2756
+        $this->set_vat_rate( $value );
2597 2757
     }
2598 2758
 
2599 2759
     /**
2600
-	 * Set the customer's city.
2601
-	 *
2602
-	 * @since 1.0.19
2603
-	 * @param  string $value city.
2604
-	 */
2605
-	public function set_city( $value ) {
2606
-		$this->set_prop( 'city', $value );
2760
+     * Set the customer's address.
2761
+     *
2762
+     * @since 1.0.19
2763
+     * @param  string $value address.
2764
+     */
2765
+    public function set_address( $value ) {
2766
+        $this->set_prop( 'address', $value );
2607 2767
     }
2608 2768
 
2609 2769
     /**
2610
-	 * Alias of self::set_city().
2611
-	 *
2612
-	 * @since 1.0.19
2613
-	 * @param  string $value city.
2614
-	 */
2615
-	public function set_user_city( $value ) {
2616
-		$this->set_city( $value );
2770
+     * Alias of self::set_address().
2771
+     *
2772
+     * @since 1.0.19
2773
+     * @param  string $value address.
2774
+     */
2775
+    public function set_user_address( $value ) {
2776
+        $this->set_address( $value );
2617 2777
     }
2618 2778
 
2619 2779
     /**
2620
-	 * Alias of self::set_city().
2621
-	 *
2622
-	 * @since 1.0.19
2623
-	 * @param  string $value city.
2624
-	 */
2625
-	public function set_customer_city( $value ) {
2626
-		$this->set_city( $value );
2780
+     * Alias of self::set_address().
2781
+     *
2782
+     * @since 1.0.19
2783
+     * @param  string $value address.
2784
+     */
2785
+    public function set_customer_address( $value ) {
2786
+        $this->set_address( $value );
2627 2787
     }
2628 2788
 
2629 2789
     /**
2630
-	 * Set the customer's zip code.
2631
-	 *
2632
-	 * @since 1.0.19
2633
-	 * @param  string $value zip.
2634
-	 */
2635
-	public function set_zip( $value ) {
2636
-		$this->set_prop( 'zip', $value );
2790
+     * Set whether the customer has viewed the invoice or not.
2791
+     *
2792
+     * @since 1.0.19
2793
+     * @param  int|bool $value confirmed.
2794
+     */
2795
+    public function set_is_viewed( $value ) {
2796
+        $this->set_prop( 'is_viewed', $value );
2637 2797
     }
2638 2798
 
2639 2799
     /**
2640
-	 * Alias of self::set_zip().
2641
-	 *
2642
-	 * @since 1.0.19
2643
-	 * @param  string $value zip.
2644
-	 */
2645
-	public function set_user_zip( $value ) {
2646
-		$this->set_zip( $value );
2800
+     * Set extra email recipients.
2801
+     *
2802
+     * @since 1.0.19
2803
+     * @param  string $value email recipients.
2804
+     */
2805
+    public function set_email_cc( $value ) {
2806
+        $this->set_prop( 'email_cc', $value );
2647 2807
     }
2648 2808
 
2649 2809
     /**
2650
-	 * Alias of self::set_zip().
2651
-	 *
2652
-	 * @since 1.0.19
2653
-	 * @param  string $value zip.
2654
-	 */
2655
-	public function set_customer_zip( $value ) {
2656
-		$this->set_zip( $value );
2810
+     * Set the invoice template.
2811
+     *
2812
+     * @since 1.0.19
2813
+     * @param  string $value template.
2814
+     */
2815
+    public function set_template( $value ) {
2816
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2817
+            $this->set_prop( 'template', $value );
2818
+        }
2657 2819
     }
2658 2820
 
2659 2821
     /**
2660
-	 * Set the customer's company.
2661
-	 *
2662
-	 * @since 1.0.19
2663
-	 * @param  string $value company.
2664
-	 */
2665
-	public function set_company( $value ) {
2666
-		$this->set_prop( 'company', $value );
2822
+     * Set the invoice source.
2823
+     *
2824
+     * @since 1.0.19
2825
+     * @param  string $value source.
2826
+     * @deprecated
2827
+     */
2828
+    public function created_via( $value ) {
2829
+        $this->set_created_via( sanitize_text_field( $value ) );
2667 2830
     }
2668 2831
 
2669 2832
     /**
2670
-	 * Alias of self::set_company().
2671
-	 *
2672
-	 * @since 1.0.19
2673
-	 * @param  string $value company.
2674
-	 */
2675
-	public function set_user_company( $value ) {
2676
-		$this->set_company( $value );
2833
+     * Set the invoice source.
2834
+     *
2835
+     * @since 1.0.19
2836
+     * @param  string $value source.
2837
+     */
2838
+    public function set_created_via( $value ) {
2839
+        $this->set_prop( 'created_via', sanitize_text_field( $value ) );
2677 2840
     }
2678 2841
 
2679 2842
     /**
2680
-	 * Alias of self::set_company().
2681
-	 *
2682
-	 * @since 1.0.19
2683
-	 * @param  string $value company.
2684
-	 */
2685
-	public function set_customer_company( $value ) {
2686
-		$this->set_company( $value );
2687
-    }
2688
-
2689
-	/**
2690
-	 * Set the customer's company id.
2691
-	 *
2692
-	 * @since 1.0.19
2693
-	 * @param  string $value company id.
2694
-	 */
2695
-	public function set_company_id( $value ) {
2696
-		$this->set_prop( 'company_id', $value );
2843
+     * Set the customer's address confirmed status.
2844
+     *
2845
+     * @since 1.0.19
2846
+     * @param  int|bool $value confirmed.
2847
+     */
2848
+    public function set_address_confirmed( $value ) {
2849
+        $this->set_prop( 'address_confirmed', $value );
2697 2850
     }
2698 2851
 
2699 2852
     /**
2700
-	 * Set the customer's var number.
2701
-	 *
2702
-	 * @since 1.0.19
2703
-	 * @param  string $value var number.
2704
-	 */
2705
-	public function set_vat_number( $value ) {
2706
-		$this->set_prop( 'vat_number', $value );
2853
+     * Alias of self::set_address_confirmed().
2854
+     *
2855
+     * @since 1.0.19
2856
+     * @param  int|bool $value confirmed.
2857
+     */
2858
+    public function set_user_address_confirmed( $value ) {
2859
+        $this->set_address_confirmed( $value );
2707 2860
     }
2708 2861
 
2709 2862
     /**
2710
-	 * Alias of self::set_vat_number().
2711
-	 *
2712
-	 * @since 1.0.19
2713
-	 * @param  string $value var number.
2714
-	 */
2715
-	public function set_user_vat_number( $value ) {
2716
-		$this->set_vat_number( $value );
2863
+     * Alias of self::set_address_confirmed().
2864
+     *
2865
+     * @since 1.0.19
2866
+     * @param  int|bool $value confirmed.
2867
+     */
2868
+    public function set_customer_address_confirmed( $value ) {
2869
+        $this->set_address_confirmed( $value );
2717 2870
     }
2718 2871
 
2719 2872
     /**
2720
-	 * Alias of self::set_vat_number().
2721
-	 *
2722
-	 * @since 1.0.19
2723
-	 * @param  string $value var number.
2724
-	 */
2725
-	public function set_customer_vat_number( $value ) {
2726
-		$this->set_vat_number( $value );
2873
+     * Set the shipping fee
2874
+     *
2875
+     * @since 1.0.19
2876
+     * @param  float $value shipping amount.
2877
+     */
2878
+    public function set_shipping( $value ) {
2879
+
2880
+        if ( ! is_numeric( $value ) ) {
2881
+            return $this->set_prop( 'shipping', null );
2882
+        }
2883
+
2884
+        $this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2727 2885
     }
2728 2886
 
2729 2887
     /**
2730
-	 * Set the customer's vat rate.
2731
-	 *
2732
-	 * @since 1.0.19
2733
-	 * @param  string $value var rate.
2734
-	 */
2735
-	public function set_vat_rate( $value ) {
2736
-		$this->set_prop( 'vat_rate', $value );
2888
+     * Set the invoice sub total.
2889
+     *
2890
+     * @since 1.0.19
2891
+     * @param  float $value sub total.
2892
+     */
2893
+    public function set_subtotal( $value ) {
2894
+        $this->set_prop( 'subtotal', max( 0, $value ) );
2737 2895
     }
2738 2896
 
2739
-    /**
2740
-	 * Alias of self::set_vat_rate().
2741
-	 *
2742
-	 * @since 1.0.19
2743
-	 * @param  string $value var number.
2744
-	 */
2745
-	public function set_user_vat_rate( $value ) {
2746
-		$this->set_vat_rate( $value );
2747
-    }
2748
-
2749
-    /**
2750
-	 * Alias of self::set_vat_rate().
2751
-	 *
2752
-	 * @since 1.0.19
2753
-	 * @param  string $value var number.
2754
-	 */
2755
-	public function set_customer_vat_rate( $value ) {
2756
-		$this->set_vat_rate( $value );
2757
-    }
2758
-
2759
-    /**
2760
-	 * Set the customer's address.
2761
-	 *
2762
-	 * @since 1.0.19
2763
-	 * @param  string $value address.
2764
-	 */
2765
-	public function set_address( $value ) {
2766
-		$this->set_prop( 'address', $value );
2767
-    }
2768
-
2769
-    /**
2770
-	 * Alias of self::set_address().
2771
-	 *
2772
-	 * @since 1.0.19
2773
-	 * @param  string $value address.
2774
-	 */
2775
-	public function set_user_address( $value ) {
2776
-		$this->set_address( $value );
2777
-    }
2778
-
2779
-    /**
2780
-	 * Alias of self::set_address().
2781
-	 *
2782
-	 * @since 1.0.19
2783
-	 * @param  string $value address.
2784
-	 */
2785
-	public function set_customer_address( $value ) {
2786
-		$this->set_address( $value );
2787
-    }
2788
-
2789
-    /**
2790
-	 * Set whether the customer has viewed the invoice or not.
2791
-	 *
2792
-	 * @since 1.0.19
2793
-	 * @param  int|bool $value confirmed.
2794
-	 */
2795
-	public function set_is_viewed( $value ) {
2796
-		$this->set_prop( 'is_viewed', $value );
2797
-	}
2798
-
2799
-	/**
2800
-	 * Set extra email recipients.
2801
-	 *
2802
-	 * @since 1.0.19
2803
-	 * @param  string $value email recipients.
2804
-	 */
2805
-	public function set_email_cc( $value ) {
2806
-		$this->set_prop( 'email_cc', $value );
2807
-	}
2808
-
2809
-	/**
2810
-	 * Set the invoice template.
2811
-	 *
2812
-	 * @since 1.0.19
2813
-	 * @param  string $value template.
2814
-	 */
2815
-	public function set_template( $value ) {
2816
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2817
-			$this->set_prop( 'template', $value );
2818
-		}
2819
-	}
2820
-
2821
-	/**
2822
-	 * Set the invoice source.
2823
-	 *
2824
-	 * @since 1.0.19
2825
-	 * @param  string $value source.
2826
-	 * @deprecated
2827
-	 */
2828
-	public function created_via( $value ) {
2829
-		$this->set_created_via( sanitize_text_field( $value ) );
2830
-	}
2831
-
2832
-	/**
2833
-	 * Set the invoice source.
2834
-	 *
2835
-	 * @since 1.0.19
2836
-	 * @param  string $value source.
2837
-	 */
2838
-	public function set_created_via( $value ) {
2839
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2840
-	}
2841
-
2842
-	/**
2843
-	 * Set the customer's address confirmed status.
2844
-	 *
2845
-	 * @since 1.0.19
2846
-	 * @param  int|bool $value confirmed.
2847
-	 */
2848
-	public function set_address_confirmed( $value ) {
2849
-		$this->set_prop( 'address_confirmed', $value );
2850
-    }
2851
-
2852
-    /**
2853
-	 * Alias of self::set_address_confirmed().
2854
-	 *
2855
-	 * @since 1.0.19
2856
-	 * @param  int|bool $value confirmed.
2857
-	 */
2858
-	public function set_user_address_confirmed( $value ) {
2859
-		$this->set_address_confirmed( $value );
2860
-    }
2861
-
2862
-    /**
2863
-	 * Alias of self::set_address_confirmed().
2864
-	 *
2865
-	 * @since 1.0.19
2866
-	 * @param  int|bool $value confirmed.
2867
-	 */
2868
-	public function set_customer_address_confirmed( $value ) {
2869
-		$this->set_address_confirmed( $value );
2870
-    }
2871
-
2872
-    /**
2873
-	 * Set the shipping fee
2874
-	 *
2875
-	 * @since 1.0.19
2876
-	 * @param  float $value shipping amount.
2877
-	 */
2878
-	public function set_shipping( $value ) {
2879
-
2880
-		if ( ! is_numeric( $value ) ) {
2881
-			return $this->set_prop( 'shipping', null );
2882
-		}
2883
-
2884
-		$this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2885
-	}
2886
-
2887
-	/**
2888
-	 * Set the invoice sub total.
2889
-	 *
2890
-	 * @since 1.0.19
2891
-	 * @param  float $value sub total.
2892
-	 */
2893
-	public function set_subtotal( $value ) {
2894
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2895
-	}
2896
-
2897
-	/**
2898
-	 * Set the invoice total.
2899
-	 *
2900
-	 * @since 1.0.19
2901
-	 * @param  float $value sub total.
2902
-	 */
2903
-	public function set_total( $value ) {
2904
-		$this->set_prop( 'total', max( 0, $value ) );
2897
+    /**
2898
+     * Set the invoice total.
2899
+     *
2900
+     * @since 1.0.19
2901
+     * @param  float $value sub total.
2902
+     */
2903
+    public function set_total( $value ) {
2904
+        $this->set_prop( 'total', max( 0, $value ) );
2905 2905
     }
2906 2906
 
2907 2907
     /**
2908
-	 * Set the invoice discount amount.
2909
-	 *
2910
-	 * @since 1.0.19
2911
-	 * @param  float $value discount total.
2912
-	 */
2913
-	public function set_total_discount( $value ) {
2914
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2908
+     * Set the invoice discount amount.
2909
+     *
2910
+     * @since 1.0.19
2911
+     * @param  float $value discount total.
2912
+     */
2913
+    public function set_total_discount( $value ) {
2914
+        $this->set_prop( 'total_discount', max( 0, $value ) );
2915 2915
     }
2916 2916
 
2917 2917
     /**
2918
-	 * Alias of self::set_total_discount().
2919
-	 *
2920
-	 * @since 1.0.19
2921
-	 * @param  float $value discount total.
2922
-	 */
2923
-	public function set_discount( $value ) {
2924
-		$this->set_total_discount( $value );
2918
+     * Alias of self::set_total_discount().
2919
+     *
2920
+     * @since 1.0.19
2921
+     * @param  float $value discount total.
2922
+     */
2923
+    public function set_discount( $value ) {
2924
+        $this->set_total_discount( $value );
2925 2925
     }
2926 2926
 
2927 2927
     /**
2928
-	 * Set the invoice tax amount.
2929
-	 *
2930
-	 * @since 1.0.19
2931
-	 * @param  float $value tax total.
2932
-	 */
2933
-	public function set_total_tax( $value ) {
2934
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2928
+     * Set the invoice tax amount.
2929
+     *
2930
+     * @since 1.0.19
2931
+     * @param  float $value tax total.
2932
+     */
2933
+    public function set_total_tax( $value ) {
2934
+        $this->set_prop( 'total_tax', max( 0, $value ) );
2935 2935
     }
2936 2936
 
2937 2937
     /**
2938
-	 * Alias of self::set_total_tax().
2939
-	 *
2940
-	 * @since 1.0.19
2941
-	 * @param  float $value tax total.
2942
-	 */
2943
-	public function set_tax_total( $value ) {
2944
-		$this->set_total_tax( $value );
2938
+     * Alias of self::set_total_tax().
2939
+     *
2940
+     * @since 1.0.19
2941
+     * @param  float $value tax total.
2942
+     */
2943
+    public function set_tax_total( $value ) {
2944
+        $this->set_total_tax( $value );
2945 2945
     }
2946 2946
 
2947 2947
     /**
2948
-	 * Set the invoice fees amount.
2949
-	 *
2950
-	 * @since 1.0.19
2951
-	 * @param  float $value fees total.
2952
-	 */
2953
-	public function set_total_fees( $value ) {
2954
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2948
+     * Set the invoice fees amount.
2949
+     *
2950
+     * @since 1.0.19
2951
+     * @param  float $value fees total.
2952
+     */
2953
+    public function set_total_fees( $value ) {
2954
+        $this->set_prop( 'total_fees', max( 0, $value ) );
2955 2955
     }
2956 2956
 
2957 2957
     /**
2958
-	 * Alias of self::set_total_fees().
2959
-	 *
2960
-	 * @since 1.0.19
2961
-	 * @param  float $value fees total.
2962
-	 */
2963
-	public function set_fees_total( $value ) {
2964
-		$this->set_total_fees( $value );
2958
+     * Alias of self::set_total_fees().
2959
+     *
2960
+     * @since 1.0.19
2961
+     * @param  float $value fees total.
2962
+     */
2963
+    public function set_fees_total( $value ) {
2964
+        $this->set_total_fees( $value );
2965 2965
     }
2966 2966
 
2967 2967
     /**
2968
-	 * Set the invoice fees.
2969
-	 *
2970
-	 * @since 1.0.19
2971
-	 * @param  array $value fees.
2972
-	 */
2973
-	public function set_fees( $value ) {
2968
+     * Set the invoice fees.
2969
+     *
2970
+     * @since 1.0.19
2971
+     * @param  array $value fees.
2972
+     */
2973
+    public function set_fees( $value ) {
2974 2974
 
2975
-		if ( ! is_array( $value ) ) {
2976
-			$value = array();
2977
-		}
2975
+        if ( ! is_array( $value ) ) {
2976
+            $value = array();
2977
+        }
2978 2978
 
2979
-		$this->set_prop( 'fees', $value );
2979
+        $this->set_prop( 'fees', $value );
2980 2980
 
2981 2981
     }
2982 2982
 
2983 2983
     /**
2984
-	 * Set the invoice taxes.
2985
-	 *
2986
-	 * @since 1.0.19
2987
-	 * @param  array $value taxes.
2988
-	 */
2989
-	public function set_taxes( $value ) {
2984
+     * Set the invoice taxes.
2985
+     *
2986
+     * @since 1.0.19
2987
+     * @param  array $value taxes.
2988
+     */
2989
+    public function set_taxes( $value ) {
2990 2990
 
2991
-		if ( ! is_array( $value ) ) {
2992
-			$value = array();
2993
-		}
2991
+        if ( ! is_array( $value ) ) {
2992
+            $value = array();
2993
+        }
2994 2994
 
2995
-		$this->set_prop( 'taxes', $value );
2995
+        $this->set_prop( 'taxes', $value );
2996 2996
 
2997 2997
     }
2998 2998
 
2999 2999
     /**
3000
-	 * Set the invoice discounts.
3001
-	 *
3002
-	 * @since 1.0.19
3003
-	 * @param  array $value discounts.
3004
-	 */
3005
-	public function set_discounts( $value ) {
3000
+     * Set the invoice discounts.
3001
+     *
3002
+     * @since 1.0.19
3003
+     * @param  array $value discounts.
3004
+     */
3005
+    public function set_discounts( $value ) {
3006 3006
 
3007
-		if ( ! is_array( $value ) ) {
3008
-			$value = array();
3009
-		}
3007
+        if ( ! is_array( $value ) ) {
3008
+            $value = array();
3009
+        }
3010 3010
 
3011
-		$this->set_prop( 'discounts', $value );
3011
+        $this->set_prop( 'discounts', $value );
3012 3012
     }
3013 3013
 
3014 3014
     /**
3015
-	 * Set the invoice items.
3016
-	 *
3017
-	 * @since 1.0.19
3018
-	 * @param  GetPaid_Form_Item[] $value items.
3019
-	 */
3020
-	public function set_items( $value ) {
3015
+     * Set the invoice items.
3016
+     *
3017
+     * @since 1.0.19
3018
+     * @param  GetPaid_Form_Item[] $value items.
3019
+     */
3020
+    public function set_items( $value ) {
3021 3021
 
3022 3022
         // Remove existing items.
3023 3023
         $this->set_prop( 'items', array() );
3024
-		$this->recurring_item = null;
3024
+        $this->recurring_item = null;
3025 3025
 
3026 3026
         // Ensure that we have an array.
3027 3027
         if ( ! is_array( $value ) ) {
@@ -3035,95 +3035,95 @@  discard block
 block discarded – undo
3035 3035
     }
3036 3036
 
3037 3037
     /**
3038
-	 * Set the payment form.
3039
-	 *
3040
-	 * @since 1.0.19
3041
-	 * @param  int $value payment form.
3042
-	 */
3043
-	public function set_payment_form( $value ) {
3044
-		$this->set_prop( 'payment_form', $value );
3038
+     * Set the payment form.
3039
+     *
3040
+     * @since 1.0.19
3041
+     * @param  int $value payment form.
3042
+     */
3043
+    public function set_payment_form( $value ) {
3044
+        $this->set_prop( 'payment_form', $value );
3045 3045
     }
3046 3046
 
3047 3047
     /**
3048
-	 * Set the submission id.
3049
-	 *
3050
-	 * @since 1.0.19
3051
-	 * @param  string $value submission id.
3052
-	 */
3053
-	public function set_submission_id( $value ) {
3054
-		$this->set_prop( 'submission_id', $value );
3048
+     * Set the submission id.
3049
+     *
3050
+     * @since 1.0.19
3051
+     * @param  string $value submission id.
3052
+     */
3053
+    public function set_submission_id( $value ) {
3054
+        $this->set_prop( 'submission_id', $value );
3055 3055
     }
3056 3056
 
3057 3057
     /**
3058
-	 * Set the discount code.
3059
-	 *
3060
-	 * @since 1.0.19
3061
-	 * @param  string $value discount code.
3062
-	 */
3063
-	public function set_discount_code( $value ) {
3064
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3058
+     * Set the discount code.
3059
+     *
3060
+     * @since 1.0.19
3061
+     * @param  string $value discount code.
3062
+     */
3063
+    public function set_discount_code( $value ) {
3064
+        $this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3065 3065
     }
3066 3066
 
3067 3067
     /**
3068
-	 * Set the gateway.
3069
-	 *
3070
-	 * @since 1.0.19
3071
-	 * @param  string $value gateway.
3072
-	 */
3073
-	public function set_gateway( $value ) {
3074
-		$this->set_prop( 'gateway', $value );
3068
+     * Set the gateway.
3069
+     *
3070
+     * @since 1.0.19
3071
+     * @param  string $value gateway.
3072
+     */
3073
+    public function set_gateway( $value ) {
3074
+        $this->set_prop( 'gateway', $value );
3075 3075
     }
3076 3076
 
3077 3077
     /**
3078
-	 * Set the transaction id.
3079
-	 *
3080
-	 * @since 1.0.19
3081
-	 * @param  string $value transaction id.
3082
-	 */
3083
-	public function set_transaction_id( $value ) {
3084
-		if ( ! empty( $value ) ) {
3085
-			$this->set_prop( 'transaction_id', $value );
3086
-		}
3078
+     * Set the transaction id.
3079
+     *
3080
+     * @since 1.0.19
3081
+     * @param  string $value transaction id.
3082
+     */
3083
+    public function set_transaction_id( $value ) {
3084
+        if ( ! empty( $value ) ) {
3085
+            $this->set_prop( 'transaction_id', $value );
3086
+        }
3087 3087
     }
3088 3088
 
3089 3089
     /**
3090
-	 * Set the currency id.
3091
-	 *
3092
-	 * @since 1.0.19
3093
-	 * @param  string $value currency id.
3094
-	 */
3095
-	public function set_currency( $value ) {
3096
-		$this->set_prop( 'currency', $value );
3090
+     * Set the currency id.
3091
+     *
3092
+     * @since 1.0.19
3093
+     * @param  string $value currency id.
3094
+     */
3095
+    public function set_currency( $value ) {
3096
+        $this->set_prop( 'currency', $value );
3097 3097
     }
3098 3098
 
3099
-	/**
3100
-	 * Set whether to disable taxes.
3101
-	 *
3102
-	 * @since 1.0.19
3103
-	 * @param  bool $value value.
3104
-	 */
3105
-	public function set_disable_taxes( $value ) {
3106
-		$this->set_prop( 'disable_taxes', (bool) $value );
3107
-	}
3099
+    /**
3100
+     * Set whether to disable taxes.
3101
+     *
3102
+     * @since 1.0.19
3103
+     * @param  bool $value value.
3104
+     */
3105
+    public function set_disable_taxes( $value ) {
3106
+        $this->set_prop( 'disable_taxes', (bool) $value );
3107
+    }
3108 3108
 
3109 3109
     /**
3110
-	 * Set the subscription id.
3111
-	 *
3112
-	 * @since 1.0.19
3113
-	 * @param  string $value subscription id.
3114
-	 */
3115
-	public function set_subscription_id( $value ) {
3116
-		$this->set_prop( 'subscription_id', $value );
3117
-	}
3110
+     * Set the subscription id.
3111
+     *
3112
+     * @since 1.0.19
3113
+     * @param  string $value subscription id.
3114
+     */
3115
+    public function set_subscription_id( $value ) {
3116
+        $this->set_prop( 'subscription_id', $value );
3117
+    }
3118 3118
 
3119
-	/**
3120
-	 * Set the remote subscription id.
3121
-	 *
3122
-	 * @since 1.0.19
3123
-	 * @param  string $value subscription id.
3124
-	 */
3125
-	public function set_remote_subscription_id( $value ) {
3126
-		$this->set_prop( 'remote_subscription_id', $value );
3119
+    /**
3120
+     * Set the remote subscription id.
3121
+     *
3122
+     * @since 1.0.19
3123
+     * @param  string $value subscription id.
3124
+     */
3125
+    public function set_remote_subscription_id( $value ) {
3126
+        $this->set_prop( 'remote_subscription_id', $value );
3127 3127
     }
3128 3128
 
3129 3129
     /*
@@ -3162,24 +3162,24 @@  discard block
 block discarded – undo
3162 3162
      */
3163 3163
     public function is_taxable() {
3164 3164
         return ! $this->get_disable_taxes();
3165
-	}
3165
+    }
3166 3166
 
3167
-	/**
3168
-	 * @deprecated
3169
-	 */
3170
-	public function has_vat() {
3167
+    /**
3168
+     * @deprecated
3169
+     */
3170
+    public function has_vat() {
3171 3171
         return $this->is_taxable();
3172
-	}
3172
+    }
3173 3173
 
3174
-	/**
3175
-	 * Checks to see if the invoice requires payment.
3176
-	 */
3177
-	public function is_free() {
3174
+    /**
3175
+     * Checks to see if the invoice requires payment.
3176
+     */
3177
+    public function is_free() {
3178 3178
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3179 3179
 
3180
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3181
-			$is_free = false;
3182
-		}
3180
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3181
+            $is_free = false;
3182
+        }
3183 3183
 
3184 3184
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3185 3185
     }
@@ -3190,46 +3190,46 @@  discard block
 block discarded – undo
3190 3190
     public function is_paid() {
3191 3191
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3192 3192
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3193
-	}
3193
+    }
3194 3194
 
3195
-	/**
3195
+    /**
3196 3196
      * Checks if the invoice needs payment.
3197 3197
      */
3198
-	public function needs_payment() {
3199
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3198
+    public function needs_payment() {
3199
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3200 3200
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3201 3201
     }
3202 3202
 
3203
-	/**
3203
+    /**
3204 3204
      * Checks if the invoice is refunded.
3205 3205
      */
3206
-	public function is_refunded() {
3206
+    public function is_refunded() {
3207 3207
         $is_refunded = $this->has_status( 'wpi-refunded' );
3208 3208
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3209
-	}
3209
+    }
3210 3210
 
3211
-	/**
3211
+    /**
3212 3212
      * Checks if the invoice is held.
3213 3213
      */
3214
-	public function is_held() {
3214
+    public function is_held() {
3215 3215
         $is_held = $this->has_status( 'wpi-onhold' );
3216 3216
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3217
-	}
3217
+    }
3218 3218
 
3219
-	/**
3219
+    /**
3220 3220
      * Checks if the invoice is due.
3221 3221
      */
3222
-	public function is_due() {
3223
-		$due_date = $this->get_due_date();
3224
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3225
-	}
3222
+    public function is_due() {
3223
+        $due_date = $this->get_due_date();
3224
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3225
+    }
3226 3226
 
3227
-	/**
3227
+    /**
3228 3228
      * Checks if the invoice is draft.
3229 3229
      */
3230
-	public function is_draft() {
3230
+    public function is_draft() {
3231 3231
         return $this->has_status( 'draft, auto-draft' );
3232
-	}
3232
+    }
3233 3233
 
3234 3234
     /**
3235 3235
      * Checks if the invoice has a given status.
@@ -3237,9 +3237,9 @@  discard block
 block discarded – undo
3237 3237
     public function has_status( $status ) {
3238 3238
         $status = wpinv_parse_list( $status );
3239 3239
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3240
-	}
3240
+    }
3241 3241
 
3242
-	/**
3242
+    /**
3243 3243
      * Checks if the invoice is of a given type.
3244 3244
      */
3245 3245
     public function is_type( $type ) {
@@ -3262,25 +3262,25 @@  discard block
 block discarded – undo
3262 3262
      */
3263 3263
     public function has_free_trial() {
3264 3264
         return $this->is_recurring() && 0 == $this->get_initial_total();
3265
-	}
3265
+    }
3266 3266
 
3267
-	/**
3267
+    /**
3268 3268
      * @deprecated
3269 3269
      */
3270 3270
     public function is_free_trial() {
3271 3271
         return $this->has_free_trial();
3272 3272
     }
3273 3273
 
3274
-	/**
3274
+    /**
3275 3275
      * Check if the initial payment if 0.
3276 3276
      *
3277 3277
      */
3278
-	public function is_initial_free() {
3278
+    public function is_initial_free() {
3279 3279
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3280 3280
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3281 3281
     }
3282 3282
 
3283
-	/**
3283
+    /**
3284 3284
      * Check if the recurring item has a free trial.
3285 3285
      *
3286 3286
      */
@@ -3293,21 +3293,21 @@  discard block
 block discarded – undo
3293 3293
 
3294 3294
         $item = $this->get_recurring( true );
3295 3295
         return $item->has_free_trial();
3296
-	}
3296
+    }
3297 3297
 
3298
-	/**
3298
+    /**
3299 3299
      * Check if the free trial is a result of a discount.
3300 3300
      */
3301 3301
     public function is_free_trial_from_discount() {
3302
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3303
-	}
3302
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3303
+    }
3304 3304
 
3305
-	/**
3305
+    /**
3306 3306
      * @deprecated
3307 3307
      */
3308 3308
     public function discount_first_payment_only() {
3309 3309
 
3310
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3310
+        $discount = wpinv_get_discount_obj( $this->get_discount_code() );
3311 3311
         if ( ! $discount->exists() || ! $this->is_recurring() ) {
3312 3312
             return true;
3313 3313
         }
@@ -3332,146 +3332,146 @@  discard block
 block discarded – undo
3332 3332
      */
3333 3333
     public function add_item( $item ) {
3334 3334
 
3335
-		if ( is_array( $item ) ) {
3336
-			$item = $this->process_array_item( $item );
3337
-		}
3335
+        if ( is_array( $item ) ) {
3336
+            $item = $this->process_array_item( $item );
3337
+        }
3338 3338
 
3339
-		if ( is_numeric( $item ) ) {
3340
-			$item = new GetPaid_Form_Item( $item );
3341
-		}
3339
+        if ( is_numeric( $item ) ) {
3340
+            $item = new GetPaid_Form_Item( $item );
3341
+        }
3342 3342
 
3343 3343
         // Make sure that it is available for purchase.
3344
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3345
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3344
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3345
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3346 3346
         }
3347 3347
 
3348 3348
         // Do we have a recurring item?
3349
-		if ( $item->is_recurring() ) {
3350
-			$this->recurring_item = $item->get_id();
3349
+        if ( $item->is_recurring() ) {
3350
+            $this->recurring_item = $item->get_id();
3351 3351
         }
3352 3352
 
3353 3353
         // Invoice id.
3354 3354
         $item->invoice_id = (int) $this->get_id();
3355 3355
 
3356
-		// Remove duplicates.
3357
-		$this->remove_item( $item->get_id() );
3356
+        // Remove duplicates.
3357
+        $this->remove_item( $item->get_id() );
3358 3358
 
3359
-		if ( 0 == $item->get_quantity() ) {
3360
-			return;
3361
-		}
3359
+        if ( 0 == $item->get_quantity() ) {
3360
+            return;
3361
+        }
3362 3362
 
3363
-		// Retrieve all items.
3363
+        // Retrieve all items.
3364 3364
         $items   = $this->get_items();
3365 3365
 
3366
-		// Add new item.
3366
+        // Add new item.
3367 3367
         $items[] = $item;
3368 3368
 
3369 3369
         $this->set_prop( 'items', $items );
3370 3370
 
3371
-		return true;
3372
-	}
3371
+        return true;
3372
+    }
3373 3373
 
3374
-	/**
3375
-	 * Converts an array to an item.
3376
-	 *
3377
-	 * @since 1.0.19
3378
-	 * @return GetPaid_Form_Item
3379
-	 */
3380
-	protected function process_array_item( $array ) {
3374
+    /**
3375
+     * Converts an array to an item.
3376
+     *
3377
+     * @since 1.0.19
3378
+     * @return GetPaid_Form_Item
3379
+     */
3380
+    protected function process_array_item( $array ) {
3381 3381
 
3382
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3383
-		$item    = new GetPaid_Form_Item( $item_id );
3382
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3383
+        $item    = new GetPaid_Form_Item( $item_id );
3384 3384
 
3385
-		// Set item data.
3386
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3387
-			if ( isset( $array[ "item_$key" ] ) ) {
3388
-				$method = "set_$key";
3389
-				$item->$method( $array[ "item_$key" ] );
3390
-			}
3391
-		}
3385
+        // Set item data.
3386
+        foreach ( array( 'name', 'price', 'description' ) as $key ) {
3387
+            if ( isset( $array[ "item_$key" ] ) ) {
3388
+                $method = "set_$key";
3389
+                $item->$method( $array[ "item_$key" ] );
3390
+            }
3391
+        }
3392 3392
 
3393
-		if ( isset( $array['quantity'] ) ) {
3394
-			$item->set_quantity( $array['quantity'] );
3395
-		}
3393
+        if ( isset( $array['quantity'] ) ) {
3394
+            $item->set_quantity( $array['quantity'] );
3395
+        }
3396 3396
 
3397
-		// Set item meta.
3398
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3399
-			$item->set_item_meta( $array['meta'] );
3400
-		}
3397
+        // Set item meta.
3398
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3399
+            $item->set_item_meta( $array['meta'] );
3400
+        }
3401 3401
 
3402
-		return $item;
3402
+        return $item;
3403 3403
 
3404
-	}
3404
+    }
3405 3405
 
3406 3406
     /**
3407
-	 * Retrieves a specific item.
3408
-	 *
3409
-	 * @since 1.0.19
3410
-	 * @return GetPaid_Form_Item|null
3411
-	 */
3412
-	public function get_item( $item_id ) {
3407
+     * Retrieves a specific item.
3408
+     *
3409
+     * @since 1.0.19
3410
+     * @return GetPaid_Form_Item|null
3411
+     */
3412
+    public function get_item( $item_id ) {
3413 3413
 
3414
-		foreach ( $this->get_items() as $item ) {
3415
-			if ( (int) $item_id == $item->get_id() ) {
3416
-				return $item;
3417
-			}
3418
-		}
3414
+        foreach ( $this->get_items() as $item ) {
3415
+            if ( (int) $item_id == $item->get_id() ) {
3416
+                return $item;
3417
+            }
3418
+        }
3419 3419
 
3420
-		return null;
3420
+        return null;
3421 3421
     }
3422 3422
 
3423 3423
     /**
3424
-	 * Removes a specific item.
3425
-	 *
3426
-	 * @since 1.0.19
3427
-	 */
3428
-	public function remove_item( $item_id ) {
3429
-		$items   = $this->get_items();
3430
-		$item_id = (int) $item_id;
3424
+     * Removes a specific item.
3425
+     *
3426
+     * @since 1.0.19
3427
+     */
3428
+    public function remove_item( $item_id ) {
3429
+        $items   = $this->get_items();
3430
+        $item_id = (int) $item_id;
3431 3431
 
3432
-		foreach ( $items as $index => $item ) {
3433
-			if ( (int) $item_id == $item->get_id() ) {
3434
-				unset( $items[ $index ] );
3435
-				$this->set_prop( 'items', $items );
3432
+        foreach ( $items as $index => $item ) {
3433
+            if ( (int) $item_id == $item->get_id() ) {
3434
+                unset( $items[ $index ] );
3435
+                $this->set_prop( 'items', $items );
3436 3436
 
3437
-				if ( $item_id == $this->recurring_item ) {
3438
-					$this->recurring_item = null;
3439
-				}
3437
+                if ( $item_id == $this->recurring_item ) {
3438
+                    $this->recurring_item = null;
3439
+                }
3440 3440
 }
3441
-		}
3441
+        }
3442 3442
 
3443 3443
     }
3444 3444
 
3445 3445
     /**
3446
-	 * Adds a fee to the invoice.
3447
-	 *
3448
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3449
-	 * @since 1.0.19
3450
-	 */
3446
+     * Adds a fee to the invoice.
3447
+     *
3448
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3449
+     * @since 1.0.19
3450
+     */
3451 3451
     public function add_fee( $fee ) {
3452 3452
 
3453
-		$fees                 = $this->get_fees();
3454
-		$fees[ $fee['name'] ] = $fee;
3455
-		$this->set_prop( 'fees', $fees );
3453
+        $fees                 = $this->get_fees();
3454
+        $fees[ $fee['name'] ] = $fee;
3455
+        $this->set_prop( 'fees', $fees );
3456 3456
 
3457 3457
     }
3458 3458
 
3459 3459
     /**
3460
-	 * Retrieves a specific fee.
3461
-	 *
3462
-	 * @since 1.0.19
3463
-	 */
3464
-	public function get_fee( $fee ) {
3460
+     * Retrieves a specific fee.
3461
+     *
3462
+     * @since 1.0.19
3463
+     */
3464
+    public function get_fee( $fee ) {
3465 3465
         $fees = $this->get_fees();
3466
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3466
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3467 3467
     }
3468 3468
 
3469 3469
     /**
3470
-	 * Removes a specific fee.
3471
-	 *
3472
-	 * @since 1.0.19
3473
-	 */
3474
-	public function remove_fee( $fee ) {
3470
+     * Removes a specific fee.
3471
+     *
3472
+     * @since 1.0.19
3473
+     */
3474
+    public function remove_fee( $fee ) {
3475 3475
         $fees = $this->get_fees();
3476 3476
         if ( isset( $fees[ $fee ] ) ) {
3477 3477
             unset( $fees[ $fee ] );
@@ -3479,55 +3479,55 @@  discard block
 block discarded – undo
3479 3479
         }
3480 3480
     }
3481 3481
 
3482
-	/**
3483
-	 * Adds a discount to the invoice.
3484
-	 *
3485
-	 * @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.
3486
-	 * @since 1.0.19
3487
-	 */
3488
-	public function add_discount( $discount ) {
3482
+    /**
3483
+     * Adds a discount to the invoice.
3484
+     *
3485
+     * @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.
3486
+     * @since 1.0.19
3487
+     */
3488
+    public function add_discount( $discount ) {
3489 3489
 
3490
-		$discounts = $this->get_discounts();
3491
-		$discounts[ $discount['name'] ] = $discount;
3492
-		$this->set_prop( 'discounts', $discounts );
3490
+        $discounts = $this->get_discounts();
3491
+        $discounts[ $discount['name'] ] = $discount;
3492
+        $this->set_prop( 'discounts', $discounts );
3493 3493
 
3494
-	}
3494
+    }
3495 3495
 
3496 3496
     /**
3497
-	 * Retrieves a specific discount.
3498
-	 *
3499
-	 * @since 1.0.19
3500
-	 * @return float
3501
-	 */
3502
-	public function get_discount( $discount = false ) {
3497
+     * Retrieves a specific discount.
3498
+     *
3499
+     * @since 1.0.19
3500
+     * @return float
3501
+     */
3502
+    public function get_discount( $discount = false ) {
3503 3503
 
3504
-		// Backwards compatibilty.
3505
-		if ( empty( $discount ) ) {
3506
-			return $this->get_total_discount();
3507
-		}
3504
+        // Backwards compatibilty.
3505
+        if ( empty( $discount ) ) {
3506
+            return $this->get_total_discount();
3507
+        }
3508 3508
 
3509 3509
         $discounts = $this->get_discounts();
3510
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3510
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3511 3511
     }
3512 3512
 
3513 3513
     /**
3514
-	 * Removes a specific discount.
3515
-	 *
3516
-	 * @since 1.0.19
3517
-	 */
3518
-	public function remove_discount( $discount ) {
3514
+     * Removes a specific discount.
3515
+     *
3516
+     * @since 1.0.19
3517
+     */
3518
+    public function remove_discount( $discount ) {
3519 3519
         $discounts = $this->get_discounts();
3520 3520
         if ( isset( $discounts[ $discount ] ) ) {
3521 3521
             unset( $discounts[ $discount ] );
3522 3522
             $this->set_prop( 'discounts', $discounts );
3523 3523
         }
3524 3524
 
3525
-		if ( 'discount_code' == $discount ) {
3526
-			foreach ( $this->get_items() as $item ) {
3527
-				$item->item_discount           = 0;
3528
-				$item->recurring_item_discount = 0;
3529
-			}
3530
-		}
3525
+        if ( 'discount_code' == $discount ) {
3526
+            foreach ( $this->get_items() as $item ) {
3527
+                $item->item_discount           = 0;
3528
+                $item->recurring_item_discount = 0;
3529
+            }
3530
+        }
3531 3531
 
3532 3532
     }
3533 3533
 
@@ -3540,34 +3540,34 @@  discard block
 block discarded – undo
3540 3540
         if ( $this->is_taxable() ) {
3541 3541
 
3542 3542
             $taxes                 = $this->get_taxes();
3543
-			$taxes[ $tax['name'] ] = $tax;
3544
-			$this->set_prop( 'taxes', $tax );
3543
+            $taxes[ $tax['name'] ] = $tax;
3544
+            $this->set_prop( 'taxes', $tax );
3545 3545
 
3546 3546
         }
3547 3547
     }
3548 3548
 
3549 3549
     /**
3550
-	 * Retrieves a specific tax.
3551
-	 *
3552
-	 * @since 1.0.19
3553
-	 */
3554
-	public function get_tax( $tax = null ) {
3550
+     * Retrieves a specific tax.
3551
+     *
3552
+     * @since 1.0.19
3553
+     */
3554
+    public function get_tax( $tax = null ) {
3555 3555
 
3556
-		// Backwards compatility.
3557
-		if ( empty( $tax ) ) {
3558
-			return $this->get_total_tax();
3559
-		}
3556
+        // Backwards compatility.
3557
+        if ( empty( $tax ) ) {
3558
+            return $this->get_total_tax();
3559
+        }
3560 3560
 
3561 3561
         $taxes = $this->get_taxes();
3562
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3562
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3563 3563
     }
3564 3564
 
3565 3565
     /**
3566
-	 * Removes a specific tax.
3567
-	 *
3568
-	 * @since 1.0.19
3569
-	 */
3570
-	public function remove_tax( $tax ) {
3566
+     * Removes a specific tax.
3567
+     *
3568
+     * @since 1.0.19
3569
+     */
3570
+    public function remove_tax( $tax ) {
3571 3571
         $taxes = $this->get_taxes();
3572 3572
         if ( isset( $taxes[ $tax ] ) ) {
3573 3573
             unset( $taxes[ $tax ] );
@@ -3576,184 +3576,184 @@  discard block
 block discarded – undo
3576 3576
     }
3577 3577
 
3578 3578
     /**
3579
-	 * Recalculates the invoice subtotal.
3580
-	 *
3581
-	 * @since 1.0.19
3582
-	 * @return float The recalculated subtotal
3583
-	 */
3584
-	public function recalculate_subtotal() {
3579
+     * Recalculates the invoice subtotal.
3580
+     *
3581
+     * @since 1.0.19
3582
+     * @return float The recalculated subtotal
3583
+     */
3584
+    public function recalculate_subtotal() {
3585 3585
         $items     = $this->get_items();
3586
-		$subtotal  = 0;
3587
-		$recurring = 0;
3586
+        $subtotal  = 0;
3587
+        $recurring = 0;
3588 3588
 
3589 3589
         foreach ( $items as $item ) {
3590
-			$subtotal  += $item->get_sub_total( 'edit' );
3591
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3590
+            $subtotal  += $item->get_sub_total( 'edit' );
3591
+            $recurring += $item->get_recurring_sub_total( 'edit' );
3592 3592
         }
3593 3593
 
3594
-		if ( wpinv_prices_include_tax() ) {
3595
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3596
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3597
-		}
3594
+        if ( wpinv_prices_include_tax() ) {
3595
+            $subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3596
+            $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3597
+        }
3598 3598
 
3599
-		$current = $this->is_renewal() ? $recurring : $subtotal;
3600
-		$this->set_subtotal( $current );
3599
+        $current = $this->is_renewal() ? $recurring : $subtotal;
3600
+        $this->set_subtotal( $current );
3601 3601
 
3602
-		$this->totals['subtotal'] = array(
3603
-			'initial'   => $subtotal,
3604
-			'recurring' => $recurring,
3605
-		);
3602
+        $this->totals['subtotal'] = array(
3603
+            'initial'   => $subtotal,
3604
+            'recurring' => $recurring,
3605
+        );
3606 3606
 
3607 3607
         return $current;
3608 3608
     }
3609 3609
 
3610 3610
     /**
3611
-	 * Recalculates the invoice discount total.
3612
-	 *
3613
-	 * @since 1.0.19
3614
-	 * @return float The recalculated discount
3615
-	 */
3616
-	public function recalculate_total_discount() {
3611
+     * Recalculates the invoice discount total.
3612
+     *
3613
+     * @since 1.0.19
3614
+     * @return float The recalculated discount
3615
+     */
3616
+    public function recalculate_total_discount() {
3617 3617
         $discounts = $this->get_discounts();
3618
-		$discount  = 0;
3619
-		$recurring = 0;
3618
+        $discount  = 0;
3619
+        $recurring = 0;
3620 3620
 
3621 3621
         foreach ( $discounts as $data ) {
3622
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3623
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3624
-		}
3622
+            $discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3623
+            $recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3624
+        }
3625 3625
 
3626
-		$current = $this->is_renewal() ? $recurring : $discount;
3626
+        $current = $this->is_renewal() ? $recurring : $discount;
3627 3627
 
3628
-		$this->set_total_discount( $current );
3628
+        $this->set_total_discount( $current );
3629 3629
 
3630
-		$this->totals['discount'] = array(
3631
-			'initial'   => $discount,
3632
-			'recurring' => $recurring,
3633
-		);
3630
+        $this->totals['discount'] = array(
3631
+            'initial'   => $discount,
3632
+            'recurring' => $recurring,
3633
+        );
3634 3634
 
3635
-		return $current;
3635
+        return $current;
3636 3636
 
3637 3637
     }
3638 3638
 
3639 3639
     /**
3640
-	 * Recalculates the invoice tax total.
3641
-	 *
3642
-	 * @since 1.0.19
3643
-	 * @return float The recalculated tax
3644
-	 */
3645
-	public function recalculate_total_tax() {
3640
+     * Recalculates the invoice tax total.
3641
+     *
3642
+     * @since 1.0.19
3643
+     * @return float The recalculated tax
3644
+     */
3645
+    public function recalculate_total_tax() {
3646 3646
 
3647
-		// Maybe disable taxes.
3648
-		$vat_number = $this->get_vat_number();
3649
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3647
+        // Maybe disable taxes.
3648
+        $vat_number = $this->get_vat_number();
3649
+        $skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3650 3650
 
3651
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3652
-			$skip_tax = false;
3653
-		}
3651
+        if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3652
+            $skip_tax = false;
3653
+        }
3654 3654
 
3655
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) {
3655
+        if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) {
3656 3656
 
3657
-			$this->totals['tax'] = array(
3658
-				'initial'   => 0,
3659
-				'recurring' => 0,
3660
-			);
3657
+            $this->totals['tax'] = array(
3658
+                'initial'   => 0,
3659
+                'recurring' => 0,
3660
+            );
3661 3661
 
3662
-			$this->tax_rate = 0;
3662
+            $this->tax_rate = 0;
3663 3663
 
3664
-			$this->set_taxes( array() );
3665
-			$current = 0;
3666
-		} else {
3664
+            $this->set_taxes( array() );
3665
+            $current = 0;
3666
+        } else {
3667 3667
 
3668
-			$item_taxes = array();
3668
+            $item_taxes = array();
3669 3669
 
3670
-			foreach ( $this->get_items() as $item ) {
3671
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3672
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3673
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3674
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3675
-				foreach ( $taxes as $name => $amount ) {
3676
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3677
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3670
+            foreach ( $this->get_items() as $item ) {
3671
+                $rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3672
+                $rates    = getpaid_filter_item_tax_rates( $item, $rates );
3673
+                $taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3674
+                $r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3675
+                foreach ( $taxes as $name => $amount ) {
3676
+                    $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3677
+                    $tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3678 3678
 
3679
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3680
-						$item_taxes[ $name ] = $tax;
3681
-						continue;
3682
-					}
3679
+                    if ( ! isset( $item_taxes[ $name ] ) ) {
3680
+                        $item_taxes[ $name ] = $tax;
3681
+                        continue;
3682
+                    }
3683 3683
 
3684
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3685
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3684
+                    $item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3685
+                    $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3686 3686
 
3687
-				}
3688
-			}
3687
+                }
3688
+            }
3689 3689
 
3690
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3691
-			$this->set_taxes( $item_taxes );
3690
+            $item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3691
+            $this->set_taxes( $item_taxes );
3692 3692
 
3693
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3694
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3693
+            $initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3694
+            $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3695 3695
 
3696
-			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3696
+            $current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3697 3697
 
3698
-			$this->totals['tax'] = array(
3699
-				'initial'   => $initial_tax,
3700
-				'recurring' => $recurring_tax,
3701
-			);
3698
+            $this->totals['tax'] = array(
3699
+                'initial'   => $initial_tax,
3700
+                'recurring' => $recurring_tax,
3701
+            );
3702 3702
 
3703
-		}
3703
+        }
3704 3704
 
3705
-		$this->set_total_tax( $current );
3705
+        $this->set_total_tax( $current );
3706 3706
 
3707
-		return $current;
3707
+        return $current;
3708 3708
 
3709 3709
     }
3710 3710
 
3711 3711
     /**
3712
-	 * Recalculates the invoice fees total.
3713
-	 *
3714
-	 * @since 1.0.19
3715
-	 * @return float The recalculated fee
3716
-	 */
3717
-	public function recalculate_total_fees() {
3718
-		$fees      = $this->get_fees();
3719
-		$fee       = 0;
3720
-		$recurring = 0;
3712
+     * Recalculates the invoice fees total.
3713
+     *
3714
+     * @since 1.0.19
3715
+     * @return float The recalculated fee
3716
+     */
3717
+    public function recalculate_total_fees() {
3718
+        $fees      = $this->get_fees();
3719
+        $fee       = 0;
3720
+        $recurring = 0;
3721 3721
 
3722 3722
         foreach ( $fees as $data ) {
3723
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3724
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3725
-		}
3723
+            $fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3724
+            $recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3725
+        }
3726 3726
 
3727
-		$current = $this->is_renewal() ? $recurring : $fee;
3728
-		$this->set_total_fees( $current );
3727
+        $current = $this->is_renewal() ? $recurring : $fee;
3728
+        $this->set_total_fees( $current );
3729 3729
 
3730
-		$this->totals['fee'] = array(
3731
-			'initial'   => $fee,
3732
-			'recurring' => $recurring,
3733
-		);
3730
+        $this->totals['fee'] = array(
3731
+            'initial'   => $fee,
3732
+            'recurring' => $recurring,
3733
+        );
3734 3734
 
3735 3735
         $this->set_total_fees( $fee );
3736 3736
         return $current;
3737 3737
     }
3738 3738
 
3739 3739
     /**
3740
-	 * Recalculates the invoice total.
3741
-	 *
3742
-	 * @since 1.0.19
3740
+     * Recalculates the invoice total.
3741
+     *
3742
+     * @since 1.0.19
3743 3743
      * @return float The invoice total
3744
-	 */
3745
-	public function recalculate_total() {
3744
+     */
3745
+    public function recalculate_total() {
3746 3746
         $this->recalculate_total_fees();
3747 3747
         $this->recalculate_total_discount();
3748
-		$this->recalculate_total_tax();
3749
-		$this->recalculate_subtotal();
3750
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3751
-		return $this->get_total();
3752
-	}
3753
-
3754
-	/**
3755
-	 * @deprecated
3756
-	 */
3748
+        $this->recalculate_total_tax();
3749
+        $this->recalculate_subtotal();
3750
+        $this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3751
+        return $this->get_total();
3752
+    }
3753
+
3754
+    /**
3755
+     * @deprecated
3756
+     */
3757 3757
     public function recalculate_totals() {
3758 3758
         $this->recalculate_total();
3759 3759
         $this->save( true );
@@ -3767,22 +3767,22 @@  discard block
 block discarded – undo
3767 3767
         return $this->get_data();
3768 3768
     }
3769 3769
 
3770
-	/**
3770
+    /**
3771 3771
      * Adds a system note to an invoice.
3772 3772
      *
3773 3773
      * @param string $note The note being added.
3774
-	 * @return int|false The new note's ID on success, false on failure.
3774
+     * @return int|false The new note's ID on success, false on failure.
3775 3775
      *
3776 3776
      */
3777 3777
     public function add_system_note( $note ) {
3778
-		return $this->add_note( $note, false, false, true );
3779
-	}
3778
+        return $this->add_note( $note, false, false, true );
3779
+    }
3780 3780
 
3781 3781
     /**
3782 3782
      * Adds a note to an invoice.
3783 3783
      *
3784 3784
      * @param string $note The note being added.
3785
-	 * @return int|false The new note's ID on success, false on failure.
3785
+     * @return int|false The new note's ID on success, false on failure.
3786 3786
      *
3787 3787
      */
3788 3788
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3792,21 +3792,21 @@  discard block
 block discarded – undo
3792 3792
             return false;
3793 3793
         }
3794 3794
 
3795
-		$author       = 'System';
3796
-		$author_email = '[email protected]';
3795
+        $author       = 'System';
3796
+        $author_email = '[email protected]';
3797 3797
 
3798
-		// If this is an admin comment or it has been added by the user.
3799
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3800
-			$user         = get_user_by( 'id', get_current_user_id() );
3798
+        // If this is an admin comment or it has been added by the user.
3799
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3800
+            $user         = get_user_by( 'id', get_current_user_id() );
3801 3801
             $author       = $user->display_name;
3802 3802
             $author_email = $user->user_email;
3803
-		}
3803
+        }
3804 3804
 
3805
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3805
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3806 3806
 
3807
-	}
3807
+    }
3808 3808
 
3809
-	/**
3809
+    /**
3810 3810
      * Generates a unique key for the invoice.
3811 3811
      */
3812 3812
     public function generate_key( $string = '' ) {
@@ -3826,113 +3826,113 @@  discard block
 block discarded – undo
3826 3826
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3827 3827
         }
3828 3828
 
3829
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3830
-
3831
-	}
3832
-
3833
-	/**
3834
-	 * Handle the status transition.
3835
-	 */
3836
-	protected function status_transition() {
3837
-		$status_transition = $this->status_transition;
3838
-
3839
-		// Reset status transition variable.
3840
-		$this->status_transition = false;
3841
-
3842
-		if ( $status_transition ) {
3843
-			try {
3844
-
3845
-				// Fire a hook for the status change.
3846
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3847
-
3848
-				// @deprecated this is deprecated and will be removed in the future.
3849
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3850
-
3851
-				if ( ! empty( $status_transition['from'] ) ) {
3852
-
3853
-					/* translators: 1: old invoice status 2: new invoice status */
3854
-					$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 ) );
3855
-
3856
-					// Fire another hook.
3857
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3858
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3829
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3859 3830
 
3860
-					// @deprecated this is deprecated and will be removed in the future.
3861
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3862
-
3863
-					// Note the transition occurred.
3864
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3865
-
3866
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3867
-					if (
3868
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3869
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3870
-					) {
3871
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3872
-					}
3873
-
3874
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3875
-					if (
3876
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3877
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3878
-					) {
3879
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3880
-					}
3881
-				} else {
3882
-					/* translators: %s: new invoice status */
3883
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) );
3884
-
3885
-					// Note the transition occurred.
3886
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3831
+    }
3887 3832
 
3888
-				}
3889
-			} catch ( Exception $e ) {
3890
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3891
-			}
3892
-		}
3893
-	}
3833
+    /**
3834
+     * Handle the status transition.
3835
+     */
3836
+    protected function status_transition() {
3837
+        $status_transition = $this->status_transition;
3838
+
3839
+        // Reset status transition variable.
3840
+        $this->status_transition = false;
3841
+
3842
+        if ( $status_transition ) {
3843
+            try {
3844
+
3845
+                // Fire a hook for the status change.
3846
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3847
+
3848
+                // @deprecated this is deprecated and will be removed in the future.
3849
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3850
+
3851
+                if ( ! empty( $status_transition['from'] ) ) {
3852
+
3853
+                    /* translators: 1: old invoice status 2: new invoice status */
3854
+                    $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 ) );
3855
+
3856
+                    // Fire another hook.
3857
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3858
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3859
+
3860
+                    // @deprecated this is deprecated and will be removed in the future.
3861
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3862
+
3863
+                    // Note the transition occurred.
3864
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3865
+
3866
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3867
+                    if (
3868
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3869
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3870
+                    ) {
3871
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3872
+                    }
3873
+
3874
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3875
+                    if (
3876
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3877
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3878
+                    ) {
3879
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3880
+                    }
3881
+                } else {
3882
+                    /* translators: %s: new invoice status */
3883
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) );
3884
+
3885
+                    // Note the transition occurred.
3886
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3887
+
3888
+                }
3889
+            } catch ( Exception $e ) {
3890
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3891
+            }
3892
+        }
3893
+    }
3894 3894
 
3895
-	/**
3896
-	 * Updates an invoice status.
3897
-	 */
3898
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3895
+    /**
3896
+     * Updates an invoice status.
3897
+     */
3898
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3899 3899
 
3900
-		// Fires before updating a status.
3901
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3900
+        // Fires before updating a status.
3901
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3902 3902
 
3903
-		// Update the status.
3904
-		$this->set_status( $new_status, $note, $manual );
3903
+        // Update the status.
3904
+        $this->set_status( $new_status, $note, $manual );
3905 3905
 
3906
-		// Save the order.
3907
-		return $this->save();
3906
+        // Save the order.
3907
+        return $this->save();
3908 3908
 
3909
-	}
3909
+    }
3910 3910
 
3911
-	/**
3912
-	 * @deprecated
3913
-	 */
3914
-	public function refresh_item_ids() {
3911
+    /**
3912
+     * @deprecated
3913
+     */
3914
+    public function refresh_item_ids() {
3915 3915
         $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3916 3916
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3917
-	}
3917
+    }
3918 3918
 
3919
-	/**
3920
-	 * @deprecated
3921
-	 */
3922
-	public function update_items( $temp = false ) {
3919
+    /**
3920
+     * @deprecated
3921
+     */
3922
+    public function update_items( $temp = false ) {
3923 3923
 
3924
-		$this->set_items( $this->get_items() );
3924
+        $this->set_items( $this->get_items() );
3925 3925
 
3926
-		if ( ! $temp ) {
3927
-			$this->save();
3928
-		}
3926
+        if ( ! $temp ) {
3927
+            $this->save();
3928
+        }
3929 3929
 
3930 3930
         return $this;
3931
-	}
3931
+    }
3932 3932
 
3933
-	/**
3934
-	 * @deprecated
3935
-	 */
3933
+    /**
3934
+     * @deprecated
3935
+     */
3936 3936
     public function validate_discount() {
3937 3937
 
3938 3938
         $discount_code = $this->get_discount_code();
@@ -3948,101 +3948,101 @@  discard block
 block discarded – undo
3948 3948
 
3949 3949
     }
3950 3950
 
3951
-	/**
3952
-	 * Refunds an invoice.
3953
-	 */
3951
+    /**
3952
+     * Refunds an invoice.
3953
+     */
3954 3954
     public function refund() {
3955
-		$this->set_status( 'wpi-refunded' );
3955
+        $this->set_status( 'wpi-refunded' );
3956 3956
         $this->save();
3957
-	}
3957
+    }
3958 3958
 
3959
-	/**
3960
-	 * Marks an invoice as paid.
3961
-	 *
3962
-	 * @param string $transaction_id
3963
-	 */
3959
+    /**
3960
+     * Marks an invoice as paid.
3961
+     *
3962
+     * @param string $transaction_id
3963
+     */
3964 3964
     public function mark_paid( $transaction_id = null, $note = '' ) {
3965 3965
 
3966
-		// Set the transaction id.
3967
-		if ( empty( $transaction_id ) ) {
3968
-			$transaction_id = $this->generate_key( 'trans_' );
3969
-		}
3966
+        // Set the transaction id.
3967
+        if ( empty( $transaction_id ) ) {
3968
+            $transaction_id = $this->generate_key( 'trans_' );
3969
+        }
3970 3970
 
3971
-		if ( ! $this->get_transaction_id() ) {
3972
-			$this->set_transaction_id( $transaction_id );
3973
-		}
3971
+        if ( ! $this->get_transaction_id() ) {
3972
+            $this->set_transaction_id( $transaction_id );
3973
+        }
3974 3974
 
3975
-		if ( $this->is_paid() && 'wpi-processing' !== $this->get_status() ) {
3976
-			return $this->save();
3977
-		}
3975
+        if ( $this->is_paid() && 'wpi-processing' !== $this->get_status() ) {
3976
+            return $this->save();
3977
+        }
3978 3978
 
3979
-		// Set the completed date.
3980
-		$this->set_date_completed( current_time( 'mysql' ) );
3979
+        // Set the completed date.
3980
+        $this->set_date_completed( current_time( 'mysql' ) );
3981 3981
 
3982
-		// Set the new status.
3983
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3984
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
3982
+        // Set the new status.
3983
+        $gateway = sanitize_text_field( $this->get_gateway_title() );
3984
+        if ( $this->is_renewal() || ! $this->is_parent() ) {
3985 3985
 
3986
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3987
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3986
+            $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3987
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3988 3988
 
3989
-			if ( 'none' == $this->get_gateway() ) {
3990
-				$_note = $note;
3991
-			}
3989
+            if ( 'none' == $this->get_gateway() ) {
3990
+                $_note = $note;
3991
+            }
3992 3992
 
3993
-			$this->set_status( 'wpi-renewal', $_note );
3993
+            $this->set_status( 'wpi-renewal', $_note );
3994 3994
 
3995
-		} else {
3995
+        } else {
3996 3996
 
3997
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3998
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3997
+            $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3998
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3999 3999
 
4000
-			if ( 'none' == $this->get_gateway() ) {
4001
-				$_note = $note;
4002
-			}
4000
+            if ( 'none' == $this->get_gateway() ) {
4001
+                $_note = $note;
4002
+            }
4003 4003
 
4004
-			$this->set_status( 'publish', $_note );
4004
+            $this->set_status( 'publish', $_note );
4005 4005
 
4006
-		}
4006
+        }
4007 4007
 
4008
-		// Set checkout mode.
4009
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
4010
-		$this->set_mode( $mode );
4008
+        // Set checkout mode.
4009
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
4010
+        $this->set_mode( $mode );
4011 4011
 
4012
-		// Save the invoice.
4012
+        // Save the invoice.
4013 4013
         $this->save();
4014
-	}
4015
-
4016
-	/**
4017
-	 * Save data to the database.
4018
-	 *
4019
-	 * @since 1.0.19
4020
-	 * @return int invoice ID
4021
-	 */
4022
-	public function save() {
4023
-		$this->maybe_set_date_paid();
4024
-		$this->maybe_set_key();
4025
-		parent::save();
4026
-		$this->clear_cache();
4027
-		$this->status_transition();
4028
-		return $this->get_id();
4029
-	}
4030
-
4031
-	/**
4014
+    }
4015
+
4016
+    /**
4017
+     * Save data to the database.
4018
+     *
4019
+     * @since 1.0.19
4020
+     * @return int invoice ID
4021
+     */
4022
+    public function save() {
4023
+        $this->maybe_set_date_paid();
4024
+        $this->maybe_set_key();
4025
+        parent::save();
4026
+        $this->clear_cache();
4027
+        $this->status_transition();
4028
+        return $this->get_id();
4029
+    }
4030
+
4031
+    /**
4032 4032
      * Clears the subscription's cache.
4033 4033
      */
4034 4034
     public function clear_cache() {
4035
-		if ( $this->get_key() ) {
4036
-			wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4037
-		}
4038
-
4039
-		if ( $this->get_number() ) {
4040
-			wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4041
-		}
4042
-
4043
-		if ( $this->get_transaction_id() ) {
4044
-			wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4045
-		}
4046
-	}
4035
+        if ( $this->get_key() ) {
4036
+            wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4037
+        }
4038
+
4039
+        if ( $this->get_number() ) {
4040
+            wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4041
+        }
4042
+
4043
+        if ( $this->get_transaction_id() ) {
4044
+            wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4045
+        }
4046
+    }
4047 4047
 
4048 4048
 }
Please login to merge, or discard this patch.
Spacing   +817 added lines, -817 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.
@@ -146,39 +146,39 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
148 148
 	 */
149
-    public function __construct( $invoice = 0 ) {
149
+    public function __construct($invoice = 0) {
150 150
 
151
-        parent::__construct( $invoice );
151
+        parent::__construct($invoice);
152 152
 
153
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
154
-			$this->set_id( (int) $invoice );
155
-		} elseif ( $invoice instanceof self ) {
156
-			$this->set_id( $invoice->get_id() );
157
-		} elseif ( ! empty( $invoice->ID ) ) {
158
-			$this->set_id( $invoice->ID );
159
-		} elseif ( is_array( $invoice ) ) {
160
-			$this->set_props( $invoice );
153
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) {
154
+			$this->set_id((int) $invoice);
155
+		} elseif ($invoice instanceof self) {
156
+			$this->set_id($invoice->get_id());
157
+		} elseif (!empty($invoice->ID)) {
158
+			$this->set_id($invoice->ID);
159
+		} elseif (is_array($invoice)) {
160
+			$this->set_props($invoice);
161 161
 
162
-			if ( isset( $invoice['ID'] ) ) {
163
-				$this->set_id( $invoice['ID'] );
162
+			if (isset($invoice['ID'])) {
163
+				$this->set_id($invoice['ID']);
164 164
 			}
165
-} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
166
-			$this->set_id( $invoice_id );
167
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
168
-			$this->set_id( $invoice_id );
169
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
170
-			$this->set_id( $invoice_id );
165
+} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
166
+			$this->set_id($invoice_id);
167
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
168
+			$this->set_id($invoice_id);
169
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
170
+			$this->set_id($invoice_id);
171 171
 		} else {
172
-			$this->set_object_read( true );
172
+			$this->set_object_read(true);
173 173
 		}
174 174
 
175 175
         // Load the datastore.
176
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
176
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
177 177
 
178
-		if ( $this->get_id() > 0 ) {
179
-            $this->post = get_post( $this->get_id() );
178
+		if ($this->get_id() > 0) {
179
+            $this->post = get_post($this->get_id());
180 180
             $this->ID   = $this->get_id();
181
-			$this->data_store->read( $this );
181
+			$this->data_store->read($this);
182 182
         }
183 183
 
184 184
     }
@@ -193,38 +193,38 @@  discard block
 block discarded – undo
193 193
 	 * @since 1.0.15
194 194
 	 * @return int
195 195
 	 */
196
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
196
+	public static function get_invoice_id_by_field($value, $field = 'key') {
197 197
         global $wpdb;
198 198
 
199 199
 		// Trim the value.
200
-		$value = trim( $value );
200
+		$value = trim($value);
201 201
 
202
-		if ( empty( $value ) ) {
202
+		if (empty($value)) {
203 203
 			return 0;
204 204
 		}
205 205
 
206 206
         // Valid fields.
207
-        $fields = array( 'key', 'number', 'transaction_id' );
207
+        $fields = array('key', 'number', 'transaction_id');
208 208
 
209 209
 		// Ensure a field has been passed.
210
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
210
+		if (empty($field) || !in_array($field, $fields)) {
211 211
 			return 0;
212 212
 		}
213 213
 
214 214
 		// Maybe retrieve from the cache.
215
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
-		if ( false !== $invoice_id ) {
215
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
216
+		if (false !== $invoice_id) {
217 217
 			return $invoice_id;
218 218
 		}
219 219
 
220 220
         // Fetch from the db.
221 221
         $table       = $wpdb->prefix . 'getpaid_invoices';
222 222
         $invoice_id  = (int) $wpdb->get_var(
223
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
223
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
224 224
         );
225 225
 
226 226
 		// Update the cache with our data
227
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
227
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
228 228
 
229 229
 		return $invoice_id;
230 230
     }
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
     /**
233 233
      * Checks if an invoice key is set.
234 234
      */
235
-    public function _isset( $key ) {
236
-        return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" );
235
+    public function _isset($key) {
236
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
237 237
     }
238 238
 
239 239
     /*
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 	 * @param  string $context View or edit context.
259 259
 	 * @return int
260 260
 	 */
261
-	public function get_parent_id( $context = 'view' ) {
262
-		return (int) $this->get_prop( 'parent_id', $context );
261
+	public function get_parent_id($context = 'view') {
262
+		return (int) $this->get_prop('parent_id', $context);
263 263
     }
264 264
 
265 265
     /**
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 * @return WPInv_Invoice
270 270
 	 */
271 271
     public function get_parent_payment() {
272
-        return new WPInv_Invoice( $this->get_parent_id() );
272
+        return new WPInv_Invoice($this->get_parent_id());
273 273
     }
274 274
 
275 275
     /**
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	 * @param  string $context View or edit context.
290 290
 	 * @return string
291 291
 	 */
292
-	public function get_status( $context = 'view' ) {
293
-		return $this->get_prop( 'status', $context );
292
+	public function get_status($context = 'view') {
293
+		return $this->get_prop('status', $context);
294 294
 	}
295 295
 
296 296
 	/**
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	 * @return array
301 301
 	 */
302 302
 	public function get_all_statuses() {
303
-		return wpinv_get_invoice_statuses( true, true, $this );
303
+		return wpinv_get_invoice_statuses(true, true, $this);
304 304
     }
305 305
 
306 306
     /**
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
     public function get_status_nicename() {
313 313
 		$statuses = $this->get_all_statuses();
314 314
 
315
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
315
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
316 316
 
317
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
317
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
318 318
     }
319 319
 
320 320
 	/**
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	 */
326 326
 	public function get_status_class() {
327 327
 		$statuses = getpaid_get_invoice_status_classes();
328
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark';
328
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'bg-dark';
329 329
 	}
330 330
 
331 331
 	/**
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
      */
337 337
     public function get_status_label_html() {
338 338
 
339
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
340
-		$status       = sanitize_html_class( $this->get_status() );
341
-		$class        = esc_attr( $this->get_status_class() );
339
+		$status_label = sanitize_text_field($this->get_status_nicename());
340
+		$status       = sanitize_html_class($this->get_status());
341
+		$class        = esc_attr($this->get_status_class());
342 342
 
343 343
 		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
344 344
 	}
@@ -350,23 +350,23 @@  discard block
 block discarded – undo
350 350
 	 * @param  string $context View or edit context.
351 351
 	 * @return string
352 352
 	 */
353
-	public function get_version( $context = 'view' ) {
354
-		return $this->get_prop( 'version', $context );
353
+	public function get_version($context = 'view') {
354
+		return $this->get_prop('version', $context);
355 355
 	}
356 356
 
357 357
 	/**
358 358
 	 * @deprecated
359 359
 	 */
360
-	public function get_invoice_date( $format = true ) {
361
-		$date      = getpaid_format_date( $this->get_date_completed() );
362
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
363
-		$formatted = getpaid_format_date( $date );
360
+	public function get_invoice_date($format = true) {
361
+		$date      = getpaid_format_date($this->get_date_completed());
362
+		$date      = empty($date) ? $this->get_date_created() : $this->get_date_completed();
363
+		$formatted = getpaid_format_date($date);
364 364
 
365
-		if ( $format ) {
365
+		if ($format) {
366 366
 			return $formatted;
367 367
 		}
368 368
 
369
-		return empty( $formatted ) ? '' : $date;
369
+		return empty($formatted) ? '' : $date;
370 370
 
371 371
     }
372 372
 
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 	 * @param  string $context View or edit context.
378 378
 	 * @return string
379 379
 	 */
380
-	public function get_date_created( $context = 'view' ) {
381
-		return $this->get_prop( 'date_created', $context );
380
+	public function get_date_created($context = 'view') {
381
+		return $this->get_prop('date_created', $context);
382 382
 	}
383 383
 
384 384
 	/**
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
 	 * @param  string $context View or edit context.
389 389
 	 * @return string
390 390
 	 */
391
-	public function get_created_date( $context = 'view' ) {
392
-		return $this->get_date_created( $context );
391
+	public function get_created_date($context = 'view') {
392
+		return $this->get_date_created($context);
393 393
     }
394 394
 
395 395
     /**
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
 	 * @param  string $context View or edit context.
400 400
 	 * @return string
401 401
 	 */
402
-	public function get_date_created_gmt( $context = 'view' ) {
403
-        $date = $this->get_date_created( $context );
402
+	public function get_date_created_gmt($context = 'view') {
403
+        $date = $this->get_date_created($context);
404 404
 
405
-        if ( $date ) {
406
-            $date = get_gmt_from_date( $date );
405
+        if ($date) {
406
+            $date = get_gmt_from_date($date);
407 407
         }
408 408
 		return $date;
409 409
     }
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 	 * @param  string $context View or edit context.
416 416
 	 * @return string
417 417
 	 */
418
-	public function get_date_modified( $context = 'view' ) {
419
-		return $this->get_prop( 'date_modified', $context );
418
+	public function get_date_modified($context = 'view') {
419
+		return $this->get_prop('date_modified', $context);
420 420
 	}
421 421
 
422 422
 	/**
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 	 * @param  string $context View or edit context.
427 427
 	 * @return string
428 428
 	 */
429
-	public function get_modified_date( $context = 'view' ) {
430
-		return $this->get_date_modified( $context );
429
+	public function get_modified_date($context = 'view') {
430
+		return $this->get_date_modified($context);
431 431
     }
432 432
 
433 433
     /**
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
 	 * @param  string $context View or edit context.
438 438
 	 * @return string
439 439
 	 */
440
-	public function get_date_modified_gmt( $context = 'view' ) {
441
-        $date = $this->get_date_modified( $context );
440
+	public function get_date_modified_gmt($context = 'view') {
441
+        $date = $this->get_date_modified($context);
442 442
 
443
-        if ( $date ) {
444
-            $date = get_gmt_from_date( $date );
443
+        if ($date) {
444
+            $date = get_gmt_from_date($date);
445 445
         }
446 446
 		return $date;
447 447
     }
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param  string $context View or edit context.
454 454
 	 * @return string
455 455
 	 */
456
-	public function get_due_date( $context = 'view' ) {
457
-		return $this->get_prop( 'due_date', $context );
456
+	public function get_due_date($context = 'view') {
457
+		return $this->get_prop('due_date', $context);
458 458
     }
459 459
 
460 460
     /**
@@ -464,8 +464,8 @@  discard block
 block discarded – undo
464 464
 	 * @param  string $context View or edit context.
465 465
 	 * @return string
466 466
 	 */
467
-	public function get_date_due( $context = 'view' ) {
468
-		return $this->get_due_date( $context );
467
+	public function get_date_due($context = 'view') {
468
+		return $this->get_due_date($context);
469 469
     }
470 470
 
471 471
     /**
@@ -475,11 +475,11 @@  discard block
 block discarded – undo
475 475
 	 * @param  string $context View or edit context.
476 476
 	 * @return string
477 477
 	 */
478
-	public function get_due_date_gmt( $context = 'view' ) {
479
-        $date = $this->get_due_date( $context );
478
+	public function get_due_date_gmt($context = 'view') {
479
+        $date = $this->get_due_date($context);
480 480
 
481
-        if ( $date ) {
482
-            $date = get_gmt_from_date( $date );
481
+        if ($date) {
482
+            $date = get_gmt_from_date($date);
483 483
         }
484 484
 		return $date;
485 485
     }
@@ -491,8 +491,8 @@  discard block
 block discarded – undo
491 491
 	 * @param  string $context View or edit context.
492 492
 	 * @return string
493 493
 	 */
494
-	public function get_gmt_date_due( $context = 'view' ) {
495
-		return $this->get_due_date_gmt( $context );
494
+	public function get_gmt_date_due($context = 'view') {
495
+		return $this->get_due_date_gmt($context);
496 496
     }
497 497
 
498 498
     /**
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
 	 * @param  string $context View or edit context.
503 503
 	 * @return string
504 504
 	 */
505
-	public function get_completed_date( $context = 'view' ) {
506
-		return $this->get_prop( 'completed_date', $context );
505
+	public function get_completed_date($context = 'view') {
506
+		return $this->get_prop('completed_date', $context);
507 507
     }
508 508
 
509 509
     /**
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
 	 * @param  string $context View or edit context.
514 514
 	 * @return string
515 515
 	 */
516
-	public function get_date_completed( $context = 'view' ) {
517
-		return $this->get_completed_date( $context );
516
+	public function get_date_completed($context = 'view') {
517
+		return $this->get_completed_date($context);
518 518
     }
519 519
 
520 520
     /**
@@ -524,11 +524,11 @@  discard block
 block discarded – undo
524 524
 	 * @param  string $context View or edit context.
525 525
 	 * @return string
526 526
 	 */
527
-	public function get_completed_date_gmt( $context = 'view' ) {
528
-        $date = $this->get_completed_date( $context );
527
+	public function get_completed_date_gmt($context = 'view') {
528
+        $date = $this->get_completed_date($context);
529 529
 
530
-        if ( $date ) {
531
-            $date = get_gmt_from_date( $date );
530
+        if ($date) {
531
+            $date = get_gmt_from_date($date);
532 532
         }
533 533
 		return $date;
534 534
     }
@@ -540,8 +540,8 @@  discard block
 block discarded – undo
540 540
 	 * @param  string $context View or edit context.
541 541
 	 * @return string
542 542
 	 */
543
-	public function get_gmt_completed_date( $context = 'view' ) {
544
-		return $this->get_completed_date_gmt( $context );
543
+	public function get_gmt_completed_date($context = 'view') {
544
+		return $this->get_completed_date_gmt($context);
545 545
     }
546 546
 
547 547
     /**
@@ -551,12 +551,12 @@  discard block
 block discarded – undo
551 551
 	 * @param  string $context View or edit context.
552 552
 	 * @return string
553 553
 	 */
554
-	public function get_number( $context = 'view' ) {
555
-		$number = $this->get_prop( 'number', $context );
554
+	public function get_number($context = 'view') {
555
+		$number = $this->get_prop('number', $context);
556 556
 
557
-		if ( empty( $number ) ) {
557
+		if (empty($number)) {
558 558
 			$number = $this->generate_number();
559
-			$this->set_number( $this->generate_number() );
559
+			$this->set_number($this->generate_number());
560 560
 		}
561 561
 
562 562
 		return $number;
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
 	public function maybe_set_number() {
571 571
         $number = $this->get_number();
572 572
 
573
-        if ( empty( $number ) || $this->get_id() == $number ) {
574
-			$this->set_number( $this->generate_number() );
573
+        if (empty($number) || $this->get_id() == $number) {
574
+			$this->set_number($this->generate_number());
575 575
         }
576 576
 
577 577
 	}
@@ -583,8 +583,8 @@  discard block
 block discarded – undo
583 583
 	 * @param  string $context View or edit context.
584 584
 	 * @return string
585 585
 	 */
586
-	public function get_key( $context = 'view' ) {
587
-        return $this->get_prop( 'key', $context );
586
+	public function get_key($context = 'view') {
587
+        return $this->get_prop('key', $context);
588 588
 	}
589 589
 
590 590
 	/**
@@ -595,9 +595,9 @@  discard block
 block discarded – undo
595 595
 	public function maybe_set_key() {
596 596
         $key = $this->get_key();
597 597
 
598
-        if ( empty( $key ) ) {
599
-            $key = $this->generate_key( $this->get_type() . '_' );
600
-            $this->set_key( $key );
598
+        if (empty($key)) {
599
+            $key = $this->generate_key($this->get_type() . '_');
600
+            $this->set_key($key);
601 601
         }
602 602
 
603 603
     }
@@ -609,8 +609,8 @@  discard block
 block discarded – undo
609 609
 	 * @param  string $context View or edit context.
610 610
 	 * @return string
611 611
 	 */
612
-	public function get_type( $context = 'view' ) {
613
-        return $this->get_prop( 'type', $context );
612
+	public function get_type($context = 'view') {
613
+        return $this->get_prop('type', $context);
614 614
 	}
615 615
 
616 616
 	/**
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 	 * @return string
621 621
 	 */
622 622
 	public function get_invoice_quote_type() {
623
-        return getpaid_get_post_type_label( $this->get_post_type(), false );
623
+        return getpaid_get_post_type_label($this->get_post_type(), false);
624 624
     }
625 625
 
626 626
     /**
@@ -630,8 +630,8 @@  discard block
 block discarded – undo
630 630
 	 * @param  string $context View or edit context.
631 631
 	 * @return string
632 632
 	 */
633
-	public function get_label( $context = 'view' ) {
634
-        return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
633
+	public function get_label($context = 'view') {
634
+        return getpaid_get_post_type_label($this->get_post_type($context), false);
635 635
 	}
636 636
 
637 637
 	/**
@@ -641,8 +641,8 @@  discard block
 block discarded – undo
641 641
 	 * @param  string $context View or edit context.
642 642
 	 * @return string
643 643
 	 */
644
-	public function get_post_type( $context = 'view' ) {
645
-        return $this->get_prop( 'post_type', $context );
644
+	public function get_post_type($context = 'view') {
645
+        return $this->get_prop('post_type', $context);
646 646
     }
647 647
 
648 648
     /**
@@ -652,8 +652,8 @@  discard block
 block discarded – undo
652 652
 	 * @param  string $context View or edit context.
653 653
 	 * @return string
654 654
 	 */
655
-	public function get_mode( $context = 'view' ) {
656
-        return $this->get_prop( 'mode', $context );
655
+	public function get_mode($context = 'view') {
656
+        return $this->get_prop('mode', $context);
657 657
     }
658 658
 
659 659
     /**
@@ -663,13 +663,13 @@  discard block
 block discarded – undo
663 663
 	 * @param  string $context View or edit context.
664 664
 	 * @return string
665 665
 	 */
666
-	public function get_path( $context = 'view' ) {
667
-        $path   = $this->get_prop( 'path', $context );
666
+	public function get_path($context = 'view') {
667
+        $path = $this->get_prop('path', $context);
668 668
 		$prefix = $this->get_type();
669 669
 
670
-		if ( 0 !== strpos( $path, $prefix ) ) {
671
-			$path = sanitize_title( $prefix . '-' . $this->get_id() );
672
-			$this->set_path( $path );
670
+		if (0 !== strpos($path, $prefix)) {
671
+			$path = sanitize_title($prefix . '-' . $this->get_id());
672
+			$this->set_path($path);
673 673
 		}
674 674
 
675 675
 		return $path;
@@ -682,8 +682,8 @@  discard block
 block discarded – undo
682 682
 	 * @param  string $context View or edit context.
683 683
 	 * @return string
684 684
 	 */
685
-	public function get_name( $context = 'view' ) {
686
-        return $this->get_prop( 'title', $context );
685
+	public function get_name($context = 'view') {
686
+        return $this->get_prop('title', $context);
687 687
     }
688 688
 
689 689
     /**
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
 	 * @param  string $context View or edit context.
694 694
 	 * @return string
695 695
 	 */
696
-	public function get_title( $context = 'view' ) {
697
-		return $this->get_name( $context );
696
+	public function get_title($context = 'view') {
697
+		return $this->get_name($context);
698 698
     }
699 699
 
700 700
     /**
@@ -704,8 +704,8 @@  discard block
 block discarded – undo
704 704
 	 * @param  string $context View or edit context.
705 705
 	 * @return string
706 706
 	 */
707
-	public function get_description( $context = 'view' ) {
708
-		return $this->get_prop( 'description', $context );
707
+	public function get_description($context = 'view') {
708
+		return $this->get_prop('description', $context);
709 709
     }
710 710
 
711 711
     /**
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
 	 * @param  string $context View or edit context.
716 716
 	 * @return string
717 717
 	 */
718
-	public function get_excerpt( $context = 'view' ) {
719
-		return $this->get_description( $context );
718
+	public function get_excerpt($context = 'view') {
719
+		return $this->get_description($context);
720 720
     }
721 721
 
722 722
     /**
@@ -726,8 +726,8 @@  discard block
 block discarded – undo
726 726
 	 * @param  string $context View or edit context.
727 727
 	 * @return string
728 728
 	 */
729
-	public function get_summary( $context = 'view' ) {
730
-		return $this->get_description( $context );
729
+	public function get_summary($context = 'view') {
730
+		return $this->get_description($context);
731 731
     }
732 732
 
733 733
     /**
@@ -737,26 +737,26 @@  discard block
 block discarded – undo
737 737
      * @param  string $context View or edit context.
738 738
 	 * @return array
739 739
 	 */
740
-    public function get_user_info( $context = 'view' ) {
740
+    public function get_user_info($context = 'view') {
741 741
 
742 742
         $user_info = array(
743
-            'user_id'    => $this->get_user_id( $context ),
744
-            'email'      => $this->get_email( $context ),
745
-            'first_name' => $this->get_first_name( $context ),
746
-            'last_name'  => $this->get_last_name( $context ),
747
-            'address'    => $this->get_address( $context ),
748
-            'phone'      => $this->get_phone( $context ),
749
-            'city'       => $this->get_city( $context ),
750
-            'country'    => $this->get_country( $context ),
751
-            'state'      => $this->get_state( $context ),
752
-            'zip'        => $this->get_zip( $context ),
753
-            'company'    => $this->get_company( $context ),
754
-			'company_id' => $this->get_company_id( $context ),
755
-            'vat_number' => $this->get_vat_number( $context ),
756
-            'discount'   => $this->get_discount_code( $context ),
743
+            'user_id'    => $this->get_user_id($context),
744
+            'email'      => $this->get_email($context),
745
+            'first_name' => $this->get_first_name($context),
746
+            'last_name'  => $this->get_last_name($context),
747
+            'address'    => $this->get_address($context),
748
+            'phone'      => $this->get_phone($context),
749
+            'city'       => $this->get_city($context),
750
+            'country'    => $this->get_country($context),
751
+            'state'      => $this->get_state($context),
752
+            'zip'        => $this->get_zip($context),
753
+            'company'    => $this->get_company($context),
754
+			'company_id' => $this->get_company_id($context),
755
+            'vat_number' => $this->get_vat_number($context),
756
+            'discount'   => $this->get_discount_code($context),
757 757
 		);
758 758
 
759
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
759
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
760 760
 
761 761
     }
762 762
 
@@ -767,8 +767,8 @@  discard block
 block discarded – undo
767 767
 	 * @param  string $context View or edit context.
768 768
 	 * @return int
769 769
 	 */
770
-	public function get_author( $context = 'view' ) {
771
-		return (int) $this->get_prop( 'author', $context );
770
+	public function get_author($context = 'view') {
771
+		return (int) $this->get_prop('author', $context);
772 772
     }
773 773
 
774 774
     /**
@@ -778,8 +778,8 @@  discard block
 block discarded – undo
778 778
 	 * @param  string $context View or edit context.
779 779
 	 * @return int
780 780
 	 */
781
-	public function get_user_id( $context = 'view' ) {
782
-		return $this->get_author( $context );
781
+	public function get_user_id($context = 'view') {
782
+		return $this->get_author($context);
783 783
     }
784 784
 
785 785
      /**
@@ -789,8 +789,8 @@  discard block
 block discarded – undo
789 789
 	 * @param  string $context View or edit context.
790 790
 	 * @return int
791 791
 	 */
792
-	public function get_customer_id( $context = 'view' ) {
793
-		return (int) $this->get_prop( 'customer_id', $context );
792
+	public function get_customer_id($context = 'view') {
793
+		return (int) $this->get_prop('customer_id', $context);
794 794
     }
795 795
 
796 796
     /**
@@ -800,8 +800,8 @@  discard block
 block discarded – undo
800 800
 	 * @param  string $context View or edit context.
801 801
 	 * @return string
802 802
 	 */
803
-	public function get_ip( $context = 'view' ) {
804
-		return $this->get_prop( 'user_ip', $context );
803
+	public function get_ip($context = 'view') {
804
+		return $this->get_prop('user_ip', $context);
805 805
     }
806 806
 
807 807
     /**
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
 	 * @param  string $context View or edit context.
812 812
 	 * @return string
813 813
 	 */
814
-	public function get_user_ip( $context = 'view' ) {
815
-		return $this->get_ip( $context );
814
+	public function get_user_ip($context = 'view') {
815
+		return $this->get_ip($context);
816 816
     }
817 817
 
818 818
      /**
@@ -822,8 +822,8 @@  discard block
 block discarded – undo
822 822
 	 * @param  string $context View or edit context.
823 823
 	 * @return string
824 824
 	 */
825
-	public function get_customer_ip( $context = 'view' ) {
826
-		return $this->get_ip( $context );
825
+	public function get_customer_ip($context = 'view') {
826
+		return $this->get_ip($context);
827 827
     }
828 828
 
829 829
     /**
@@ -833,8 +833,8 @@  discard block
 block discarded – undo
833 833
 	 * @param  string $context View or edit context.
834 834
 	 * @return string
835 835
 	 */
836
-	public function get_first_name( $context = 'view' ) {
837
-		return $this->get_prop( 'first_name', $context );
836
+	public function get_first_name($context = 'view') {
837
+		return $this->get_prop('first_name', $context);
838 838
     }
839 839
 
840 840
     /**
@@ -844,8 +844,8 @@  discard block
 block discarded – undo
844 844
 	 * @param  string $context View or edit context.
845 845
 	 * @return string
846 846
 	 */
847
-	public function get_user_first_name( $context = 'view' ) {
848
-		return $this->get_first_name( $context );
847
+	public function get_user_first_name($context = 'view') {
848
+		return $this->get_first_name($context);
849 849
     }
850 850
 
851 851
      /**
@@ -855,8 +855,8 @@  discard block
 block discarded – undo
855 855
 	 * @param  string $context View or edit context.
856 856
 	 * @return string
857 857
 	 */
858
-	public function get_customer_first_name( $context = 'view' ) {
859
-		return $this->get_first_name( $context );
858
+	public function get_customer_first_name($context = 'view') {
859
+		return $this->get_first_name($context);
860 860
     }
861 861
 
862 862
     /**
@@ -866,8 +866,8 @@  discard block
 block discarded – undo
866 866
 	 * @param  string $context View or edit context.
867 867
 	 * @return string
868 868
 	 */
869
-	public function get_last_name( $context = 'view' ) {
870
-		return $this->get_prop( 'last_name', $context );
869
+	public function get_last_name($context = 'view') {
870
+		return $this->get_prop('last_name', $context);
871 871
     }
872 872
 
873 873
     /**
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
 	 * @param  string $context View or edit context.
878 878
 	 * @return string
879 879
 	 */
880
-	public function get_user_last_name( $context = 'view' ) {
881
-		return $this->get_last_name( $context );
880
+	public function get_user_last_name($context = 'view') {
881
+		return $this->get_last_name($context);
882 882
     }
883 883
 
884 884
     /**
@@ -888,8 +888,8 @@  discard block
 block discarded – undo
888 888
 	 * @param  string $context View or edit context.
889 889
 	 * @return string
890 890
 	 */
891
-	public function get_customer_last_name( $context = 'view' ) {
892
-		return $this->get_last_name( $context );
891
+	public function get_customer_last_name($context = 'view') {
892
+		return $this->get_last_name($context);
893 893
     }
894 894
 
895 895
     /**
@@ -899,22 +899,22 @@  discard block
 block discarded – undo
899 899
 	 * @param  string $context View or edit context.
900 900
 	 * @return string
901 901
 	 */
902
-	public function get_full_name( $context = 'view' ) {
903
-		$name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
902
+	public function get_full_name($context = 'view') {
903
+		$name = trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
904 904
 
905
-		if ( ! $name ) {
906
-			$user = get_userdata( $this->get_author( $context ) );
905
+		if (!$name) {
906
+			$user = get_userdata($this->get_author($context));
907 907
 
908
-			if ( $user ) {
908
+			if ($user) {
909 909
 				$name = $user->display_name;
910 910
 			}
911 911
 		}
912 912
 
913
-		if ( ! $name ) {
914
-			$name = $this->get_email( $context );
913
+		if (!$name) {
914
+			$name = $this->get_email($context);
915 915
 		}
916 916
 
917
-		return apply_filters( 'wpinv_invoice_user_full_name', $name, $this );
917
+		return apply_filters('wpinv_invoice_user_full_name', $name, $this);
918 918
     }
919 919
 
920 920
     /**
@@ -924,8 +924,8 @@  discard block
 block discarded – undo
924 924
 	 * @param  string $context View or edit context.
925 925
 	 * @return string
926 926
 	 */
927
-	public function get_user_full_name( $context = 'view' ) {
928
-		return $this->get_full_name( $context );
927
+	public function get_user_full_name($context = 'view') {
928
+		return $this->get_full_name($context);
929 929
     }
930 930
 
931 931
     /**
@@ -935,8 +935,8 @@  discard block
 block discarded – undo
935 935
 	 * @param  string $context View or edit context.
936 936
 	 * @return string
937 937
 	 */
938
-	public function get_customer_full_name( $context = 'view' ) {
939
-		return $this->get_full_name( $context );
938
+	public function get_customer_full_name($context = 'view') {
939
+		return $this->get_full_name($context);
940 940
     }
941 941
 
942 942
     /**
@@ -946,8 +946,8 @@  discard block
 block discarded – undo
946 946
 	 * @param  string $context View or edit context.
947 947
 	 * @return string
948 948
 	 */
949
-	public function get_phone( $context = 'view' ) {
950
-		return $this->get_prop( 'phone', $context );
949
+	public function get_phone($context = 'view') {
950
+		return $this->get_prop('phone', $context);
951 951
     }
952 952
 
953 953
     /**
@@ -957,8 +957,8 @@  discard block
 block discarded – undo
957 957
 	 * @param  string $context View or edit context.
958 958
 	 * @return string
959 959
 	 */
960
-	public function get_phone_number( $context = 'view' ) {
961
-		return $this->get_phone( $context );
960
+	public function get_phone_number($context = 'view') {
961
+		return $this->get_phone($context);
962 962
     }
963 963
 
964 964
     /**
@@ -968,8 +968,8 @@  discard block
 block discarded – undo
968 968
 	 * @param  string $context View or edit context.
969 969
 	 * @return string
970 970
 	 */
971
-	public function get_user_phone( $context = 'view' ) {
972
-		return $this->get_phone( $context );
971
+	public function get_user_phone($context = 'view') {
972
+		return $this->get_phone($context);
973 973
     }
974 974
 
975 975
     /**
@@ -979,8 +979,8 @@  discard block
 block discarded – undo
979 979
 	 * @param  string $context View or edit context.
980 980
 	 * @return string
981 981
 	 */
982
-	public function get_customer_phone( $context = 'view' ) {
983
-		return $this->get_phone( $context );
982
+	public function get_customer_phone($context = 'view') {
983
+		return $this->get_phone($context);
984 984
     }
985 985
 
986 986
     /**
@@ -990,8 +990,8 @@  discard block
 block discarded – undo
990 990
 	 * @param  string $context View or edit context.
991 991
 	 * @return string
992 992
 	 */
993
-	public function get_email( $context = 'view' ) {
994
-		return $this->get_prop( 'email', $context );
993
+	public function get_email($context = 'view') {
994
+		return $this->get_prop('email', $context);
995 995
     }
996 996
 
997 997
     /**
@@ -1001,8 +1001,8 @@  discard block
 block discarded – undo
1001 1001
 	 * @param  string $context View or edit context.
1002 1002
 	 * @return string
1003 1003
 	 */
1004
-	public function get_email_address( $context = 'view' ) {
1005
-		return $this->get_email( $context );
1004
+	public function get_email_address($context = 'view') {
1005
+		return $this->get_email($context);
1006 1006
     }
1007 1007
 
1008 1008
     /**
@@ -1012,8 +1012,8 @@  discard block
 block discarded – undo
1012 1012
 	 * @param  string $context View or edit context.
1013 1013
 	 * @return string
1014 1014
 	 */
1015
-	public function get_user_email( $context = 'view' ) {
1016
-		return $this->get_email( $context );
1015
+	public function get_user_email($context = 'view') {
1016
+		return $this->get_email($context);
1017 1017
     }
1018 1018
 
1019 1019
     /**
@@ -1023,8 +1023,8 @@  discard block
 block discarded – undo
1023 1023
 	 * @param  string $context View or edit context.
1024 1024
 	 * @return string
1025 1025
 	 */
1026
-	public function get_customer_email( $context = 'view' ) {
1027
-		return $this->get_email( $context );
1026
+	public function get_customer_email($context = 'view') {
1027
+		return $this->get_email($context);
1028 1028
     }
1029 1029
 
1030 1030
     /**
@@ -1034,9 +1034,9 @@  discard block
 block discarded – undo
1034 1034
 	 * @param  string $context View or edit context.
1035 1035
 	 * @return string
1036 1036
 	 */
1037
-	public function get_country( $context = 'view' ) {
1038
-		$country = $this->get_prop( 'country', $context );
1039
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1037
+	public function get_country($context = 'view') {
1038
+		$country = $this->get_prop('country', $context);
1039
+		return empty($country) ? wpinv_get_default_country() : $country;
1040 1040
     }
1041 1041
 
1042 1042
     /**
@@ -1046,8 +1046,8 @@  discard block
 block discarded – undo
1046 1046
 	 * @param  string $context View or edit context.
1047 1047
 	 * @return string
1048 1048
 	 */
1049
-	public function get_user_country( $context = 'view' ) {
1050
-		return $this->get_country( $context );
1049
+	public function get_user_country($context = 'view') {
1050
+		return $this->get_country($context);
1051 1051
     }
1052 1052
 
1053 1053
     /**
@@ -1057,8 +1057,8 @@  discard block
 block discarded – undo
1057 1057
 	 * @param  string $context View or edit context.
1058 1058
 	 * @return string
1059 1059
 	 */
1060
-	public function get_customer_country( $context = 'view' ) {
1061
-		return $this->get_country( $context );
1060
+	public function get_customer_country($context = 'view') {
1061
+		return $this->get_country($context);
1062 1062
     }
1063 1063
 
1064 1064
     /**
@@ -1068,9 +1068,9 @@  discard block
 block discarded – undo
1068 1068
 	 * @param  string $context View or edit context.
1069 1069
 	 * @return string
1070 1070
 	 */
1071
-	public function get_state( $context = 'view' ) {
1072
-		$state = $this->get_prop( 'state', $context );
1073
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1071
+	public function get_state($context = 'view') {
1072
+		$state = $this->get_prop('state', $context);
1073
+		return empty($state) ? wpinv_get_default_state() : $state;
1074 1074
     }
1075 1075
 
1076 1076
     /**
@@ -1080,8 +1080,8 @@  discard block
 block discarded – undo
1080 1080
 	 * @param  string $context View or edit context.
1081 1081
 	 * @return string
1082 1082
 	 */
1083
-	public function get_user_state( $context = 'view' ) {
1084
-		return $this->get_state( $context );
1083
+	public function get_user_state($context = 'view') {
1084
+		return $this->get_state($context);
1085 1085
     }
1086 1086
 
1087 1087
     /**
@@ -1091,8 +1091,8 @@  discard block
 block discarded – undo
1091 1091
 	 * @param  string $context View or edit context.
1092 1092
 	 * @return string
1093 1093
 	 */
1094
-	public function get_customer_state( $context = 'view' ) {
1095
-		return $this->get_state( $context );
1094
+	public function get_customer_state($context = 'view') {
1095
+		return $this->get_state($context);
1096 1096
     }
1097 1097
 
1098 1098
     /**
@@ -1102,8 +1102,8 @@  discard block
 block discarded – undo
1102 1102
 	 * @param  string $context View or edit context.
1103 1103
 	 * @return string
1104 1104
 	 */
1105
-	public function get_city( $context = 'view' ) {
1106
-		return $this->get_prop( 'city', $context );
1105
+	public function get_city($context = 'view') {
1106
+		return $this->get_prop('city', $context);
1107 1107
     }
1108 1108
 
1109 1109
     /**
@@ -1113,8 +1113,8 @@  discard block
 block discarded – undo
1113 1113
 	 * @param  string $context View or edit context.
1114 1114
 	 * @return string
1115 1115
 	 */
1116
-	public function get_user_city( $context = 'view' ) {
1117
-		return $this->get_city( $context );
1116
+	public function get_user_city($context = 'view') {
1117
+		return $this->get_city($context);
1118 1118
     }
1119 1119
 
1120 1120
     /**
@@ -1124,8 +1124,8 @@  discard block
 block discarded – undo
1124 1124
 	 * @param  string $context View or edit context.
1125 1125
 	 * @return string
1126 1126
 	 */
1127
-	public function get_customer_city( $context = 'view' ) {
1128
-		return $this->get_city( $context );
1127
+	public function get_customer_city($context = 'view') {
1128
+		return $this->get_city($context);
1129 1129
     }
1130 1130
 
1131 1131
     /**
@@ -1135,8 +1135,8 @@  discard block
 block discarded – undo
1135 1135
 	 * @param  string $context View or edit context.
1136 1136
 	 * @return string
1137 1137
 	 */
1138
-	public function get_zip( $context = 'view' ) {
1139
-		return $this->get_prop( 'zip', $context );
1138
+	public function get_zip($context = 'view') {
1139
+		return $this->get_prop('zip', $context);
1140 1140
     }
1141 1141
 
1142 1142
     /**
@@ -1146,8 +1146,8 @@  discard block
 block discarded – undo
1146 1146
 	 * @param  string $context View or edit context.
1147 1147
 	 * @return string
1148 1148
 	 */
1149
-	public function get_user_zip( $context = 'view' ) {
1150
-		return $this->get_zip( $context );
1149
+	public function get_user_zip($context = 'view') {
1150
+		return $this->get_zip($context);
1151 1151
     }
1152 1152
 
1153 1153
     /**
@@ -1157,8 +1157,8 @@  discard block
 block discarded – undo
1157 1157
 	 * @param  string $context View or edit context.
1158 1158
 	 * @return string
1159 1159
 	 */
1160
-	public function get_customer_zip( $context = 'view' ) {
1161
-		return $this->get_zip( $context );
1160
+	public function get_customer_zip($context = 'view') {
1161
+		return $this->get_zip($context);
1162 1162
     }
1163 1163
 
1164 1164
     /**
@@ -1168,8 +1168,8 @@  discard block
 block discarded – undo
1168 1168
 	 * @param  string $context View or edit context.
1169 1169
 	 * @return string
1170 1170
 	 */
1171
-	public function get_company( $context = 'view' ) {
1172
-		return $this->get_prop( 'company', $context );
1171
+	public function get_company($context = 'view') {
1172
+		return $this->get_prop('company', $context);
1173 1173
     }
1174 1174
 
1175 1175
     /**
@@ -1179,8 +1179,8 @@  discard block
 block discarded – undo
1179 1179
 	 * @param  string $context View or edit context.
1180 1180
 	 * @return string
1181 1181
 	 */
1182
-	public function get_user_company( $context = 'view' ) {
1183
-		return $this->get_company( $context );
1182
+	public function get_user_company($context = 'view') {
1183
+		return $this->get_company($context);
1184 1184
     }
1185 1185
 
1186 1186
     /**
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 	 * @param  string $context View or edit context.
1191 1191
 	 * @return string
1192 1192
 	 */
1193
-	public function get_customer_company( $context = 'view' ) {
1194
-		return $this->get_company( $context );
1193
+	public function get_customer_company($context = 'view') {
1194
+		return $this->get_company($context);
1195 1195
     }
1196 1196
 
1197 1197
 	/**
@@ -1201,8 +1201,8 @@  discard block
 block discarded – undo
1201 1201
 	 * @param  string $context View or edit context.
1202 1202
 	 * @return string
1203 1203
 	 */
1204
-	public function get_company_id( $context = 'view' ) {
1205
-		return $this->get_prop( 'company_id', $context );
1204
+	public function get_company_id($context = 'view') {
1205
+		return $this->get_prop('company_id', $context);
1206 1206
     }
1207 1207
 
1208 1208
     /**
@@ -1212,8 +1212,8 @@  discard block
 block discarded – undo
1212 1212
 	 * @param  string $context View or edit context.
1213 1213
 	 * @return string
1214 1214
 	 */
1215
-	public function get_vat_number( $context = 'view' ) {
1216
-		return $this->get_prop( 'vat_number', $context );
1215
+	public function get_vat_number($context = 'view') {
1216
+		return $this->get_prop('vat_number', $context);
1217 1217
     }
1218 1218
 
1219 1219
     /**
@@ -1223,8 +1223,8 @@  discard block
 block discarded – undo
1223 1223
 	 * @param  string $context View or edit context.
1224 1224
 	 * @return string
1225 1225
 	 */
1226
-	public function get_user_vat_number( $context = 'view' ) {
1227
-		return $this->get_vat_number( $context );
1226
+	public function get_user_vat_number($context = 'view') {
1227
+		return $this->get_vat_number($context);
1228 1228
     }
1229 1229
 
1230 1230
     /**
@@ -1234,8 +1234,8 @@  discard block
 block discarded – undo
1234 1234
 	 * @param  string $context View or edit context.
1235 1235
 	 * @return string
1236 1236
 	 */
1237
-	public function get_customer_vat_number( $context = 'view' ) {
1238
-		return $this->get_vat_number( $context );
1237
+	public function get_customer_vat_number($context = 'view') {
1238
+		return $this->get_vat_number($context);
1239 1239
     }
1240 1240
 
1241 1241
     /**
@@ -1245,8 +1245,8 @@  discard block
 block discarded – undo
1245 1245
 	 * @param  string $context View or edit context.
1246 1246
 	 * @return string
1247 1247
 	 */
1248
-	public function get_vat_rate( $context = 'view' ) {
1249
-		return $this->get_prop( 'vat_rate', $context );
1248
+	public function get_vat_rate($context = 'view') {
1249
+		return $this->get_prop('vat_rate', $context);
1250 1250
     }
1251 1251
 
1252 1252
     /**
@@ -1256,8 +1256,8 @@  discard block
 block discarded – undo
1256 1256
 	 * @param  string $context View or edit context.
1257 1257
 	 * @return string
1258 1258
 	 */
1259
-	public function get_user_vat_rate( $context = 'view' ) {
1260
-		return $this->get_vat_rate( $context );
1259
+	public function get_user_vat_rate($context = 'view') {
1260
+		return $this->get_vat_rate($context);
1261 1261
     }
1262 1262
 
1263 1263
     /**
@@ -1267,8 +1267,8 @@  discard block
 block discarded – undo
1267 1267
 	 * @param  string $context View or edit context.
1268 1268
 	 * @return string
1269 1269
 	 */
1270
-	public function get_customer_vat_rate( $context = 'view' ) {
1271
-		return $this->get_vat_rate( $context );
1270
+	public function get_customer_vat_rate($context = 'view') {
1271
+		return $this->get_vat_rate($context);
1272 1272
     }
1273 1273
 
1274 1274
     /**
@@ -1278,8 +1278,8 @@  discard block
 block discarded – undo
1278 1278
 	 * @param  string $context View or edit context.
1279 1279
 	 * @return string
1280 1280
 	 */
1281
-	public function get_address( $context = 'view' ) {
1282
-		return $this->get_prop( 'address', $context );
1281
+	public function get_address($context = 'view') {
1282
+		return $this->get_prop('address', $context);
1283 1283
     }
1284 1284
 
1285 1285
     /**
@@ -1289,8 +1289,8 @@  discard block
 block discarded – undo
1289 1289
 	 * @param  string $context View or edit context.
1290 1290
 	 * @return string
1291 1291
 	 */
1292
-	public function get_user_address( $context = 'view' ) {
1293
-		return $this->get_address( $context );
1292
+	public function get_user_address($context = 'view') {
1293
+		return $this->get_address($context);
1294 1294
     }
1295 1295
 
1296 1296
     /**
@@ -1300,8 +1300,8 @@  discard block
 block discarded – undo
1300 1300
 	 * @param  string $context View or edit context.
1301 1301
 	 * @return string
1302 1302
 	 */
1303
-	public function get_customer_address( $context = 'view' ) {
1304
-		return $this->get_address( $context );
1303
+	public function get_customer_address($context = 'view') {
1304
+		return $this->get_address($context);
1305 1305
     }
1306 1306
 
1307 1307
     /**
@@ -1311,8 +1311,8 @@  discard block
 block discarded – undo
1311 1311
 	 * @param  string $context View or edit context.
1312 1312
 	 * @return bool
1313 1313
 	 */
1314
-	public function get_is_viewed( $context = 'view' ) {
1315
-		return (bool) $this->get_prop( 'is_viewed', $context );
1314
+	public function get_is_viewed($context = 'view') {
1315
+		return (bool) $this->get_prop('is_viewed', $context);
1316 1316
 	}
1317 1317
 
1318 1318
 	/**
@@ -1322,8 +1322,8 @@  discard block
 block discarded – undo
1322 1322
 	 * @param  string $context View or edit context.
1323 1323
 	 * @return bool
1324 1324
 	 */
1325
-	public function get_email_cc( $context = 'view' ) {
1326
-		return $this->get_prop( 'email_cc', $context );
1325
+	public function get_email_cc($context = 'view') {
1326
+		return $this->get_prop('email_cc', $context);
1327 1327
 	}
1328 1328
 
1329 1329
 	/**
@@ -1333,8 +1333,8 @@  discard block
 block discarded – undo
1333 1333
 	 * @param  string $context View or edit context.
1334 1334
 	 * @return bool
1335 1335
 	 */
1336
-	public function get_template( $context = 'view' ) {
1337
-		return $this->get_prop( 'template', $context );
1336
+	public function get_template($context = 'view') {
1337
+		return $this->get_prop('template', $context);
1338 1338
 	}
1339 1339
 
1340 1340
 	/**
@@ -1344,8 +1344,8 @@  discard block
 block discarded – undo
1344 1344
 	 * @param  string $context View or edit context.
1345 1345
 	 * @return bool
1346 1346
 	 */
1347
-	public function get_created_via( $context = 'view' ) {
1348
-		return $this->get_prop( 'created_via', $context );
1347
+	public function get_created_via($context = 'view') {
1348
+		return $this->get_prop('created_via', $context);
1349 1349
 	}
1350 1350
 
1351 1351
 	/**
@@ -1355,8 +1355,8 @@  discard block
 block discarded – undo
1355 1355
 	 * @param  string $context View or edit context.
1356 1356
 	 * @return bool
1357 1357
 	 */
1358
-	public function get_address_confirmed( $context = 'view' ) {
1359
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1358
+	public function get_address_confirmed($context = 'view') {
1359
+		return (bool) $this->get_prop('address_confirmed', $context);
1360 1360
     }
1361 1361
 
1362 1362
     /**
@@ -1366,8 +1366,8 @@  discard block
 block discarded – undo
1366 1366
 	 * @param  string $context View or edit context.
1367 1367
 	 * @return bool
1368 1368
 	 */
1369
-	public function get_user_address_confirmed( $context = 'view' ) {
1370
-		return $this->get_address_confirmed( $context );
1369
+	public function get_user_address_confirmed($context = 'view') {
1370
+		return $this->get_address_confirmed($context);
1371 1371
     }
1372 1372
 
1373 1373
     /**
@@ -1377,8 +1377,8 @@  discard block
 block discarded – undo
1377 1377
 	 * @param  string $context View or edit context.
1378 1378
 	 * @return bool
1379 1379
 	 */
1380
-	public function get_customer_address_confirmed( $context = 'view' ) {
1381
-		return $this->get_address_confirmed( $context );
1380
+	public function get_customer_address_confirmed($context = 'view') {
1381
+		return $this->get_address_confirmed($context);
1382 1382
     }
1383 1383
 
1384 1384
 	/**
@@ -1389,8 +1389,8 @@  discard block
 block discarded – undo
1389 1389
 	 */
1390 1390
 	public function get_shipping_address() {
1391 1391
 
1392
-		$shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1393
-		return is_array( $shipping_address ) ? $shipping_address : false;
1392
+		$shipping_address = get_post_meta($this->get_id(), 'shipping_address', true);
1393
+		return is_array($shipping_address) ? $shipping_address : false;
1394 1394
     }
1395 1395
 
1396 1396
 	/**
@@ -1407,17 +1407,17 @@  discard block
 block discarded – undo
1407 1407
 	 * @param  string $context View or edit context.
1408 1408
 	 * @return float
1409 1409
 	 */
1410
-	public function get_shipping( $context = 'view' ) {
1410
+	public function get_shipping($context = 'view') {
1411 1411
 
1412
-		if ( $context = 'view' ) {
1413
-			return floatval( $this->get_prop( 'shipping', $context ) );
1412
+		if ($context = 'view') {
1413
+			return floatval($this->get_prop('shipping', $context));
1414 1414
 		}
1415 1415
 
1416
-		return $this->get_prop( 'shipping', $context );
1416
+		return $this->get_prop('shipping', $context);
1417 1417
     }
1418 1418
 
1419 1419
 	public function has_shipping() {
1420
-		return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' );
1420
+		return defined('GETPAID_SHIPPING_CALCULATOR_VERSION') && null !== $this->get_prop('shipping', 'edit');
1421 1421
     }
1422 1422
 
1423 1423
     /**
@@ -1427,12 +1427,12 @@  discard block
 block discarded – undo
1427 1427
 	 * @param  string $context View or edit context.
1428 1428
 	 * @return float
1429 1429
 	 */
1430
-	public function get_subtotal( $context = 'view' ) {
1431
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1430
+	public function get_subtotal($context = 'view') {
1431
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1432 1432
 
1433 1433
         // Backwards compatibility.
1434
-        if ( is_bool( $context ) && $context ) {
1435
-            return wpinv_price( $subtotal, $this->get_currency() );
1434
+        if (is_bool($context) && $context) {
1435
+            return wpinv_price($subtotal, $this->get_currency());
1436 1436
         }
1437 1437
 
1438 1438
         return $subtotal;
@@ -1445,8 +1445,8 @@  discard block
 block discarded – undo
1445 1445
 	 * @param  string $context View or edit context.
1446 1446
 	 * @return float
1447 1447
 	 */
1448
-	public function get_total_discount( $context = 'view' ) {
1449
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1448
+	public function get_total_discount($context = 'view') {
1449
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context)));
1450 1450
     }
1451 1451
 
1452 1452
     /**
@@ -1456,18 +1456,18 @@  discard block
 block discarded – undo
1456 1456
 	 * @param  string $context View or edit context.
1457 1457
 	 * @return float
1458 1458
 	 */
1459
-	public function get_total_tax( $context = 'view' ) {
1460
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1459
+	public function get_total_tax($context = 'view') {
1460
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context)));
1461 1461
 	}
1462 1462
 
1463 1463
 	/**
1464 1464
 	 * @deprecated
1465 1465
 	 */
1466
-	public function get_final_tax( $currency = false ) {
1466
+	public function get_final_tax($currency = false) {
1467 1467
 		$tax = $this->get_total_tax();
1468 1468
 
1469
-        if ( $currency ) {
1470
-			return wpinv_price( $tax, $this->get_currency() );
1469
+        if ($currency) {
1470
+			return wpinv_price($tax, $this->get_currency());
1471 1471
         }
1472 1472
 
1473 1473
         return $tax;
@@ -1480,8 +1480,8 @@  discard block
 block discarded – undo
1480 1480
 	 * @param  string $context View or edit context.
1481 1481
 	 * @return float
1482 1482
 	 */
1483
-	public function get_total_fees( $context = 'view' ) {
1484
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1483
+	public function get_total_fees($context = 'view') {
1484
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context)));
1485 1485
     }
1486 1486
 
1487 1487
     /**
@@ -1491,8 +1491,8 @@  discard block
 block discarded – undo
1491 1491
 	 * @param  string $context View or edit context.
1492 1492
 	 * @return float
1493 1493
 	 */
1494
-	public function get_fees_total( $context = 'view' ) {
1495
-		return $this->get_total_fees( $context );
1494
+	public function get_fees_total($context = 'view') {
1495
+		return $this->get_total_fees($context);
1496 1496
     }
1497 1497
 
1498 1498
     /**
@@ -1501,14 +1501,14 @@  discard block
 block discarded – undo
1501 1501
 	 * @since 1.0.19
1502 1502
      * @return float
1503 1503
 	 */
1504
-	public function get_total( $context = 'view' ) {
1505
-		$total = $this->get_prop( 'total', $context );
1504
+	public function get_total($context = 'view') {
1505
+		$total = $this->get_prop('total', $context);
1506 1506
 
1507
-		if ( $this->has_shipping() && $context == 'view' ) {
1508
-			$total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1507
+		if ($this->has_shipping() && $context == 'view') {
1508
+			$total = $this->get_prop('total', $context) + $this->get_shipping($context);
1509 1509
 		}
1510 1510
 
1511
-		return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1511
+		return wpinv_round_amount(wpinv_sanitize_amount($total));
1512 1512
 	}
1513 1513
 
1514 1514
 	/**
@@ -1520,20 +1520,20 @@  discard block
 block discarded – undo
1520 1520
 	public function get_non_recurring_total() {
1521 1521
 
1522 1522
 		$subtotal = 0;
1523
-		foreach ( $this->get_items() as $item ) {
1524
-			if ( ! $item->is_recurring() ) {
1523
+		foreach ($this->get_items() as $item) {
1524
+			if (!$item->is_recurring()) {
1525 1525
 				$subtotal += $item->get_sub_total();
1526 1526
 			}
1527 1527
 		}
1528 1528
 
1529
-		foreach ( $this->get_fees() as $fee ) {
1530
-			if ( empty( $fee['recurring_fee'] ) ) {
1531
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1529
+		foreach ($this->get_fees() as $fee) {
1530
+			if (empty($fee['recurring_fee'])) {
1531
+				$subtotal += wpinv_sanitize_amount($fee['initial_fee']);
1532 1532
 			}
1533 1533
 		}
1534 1534
 
1535
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1536
-        return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1535
+		$subtotal = wpinv_round_amount(wpinv_sanitize_amount($subtotal));
1536
+        return apply_filters('wpinv_get_non_recurring_invoice_total', $subtotal, $this);
1537 1537
 
1538 1538
     }
1539 1539
 
@@ -1556,7 +1556,7 @@  discard block
 block discarded – undo
1556 1556
 	 */
1557 1557
     public function get_initial_total() {
1558 1558
 
1559
-		if ( empty( $this->totals ) ) {
1559
+		if (empty($this->totals)) {
1560 1560
 			$this->recalculate_total();
1561 1561
 		}
1562 1562
 
@@ -1566,12 +1566,12 @@  discard block
 block discarded – undo
1566 1566
 		$subtotal = $this->totals['subtotal']['initial'];
1567 1567
 		$total    = $tax + $fee - $discount + $subtotal;
1568 1568
 
1569
-		if ( 0 > $total ) {
1569
+		if (0 > $total) {
1570 1570
 			$total = 0;
1571 1571
 		}
1572 1572
 
1573
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1574
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1573
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1574
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1575 1575
 	}
1576 1576
 
1577 1577
 	/**
@@ -1583,7 +1583,7 @@  discard block
 block discarded – undo
1583 1583
 	 */
1584 1584
     public function get_recurring_total() {
1585 1585
 
1586
-		if ( empty( $this->totals ) ) {
1586
+		if (empty($this->totals)) {
1587 1587
 			$this->recalculate_total();
1588 1588
 		}
1589 1589
 
@@ -1593,12 +1593,12 @@  discard block
 block discarded – undo
1593 1593
 		$subtotal = $this->totals['subtotal']['recurring'];
1594 1594
 		$total    = $tax + $fee - $discount + $subtotal;
1595 1595
 
1596
-		if ( 0 > $total ) {
1596
+		if (0 > $total) {
1597 1597
 			$total = 0;
1598 1598
 		}
1599 1599
 
1600
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1601
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1600
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1601
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1602 1602
 	}
1603 1603
 
1604 1604
 	/**
@@ -1609,10 +1609,10 @@  discard block
 block discarded – undo
1609 1609
 	 * @param string $currency Whether to include the currency.
1610 1610
      * @return float|string
1611 1611
 	 */
1612
-    public function get_recurring_details( $field = '', $currency = false ) {
1612
+    public function get_recurring_details($field = '', $currency = false) {
1613 1613
 
1614 1614
 		// Maybe recalculate totals.
1615
-		if ( empty( $this->totals ) ) {
1615
+		if (empty($this->totals)) {
1616 1616
 			$this->recalculate_total();
1617 1617
 		}
1618 1618
 
@@ -1632,8 +1632,8 @@  discard block
 block discarded – undo
1632 1632
 			$currency
1633 1633
 		);
1634 1634
 
1635
-        if ( isset( $data[ $field ] ) ) {
1636
-            return ( $currency ? wpinv_price( $data[ $field ], $this->get_currency() ) : $data[ $field ] );
1635
+        if (isset($data[$field])) {
1636
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1637 1637
         }
1638 1638
 
1639 1639
         return $data;
@@ -1646,8 +1646,8 @@  discard block
 block discarded – undo
1646 1646
 	 * @param  string $context View or edit context.
1647 1647
 	 * @return array
1648 1648
 	 */
1649
-	public function get_fees( $context = 'view' ) {
1650
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1649
+	public function get_fees($context = 'view') {
1650
+		return wpinv_parse_list($this->get_prop('fees', $context));
1651 1651
     }
1652 1652
 
1653 1653
     /**
@@ -1657,8 +1657,8 @@  discard block
 block discarded – undo
1657 1657
 	 * @param  string $context View or edit context.
1658 1658
 	 * @return array
1659 1659
 	 */
1660
-	public function get_discounts( $context = 'view' ) {
1661
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1660
+	public function get_discounts($context = 'view') {
1661
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1662 1662
     }
1663 1663
 
1664 1664
     /**
@@ -1668,8 +1668,8 @@  discard block
 block discarded – undo
1668 1668
 	 * @param  string $context View or edit context.
1669 1669
 	 * @return array
1670 1670
 	 */
1671
-	public function get_taxes( $context = 'view' ) {
1672
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1671
+	public function get_taxes($context = 'view') {
1672
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1673 1673
     }
1674 1674
 
1675 1675
     /**
@@ -1679,8 +1679,8 @@  discard block
 block discarded – undo
1679 1679
 	 * @param  string $context View or edit context.
1680 1680
 	 * @return GetPaid_Form_Item[]
1681 1681
 	 */
1682
-	public function get_items( $context = 'view' ) {
1683
-        return $this->get_prop( 'items', $context );
1682
+	public function get_items($context = 'view') {
1683
+        return $this->get_prop('items', $context);
1684 1684
 	}
1685 1685
 
1686 1686
 	/**
@@ -1690,7 +1690,7 @@  discard block
 block discarded – undo
1690 1690
 	 * @return string
1691 1691
 	 */
1692 1692
 	public function get_item_ids() {
1693
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1693
+		return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id'));
1694 1694
     }
1695 1695
 
1696 1696
     /**
@@ -1700,8 +1700,8 @@  discard block
 block discarded – undo
1700 1700
 	 * @param  string $context View or edit context.
1701 1701
 	 * @return int
1702 1702
 	 */
1703
-	public function get_payment_form( $context = 'view' ) {
1704
-		return intval( $this->get_prop( 'payment_form', $context ) );
1703
+	public function get_payment_form($context = 'view') {
1704
+		return intval($this->get_prop('payment_form', $context));
1705 1705
     }
1706 1706
 
1707 1707
     /**
@@ -1711,8 +1711,8 @@  discard block
 block discarded – undo
1711 1711
 	 * @param  string $context View or edit context.
1712 1712
 	 * @return string
1713 1713
 	 */
1714
-	public function get_submission_id( $context = 'view' ) {
1715
-		return $this->get_prop( 'submission_id', $context );
1714
+	public function get_submission_id($context = 'view') {
1715
+		return $this->get_prop('submission_id', $context);
1716 1716
     }
1717 1717
 
1718 1718
     /**
@@ -1722,8 +1722,8 @@  discard block
 block discarded – undo
1722 1722
 	 * @param  string $context View or edit context.
1723 1723
 	 * @return string
1724 1724
 	 */
1725
-	public function get_discount_code( $context = 'view' ) {
1726
-		return $this->get_prop( 'discount_code', $context );
1725
+	public function get_discount_code($context = 'view') {
1726
+		return $this->get_prop('discount_code', $context);
1727 1727
     }
1728 1728
 
1729 1729
     /**
@@ -1733,8 +1733,8 @@  discard block
 block discarded – undo
1733 1733
 	 * @param  string $context View or edit context.
1734 1734
 	 * @return string
1735 1735
 	 */
1736
-	public function get_gateway( $context = 'view' ) {
1737
-		return $this->get_prop( 'gateway', $context );
1736
+	public function get_gateway($context = 'view') {
1737
+		return $this->get_prop('gateway', $context);
1738 1738
     }
1739 1739
 
1740 1740
     /**
@@ -1744,8 +1744,8 @@  discard block
 block discarded – undo
1744 1744
 	 * @return string
1745 1745
 	 */
1746 1746
     public function get_gateway_title() {
1747
-        $title = wpinv_get_gateway_checkout_label( $this->get_gateway() );
1748
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1747
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1748
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1749 1749
     }
1750 1750
 
1751 1751
     /**
@@ -1755,8 +1755,8 @@  discard block
 block discarded – undo
1755 1755
 	 * @param  string $context View or edit context.
1756 1756
 	 * @return string
1757 1757
 	 */
1758
-	public function get_transaction_id( $context = 'view' ) {
1759
-		return $this->get_prop( 'transaction_id', $context );
1758
+	public function get_transaction_id($context = 'view') {
1759
+		return $this->get_prop('transaction_id', $context);
1760 1760
     }
1761 1761
 
1762 1762
     /**
@@ -1766,9 +1766,9 @@  discard block
 block discarded – undo
1766 1766
 	 * @param  string $context View or edit context.
1767 1767
 	 * @return string
1768 1768
 	 */
1769
-	public function get_currency( $context = 'view' ) {
1770
-        $currency = $this->get_prop( 'currency', $context );
1771
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1769
+	public function get_currency($context = 'view') {
1770
+        $currency = $this->get_prop('currency', $context);
1771
+        return empty($currency) ? wpinv_get_currency() : $currency;
1772 1772
     }
1773 1773
 
1774 1774
     /**
@@ -1778,8 +1778,8 @@  discard block
 block discarded – undo
1778 1778
 	 * @param  string $context View or edit context.
1779 1779
 	 * @return bool
1780 1780
 	 */
1781
-	public function get_disable_taxes( $context = 'view' ) {
1782
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1781
+	public function get_disable_taxes($context = 'view') {
1782
+        return (bool) $this->get_prop('disable_taxes', $context);
1783 1783
     }
1784 1784
 
1785 1785
     /**
@@ -1789,8 +1789,8 @@  discard block
 block discarded – undo
1789 1789
 	 * @param  string $context View or edit context.
1790 1790
 	 * @return int
1791 1791
 	 */
1792
-    public function get_subscription_id( $context = 'view' ) {
1793
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1792
+    public function get_subscription_id($context = 'view') {
1793
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1794 1794
 	}
1795 1795
 
1796 1796
 	/**
@@ -1800,12 +1800,12 @@  discard block
 block discarded – undo
1800 1800
 	 * @param  string $context View or edit context.
1801 1801
 	 * @return int
1802 1802
 	 */
1803
-    public function get_remote_subscription_id( $context = 'view' ) {
1804
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1803
+    public function get_remote_subscription_id($context = 'view') {
1804
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1805 1805
 
1806
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1806
+        if (empty($subscription_id) && $this->is_renewal()) {
1807 1807
             $parent = $this->get_parent();
1808
-            return $parent->get_remote_subscription_id( $context );
1808
+            return $parent->get_remote_subscription_id($context);
1809 1809
         }
1810 1810
 
1811 1811
         return $subscription_id;
@@ -1818,20 +1818,20 @@  discard block
 block discarded – undo
1818 1818
 	 * @param  string $context View or edit context.
1819 1819
 	 * @return array
1820 1820
 	 */
1821
-    public function get_payment_meta( $context = 'view' ) {
1821
+    public function get_payment_meta($context = 'view') {
1822 1822
 
1823 1823
         return array(
1824
-            'price'        => $this->get_total( $context ),
1825
-            'date'         => $this->get_date_created( $context ),
1826
-            'user_email'   => $this->get_email( $context ),
1827
-            'invoice_key'  => $this->get_key( $context ),
1828
-            'currency'     => $this->get_currency( $context ),
1829
-            'items'        => $this->get_items( $context ),
1830
-            'user_info'    => $this->get_user_info( $context ),
1824
+            'price'        => $this->get_total($context),
1825
+            'date'         => $this->get_date_created($context),
1826
+            'user_email'   => $this->get_email($context),
1827
+            'invoice_key'  => $this->get_key($context),
1828
+            'currency'     => $this->get_currency($context),
1829
+            'items'        => $this->get_items($context),
1830
+            'user_info'    => $this->get_user_info($context),
1831 1831
             'cart_details' => $this->get_cart_details(),
1832
-            'status'       => $this->get_status( $context ),
1833
-            'fees'         => $this->get_fees( $context ),
1834
-            'taxes'        => $this->get_taxes( $context ),
1832
+            'status'       => $this->get_status($context),
1833
+            'fees'         => $this->get_fees($context),
1834
+            'taxes'        => $this->get_taxes($context),
1835 1835
         );
1836 1836
 
1837 1837
     }
@@ -1846,9 +1846,9 @@  discard block
 block discarded – undo
1846 1846
         $items        = $this->get_items();
1847 1847
         $cart_details = array();
1848 1848
 
1849
-        foreach ( $items as $item ) {
1849
+        foreach ($items as $item) {
1850 1850
 			$item->invoice_id = $this->get_id();
1851
-            $cart_details[]   = $item->prepare_data_for_saving();
1851
+            $cart_details[] = $item->prepare_data_for_saving();
1852 1852
         }
1853 1853
 
1854 1854
         return $cart_details;
@@ -1859,11 +1859,11 @@  discard block
 block discarded – undo
1859 1859
 	 *
1860 1860
 	 * @return null|GetPaid_Form_Item|int
1861 1861
 	 */
1862
-	public function get_recurring( $object = false ) {
1862
+	public function get_recurring($object = false) {
1863 1863
 
1864 1864
 		// Are we returning an object?
1865
-        if ( $object ) {
1866
-            return $this->get_item( $this->recurring_item );
1865
+        if ($object) {
1866
+            return $this->get_item($this->recurring_item);
1867 1867
         }
1868 1868
 
1869 1869
         return $this->recurring_item;
@@ -1878,15 +1878,15 @@  discard block
 block discarded – undo
1878 1878
 	public function get_subscription_name() {
1879 1879
 
1880 1880
 		// Retrieve the recurring name
1881
-        $item = $this->get_recurring( true );
1881
+        $item = $this->get_recurring(true);
1882 1882
 
1883 1883
 		// Abort if it does not exist.
1884
-        if ( empty( $item ) ) {
1884
+        if (empty($item)) {
1885 1885
             return '';
1886 1886
         }
1887 1887
 
1888 1888
 		// Return the item name.
1889
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1889
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1890 1890
 	}
1891 1891
 
1892 1892
 	/**
@@ -1896,9 +1896,9 @@  discard block
 block discarded – undo
1896 1896
 	 * @return string
1897 1897
 	 */
1898 1898
 	public function get_view_url() {
1899
-        $invoice_url = get_permalink( $this->get_id() );
1900
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1901
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1899
+        $invoice_url = get_permalink($this->get_id());
1900
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1901
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1902 1902
 	}
1903 1903
 
1904 1904
 	/**
@@ -1907,25 +1907,25 @@  discard block
 block discarded – undo
1907 1907
 	 * @since 1.0.19
1908 1908
 	 * @return string
1909 1909
 	 */
1910
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1910
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1911 1911
 
1912 1912
 		// Retrieve the checkout url.
1913 1913
         $pay_url = wpinv_get_checkout_uri();
1914 1914
 
1915 1915
 		// Maybe force ssl.
1916
-        if ( is_ssl() ) {
1917
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1916
+        if (is_ssl()) {
1917
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1918 1918
         }
1919 1919
 
1920 1920
 		// Add the invoice key.
1921
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1921
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1922 1922
 
1923 1923
 		// (Maybe?) add a secret
1924
-        if ( $secret ) {
1925
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1924
+        if ($secret) {
1925
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1926 1926
         }
1927 1927
 
1928
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1928
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1929 1929
 	}
1930 1930
 
1931 1931
 	/**
@@ -1940,14 +1940,14 @@  discard block
 block discarded – undo
1940 1940
         $receipt_url = wpinv_get_success_page_uri();
1941 1941
 
1942 1942
 		// Maybe force ssl.
1943
-        if ( is_ssl() ) {
1944
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1943
+        if (is_ssl()) {
1944
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1945 1945
         }
1946 1946
 
1947 1947
 		// Add the invoice key.
1948
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1948
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1949 1949
 
1950
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1950
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1951 1951
 	}
1952 1952
 
1953 1953
 	/**
@@ -1957,7 +1957,7 @@  discard block
 block discarded – undo
1957 1957
 	 * @return string
1958 1958
 	 */
1959 1959
 	public function get_transaction_url() {
1960
-		return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1960
+		return apply_filters('getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this);
1961 1961
 	}
1962 1962
 
1963 1963
 	/**
@@ -1970,7 +1970,7 @@  discard block
 block discarded – undo
1970 1970
 
1971 1971
 		$type   = $this->get_type();
1972 1972
 		$status = "wpi-$type-pending";
1973
-		return str_replace( '-invoice', '', $status );
1973
+		return str_replace('-invoice', '', $status);
1974 1974
 
1975 1975
 	}
1976 1976
 
@@ -1984,14 +1984,14 @@  discard block
 block discarded – undo
1984 1984
 	 * @param  string $context View or edit context.
1985 1985
 	 * @return mixed Value of the given invoice property (if set).
1986 1986
 	 */
1987
-	public function get( $key, $context = 'view' ) {
1987
+	public function get($key, $context = 'view') {
1988 1988
 		$method = "get_$key";
1989 1989
 
1990
-		if ( is_callable( array( $this, $method ) ) ) {
1991
-			return $this->$method( $context );
1990
+		if (is_callable(array($this, $method))) {
1991
+			return $this->$method($context);
1992 1992
 		}
1993 1993
 
1994
-        return $this->get_prop( $key, $context );
1994
+        return $this->get_prop($key, $context);
1995 1995
 	}
1996 1996
 
1997 1997
     /*
@@ -2014,11 +2014,11 @@  discard block
 block discarded – undo
2014 2014
 	 * @param  mixed $value new value.
2015 2015
 	 * @return mixed Value of the given invoice property (if set).
2016 2016
 	 */
2017
-	public function set( $key, $value ) {
2017
+	public function set($key, $value) {
2018 2018
 
2019 2019
         $setter = "set_$key";
2020
-        if ( is_callable( array( $this, $setter ) ) ) {
2021
-            $this->{$setter}( $value );
2020
+        if (is_callable(array($this, $setter))) {
2021
+            $this->{$setter}($value);
2022 2022
         }
2023 2023
 
2024 2024
 	}
@@ -2032,45 +2032,45 @@  discard block
 block discarded – undo
2032 2032
 	 * @param bool   $manual_update Is this a manual status change?.
2033 2033
 	 * @return array details of change.
2034 2034
 	 */
2035
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
2035
+	public function set_status($new_status, $note = '', $manual_update = false) {
2036 2036
 		$old_status = $this->get_status();
2037 2037
 
2038 2038
 		$statuses = $this->get_all_statuses();
2039 2039
 
2040
-		if ( isset( $statuses['draft'] ) ) {
2041
-			unset( $statuses['draft'] );
2040
+		if (isset($statuses['draft'])) {
2041
+			unset($statuses['draft']);
2042 2042
 		}
2043 2043
 
2044
-		$this->set_prop( 'status', $new_status );
2044
+		$this->set_prop('status', $new_status);
2045 2045
 
2046 2046
 		// If setting the status, ensure it's set to a valid status.
2047
-		if ( true === $this->object_read ) {
2047
+		if (true === $this->object_read) {
2048 2048
 
2049 2049
 			// Only allow valid new status.
2050
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
2050
+			if (!array_key_exists($new_status, $statuses)) {
2051 2051
 				$new_status = $this->get_default_status();
2052 2052
 			}
2053 2053
 
2054 2054
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2055
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2055
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
2056 2056
 				$old_status = $this->get_default_status();
2057 2057
 			}
2058 2058
 
2059 2059
 			// Paid - Renewal (i.e when duplicating a parent invoice )
2060
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2060
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
2061 2061
 				$old_status = 'wpi-pending';
2062 2062
 			}
2063 2063
 
2064
-			if ( $old_status !== $new_status ) {
2064
+			if ($old_status !== $new_status) {
2065 2065
 				$this->status_transition = array(
2066
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2066
+					'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
2067 2067
 					'to'     => $new_status,
2068 2068
 					'note'   => $note,
2069 2069
 					'manual' => (bool) $manual_update,
2070 2070
 				);
2071 2071
 
2072
-				if ( $manual_update ) {
2073
-					do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status );
2072
+				if ($manual_update) {
2073
+					do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
2074 2074
 				}
2075 2075
 
2076 2076
 				$this->maybe_set_date_paid();
@@ -2094,8 +2094,8 @@  discard block
 block discarded – undo
2094 2094
 	 */
2095 2095
 	public function maybe_set_date_paid() {
2096 2096
 
2097
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2098
-			$this->set_date_completed( current_time( 'mysql' ) );
2097
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
2098
+			$this->set_date_completed(current_time('mysql'));
2099 2099
 		}
2100 2100
 	}
2101 2101
 
@@ -2104,11 +2104,11 @@  discard block
 block discarded – undo
2104 2104
 	 *
2105 2105
 	 * @since 1.0.19
2106 2106
 	 */
2107
-	public function set_parent_id( $value ) {
2108
-		if ( $value && ( $value === $this->get_id() ) ) {
2107
+	public function set_parent_id($value) {
2108
+		if ($value && ($value === $this->get_id())) {
2109 2109
 			return;
2110 2110
 		}
2111
-		$this->set_prop( 'parent_id', absint( $value ) );
2111
+		$this->set_prop('parent_id', absint($value));
2112 2112
     }
2113 2113
 
2114 2114
     /**
@@ -2116,8 +2116,8 @@  discard block
 block discarded – undo
2116 2116
 	 *
2117 2117
 	 * @since 1.0.19
2118 2118
 	 */
2119
-	public function set_version( $value ) {
2120
-		$this->set_prop( 'version', $value );
2119
+	public function set_version($value) {
2120
+		$this->set_prop('version', $value);
2121 2121
     }
2122 2122
 
2123 2123
     /**
@@ -2127,15 +2127,15 @@  discard block
 block discarded – undo
2127 2127
 	 * @param string $value Value to set.
2128 2128
      * @return bool Whether or not the date was set.
2129 2129
 	 */
2130
-	public function set_date_created( $value ) {
2131
-        $date = strtotime( $value );
2130
+	public function set_date_created($value) {
2131
+        $date = strtotime($value);
2132 2132
 
2133
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2134
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
2133
+        if ($date && $value !== '0000-00-00 00:00:00') {
2134
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
2135 2135
             return true;
2136 2136
         }
2137 2137
 
2138
-		$this->set_prop( 'date_created', '' );
2138
+		$this->set_prop('date_created', '');
2139 2139
 		return false;
2140 2140
 
2141 2141
     }
@@ -2147,15 +2147,15 @@  discard block
 block discarded – undo
2147 2147
 	 * @param string $value Value to set.
2148 2148
      * @return bool Whether or not the date was set.
2149 2149
 	 */
2150
-	public function set_due_date( $value ) {
2151
-        $date = strtotime( $value );
2150
+	public function set_due_date($value) {
2151
+        $date = strtotime($value);
2152 2152
 
2153
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2154
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
2153
+        if ($date && $value !== '0000-00-00 00:00:00') {
2154
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
2155 2155
             return true;
2156 2156
         }
2157 2157
 
2158
-		$this->set_prop( 'due_date', '' );
2158
+		$this->set_prop('due_date', '');
2159 2159
         return false;
2160 2160
 
2161 2161
     }
@@ -2166,8 +2166,8 @@  discard block
 block discarded – undo
2166 2166
 	 * @since 1.0.19
2167 2167
 	 * @param  string $value New name.
2168 2168
 	 */
2169
-	public function set_date_due( $value ) {
2170
-		$this->set_due_date( $value );
2169
+	public function set_date_due($value) {
2170
+		$this->set_due_date($value);
2171 2171
     }
2172 2172
 
2173 2173
     /**
@@ -2177,15 +2177,15 @@  discard block
 block discarded – undo
2177 2177
 	 * @param string $value Value to set.
2178 2178
      * @return bool Whether or not the date was set.
2179 2179
 	 */
2180
-	public function set_completed_date( $value ) {
2181
-        $date = strtotime( $value );
2180
+	public function set_completed_date($value) {
2181
+        $date = strtotime($value);
2182 2182
 
2183
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2184
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2183
+        if ($date && $value !== '0000-00-00 00:00:00') {
2184
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2185 2185
             return true;
2186 2186
         }
2187 2187
 
2188
-		$this->set_prop( 'completed_date', '' );
2188
+		$this->set_prop('completed_date', '');
2189 2189
         return false;
2190 2190
 
2191 2191
     }
@@ -2196,8 +2196,8 @@  discard block
 block discarded – undo
2196 2196
 	 * @since 1.0.19
2197 2197
 	 * @param  string $value New name.
2198 2198
 	 */
2199
-	public function set_date_completed( $value ) {
2200
-		$this->set_completed_date( $value );
2199
+	public function set_date_completed($value) {
2200
+		$this->set_completed_date($value);
2201 2201
     }
2202 2202
 
2203 2203
     /**
@@ -2207,15 +2207,15 @@  discard block
 block discarded – undo
2207 2207
 	 * @param string $value Value to set.
2208 2208
      * @return bool Whether or not the date was set.
2209 2209
 	 */
2210
-	public function set_date_modified( $value ) {
2211
-        $date = strtotime( $value );
2210
+	public function set_date_modified($value) {
2211
+        $date = strtotime($value);
2212 2212
 
2213
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2214
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2213
+        if ($date && $value !== '0000-00-00 00:00:00') {
2214
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2215 2215
             return true;
2216 2216
         }
2217 2217
 
2218
-		$this->set_prop( 'date_modified', '' );
2218
+		$this->set_prop('date_modified', '');
2219 2219
         return false;
2220 2220
 
2221 2221
     }
@@ -2226,9 +2226,9 @@  discard block
 block discarded – undo
2226 2226
 	 * @since 1.0.19
2227 2227
 	 * @param  string $value New number.
2228 2228
 	 */
2229
-	public function set_number( $value ) {
2230
-        $number = sanitize_text_field( $value );
2231
-		$this->set_prop( 'number', $number );
2229
+	public function set_number($value) {
2230
+        $number = sanitize_text_field($value);
2231
+		$this->set_prop('number', $number);
2232 2232
     }
2233 2233
 
2234 2234
     /**
@@ -2237,9 +2237,9 @@  discard block
 block discarded – undo
2237 2237
 	 * @since 1.0.19
2238 2238
 	 * @param  string $value Type.
2239 2239
 	 */
2240
-	public function set_type( $value ) {
2241
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2242
-		$this->set_prop( 'type', $type );
2240
+	public function set_type($value) {
2241
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2242
+		$this->set_prop('type', $type);
2243 2243
 	}
2244 2244
 
2245 2245
     /**
@@ -2248,10 +2248,10 @@  discard block
 block discarded – undo
2248 2248
 	 * @since 1.0.19
2249 2249
 	 * @param  string $value Post type.
2250 2250
 	 */
2251
-	public function set_post_type( $value ) {
2252
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2253
-			$this->set_type( $value );
2254
-            $this->set_prop( 'post_type', $value );
2251
+	public function set_post_type($value) {
2252
+        if (getpaid_is_invoice_post_type($value)) {
2253
+			$this->set_type($value);
2254
+            $this->set_prop('post_type', $value);
2255 2255
         }
2256 2256
     }
2257 2257
 
@@ -2261,9 +2261,9 @@  discard block
 block discarded – undo
2261 2261
 	 * @since 1.0.19
2262 2262
 	 * @param  string $value New key.
2263 2263
 	 */
2264
-	public function set_key( $value ) {
2265
-        $key = sanitize_text_field( $value );
2266
-		$this->set_prop( 'key', $key );
2264
+	public function set_key($value) {
2265
+        $key = sanitize_text_field($value);
2266
+		$this->set_prop('key', $key);
2267 2267
     }
2268 2268
 
2269 2269
     /**
@@ -2272,9 +2272,9 @@  discard block
 block discarded – undo
2272 2272
 	 * @since 1.0.19
2273 2273
 	 * @param  string $value mode.
2274 2274
 	 */
2275
-	public function set_mode( $value ) {
2276
-        if ( in_array( $value, array( 'live', 'test' ) ) ) {
2277
-            $this->set_prop( 'mode', $value );
2275
+	public function set_mode($value) {
2276
+        if (in_array($value, array('live', 'test'))) {
2277
+            $this->set_prop('mode', $value);
2278 2278
         }
2279 2279
     }
2280 2280
 
@@ -2284,8 +2284,8 @@  discard block
 block discarded – undo
2284 2284
 	 * @since 1.0.19
2285 2285
 	 * @param  string $value path.
2286 2286
 	 */
2287
-	public function set_path( $value ) {
2288
-        $this->set_prop( 'path', $value );
2287
+	public function set_path($value) {
2288
+        $this->set_prop('path', $value);
2289 2289
     }
2290 2290
 
2291 2291
     /**
@@ -2294,9 +2294,9 @@  discard block
 block discarded – undo
2294 2294
 	 * @since 1.0.19
2295 2295
 	 * @param  string $value New name.
2296 2296
 	 */
2297
-	public function set_name( $value ) {
2298
-        $name = sanitize_text_field( $value );
2299
-		$this->set_prop( 'name', $name );
2297
+	public function set_name($value) {
2298
+        $name = sanitize_text_field($value);
2299
+		$this->set_prop('name', $name);
2300 2300
     }
2301 2301
 
2302 2302
     /**
@@ -2305,8 +2305,8 @@  discard block
 block discarded – undo
2305 2305
 	 * @since 1.0.19
2306 2306
 	 * @param  string $value New name.
2307 2307
 	 */
2308
-	public function set_title( $value ) {
2309
-		$this->set_name( $value );
2308
+	public function set_title($value) {
2309
+		$this->set_name($value);
2310 2310
     }
2311 2311
 
2312 2312
     /**
@@ -2315,9 +2315,9 @@  discard block
 block discarded – undo
2315 2315
 	 * @since 1.0.19
2316 2316
 	 * @param  string $value New description.
2317 2317
 	 */
2318
-	public function set_description( $value ) {
2319
-        $description = wp_kses_post( $value );
2320
-		$this->set_prop( 'description', $description );
2318
+	public function set_description($value) {
2319
+        $description = wp_kses_post($value);
2320
+		$this->set_prop('description', $description);
2321 2321
     }
2322 2322
 
2323 2323
     /**
@@ -2326,8 +2326,8 @@  discard block
 block discarded – undo
2326 2326
 	 * @since 1.0.19
2327 2327
 	 * @param  string $value New description.
2328 2328
 	 */
2329
-	public function set_excerpt( $value ) {
2330
-		$this->set_description( $value );
2329
+	public function set_excerpt($value) {
2330
+		$this->set_description($value);
2331 2331
     }
2332 2332
 
2333 2333
     /**
@@ -2336,8 +2336,8 @@  discard block
 block discarded – undo
2336 2336
 	 * @since 1.0.19
2337 2337
 	 * @param  string $value New description.
2338 2338
 	 */
2339
-	public function set_summary( $value ) {
2340
-		$this->set_description( $value );
2339
+	public function set_summary($value) {
2340
+		$this->set_description($value);
2341 2341
     }
2342 2342
 
2343 2343
     /**
@@ -2346,12 +2346,12 @@  discard block
 block discarded – undo
2346 2346
 	 * @since 1.0.19
2347 2347
 	 * @param  int $value New author.
2348 2348
 	 */
2349
-	public function set_author( $value ) {
2350
-		$user = get_user_by( 'id', (int) $value );
2349
+	public function set_author($value) {
2350
+		$user = get_user_by('id', (int) $value);
2351 2351
 
2352
-		if ( $user && $user->ID ) {
2353
-			$this->set_prop( 'author', $user->ID );
2354
-			$this->set_prop( 'email', $user->user_email );
2352
+		if ($user && $user->ID) {
2353
+			$this->set_prop('author', $user->ID);
2354
+			$this->set_prop('email', $user->user_email);
2355 2355
 		}
2356 2356
 
2357 2357
     }
@@ -2362,8 +2362,8 @@  discard block
 block discarded – undo
2362 2362
 	 * @since 1.0.19
2363 2363
 	 * @param  int $value New user id.
2364 2364
 	 */
2365
-	public function set_user_id( $value ) {
2366
-		$this->set_author( $value );
2365
+	public function set_user_id($value) {
2366
+		$this->set_author($value);
2367 2367
     }
2368 2368
 
2369 2369
     /**
@@ -2372,8 +2372,8 @@  discard block
 block discarded – undo
2372 2372
 	 * @since 1.0.19
2373 2373
 	 * @param  int $value New user id.
2374 2374
 	 */
2375
-	public function set_customer_id( $value ) {
2376
-		$this->set_prop( 'customer_id', (int) $value );
2375
+	public function set_customer_id($value) {
2376
+		$this->set_prop('customer_id', (int) $value);
2377 2377
     }
2378 2378
 
2379 2379
     /**
@@ -2382,8 +2382,8 @@  discard block
 block discarded – undo
2382 2382
 	 * @since 1.0.19
2383 2383
 	 * @param  string $value ip address.
2384 2384
 	 */
2385
-	public function set_ip( $value ) {
2386
-		$this->set_prop( 'ip', $value );
2385
+	public function set_ip($value) {
2386
+		$this->set_prop('ip', $value);
2387 2387
     }
2388 2388
 
2389 2389
     /**
@@ -2392,8 +2392,8 @@  discard block
 block discarded – undo
2392 2392
 	 * @since 1.0.19
2393 2393
 	 * @param  string $value ip address.
2394 2394
 	 */
2395
-	public function set_user_ip( $value ) {
2396
-		$this->set_ip( $value );
2395
+	public function set_user_ip($value) {
2396
+		$this->set_ip($value);
2397 2397
     }
2398 2398
 
2399 2399
     /**
@@ -2402,8 +2402,8 @@  discard block
 block discarded – undo
2402 2402
 	 * @since 1.0.19
2403 2403
 	 * @param  string $value first name.
2404 2404
 	 */
2405
-	public function set_first_name( $value ) {
2406
-		$this->set_prop( 'first_name', $value );
2405
+	public function set_first_name($value) {
2406
+		$this->set_prop('first_name', $value);
2407 2407
     }
2408 2408
 
2409 2409
     /**
@@ -2412,8 +2412,8 @@  discard block
 block discarded – undo
2412 2412
 	 * @since 1.0.19
2413 2413
 	 * @param  string $value first name.
2414 2414
 	 */
2415
-	public function set_user_first_name( $value ) {
2416
-		$this->set_first_name( $value );
2415
+	public function set_user_first_name($value) {
2416
+		$this->set_first_name($value);
2417 2417
     }
2418 2418
 
2419 2419
     /**
@@ -2422,8 +2422,8 @@  discard block
 block discarded – undo
2422 2422
 	 * @since 1.0.19
2423 2423
 	 * @param  string $value first name.
2424 2424
 	 */
2425
-	public function set_customer_first_name( $value ) {
2426
-		$this->set_first_name( $value );
2425
+	public function set_customer_first_name($value) {
2426
+		$this->set_first_name($value);
2427 2427
     }
2428 2428
 
2429 2429
     /**
@@ -2432,8 +2432,8 @@  discard block
 block discarded – undo
2432 2432
 	 * @since 1.0.19
2433 2433
 	 * @param  string $value last name.
2434 2434
 	 */
2435
-	public function set_last_name( $value ) {
2436
-		$this->set_prop( 'last_name', $value );
2435
+	public function set_last_name($value) {
2436
+		$this->set_prop('last_name', $value);
2437 2437
     }
2438 2438
 
2439 2439
     /**
@@ -2442,8 +2442,8 @@  discard block
 block discarded – undo
2442 2442
 	 * @since 1.0.19
2443 2443
 	 * @param  string $value last name.
2444 2444
 	 */
2445
-	public function set_user_last_name( $value ) {
2446
-		$this->set_last_name( $value );
2445
+	public function set_user_last_name($value) {
2446
+		$this->set_last_name($value);
2447 2447
     }
2448 2448
 
2449 2449
     /**
@@ -2452,8 +2452,8 @@  discard block
 block discarded – undo
2452 2452
 	 * @since 1.0.19
2453 2453
 	 * @param  string $value last name.
2454 2454
 	 */
2455
-	public function set_customer_last_name( $value ) {
2456
-		$this->set_last_name( $value );
2455
+	public function set_customer_last_name($value) {
2456
+		$this->set_last_name($value);
2457 2457
     }
2458 2458
 
2459 2459
     /**
@@ -2462,8 +2462,8 @@  discard block
 block discarded – undo
2462 2462
 	 * @since 1.0.19
2463 2463
 	 * @param  string $value phone.
2464 2464
 	 */
2465
-	public function set_phone( $value ) {
2466
-		$this->set_prop( 'phone', $value );
2465
+	public function set_phone($value) {
2466
+		$this->set_prop('phone', $value);
2467 2467
     }
2468 2468
 
2469 2469
     /**
@@ -2472,8 +2472,8 @@  discard block
 block discarded – undo
2472 2472
 	 * @since 1.0.19
2473 2473
 	 * @param  string $value phone.
2474 2474
 	 */
2475
-	public function set_user_phone( $value ) {
2476
-		$this->set_phone( $value );
2475
+	public function set_user_phone($value) {
2476
+		$this->set_phone($value);
2477 2477
     }
2478 2478
 
2479 2479
     /**
@@ -2482,8 +2482,8 @@  discard block
 block discarded – undo
2482 2482
 	 * @since 1.0.19
2483 2483
 	 * @param  string $value phone.
2484 2484
 	 */
2485
-	public function set_customer_phone( $value ) {
2486
-		$this->set_phone( $value );
2485
+	public function set_customer_phone($value) {
2486
+		$this->set_phone($value);
2487 2487
     }
2488 2488
 
2489 2489
     /**
@@ -2492,8 +2492,8 @@  discard block
 block discarded – undo
2492 2492
 	 * @since 1.0.19
2493 2493
 	 * @param  string $value phone.
2494 2494
 	 */
2495
-	public function set_phone_number( $value ) {
2496
-		$this->set_phone( $value );
2495
+	public function set_phone_number($value) {
2496
+		$this->set_phone($value);
2497 2497
     }
2498 2498
 
2499 2499
     /**
@@ -2502,8 +2502,8 @@  discard block
 block discarded – undo
2502 2502
 	 * @since 1.0.19
2503 2503
 	 * @param  string $value email address.
2504 2504
 	 */
2505
-	public function set_email( $value ) {
2506
-		$this->set_prop( 'email', $value );
2505
+	public function set_email($value) {
2506
+		$this->set_prop('email', $value);
2507 2507
     }
2508 2508
 
2509 2509
     /**
@@ -2512,8 +2512,8 @@  discard block
 block discarded – undo
2512 2512
 	 * @since 1.0.19
2513 2513
 	 * @param  string $value email address.
2514 2514
 	 */
2515
-	public function set_user_email( $value ) {
2516
-		$this->set_email( $value );
2515
+	public function set_user_email($value) {
2516
+		$this->set_email($value);
2517 2517
     }
2518 2518
 
2519 2519
     /**
@@ -2522,8 +2522,8 @@  discard block
 block discarded – undo
2522 2522
 	 * @since 1.0.19
2523 2523
 	 * @param  string $value email address.
2524 2524
 	 */
2525
-	public function set_email_address( $value ) {
2526
-		$this->set_email( $value );
2525
+	public function set_email_address($value) {
2526
+		$this->set_email($value);
2527 2527
     }
2528 2528
 
2529 2529
     /**
@@ -2532,8 +2532,8 @@  discard block
 block discarded – undo
2532 2532
 	 * @since 1.0.19
2533 2533
 	 * @param  string $value email address.
2534 2534
 	 */
2535
-	public function set_customer_email( $value ) {
2536
-		$this->set_email( $value );
2535
+	public function set_customer_email($value) {
2536
+		$this->set_email($value);
2537 2537
     }
2538 2538
 
2539 2539
     /**
@@ -2542,8 +2542,8 @@  discard block
 block discarded – undo
2542 2542
 	 * @since 1.0.19
2543 2543
 	 * @param  string $value country.
2544 2544
 	 */
2545
-	public function set_country( $value ) {
2546
-		$this->set_prop( 'country', $value );
2545
+	public function set_country($value) {
2546
+		$this->set_prop('country', $value);
2547 2547
     }
2548 2548
 
2549 2549
     /**
@@ -2552,8 +2552,8 @@  discard block
 block discarded – undo
2552 2552
 	 * @since 1.0.19
2553 2553
 	 * @param  string $value country.
2554 2554
 	 */
2555
-	public function set_user_country( $value ) {
2556
-		$this->set_country( $value );
2555
+	public function set_user_country($value) {
2556
+		$this->set_country($value);
2557 2557
     }
2558 2558
 
2559 2559
     /**
@@ -2562,8 +2562,8 @@  discard block
 block discarded – undo
2562 2562
 	 * @since 1.0.19
2563 2563
 	 * @param  string $value country.
2564 2564
 	 */
2565
-	public function set_customer_country( $value ) {
2566
-		$this->set_country( $value );
2565
+	public function set_customer_country($value) {
2566
+		$this->set_country($value);
2567 2567
     }
2568 2568
 
2569 2569
     /**
@@ -2572,8 +2572,8 @@  discard block
 block discarded – undo
2572 2572
 	 * @since 1.0.19
2573 2573
 	 * @param  string $value state.
2574 2574
 	 */
2575
-	public function set_state( $value ) {
2576
-		$this->set_prop( 'state', $value );
2575
+	public function set_state($value) {
2576
+		$this->set_prop('state', $value);
2577 2577
     }
2578 2578
 
2579 2579
     /**
@@ -2582,8 +2582,8 @@  discard block
 block discarded – undo
2582 2582
 	 * @since 1.0.19
2583 2583
 	 * @param  string $value state.
2584 2584
 	 */
2585
-	public function set_user_state( $value ) {
2586
-		$this->set_state( $value );
2585
+	public function set_user_state($value) {
2586
+		$this->set_state($value);
2587 2587
     }
2588 2588
 
2589 2589
     /**
@@ -2592,8 +2592,8 @@  discard block
 block discarded – undo
2592 2592
 	 * @since 1.0.19
2593 2593
 	 * @param  string $value state.
2594 2594
 	 */
2595
-	public function set_customer_state( $value ) {
2596
-		$this->set_state( $value );
2595
+	public function set_customer_state($value) {
2596
+		$this->set_state($value);
2597 2597
     }
2598 2598
 
2599 2599
     /**
@@ -2602,8 +2602,8 @@  discard block
 block discarded – undo
2602 2602
 	 * @since 1.0.19
2603 2603
 	 * @param  string $value city.
2604 2604
 	 */
2605
-	public function set_city( $value ) {
2606
-		$this->set_prop( 'city', $value );
2605
+	public function set_city($value) {
2606
+		$this->set_prop('city', $value);
2607 2607
     }
2608 2608
 
2609 2609
     /**
@@ -2612,8 +2612,8 @@  discard block
 block discarded – undo
2612 2612
 	 * @since 1.0.19
2613 2613
 	 * @param  string $value city.
2614 2614
 	 */
2615
-	public function set_user_city( $value ) {
2616
-		$this->set_city( $value );
2615
+	public function set_user_city($value) {
2616
+		$this->set_city($value);
2617 2617
     }
2618 2618
 
2619 2619
     /**
@@ -2622,8 +2622,8 @@  discard block
 block discarded – undo
2622 2622
 	 * @since 1.0.19
2623 2623
 	 * @param  string $value city.
2624 2624
 	 */
2625
-	public function set_customer_city( $value ) {
2626
-		$this->set_city( $value );
2625
+	public function set_customer_city($value) {
2626
+		$this->set_city($value);
2627 2627
     }
2628 2628
 
2629 2629
     /**
@@ -2632,8 +2632,8 @@  discard block
 block discarded – undo
2632 2632
 	 * @since 1.0.19
2633 2633
 	 * @param  string $value zip.
2634 2634
 	 */
2635
-	public function set_zip( $value ) {
2636
-		$this->set_prop( 'zip', $value );
2635
+	public function set_zip($value) {
2636
+		$this->set_prop('zip', $value);
2637 2637
     }
2638 2638
 
2639 2639
     /**
@@ -2642,8 +2642,8 @@  discard block
 block discarded – undo
2642 2642
 	 * @since 1.0.19
2643 2643
 	 * @param  string $value zip.
2644 2644
 	 */
2645
-	public function set_user_zip( $value ) {
2646
-		$this->set_zip( $value );
2645
+	public function set_user_zip($value) {
2646
+		$this->set_zip($value);
2647 2647
     }
2648 2648
 
2649 2649
     /**
@@ -2652,8 +2652,8 @@  discard block
 block discarded – undo
2652 2652
 	 * @since 1.0.19
2653 2653
 	 * @param  string $value zip.
2654 2654
 	 */
2655
-	public function set_customer_zip( $value ) {
2656
-		$this->set_zip( $value );
2655
+	public function set_customer_zip($value) {
2656
+		$this->set_zip($value);
2657 2657
     }
2658 2658
 
2659 2659
     /**
@@ -2662,8 +2662,8 @@  discard block
 block discarded – undo
2662 2662
 	 * @since 1.0.19
2663 2663
 	 * @param  string $value company.
2664 2664
 	 */
2665
-	public function set_company( $value ) {
2666
-		$this->set_prop( 'company', $value );
2665
+	public function set_company($value) {
2666
+		$this->set_prop('company', $value);
2667 2667
     }
2668 2668
 
2669 2669
     /**
@@ -2672,8 +2672,8 @@  discard block
 block discarded – undo
2672 2672
 	 * @since 1.0.19
2673 2673
 	 * @param  string $value company.
2674 2674
 	 */
2675
-	public function set_user_company( $value ) {
2676
-		$this->set_company( $value );
2675
+	public function set_user_company($value) {
2676
+		$this->set_company($value);
2677 2677
     }
2678 2678
 
2679 2679
     /**
@@ -2682,8 +2682,8 @@  discard block
 block discarded – undo
2682 2682
 	 * @since 1.0.19
2683 2683
 	 * @param  string $value company.
2684 2684
 	 */
2685
-	public function set_customer_company( $value ) {
2686
-		$this->set_company( $value );
2685
+	public function set_customer_company($value) {
2686
+		$this->set_company($value);
2687 2687
     }
2688 2688
 
2689 2689
 	/**
@@ -2692,8 +2692,8 @@  discard block
 block discarded – undo
2692 2692
 	 * @since 1.0.19
2693 2693
 	 * @param  string $value company id.
2694 2694
 	 */
2695
-	public function set_company_id( $value ) {
2696
-		$this->set_prop( 'company_id', $value );
2695
+	public function set_company_id($value) {
2696
+		$this->set_prop('company_id', $value);
2697 2697
     }
2698 2698
 
2699 2699
     /**
@@ -2702,8 +2702,8 @@  discard block
 block discarded – undo
2702 2702
 	 * @since 1.0.19
2703 2703
 	 * @param  string $value var number.
2704 2704
 	 */
2705
-	public function set_vat_number( $value ) {
2706
-		$this->set_prop( 'vat_number', $value );
2705
+	public function set_vat_number($value) {
2706
+		$this->set_prop('vat_number', $value);
2707 2707
     }
2708 2708
 
2709 2709
     /**
@@ -2712,8 +2712,8 @@  discard block
 block discarded – undo
2712 2712
 	 * @since 1.0.19
2713 2713
 	 * @param  string $value var number.
2714 2714
 	 */
2715
-	public function set_user_vat_number( $value ) {
2716
-		$this->set_vat_number( $value );
2715
+	public function set_user_vat_number($value) {
2716
+		$this->set_vat_number($value);
2717 2717
     }
2718 2718
 
2719 2719
     /**
@@ -2722,8 +2722,8 @@  discard block
 block discarded – undo
2722 2722
 	 * @since 1.0.19
2723 2723
 	 * @param  string $value var number.
2724 2724
 	 */
2725
-	public function set_customer_vat_number( $value ) {
2726
-		$this->set_vat_number( $value );
2725
+	public function set_customer_vat_number($value) {
2726
+		$this->set_vat_number($value);
2727 2727
     }
2728 2728
 
2729 2729
     /**
@@ -2732,8 +2732,8 @@  discard block
 block discarded – undo
2732 2732
 	 * @since 1.0.19
2733 2733
 	 * @param  string $value var rate.
2734 2734
 	 */
2735
-	public function set_vat_rate( $value ) {
2736
-		$this->set_prop( 'vat_rate', $value );
2735
+	public function set_vat_rate($value) {
2736
+		$this->set_prop('vat_rate', $value);
2737 2737
     }
2738 2738
 
2739 2739
     /**
@@ -2742,8 +2742,8 @@  discard block
 block discarded – undo
2742 2742
 	 * @since 1.0.19
2743 2743
 	 * @param  string $value var number.
2744 2744
 	 */
2745
-	public function set_user_vat_rate( $value ) {
2746
-		$this->set_vat_rate( $value );
2745
+	public function set_user_vat_rate($value) {
2746
+		$this->set_vat_rate($value);
2747 2747
     }
2748 2748
 
2749 2749
     /**
@@ -2752,8 +2752,8 @@  discard block
 block discarded – undo
2752 2752
 	 * @since 1.0.19
2753 2753
 	 * @param  string $value var number.
2754 2754
 	 */
2755
-	public function set_customer_vat_rate( $value ) {
2756
-		$this->set_vat_rate( $value );
2755
+	public function set_customer_vat_rate($value) {
2756
+		$this->set_vat_rate($value);
2757 2757
     }
2758 2758
 
2759 2759
     /**
@@ -2762,8 +2762,8 @@  discard block
 block discarded – undo
2762 2762
 	 * @since 1.0.19
2763 2763
 	 * @param  string $value address.
2764 2764
 	 */
2765
-	public function set_address( $value ) {
2766
-		$this->set_prop( 'address', $value );
2765
+	public function set_address($value) {
2766
+		$this->set_prop('address', $value);
2767 2767
     }
2768 2768
 
2769 2769
     /**
@@ -2772,8 +2772,8 @@  discard block
 block discarded – undo
2772 2772
 	 * @since 1.0.19
2773 2773
 	 * @param  string $value address.
2774 2774
 	 */
2775
-	public function set_user_address( $value ) {
2776
-		$this->set_address( $value );
2775
+	public function set_user_address($value) {
2776
+		$this->set_address($value);
2777 2777
     }
2778 2778
 
2779 2779
     /**
@@ -2782,8 +2782,8 @@  discard block
 block discarded – undo
2782 2782
 	 * @since 1.0.19
2783 2783
 	 * @param  string $value address.
2784 2784
 	 */
2785
-	public function set_customer_address( $value ) {
2786
-		$this->set_address( $value );
2785
+	public function set_customer_address($value) {
2786
+		$this->set_address($value);
2787 2787
     }
2788 2788
 
2789 2789
     /**
@@ -2792,8 +2792,8 @@  discard block
 block discarded – undo
2792 2792
 	 * @since 1.0.19
2793 2793
 	 * @param  int|bool $value confirmed.
2794 2794
 	 */
2795
-	public function set_is_viewed( $value ) {
2796
-		$this->set_prop( 'is_viewed', $value );
2795
+	public function set_is_viewed($value) {
2796
+		$this->set_prop('is_viewed', $value);
2797 2797
 	}
2798 2798
 
2799 2799
 	/**
@@ -2802,8 +2802,8 @@  discard block
 block discarded – undo
2802 2802
 	 * @since 1.0.19
2803 2803
 	 * @param  string $value email recipients.
2804 2804
 	 */
2805
-	public function set_email_cc( $value ) {
2806
-		$this->set_prop( 'email_cc', $value );
2805
+	public function set_email_cc($value) {
2806
+		$this->set_prop('email_cc', $value);
2807 2807
 	}
2808 2808
 
2809 2809
 	/**
@@ -2812,9 +2812,9 @@  discard block
 block discarded – undo
2812 2812
 	 * @since 1.0.19
2813 2813
 	 * @param  string $value template.
2814 2814
 	 */
2815
-	public function set_template( $value ) {
2816
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2817
-			$this->set_prop( 'template', $value );
2815
+	public function set_template($value) {
2816
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2817
+			$this->set_prop('template', $value);
2818 2818
 		}
2819 2819
 	}
2820 2820
 
@@ -2825,8 +2825,8 @@  discard block
 block discarded – undo
2825 2825
 	 * @param  string $value source.
2826 2826
 	 * @deprecated
2827 2827
 	 */
2828
-	public function created_via( $value ) {
2829
-		$this->set_created_via( sanitize_text_field( $value ) );
2828
+	public function created_via($value) {
2829
+		$this->set_created_via(sanitize_text_field($value));
2830 2830
 	}
2831 2831
 
2832 2832
 	/**
@@ -2835,8 +2835,8 @@  discard block
 block discarded – undo
2835 2835
 	 * @since 1.0.19
2836 2836
 	 * @param  string $value source.
2837 2837
 	 */
2838
-	public function set_created_via( $value ) {
2839
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2838
+	public function set_created_via($value) {
2839
+		$this->set_prop('created_via', sanitize_text_field($value));
2840 2840
 	}
2841 2841
 
2842 2842
 	/**
@@ -2845,8 +2845,8 @@  discard block
 block discarded – undo
2845 2845
 	 * @since 1.0.19
2846 2846
 	 * @param  int|bool $value confirmed.
2847 2847
 	 */
2848
-	public function set_address_confirmed( $value ) {
2849
-		$this->set_prop( 'address_confirmed', $value );
2848
+	public function set_address_confirmed($value) {
2849
+		$this->set_prop('address_confirmed', $value);
2850 2850
     }
2851 2851
 
2852 2852
     /**
@@ -2855,8 +2855,8 @@  discard block
 block discarded – undo
2855 2855
 	 * @since 1.0.19
2856 2856
 	 * @param  int|bool $value confirmed.
2857 2857
 	 */
2858
-	public function set_user_address_confirmed( $value ) {
2859
-		$this->set_address_confirmed( $value );
2858
+	public function set_user_address_confirmed($value) {
2859
+		$this->set_address_confirmed($value);
2860 2860
     }
2861 2861
 
2862 2862
     /**
@@ -2865,8 +2865,8 @@  discard block
 block discarded – undo
2865 2865
 	 * @since 1.0.19
2866 2866
 	 * @param  int|bool $value confirmed.
2867 2867
 	 */
2868
-	public function set_customer_address_confirmed( $value ) {
2869
-		$this->set_address_confirmed( $value );
2868
+	public function set_customer_address_confirmed($value) {
2869
+		$this->set_address_confirmed($value);
2870 2870
     }
2871 2871
 
2872 2872
     /**
@@ -2875,13 +2875,13 @@  discard block
 block discarded – undo
2875 2875
 	 * @since 1.0.19
2876 2876
 	 * @param  float $value shipping amount.
2877 2877
 	 */
2878
-	public function set_shipping( $value ) {
2878
+	public function set_shipping($value) {
2879 2879
 
2880
-		if ( ! is_numeric( $value ) ) {
2881
-			return $this->set_prop( 'shipping', null );
2880
+		if (!is_numeric($value)) {
2881
+			return $this->set_prop('shipping', null);
2882 2882
 		}
2883 2883
 
2884
-		$this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2884
+		$this->set_prop('shipping', max(0, floatval($value)));
2885 2885
 	}
2886 2886
 
2887 2887
 	/**
@@ -2890,8 +2890,8 @@  discard block
 block discarded – undo
2890 2890
 	 * @since 1.0.19
2891 2891
 	 * @param  float $value sub total.
2892 2892
 	 */
2893
-	public function set_subtotal( $value ) {
2894
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2893
+	public function set_subtotal($value) {
2894
+		$this->set_prop('subtotal', max(0, $value));
2895 2895
 	}
2896 2896
 
2897 2897
 	/**
@@ -2900,8 +2900,8 @@  discard block
 block discarded – undo
2900 2900
 	 * @since 1.0.19
2901 2901
 	 * @param  float $value sub total.
2902 2902
 	 */
2903
-	public function set_total( $value ) {
2904
-		$this->set_prop( 'total', max( 0, $value ) );
2903
+	public function set_total($value) {
2904
+		$this->set_prop('total', max(0, $value));
2905 2905
     }
2906 2906
 
2907 2907
     /**
@@ -2910,8 +2910,8 @@  discard block
 block discarded – undo
2910 2910
 	 * @since 1.0.19
2911 2911
 	 * @param  float $value discount total.
2912 2912
 	 */
2913
-	public function set_total_discount( $value ) {
2914
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2913
+	public function set_total_discount($value) {
2914
+		$this->set_prop('total_discount', max(0, $value));
2915 2915
     }
2916 2916
 
2917 2917
     /**
@@ -2920,8 +2920,8 @@  discard block
 block discarded – undo
2920 2920
 	 * @since 1.0.19
2921 2921
 	 * @param  float $value discount total.
2922 2922
 	 */
2923
-	public function set_discount( $value ) {
2924
-		$this->set_total_discount( $value );
2923
+	public function set_discount($value) {
2924
+		$this->set_total_discount($value);
2925 2925
     }
2926 2926
 
2927 2927
     /**
@@ -2930,8 +2930,8 @@  discard block
 block discarded – undo
2930 2930
 	 * @since 1.0.19
2931 2931
 	 * @param  float $value tax total.
2932 2932
 	 */
2933
-	public function set_total_tax( $value ) {
2934
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2933
+	public function set_total_tax($value) {
2934
+		$this->set_prop('total_tax', max(0, $value));
2935 2935
     }
2936 2936
 
2937 2937
     /**
@@ -2940,8 +2940,8 @@  discard block
 block discarded – undo
2940 2940
 	 * @since 1.0.19
2941 2941
 	 * @param  float $value tax total.
2942 2942
 	 */
2943
-	public function set_tax_total( $value ) {
2944
-		$this->set_total_tax( $value );
2943
+	public function set_tax_total($value) {
2944
+		$this->set_total_tax($value);
2945 2945
     }
2946 2946
 
2947 2947
     /**
@@ -2950,8 +2950,8 @@  discard block
 block discarded – undo
2950 2950
 	 * @since 1.0.19
2951 2951
 	 * @param  float $value fees total.
2952 2952
 	 */
2953
-	public function set_total_fees( $value ) {
2954
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2953
+	public function set_total_fees($value) {
2954
+		$this->set_prop('total_fees', max(0, $value));
2955 2955
     }
2956 2956
 
2957 2957
     /**
@@ -2960,8 +2960,8 @@  discard block
 block discarded – undo
2960 2960
 	 * @since 1.0.19
2961 2961
 	 * @param  float $value fees total.
2962 2962
 	 */
2963
-	public function set_fees_total( $value ) {
2964
-		$this->set_total_fees( $value );
2963
+	public function set_fees_total($value) {
2964
+		$this->set_total_fees($value);
2965 2965
     }
2966 2966
 
2967 2967
     /**
@@ -2970,13 +2970,13 @@  discard block
 block discarded – undo
2970 2970
 	 * @since 1.0.19
2971 2971
 	 * @param  array $value fees.
2972 2972
 	 */
2973
-	public function set_fees( $value ) {
2973
+	public function set_fees($value) {
2974 2974
 
2975
-		if ( ! is_array( $value ) ) {
2975
+		if (!is_array($value)) {
2976 2976
 			$value = array();
2977 2977
 		}
2978 2978
 
2979
-		$this->set_prop( 'fees', $value );
2979
+		$this->set_prop('fees', $value);
2980 2980
 
2981 2981
     }
2982 2982
 
@@ -2986,13 +2986,13 @@  discard block
 block discarded – undo
2986 2986
 	 * @since 1.0.19
2987 2987
 	 * @param  array $value taxes.
2988 2988
 	 */
2989
-	public function set_taxes( $value ) {
2989
+	public function set_taxes($value) {
2990 2990
 
2991
-		if ( ! is_array( $value ) ) {
2991
+		if (!is_array($value)) {
2992 2992
 			$value = array();
2993 2993
 		}
2994 2994
 
2995
-		$this->set_prop( 'taxes', $value );
2995
+		$this->set_prop('taxes', $value);
2996 2996
 
2997 2997
     }
2998 2998
 
@@ -3002,13 +3002,13 @@  discard block
 block discarded – undo
3002 3002
 	 * @since 1.0.19
3003 3003
 	 * @param  array $value discounts.
3004 3004
 	 */
3005
-	public function set_discounts( $value ) {
3005
+	public function set_discounts($value) {
3006 3006
 
3007
-		if ( ! is_array( $value ) ) {
3007
+		if (!is_array($value)) {
3008 3008
 			$value = array();
3009 3009
 		}
3010 3010
 
3011
-		$this->set_prop( 'discounts', $value );
3011
+		$this->set_prop('discounts', $value);
3012 3012
     }
3013 3013
 
3014 3014
     /**
@@ -3017,19 +3017,19 @@  discard block
 block discarded – undo
3017 3017
 	 * @since 1.0.19
3018 3018
 	 * @param  GetPaid_Form_Item[] $value items.
3019 3019
 	 */
3020
-	public function set_items( $value ) {
3020
+	public function set_items($value) {
3021 3021
 
3022 3022
         // Remove existing items.
3023
-        $this->set_prop( 'items', array() );
3023
+        $this->set_prop('items', array());
3024 3024
 		$this->recurring_item = null;
3025 3025
 
3026 3026
         // Ensure that we have an array.
3027
-        if ( ! is_array( $value ) ) {
3027
+        if (!is_array($value)) {
3028 3028
             return;
3029 3029
         }
3030 3030
 
3031
-        foreach ( $value as $item ) {
3032
-            $this->add_item( $item );
3031
+        foreach ($value as $item) {
3032
+            $this->add_item($item);
3033 3033
         }
3034 3034
 
3035 3035
     }
@@ -3040,8 +3040,8 @@  discard block
 block discarded – undo
3040 3040
 	 * @since 1.0.19
3041 3041
 	 * @param  int $value payment form.
3042 3042
 	 */
3043
-	public function set_payment_form( $value ) {
3044
-		$this->set_prop( 'payment_form', $value );
3043
+	public function set_payment_form($value) {
3044
+		$this->set_prop('payment_form', $value);
3045 3045
     }
3046 3046
 
3047 3047
     /**
@@ -3050,8 +3050,8 @@  discard block
 block discarded – undo
3050 3050
 	 * @since 1.0.19
3051 3051
 	 * @param  string $value submission id.
3052 3052
 	 */
3053
-	public function set_submission_id( $value ) {
3054
-		$this->set_prop( 'submission_id', $value );
3053
+	public function set_submission_id($value) {
3054
+		$this->set_prop('submission_id', $value);
3055 3055
     }
3056 3056
 
3057 3057
     /**
@@ -3060,8 +3060,8 @@  discard block
 block discarded – undo
3060 3060
 	 * @since 1.0.19
3061 3061
 	 * @param  string $value discount code.
3062 3062
 	 */
3063
-	public function set_discount_code( $value ) {
3064
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3063
+	public function set_discount_code($value) {
3064
+		$this->set_prop('discount_code', sanitize_text_field($value));
3065 3065
     }
3066 3066
 
3067 3067
     /**
@@ -3070,8 +3070,8 @@  discard block
 block discarded – undo
3070 3070
 	 * @since 1.0.19
3071 3071
 	 * @param  string $value gateway.
3072 3072
 	 */
3073
-	public function set_gateway( $value ) {
3074
-		$this->set_prop( 'gateway', $value );
3073
+	public function set_gateway($value) {
3074
+		$this->set_prop('gateway', $value);
3075 3075
     }
3076 3076
 
3077 3077
     /**
@@ -3080,9 +3080,9 @@  discard block
 block discarded – undo
3080 3080
 	 * @since 1.0.19
3081 3081
 	 * @param  string $value transaction id.
3082 3082
 	 */
3083
-	public function set_transaction_id( $value ) {
3084
-		if ( ! empty( $value ) ) {
3085
-			$this->set_prop( 'transaction_id', $value );
3083
+	public function set_transaction_id($value) {
3084
+		if (!empty($value)) {
3085
+			$this->set_prop('transaction_id', $value);
3086 3086
 		}
3087 3087
     }
3088 3088
 
@@ -3092,8 +3092,8 @@  discard block
 block discarded – undo
3092 3092
 	 * @since 1.0.19
3093 3093
 	 * @param  string $value currency id.
3094 3094
 	 */
3095
-	public function set_currency( $value ) {
3096
-		$this->set_prop( 'currency', $value );
3095
+	public function set_currency($value) {
3096
+		$this->set_prop('currency', $value);
3097 3097
     }
3098 3098
 
3099 3099
 	/**
@@ -3102,8 +3102,8 @@  discard block
 block discarded – undo
3102 3102
 	 * @since 1.0.19
3103 3103
 	 * @param  bool $value value.
3104 3104
 	 */
3105
-	public function set_disable_taxes( $value ) {
3106
-		$this->set_prop( 'disable_taxes', (bool) $value );
3105
+	public function set_disable_taxes($value) {
3106
+		$this->set_prop('disable_taxes', (bool) $value);
3107 3107
 	}
3108 3108
 
3109 3109
     /**
@@ -3112,8 +3112,8 @@  discard block
 block discarded – undo
3112 3112
 	 * @since 1.0.19
3113 3113
 	 * @param  string $value subscription id.
3114 3114
 	 */
3115
-	public function set_subscription_id( $value ) {
3116
-		$this->set_prop( 'subscription_id', $value );
3115
+	public function set_subscription_id($value) {
3116
+		$this->set_prop('subscription_id', $value);
3117 3117
 	}
3118 3118
 
3119 3119
 	/**
@@ -3122,8 +3122,8 @@  discard block
 block discarded – undo
3122 3122
 	 * @since 1.0.19
3123 3123
 	 * @param  string $value subscription id.
3124 3124
 	 */
3125
-	public function set_remote_subscription_id( $value ) {
3126
-		$this->set_prop( 'remote_subscription_id', $value );
3125
+	public function set_remote_subscription_id($value) {
3126
+		$this->set_prop('remote_subscription_id', $value);
3127 3127
     }
3128 3128
 
3129 3129
     /*
@@ -3140,28 +3140,28 @@  discard block
 block discarded – undo
3140 3140
      */
3141 3141
     public function is_parent() {
3142 3142
         $parent = $this->get_parent_id();
3143
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
3143
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
3144 3144
     }
3145 3145
 
3146 3146
     /**
3147 3147
      * Checks if this is a renewal invoice.
3148 3148
      */
3149 3149
     public function is_renewal() {
3150
-        return $this->is_recurring() && ! $this->is_parent();
3150
+        return $this->is_recurring() && !$this->is_parent();
3151 3151
     }
3152 3152
 
3153 3153
     /**
3154 3154
      * Checks if this is a recurring invoice.
3155 3155
      */
3156 3156
     public function is_recurring() {
3157
-        return ! empty( $this->recurring_item );
3157
+        return !empty($this->recurring_item);
3158 3158
     }
3159 3159
 
3160 3160
     /**
3161 3161
      * Checks if this is a taxable invoice.
3162 3162
      */
3163 3163
     public function is_taxable() {
3164
-        return ! $this->get_disable_taxes();
3164
+        return !$this->get_disable_taxes();
3165 3165
 	}
3166 3166
 
3167 3167
 	/**
@@ -3175,45 +3175,45 @@  discard block
 block discarded – undo
3175 3175
 	 * Checks to see if the invoice requires payment.
3176 3176
 	 */
3177 3177
 	public function is_free() {
3178
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3178
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
3179 3179
 
3180
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3180
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
3181 3181
 			$is_free = false;
3182 3182
 		}
3183 3183
 
3184
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3184
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
3185 3185
     }
3186 3186
 
3187 3187
     /**
3188 3188
      * Checks if the invoice is paid.
3189 3189
      */
3190 3190
     public function is_paid() {
3191
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3192
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3191
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
3192
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
3193 3193
 	}
3194 3194
 
3195 3195
 	/**
3196 3196
      * Checks if the invoice needs payment.
3197 3197
      */
3198 3198
 	public function needs_payment() {
3199
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3200
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3199
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
3200
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
3201 3201
     }
3202 3202
 
3203 3203
 	/**
3204 3204
      * Checks if the invoice is refunded.
3205 3205
      */
3206 3206
 	public function is_refunded() {
3207
-        $is_refunded = $this->has_status( 'wpi-refunded' );
3208
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3207
+        $is_refunded = $this->has_status('wpi-refunded');
3208
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
3209 3209
 	}
3210 3210
 
3211 3211
 	/**
3212 3212
      * Checks if the invoice is held.
3213 3213
      */
3214 3214
 	public function is_held() {
3215
-        $is_held = $this->has_status( 'wpi-onhold' );
3216
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3215
+        $is_held = $this->has_status('wpi-onhold');
3216
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
3217 3217
 	}
3218 3218
 
3219 3219
 	/**
@@ -3221,30 +3221,30 @@  discard block
 block discarded – undo
3221 3221
      */
3222 3222
 	public function is_due() {
3223 3223
 		$due_date = $this->get_due_date();
3224
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3224
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3225 3225
 	}
3226 3226
 
3227 3227
 	/**
3228 3228
      * Checks if the invoice is draft.
3229 3229
      */
3230 3230
 	public function is_draft() {
3231
-        return $this->has_status( 'draft, auto-draft' );
3231
+        return $this->has_status('draft, auto-draft');
3232 3232
 	}
3233 3233
 
3234 3234
     /**
3235 3235
      * Checks if the invoice has a given status.
3236 3236
      */
3237
-    public function has_status( $status ) {
3238
-        $status = wpinv_parse_list( $status );
3239
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3237
+    public function has_status($status) {
3238
+        $status = wpinv_parse_list($status);
3239
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3240 3240
 	}
3241 3241
 
3242 3242
 	/**
3243 3243
      * Checks if the invoice is of a given type.
3244 3244
      */
3245
-    public function is_type( $type ) {
3246
-        $type = wpinv_parse_list( $type );
3247
-        return in_array( $this->get_type(), $type );
3245
+    public function is_type($type) {
3246
+        $type = wpinv_parse_list($type);
3247
+        return in_array($this->get_type(), $type);
3248 3248
     }
3249 3249
 
3250 3250
     /**
@@ -3276,8 +3276,8 @@  discard block
 block discarded – undo
3276 3276
      *
3277 3277
      */
3278 3278
 	public function is_initial_free() {
3279
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3280
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3279
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3280
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3281 3281
     }
3282 3282
 
3283 3283
 	/**
@@ -3287,11 +3287,11 @@  discard block
 block discarded – undo
3287 3287
     public function item_has_free_trial() {
3288 3288
 
3289 3289
         // Ensure we have a recurring item.
3290
-        if ( ! $this->is_recurring() ) {
3290
+        if (!$this->is_recurring()) {
3291 3291
             return false;
3292 3292
         }
3293 3293
 
3294
-        $item = $this->get_recurring( true );
3294
+        $item = $this->get_recurring(true);
3295 3295
         return $item->has_free_trial();
3296 3296
 	}
3297 3297
 
@@ -3299,7 +3299,7 @@  discard block
 block discarded – undo
3299 3299
      * Check if the free trial is a result of a discount.
3300 3300
      */
3301 3301
     public function is_free_trial_from_discount() {
3302
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3302
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3303 3303
 	}
3304 3304
 
3305 3305
 	/**
@@ -3307,12 +3307,12 @@  discard block
 block discarded – undo
3307 3307
      */
3308 3308
     public function discount_first_payment_only() {
3309 3309
 
3310
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3311
-        if ( ! $discount->exists() || ! $this->is_recurring() ) {
3310
+		$discount = wpinv_get_discount_obj($this->get_discount_code());
3311
+        if (!$discount->exists() || !$this->is_recurring()) {
3312 3312
             return true;
3313 3313
         }
3314 3314
 
3315
-        return ! $discount->get_is_recurring();
3315
+        return !$discount->get_is_recurring();
3316 3316
     }
3317 3317
 
3318 3318
     /*
@@ -3330,23 +3330,23 @@  discard block
 block discarded – undo
3330 3330
      * @param GetPaid_Form_Item|array $item
3331 3331
      * @return WP_Error|Bool
3332 3332
      */
3333
-    public function add_item( $item ) {
3333
+    public function add_item($item) {
3334 3334
 
3335
-		if ( is_array( $item ) ) {
3336
-			$item = $this->process_array_item( $item );
3335
+		if (is_array($item)) {
3336
+			$item = $this->process_array_item($item);
3337 3337
 		}
3338 3338
 
3339
-		if ( is_numeric( $item ) ) {
3340
-			$item = new GetPaid_Form_Item( $item );
3339
+		if (is_numeric($item)) {
3340
+			$item = new GetPaid_Form_Item($item);
3341 3341
 		}
3342 3342
 
3343 3343
         // Make sure that it is available for purchase.
3344
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3345
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3344
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3345
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3346 3346
         }
3347 3347
 
3348 3348
         // Do we have a recurring item?
3349
-		if ( $item->is_recurring() ) {
3349
+		if ($item->is_recurring()) {
3350 3350
 			$this->recurring_item = $item->get_id();
3351 3351
         }
3352 3352
 
@@ -3354,9 +3354,9 @@  discard block
 block discarded – undo
3354 3354
         $item->invoice_id = (int) $this->get_id();
3355 3355
 
3356 3356
 		// Remove duplicates.
3357
-		$this->remove_item( $item->get_id() );
3357
+		$this->remove_item($item->get_id());
3358 3358
 
3359
-		if ( 0 == $item->get_quantity() ) {
3359
+		if (0 == $item->get_quantity()) {
3360 3360
 			return;
3361 3361
 		}
3362 3362
 
@@ -3366,7 +3366,7 @@  discard block
 block discarded – undo
3366 3366
 		// Add new item.
3367 3367
         $items[] = $item;
3368 3368
 
3369
-        $this->set_prop( 'items', $items );
3369
+        $this->set_prop('items', $items);
3370 3370
 
3371 3371
 		return true;
3372 3372
 	}
@@ -3377,26 +3377,26 @@  discard block
 block discarded – undo
3377 3377
 	 * @since 1.0.19
3378 3378
 	 * @return GetPaid_Form_Item
3379 3379
 	 */
3380
-	protected function process_array_item( $array ) {
3380
+	protected function process_array_item($array) {
3381 3381
 
3382
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3383
-		$item    = new GetPaid_Form_Item( $item_id );
3382
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3383
+		$item    = new GetPaid_Form_Item($item_id);
3384 3384
 
3385 3385
 		// Set item data.
3386
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3387
-			if ( isset( $array[ "item_$key" ] ) ) {
3386
+		foreach (array('name', 'price', 'description') as $key) {
3387
+			if (isset($array["item_$key"])) {
3388 3388
 				$method = "set_$key";
3389
-				$item->$method( $array[ "item_$key" ] );
3389
+				$item->$method($array["item_$key"]);
3390 3390
 			}
3391 3391
 		}
3392 3392
 
3393
-		if ( isset( $array['quantity'] ) ) {
3394
-			$item->set_quantity( $array['quantity'] );
3393
+		if (isset($array['quantity'])) {
3394
+			$item->set_quantity($array['quantity']);
3395 3395
 		}
3396 3396
 
3397 3397
 		// Set item meta.
3398
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3399
-			$item->set_item_meta( $array['meta'] );
3398
+		if (isset($array['meta']) && is_array($array['meta'])) {
3399
+			$item->set_item_meta($array['meta']);
3400 3400
 		}
3401 3401
 
3402 3402
 		return $item;
@@ -3409,10 +3409,10 @@  discard block
 block discarded – undo
3409 3409
 	 * @since 1.0.19
3410 3410
 	 * @return GetPaid_Form_Item|null
3411 3411
 	 */
3412
-	public function get_item( $item_id ) {
3412
+	public function get_item($item_id) {
3413 3413
 
3414
-		foreach ( $this->get_items() as $item ) {
3415
-			if ( (int) $item_id == $item->get_id() ) {
3414
+		foreach ($this->get_items() as $item) {
3415
+			if ((int) $item_id == $item->get_id()) {
3416 3416
 				return $item;
3417 3417
 			}
3418 3418
 		}
@@ -3425,16 +3425,16 @@  discard block
 block discarded – undo
3425 3425
 	 *
3426 3426
 	 * @since 1.0.19
3427 3427
 	 */
3428
-	public function remove_item( $item_id ) {
3428
+	public function remove_item($item_id) {
3429 3429
 		$items   = $this->get_items();
3430 3430
 		$item_id = (int) $item_id;
3431 3431
 
3432
-		foreach ( $items as $index => $item ) {
3433
-			if ( (int) $item_id == $item->get_id() ) {
3434
-				unset( $items[ $index ] );
3435
-				$this->set_prop( 'items', $items );
3432
+		foreach ($items as $index => $item) {
3433
+			if ((int) $item_id == $item->get_id()) {
3434
+				unset($items[$index]);
3435
+				$this->set_prop('items', $items);
3436 3436
 
3437
-				if ( $item_id == $this->recurring_item ) {
3437
+				if ($item_id == $this->recurring_item) {
3438 3438
 					$this->recurring_item = null;
3439 3439
 				}
3440 3440
 }
@@ -3448,11 +3448,11 @@  discard block
 block discarded – undo
3448 3448
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3449 3449
 	 * @since 1.0.19
3450 3450
 	 */
3451
-    public function add_fee( $fee ) {
3451
+    public function add_fee($fee) {
3452 3452
 
3453 3453
 		$fees                 = $this->get_fees();
3454
-		$fees[ $fee['name'] ] = $fee;
3455
-		$this->set_prop( 'fees', $fees );
3454
+		$fees[$fee['name']] = $fee;
3455
+		$this->set_prop('fees', $fees);
3456 3456
 
3457 3457
     }
3458 3458
 
@@ -3461,9 +3461,9 @@  discard block
 block discarded – undo
3461 3461
 	 *
3462 3462
 	 * @since 1.0.19
3463 3463
 	 */
3464
-	public function get_fee( $fee ) {
3464
+	public function get_fee($fee) {
3465 3465
         $fees = $this->get_fees();
3466
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3466
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3467 3467
     }
3468 3468
 
3469 3469
     /**
@@ -3471,11 +3471,11 @@  discard block
 block discarded – undo
3471 3471
 	 *
3472 3472
 	 * @since 1.0.19
3473 3473
 	 */
3474
-	public function remove_fee( $fee ) {
3474
+	public function remove_fee($fee) {
3475 3475
         $fees = $this->get_fees();
3476
-        if ( isset( $fees[ $fee ] ) ) {
3477
-            unset( $fees[ $fee ] );
3478
-            $this->set_prop( 'fees', $fees );
3476
+        if (isset($fees[$fee])) {
3477
+            unset($fees[$fee]);
3478
+            $this->set_prop('fees', $fees);
3479 3479
         }
3480 3480
     }
3481 3481
 
@@ -3485,11 +3485,11 @@  discard block
 block discarded – undo
3485 3485
 	 * @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.
3486 3486
 	 * @since 1.0.19
3487 3487
 	 */
3488
-	public function add_discount( $discount ) {
3488
+	public function add_discount($discount) {
3489 3489
 
3490 3490
 		$discounts = $this->get_discounts();
3491
-		$discounts[ $discount['name'] ] = $discount;
3492
-		$this->set_prop( 'discounts', $discounts );
3491
+		$discounts[$discount['name']] = $discount;
3492
+		$this->set_prop('discounts', $discounts);
3493 3493
 
3494 3494
 	}
3495 3495
 
@@ -3499,15 +3499,15 @@  discard block
 block discarded – undo
3499 3499
 	 * @since 1.0.19
3500 3500
 	 * @return float
3501 3501
 	 */
3502
-	public function get_discount( $discount = false ) {
3502
+	public function get_discount($discount = false) {
3503 3503
 
3504 3504
 		// Backwards compatibilty.
3505
-		if ( empty( $discount ) ) {
3505
+		if (empty($discount)) {
3506 3506
 			return $this->get_total_discount();
3507 3507
 		}
3508 3508
 
3509 3509
         $discounts = $this->get_discounts();
3510
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3510
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3511 3511
     }
3512 3512
 
3513 3513
     /**
@@ -3515,15 +3515,15 @@  discard block
 block discarded – undo
3515 3515
 	 *
3516 3516
 	 * @since 1.0.19
3517 3517
 	 */
3518
-	public function remove_discount( $discount ) {
3518
+	public function remove_discount($discount) {
3519 3519
         $discounts = $this->get_discounts();
3520
-        if ( isset( $discounts[ $discount ] ) ) {
3521
-            unset( $discounts[ $discount ] );
3522
-            $this->set_prop( 'discounts', $discounts );
3520
+        if (isset($discounts[$discount])) {
3521
+            unset($discounts[$discount]);
3522
+            $this->set_prop('discounts', $discounts);
3523 3523
         }
3524 3524
 
3525
-		if ( 'discount_code' == $discount ) {
3526
-			foreach ( $this->get_items() as $item ) {
3525
+		if ('discount_code' == $discount) {
3526
+			foreach ($this->get_items() as $item) {
3527 3527
 				$item->item_discount           = 0;
3528 3528
 				$item->recurring_item_discount = 0;
3529 3529
 			}
@@ -3536,12 +3536,12 @@  discard block
 block discarded – undo
3536 3536
      *
3537 3537
      * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
3538 3538
      */
3539
-    public function add_tax( $tax ) {
3540
-        if ( $this->is_taxable() ) {
3539
+    public function add_tax($tax) {
3540
+        if ($this->is_taxable()) {
3541 3541
 
3542
-            $taxes                 = $this->get_taxes();
3543
-			$taxes[ $tax['name'] ] = $tax;
3544
-			$this->set_prop( 'taxes', $tax );
3542
+            $taxes = $this->get_taxes();
3543
+			$taxes[$tax['name']] = $tax;
3544
+			$this->set_prop('taxes', $tax);
3545 3545
 
3546 3546
         }
3547 3547
     }
@@ -3551,15 +3551,15 @@  discard block
 block discarded – undo
3551 3551
 	 *
3552 3552
 	 * @since 1.0.19
3553 3553
 	 */
3554
-	public function get_tax( $tax = null ) {
3554
+	public function get_tax($tax = null) {
3555 3555
 
3556 3556
 		// Backwards compatility.
3557
-		if ( empty( $tax ) ) {
3557
+		if (empty($tax)) {
3558 3558
 			return $this->get_total_tax();
3559 3559
 		}
3560 3560
 
3561 3561
         $taxes = $this->get_taxes();
3562
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3562
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3563 3563
     }
3564 3564
 
3565 3565
     /**
@@ -3567,11 +3567,11 @@  discard block
 block discarded – undo
3567 3567
 	 *
3568 3568
 	 * @since 1.0.19
3569 3569
 	 */
3570
-	public function remove_tax( $tax ) {
3570
+	public function remove_tax($tax) {
3571 3571
         $taxes = $this->get_taxes();
3572
-        if ( isset( $taxes[ $tax ] ) ) {
3573
-            unset( $taxes[ $tax ] );
3574
-            $this->set_prop( 'taxes', $taxes );
3572
+        if (isset($taxes[$tax])) {
3573
+            unset($taxes[$tax]);
3574
+            $this->set_prop('taxes', $taxes);
3575 3575
         }
3576 3576
     }
3577 3577
 
@@ -3582,22 +3582,22 @@  discard block
 block discarded – undo
3582 3582
 	 * @return float The recalculated subtotal
3583 3583
 	 */
3584 3584
 	public function recalculate_subtotal() {
3585
-        $items     = $this->get_items();
3585
+        $items = $this->get_items();
3586 3586
 		$subtotal  = 0;
3587 3587
 		$recurring = 0;
3588 3588
 
3589
-        foreach ( $items as $item ) {
3590
-			$subtotal  += $item->get_sub_total( 'edit' );
3591
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3589
+        foreach ($items as $item) {
3590
+			$subtotal  += $item->get_sub_total('edit');
3591
+			$recurring += $item->get_recurring_sub_total('edit');
3592 3592
         }
3593 3593
 
3594
-		if ( wpinv_prices_include_tax() ) {
3595
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3596
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3594
+		if (wpinv_prices_include_tax()) {
3595
+			$subtotal  = max(0, $subtotal - $this->totals['tax']['initial']);
3596
+			$recurring = max(0, $recurring - $this->totals['tax']['recurring']);
3597 3597
 		}
3598 3598
 
3599 3599
 		$current = $this->is_renewal() ? $recurring : $subtotal;
3600
-		$this->set_subtotal( $current );
3600
+		$this->set_subtotal($current);
3601 3601
 
3602 3602
 		$this->totals['subtotal'] = array(
3603 3603
 			'initial'   => $subtotal,
@@ -3618,14 +3618,14 @@  discard block
 block discarded – undo
3618 3618
 		$discount  = 0;
3619 3619
 		$recurring = 0;
3620 3620
 
3621
-        foreach ( $discounts as $data ) {
3622
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3623
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3621
+        foreach ($discounts as $data) {
3622
+			$discount  += wpinv_sanitize_amount($data['initial_discount']);
3623
+			$recurring += wpinv_sanitize_amount($data['recurring_discount']);
3624 3624
 		}
3625 3625
 
3626 3626
 		$current = $this->is_renewal() ? $recurring : $discount;
3627 3627
 
3628
-		$this->set_total_discount( $current );
3628
+		$this->set_total_discount($current);
3629 3629
 
3630 3630
 		$this->totals['discount'] = array(
3631 3631
 			'initial'   => $discount,
@@ -3646,13 +3646,13 @@  discard block
 block discarded – undo
3646 3646
 
3647 3647
 		// Maybe disable taxes.
3648 3648
 		$vat_number = $this->get_vat_number();
3649
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3649
+		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number);
3650 3650
 
3651
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3651
+		if (wpinv_is_base_country($this->get_country()) && 'vat_too' === wpinv_get_option('vat_same_country_rule', 'vat_too')) {
3652 3652
 			$skip_tax = false;
3653 3653
 		}
3654 3654
 
3655
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) {
3655
+		if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) {
3656 3656
 
3657 3657
 			$this->totals['tax'] = array(
3658 3658
 				'initial'   => 0,
@@ -3661,37 +3661,37 @@  discard block
 block discarded – undo
3661 3661
 
3662 3662
 			$this->tax_rate = 0;
3663 3663
 
3664
-			$this->set_taxes( array() );
3664
+			$this->set_taxes(array());
3665 3665
 			$current = 0;
3666 3666
 		} else {
3667 3667
 
3668 3668
 			$item_taxes = array();
3669 3669
 
3670
-			foreach ( $this->get_items() as $item ) {
3671
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3672
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3673
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3674
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3675
-				foreach ( $taxes as $name => $amount ) {
3676
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3677
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3678
-
3679
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3680
-						$item_taxes[ $name ] = $tax;
3670
+			foreach ($this->get_items() as $item) {
3671
+				$rates    = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state());
3672
+				$rates    = getpaid_filter_item_tax_rates($item, $rates);
3673
+				$taxes    = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates);
3674
+				$r_taxes  = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates);
3675
+				foreach ($taxes as $name => $amount) {
3676
+					$recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0;
3677
+					$tax       = getpaid_prepare_item_tax($item, $name, $amount, $recurring);
3678
+
3679
+					if (!isset($item_taxes[$name])) {
3680
+						$item_taxes[$name] = $tax;
3681 3681
 						continue;
3682 3682
 					}
3683 3683
 
3684
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3685
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3684
+					$item_taxes[$name]['initial_tax']   += $tax['initial_tax'];
3685
+					$item_taxes[$name]['recurring_tax'] += $tax['recurring_tax'];
3686 3686
 
3687 3687
 				}
3688 3688
 			}
3689 3689
 
3690
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3691
-			$this->set_taxes( $item_taxes );
3690
+			$item_taxes = array_replace($this->get_taxes(), $item_taxes);
3691
+			$this->set_taxes($item_taxes);
3692 3692
 
3693
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3694
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3693
+			$initial_tax   = array_sum(wp_list_pluck($item_taxes, 'initial_tax'));
3694
+			$recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax'));
3695 3695
 
3696 3696
 			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3697 3697
 
@@ -3702,7 +3702,7 @@  discard block
 block discarded – undo
3702 3702
 
3703 3703
 		}
3704 3704
 
3705
-		$this->set_total_tax( $current );
3705
+		$this->set_total_tax($current);
3706 3706
 
3707 3707
 		return $current;
3708 3708
 
@@ -3719,20 +3719,20 @@  discard block
 block discarded – undo
3719 3719
 		$fee       = 0;
3720 3720
 		$recurring = 0;
3721 3721
 
3722
-        foreach ( $fees as $data ) {
3723
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3724
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3722
+        foreach ($fees as $data) {
3723
+			$fee       += wpinv_sanitize_amount($data['initial_fee']);
3724
+			$recurring += wpinv_sanitize_amount($data['recurring_fee']);
3725 3725
 		}
3726 3726
 
3727 3727
 		$current = $this->is_renewal() ? $recurring : $fee;
3728
-		$this->set_total_fees( $current );
3728
+		$this->set_total_fees($current);
3729 3729
 
3730 3730
 		$this->totals['fee'] = array(
3731 3731
 			'initial'   => $fee,
3732 3732
 			'recurring' => $recurring,
3733 3733
 		);
3734 3734
 
3735
-        $this->set_total_fees( $fee );
3735
+        $this->set_total_fees($fee);
3736 3736
         return $current;
3737 3737
     }
3738 3738
 
@@ -3747,7 +3747,7 @@  discard block
 block discarded – undo
3747 3747
         $this->recalculate_total_discount();
3748 3748
 		$this->recalculate_total_tax();
3749 3749
 		$this->recalculate_subtotal();
3750
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3750
+		$this->set_total($this->get_total_tax('edit') + $this->get_total_fees('edit') + $this->get_subtotal('edit') - $this->get_total_discount('edit'));
3751 3751
 		return $this->get_total();
3752 3752
 	}
3753 3753
 
@@ -3756,7 +3756,7 @@  discard block
 block discarded – undo
3756 3756
 	 */
3757 3757
     public function recalculate_totals() {
3758 3758
         $this->recalculate_total();
3759
-        $this->save( true );
3759
+        $this->save(true);
3760 3760
         return $this;
3761 3761
     }
3762 3762
 
@@ -3774,8 +3774,8 @@  discard block
 block discarded – undo
3774 3774
 	 * @return int|false The new note's ID on success, false on failure.
3775 3775
      *
3776 3776
      */
3777
-    public function add_system_note( $note ) {
3778
-		return $this->add_note( $note, false, false, true );
3777
+    public function add_system_note($note) {
3778
+		return $this->add_note($note, false, false, true);
3779 3779
 	}
3780 3780
 
3781 3781
     /**
@@ -3785,10 +3785,10 @@  discard block
 block discarded – undo
3785 3785
 	 * @return int|false The new note's ID on success, false on failure.
3786 3786
      *
3787 3787
      */
3788
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3788
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3789 3789
 
3790 3790
         // Bail if no note specified or this invoice is not yet saved.
3791
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3791
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3792 3792
             return false;
3793 3793
         }
3794 3794
 
@@ -3796,23 +3796,23 @@  discard block
 block discarded – undo
3796 3796
 		$author_email = '[email protected]';
3797 3797
 
3798 3798
 		// If this is an admin comment or it has been added by the user.
3799
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3800
-			$user         = get_user_by( 'id', get_current_user_id() );
3799
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3800
+			$user = get_user_by('id', get_current_user_id());
3801 3801
             $author       = $user->display_name;
3802 3802
             $author_email = $user->user_email;
3803 3803
 		}
3804 3804
 
3805
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3805
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3806 3806
 
3807 3807
 	}
3808 3808
 
3809 3809
 	/**
3810 3810
      * Generates a unique key for the invoice.
3811 3811
      */
3812
-    public function generate_key( $string = '' ) {
3813
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3812
+    public function generate_key($string = '') {
3813
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3814 3814
         return strtolower(
3815
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3815
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3816 3816
         );
3817 3817
     }
3818 3818
 
@@ -3822,11 +3822,11 @@  discard block
 block discarded – undo
3822 3822
     public function generate_number() {
3823 3823
         $number = $this->get_id();
3824 3824
 
3825
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3826
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3825
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3826
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3827 3827
         }
3828 3828
 
3829
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3829
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3830 3830
 
3831 3831
 	}
3832 3832
 
@@ -3839,55 +3839,55 @@  discard block
 block discarded – undo
3839 3839
 		// Reset status transition variable.
3840 3840
 		$this->status_transition = false;
3841 3841
 
3842
-		if ( $status_transition ) {
3842
+		if ($status_transition) {
3843 3843
 			try {
3844 3844
 
3845 3845
 				// Fire a hook for the status change.
3846
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3846
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3847 3847
 
3848 3848
 				// @deprecated this is deprecated and will be removed in the future.
3849
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3849
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3850 3850
 
3851
-				if ( ! empty( $status_transition['from'] ) ) {
3851
+				if (!empty($status_transition['from'])) {
3852 3852
 
3853 3853
 					/* translators: 1: old invoice status 2: new invoice status */
3854
-					$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 ) );
3854
+					$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));
3855 3855
 
3856 3856
 					// Fire another hook.
3857
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3858
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3857
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3858
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3859 3859
 
3860 3860
 					// @deprecated this is deprecated and will be removed in the future.
3861
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3861
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3862 3862
 
3863 3863
 					// Note the transition occurred.
3864
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3864
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']);
3865 3865
 
3866 3866
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3867 3867
 					if (
3868
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3869
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3868
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3869
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3870 3870
 					) {
3871
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3871
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3872 3872
 					}
3873 3873
 
3874 3874
 					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3875 3875
 					if (
3876
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3877
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3876
+						in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3877
+						&& in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3878 3878
 					) {
3879
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3879
+						do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition);
3880 3880
 					}
3881 3881
 				} else {
3882 3882
 					/* translators: %s: new invoice status */
3883
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) );
3883
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this));
3884 3884
 
3885 3885
 					// Note the transition occurred.
3886
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3886
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3887 3887
 
3888 3888
 				}
3889
-			} catch ( Exception $e ) {
3890
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3889
+			} catch (Exception $e) {
3890
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3891 3891
 			}
3892 3892
 		}
3893 3893
 	}
@@ -3895,13 +3895,13 @@  discard block
 block discarded – undo
3895 3895
 	/**
3896 3896
 	 * Updates an invoice status.
3897 3897
 	 */
3898
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3898
+	public function update_status($new_status = false, $note = '', $manual = false) {
3899 3899
 
3900 3900
 		// Fires before updating a status.
3901
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3901
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3902 3902
 
3903 3903
 		// Update the status.
3904
-		$this->set_status( $new_status, $note, $manual );
3904
+		$this->set_status($new_status, $note, $manual);
3905 3905
 
3906 3906
 		// Save the order.
3907 3907
 		return $this->save();
@@ -3912,18 +3912,18 @@  discard block
 block discarded – undo
3912 3912
 	 * @deprecated
3913 3913
 	 */
3914 3914
 	public function refresh_item_ids() {
3915
-        $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3916
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3915
+        $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id')));
3916
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3917 3917
 	}
3918 3918
 
3919 3919
 	/**
3920 3920
 	 * @deprecated
3921 3921
 	 */
3922
-	public function update_items( $temp = false ) {
3922
+	public function update_items($temp = false) {
3923 3923
 
3924
-		$this->set_items( $this->get_items() );
3924
+		$this->set_items($this->get_items());
3925 3925
 
3926
-		if ( ! $temp ) {
3926
+		if (!$temp) {
3927 3927
 			$this->save();
3928 3928
 		}
3929 3929
 
@@ -3937,11 +3937,11 @@  discard block
 block discarded – undo
3937 3937
 
3938 3938
         $discount_code = $this->get_discount_code();
3939 3939
 
3940
-        if ( empty( $discount_code ) ) {
3940
+        if (empty($discount_code)) {
3941 3941
             return false;
3942 3942
         }
3943 3943
 
3944
-        $discount = wpinv_get_discount_obj( $discount_code );
3944
+        $discount = wpinv_get_discount_obj($discount_code);
3945 3945
 
3946 3946
         // Ensure it is active.
3947 3947
         return $discount->exists();
@@ -3952,7 +3952,7 @@  discard block
 block discarded – undo
3952 3952
 	 * Refunds an invoice.
3953 3953
 	 */
3954 3954
     public function refund() {
3955
-		$this->set_status( 'wpi-refunded' );
3955
+		$this->set_status('wpi-refunded');
3956 3956
         $this->save();
3957 3957
 	}
3958 3958
 
@@ -3961,53 +3961,53 @@  discard block
 block discarded – undo
3961 3961
 	 *
3962 3962
 	 * @param string $transaction_id
3963 3963
 	 */
3964
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3964
+    public function mark_paid($transaction_id = null, $note = '') {
3965 3965
 
3966 3966
 		// Set the transaction id.
3967
-		if ( empty( $transaction_id ) ) {
3968
-			$transaction_id = $this->generate_key( 'trans_' );
3967
+		if (empty($transaction_id)) {
3968
+			$transaction_id = $this->generate_key('trans_');
3969 3969
 		}
3970 3970
 
3971
-		if ( ! $this->get_transaction_id() ) {
3972
-			$this->set_transaction_id( $transaction_id );
3971
+		if (!$this->get_transaction_id()) {
3972
+			$this->set_transaction_id($transaction_id);
3973 3973
 		}
3974 3974
 
3975
-		if ( $this->is_paid() && 'wpi-processing' !== $this->get_status() ) {
3975
+		if ($this->is_paid() && 'wpi-processing' !== $this->get_status()) {
3976 3976
 			return $this->save();
3977 3977
 		}
3978 3978
 
3979 3979
 		// Set the completed date.
3980
-		$this->set_date_completed( current_time( 'mysql' ) );
3980
+		$this->set_date_completed(current_time('mysql'));
3981 3981
 
3982 3982
 		// Set the new status.
3983
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3984
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
3983
+		$gateway = sanitize_text_field($this->get_gateway_title());
3984
+		if ($this->is_renewal() || !$this->is_parent()) {
3985 3985
 
3986
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3987
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3986
+			$_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway);
3987
+			$_note = $_note . empty($note) ? '' : " ($note)";
3988 3988
 
3989
-			if ( 'none' == $this->get_gateway() ) {
3989
+			if ('none' == $this->get_gateway()) {
3990 3990
 				$_note = $note;
3991 3991
 			}
3992 3992
 
3993
-			$this->set_status( 'wpi-renewal', $_note );
3993
+			$this->set_status('wpi-renewal', $_note);
3994 3994
 
3995 3995
 		} else {
3996 3996
 
3997
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3998
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3997
+			$_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway);
3998
+			$_note = $_note . empty($note) ? '' : " ($note)";
3999 3999
 
4000
-			if ( 'none' == $this->get_gateway() ) {
4000
+			if ('none' == $this->get_gateway()) {
4001 4001
 				$_note = $note;
4002 4002
 			}
4003 4003
 
4004
-			$this->set_status( 'publish', $_note );
4004
+			$this->set_status('publish', $_note);
4005 4005
 
4006 4006
 		}
4007 4007
 
4008 4008
 		// Set checkout mode.
4009
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
4010
-		$this->set_mode( $mode );
4009
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
4010
+		$this->set_mode($mode);
4011 4011
 
4012 4012
 		// Save the invoice.
4013 4013
         $this->save();
@@ -4032,16 +4032,16 @@  discard block
 block discarded – undo
4032 4032
      * Clears the subscription's cache.
4033 4033
      */
4034 4034
     public function clear_cache() {
4035
-		if ( $this->get_key() ) {
4036
-			wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4035
+		if ($this->get_key()) {
4036
+			wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
4037 4037
 		}
4038 4038
 
4039
-		if ( $this->get_number() ) {
4040
-			wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4039
+		if ($this->get_number()) {
4040
+			wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
4041 4041
 		}
4042 4042
 
4043
-		if ( $this->get_transaction_id() ) {
4044
-			wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4043
+		if ($this->get_transaction_id()) {
4044
+			wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
4045 4045
 		}
4046 4046
 	}
4047 4047
 
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-data-store.php 1 patch
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -11,187 +11,187 @@
 block discarded – undo
11 11
  */
12 12
 class GetPaid_Data_Store {
13 13
 
14
-	/**
15
-	 * Contains an instance of the data store class that we are working with.
16
-	 *
17
-	 * @var GetPaid_Data_Store
18
-	 */
19
-	private $instance = null;
20
-
21
-	/**
22
-	 * Contains an array of default supported data stores.
23
-	 * Format of object name => class name.
24
-	 * Example: 'item' => 'GetPaid_Item_Data_Store'
25
-	 * You can also pass something like item-<type> for item stores and
26
-	 * that type will be used first when available, if a store is requested like
27
-	 * this and doesn't exist, then the store would fall back to 'item'.
28
-	 * Ran through `getpaid_data_stores`.
29
-	 *
30
-	 * @var array
31
-	 */
32
-	private $stores = array(
33
-		'item'         => 'GetPaid_Item_Data_Store',
34
-		'payment_form' => 'GetPaid_Payment_Form_Data_Store',
35
-		'discount'     => 'GetPaid_Discount_Data_Store',
36
-		'invoice'      => 'GetPaid_Invoice_Data_Store',
37
-		'subscription' => 'GetPaid_Subscription_Data_Store',
38
-		'customer'     => 'GetPaid_Customer_Data_Store',
39
-	);
40
-
41
-	/**
42
-	 * Contains the name of the current data store's class name.
43
-	 *
44
-	 * @var string
45
-	 */
46
-	private $current_class_name = '';
47
-
48
-	/**
49
-	 * The object type this store works with.
50
-	 *
51
-	 * @var string
52
-	 */
53
-	private $object_type = '';
54
-
55
-	/**
56
-	 * Tells GetPaid_Data_Store which object
57
-	 * store we want to work with.
58
-	 *
59
-	 * @param string $object_type Name of object.
60
-	 */
61
-	public function __construct( $object_type ) {
62
-		$this->object_type = $object_type;
63
-		$this->stores      = apply_filters( 'getpaid_data_stores', $this->stores );
64
-
65
-		// If this object type can't be found, check to see if we can load one
66
-		// level up (so if item-type isn't found, we try item).
67
-		if ( ! array_key_exists( $object_type, $this->stores ) ) {
68
-			$pieces      = explode( '-', $object_type );
69
-			$object_type = $pieces[0];
70
-		}
71
-
72
-		if ( array_key_exists( $object_type, $this->stores ) ) {
73
-			$store = apply_filters( 'getpaid_' . $object_type . '_data_store', $this->stores[ $object_type ] );
74
-			if ( is_object( $store ) ) {
75
-				$this->current_class_name = get_class( $store );
76
-				$this->instance           = $store;
77
-			} else {
78
-				if ( ! class_exists( $store ) ) {
79
-					throw new Exception( __( 'Data store class does not exist.', 'invoicing' ) );
80
-				}
81
-				$this->current_class_name = $store;
82
-				$this->instance           = new $store();
83
-			}
84
-		} else {
85
-			throw new Exception( __( 'Invalid data store.', 'invoicing' ) );
86
-		}
87
-	}
88
-
89
-	/**
90
-	 * Only store the object type to avoid serializing the data store instance.
91
-	 *
92
-	 * @return array
93
-	 */
94
-	public function __sleep() {
95
-		return array( 'object_type' );
96
-	}
97
-
98
-	/**
99
-	 * Re-run the constructor with the object type.
100
-	 *
101
-	 * @throws Exception When validation fails.
102
-	 */
103
-	public function __wakeup() {
104
-		$this->__construct( $this->object_type );
105
-	}
106
-
107
-	/**
108
-	 * Loads a data store.
109
-	 *
110
-	 * @param string $object_type Name of object.
111
-	 *
112
-	 * @since 1.0.19
113
-	 * @throws Exception When validation fails.
114
-	 * @return GetPaid_Data_Store
115
-	 */
116
-	public static function load( $object_type ) {
117
-		return new GetPaid_Data_Store( $object_type );
118
-	}
119
-
120
-	/**
121
-	 * Returns the class name of the current data store.
122
-	 *
123
-	 * @since 1.0.19
124
-	 * @return string
125
-	 */
126
-	public function get_current_class_name() {
127
-		return $this->current_class_name;
128
-	}
129
-
130
-	/**
131
-	 * Returns the object type of the current data store.
132
-	 *
133
-	 * @since 1.0.19
134
-	 * @return string
135
-	 */
136
-	public function get_object_type() {
137
-		return $this->object_type;
138
-	}
139
-
140
-	/**
141
-	 * Reads an object from the data store.
142
-	 *
143
-	 * @since 1.0.19
144
-	 * @param GetPaid_Data $data GetPaid data instance.
145
-	 */
146
-	public function read( &$data ) {
147
-		$this->instance->read( $data );
148
-	}
149
-
150
-	/**
151
-	 * Create an object in the data store.
152
-	 *
153
-	 * @since 1.0.19
154
-	 * @param GetPaid_Data $data GetPaid data instance.
155
-	 */
156
-	public function create( &$data ) {
157
-		$this->instance->create( $data );
158
-	}
159
-
160
-	/**
161
-	 * Update an object in the data store.
162
-	 *
163
-	 * @since 1.0.19
164
-	 * @param GetPaid_Data $data GetPaid data instance.
165
-	 */
166
-	public function update( &$data ) {
167
-		$this->instance->update( $data );
168
-	}
169
-
170
-	/**
171
-	 * Delete an object from the data store.
172
-	 *
173
-	 * @since 1.0.19
174
-	 * @param GetPaid_Data $data GetPaid data instance.
175
-	 * @param array   $args Array of args to pass to the delete method.
176
-	 */
177
-	public function delete( &$data, $args = array() ) {
178
-		$this->instance->delete( $data, $args );
179
-	}
180
-
181
-	/**
182
-	 * Data stores can define additional function. This passes
183
-	 * through to the instance if that function exists.
184
-	 *
185
-	 * @since 1.0.19
186
-	 * @param string $method     Method.
187
-	 * @return mixed
188
-	 */
189
-	public function __call( $method, $parameters ) {
190
-		if ( is_callable( array( $this->instance, $method ) ) ) {
191
-			$object     = array_shift( $parameters );
192
-			$parameters = array_merge( array( &$object ), $parameters );
193
-			return call_user_func_array( array( $this->instance, $method ), $parameters );
194
-		}
195
-	}
14
+    /**
15
+     * Contains an instance of the data store class that we are working with.
16
+     *
17
+     * @var GetPaid_Data_Store
18
+     */
19
+    private $instance = null;
20
+
21
+    /**
22
+     * Contains an array of default supported data stores.
23
+     * Format of object name => class name.
24
+     * Example: 'item' => 'GetPaid_Item_Data_Store'
25
+     * You can also pass something like item-<type> for item stores and
26
+     * that type will be used first when available, if a store is requested like
27
+     * this and doesn't exist, then the store would fall back to 'item'.
28
+     * Ran through `getpaid_data_stores`.
29
+     *
30
+     * @var array
31
+     */
32
+    private $stores = array(
33
+        'item'         => 'GetPaid_Item_Data_Store',
34
+        'payment_form' => 'GetPaid_Payment_Form_Data_Store',
35
+        'discount'     => 'GetPaid_Discount_Data_Store',
36
+        'invoice'      => 'GetPaid_Invoice_Data_Store',
37
+        'subscription' => 'GetPaid_Subscription_Data_Store',
38
+        'customer'     => 'GetPaid_Customer_Data_Store',
39
+    );
40
+
41
+    /**
42
+     * Contains the name of the current data store's class name.
43
+     *
44
+     * @var string
45
+     */
46
+    private $current_class_name = '';
47
+
48
+    /**
49
+     * The object type this store works with.
50
+     *
51
+     * @var string
52
+     */
53
+    private $object_type = '';
54
+
55
+    /**
56
+     * Tells GetPaid_Data_Store which object
57
+     * store we want to work with.
58
+     *
59
+     * @param string $object_type Name of object.
60
+     */
61
+    public function __construct( $object_type ) {
62
+        $this->object_type = $object_type;
63
+        $this->stores      = apply_filters( 'getpaid_data_stores', $this->stores );
64
+
65
+        // If this object type can't be found, check to see if we can load one
66
+        // level up (so if item-type isn't found, we try item).
67
+        if ( ! array_key_exists( $object_type, $this->stores ) ) {
68
+            $pieces      = explode( '-', $object_type );
69
+            $object_type = $pieces[0];
70
+        }
71
+
72
+        if ( array_key_exists( $object_type, $this->stores ) ) {
73
+            $store = apply_filters( 'getpaid_' . $object_type . '_data_store', $this->stores[ $object_type ] );
74
+            if ( is_object( $store ) ) {
75
+                $this->current_class_name = get_class( $store );
76
+                $this->instance           = $store;
77
+            } else {
78
+                if ( ! class_exists( $store ) ) {
79
+                    throw new Exception( __( 'Data store class does not exist.', 'invoicing' ) );
80
+                }
81
+                $this->current_class_name = $store;
82
+                $this->instance           = new $store();
83
+            }
84
+        } else {
85
+            throw new Exception( __( 'Invalid data store.', 'invoicing' ) );
86
+        }
87
+    }
88
+
89
+    /**
90
+     * Only store the object type to avoid serializing the data store instance.
91
+     *
92
+     * @return array
93
+     */
94
+    public function __sleep() {
95
+        return array( 'object_type' );
96
+    }
97
+
98
+    /**
99
+     * Re-run the constructor with the object type.
100
+     *
101
+     * @throws Exception When validation fails.
102
+     */
103
+    public function __wakeup() {
104
+        $this->__construct( $this->object_type );
105
+    }
106
+
107
+    /**
108
+     * Loads a data store.
109
+     *
110
+     * @param string $object_type Name of object.
111
+     *
112
+     * @since 1.0.19
113
+     * @throws Exception When validation fails.
114
+     * @return GetPaid_Data_Store
115
+     */
116
+    public static function load( $object_type ) {
117
+        return new GetPaid_Data_Store( $object_type );
118
+    }
119
+
120
+    /**
121
+     * Returns the class name of the current data store.
122
+     *
123
+     * @since 1.0.19
124
+     * @return string
125
+     */
126
+    public function get_current_class_name() {
127
+        return $this->current_class_name;
128
+    }
129
+
130
+    /**
131
+     * Returns the object type of the current data store.
132
+     *
133
+     * @since 1.0.19
134
+     * @return string
135
+     */
136
+    public function get_object_type() {
137
+        return $this->object_type;
138
+    }
139
+
140
+    /**
141
+     * Reads an object from the data store.
142
+     *
143
+     * @since 1.0.19
144
+     * @param GetPaid_Data $data GetPaid data instance.
145
+     */
146
+    public function read( &$data ) {
147
+        $this->instance->read( $data );
148
+    }
149
+
150
+    /**
151
+     * Create an object in the data store.
152
+     *
153
+     * @since 1.0.19
154
+     * @param GetPaid_Data $data GetPaid data instance.
155
+     */
156
+    public function create( &$data ) {
157
+        $this->instance->create( $data );
158
+    }
159
+
160
+    /**
161
+     * Update an object in the data store.
162
+     *
163
+     * @since 1.0.19
164
+     * @param GetPaid_Data $data GetPaid data instance.
165
+     */
166
+    public function update( &$data ) {
167
+        $this->instance->update( $data );
168
+    }
169
+
170
+    /**
171
+     * Delete an object from the data store.
172
+     *
173
+     * @since 1.0.19
174
+     * @param GetPaid_Data $data GetPaid data instance.
175
+     * @param array   $args Array of args to pass to the delete method.
176
+     */
177
+    public function delete( &$data, $args = array() ) {
178
+        $this->instance->delete( $data, $args );
179
+    }
180
+
181
+    /**
182
+     * Data stores can define additional function. This passes
183
+     * through to the instance if that function exists.
184
+     *
185
+     * @since 1.0.19
186
+     * @param string $method     Method.
187
+     * @return mixed
188
+     */
189
+    public function __call( $method, $parameters ) {
190
+        if ( is_callable( array( $this->instance, $method ) ) ) {
191
+            $object     = array_shift( $parameters );
192
+            $parameters = array_merge( array( &$object ), $parameters );
193
+            return call_user_func_array( array( $this->instance, $method ), $parameters );
194
+        }
195
+    }
196 196
 
197 197
 }
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-customer-data-store.php 2 patches
Indentation   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 if ( ! defined( 'ABSPATH' ) ) {
8
-	exit;
8
+    exit;
9 9
 }
10 10
 
11 11
 /**
@@ -15,196 +15,196 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class GetPaid_Customer_Data_Store {
17 17
 
18
-	/*
18
+    /*
19 19
 	|--------------------------------------------------------------------------
20 20
 	| CRUD Methods
21 21
 	|--------------------------------------------------------------------------
22 22
 	*/
23 23
 
24
-	/**
25
-	 * Method to create a new customer in the database.
26
-	 *
27
-	 * @param GetPaid_Customer $customer customer object.
28
-	 */
29
-	public function create( &$customer ) {
30
-		global $wpdb;
31
-
32
-		$values  = array();
33
-		$formats = array();
34
-
35
-		$fields = self::get_database_fields();
36
-		unset( $fields['id'] );
37
-
38
-		foreach ( $fields as $key => $format ) {
39
-			$values[ $key ] = $customer->get( $key, 'edit' );
40
-			$formats[]      = $format;
41
-		}
42
-
43
-		$result = $wpdb->insert( $wpdb->prefix . 'getpaid_customers', $values, $formats );
44
-
45
-		if ( $result ) {
46
-			$customer->set_id( $wpdb->insert_id );
47
-			$customer->apply_changes();
48
-			$customer->clear_cache();
49
-			do_action( 'getpaid_new_customer', $customer );
50
-			return true;
51
-		}
52
-
53
-		return false;
54
-	}
55
-
56
-	/**
57
-	 * Method to read a customer from the database.
58
-	 *
59
-	 * @param GetPaid_Customer $customer customer object.
60
-	 *
61
-	 */
62
-	public function read( &$customer ) {
63
-		global $wpdb;
64
-
65
-		$customer->set_defaults();
66
-
67
-		if ( ! $customer->get_id() ) {
68
-			$customer->last_error = 'Invalid customer.';
69
-			$customer->set_id( 0 );
70
-			return false;
71
-		}
72
-
73
-		// Maybe retrieve from the cache.
74
-		$raw_customer = wp_cache_get( $customer->get_id(), 'getpaid_customers' );
75
-
76
-		// If not found, retrieve from the db.
77
-		if ( false === $raw_customer ) {
78
-
79
-			$raw_customer = $wpdb->get_row(
80
-				$wpdb->prepare(
81
-					"SELECT * FROM {$wpdb->prefix}getpaid_customers WHERE id = %d",
82
-					$customer->get_id()
83
-				)
84
-			);
85
-
86
-			// Update the cache with our data
87
-			wp_cache_set( $customer->get_id(), $raw_customer, 'getpaid_customers' );
88
-
89
-		}
90
-
91
-		if ( ! $raw_customer ) {
92
-			$raw_customer->last_error = 'Invalid customer.';
93
-			return false;
94
-		}
95
-
96
-		// Loop through raw customer fields.
97
-		foreach ( (array) $raw_customer as $key => $value ) {
98
-			$customer->set( $key, $value );
99
-		}
100
-
101
-		$customer->set_object_read( true );
102
-		do_action( 'getpaid_read_customer', $customer );
103
-
104
-	}
105
-
106
-	/**
107
-	 * Method to update a customer in the database.
108
-	 *
109
-	 * @param GetPaid_Customer $customer Customer object.
110
-	 */
111
-	public function update( &$customer ) {
112
-		global $wpdb;
113
-
114
-		do_action( 'getpaid_before_update_customer', $customer, $customer->get_changes() );
115
-
116
-		$changes = $customer->get_changes();
117
-		$values  = array();
118
-		$format  = array();
119
-
120
-		foreach ( self::get_database_fields() as $key => $format ) {
121
-			if ( array_key_exists( $key, $changes ) ) {
122
-				$values[ $key ] = $customer->get( $key, 'edit' );
123
-				$formats[]      = $format;
124
-			}
125
-		}
126
-
127
-		if ( empty( $values ) ) {
128
-			return;
129
-		}
130
-
131
-		$wpdb->update(
132
-			$wpdb->prefix . 'getpaid_customers',
133
-			$values,
134
-			array(
135
-				'id' => $customer->get_id(),
136
-			),
137
-			$formats,
138
-			'%d'
139
-		);
140
-
141
-		// Apply the changes.
142
-		$customer->apply_changes();
143
-
144
-		// Delete cache.
145
-		$customer->clear_cache();
146
-
147
-		// Fire a hook.
148
-		do_action( 'getpaid_update_customer', $customer );
149
-
150
-	}
151
-
152
-	/**
153
-	 * Method to delete a customer from the database.
154
-	 *
155
-	 * @param GetPaid_Customer $customer
156
-	 */
157
-	public function delete( &$customer ) {
158
-		global $wpdb;
159
-
160
-		do_action( 'getpaid_before_delete_customer', $customer );
161
-
162
-		$wpdb->delete(
163
-			$wpdb->prefix . 'getpaid_customers',
164
-			array(
165
-				'id' => $customer->get_id(),
166
-			),
167
-			'%d'
168
-		);
169
-
170
-		// Delete cache.
171
-		$customer->clear_cache();
172
-
173
-		// Fire a hook.
174
-		do_action( 'getpaid_delete_customer', $customer );
175
-
176
-		$customer->set_id( 0 );
177
-	}
178
-
179
-	/*
24
+    /**
25
+     * Method to create a new customer in the database.
26
+     *
27
+     * @param GetPaid_Customer $customer customer object.
28
+     */
29
+    public function create( &$customer ) {
30
+        global $wpdb;
31
+
32
+        $values  = array();
33
+        $formats = array();
34
+
35
+        $fields = self::get_database_fields();
36
+        unset( $fields['id'] );
37
+
38
+        foreach ( $fields as $key => $format ) {
39
+            $values[ $key ] = $customer->get( $key, 'edit' );
40
+            $formats[]      = $format;
41
+        }
42
+
43
+        $result = $wpdb->insert( $wpdb->prefix . 'getpaid_customers', $values, $formats );
44
+
45
+        if ( $result ) {
46
+            $customer->set_id( $wpdb->insert_id );
47
+            $customer->apply_changes();
48
+            $customer->clear_cache();
49
+            do_action( 'getpaid_new_customer', $customer );
50
+            return true;
51
+        }
52
+
53
+        return false;
54
+    }
55
+
56
+    /**
57
+     * Method to read a customer from the database.
58
+     *
59
+     * @param GetPaid_Customer $customer customer object.
60
+     *
61
+     */
62
+    public function read( &$customer ) {
63
+        global $wpdb;
64
+
65
+        $customer->set_defaults();
66
+
67
+        if ( ! $customer->get_id() ) {
68
+            $customer->last_error = 'Invalid customer.';
69
+            $customer->set_id( 0 );
70
+            return false;
71
+        }
72
+
73
+        // Maybe retrieve from the cache.
74
+        $raw_customer = wp_cache_get( $customer->get_id(), 'getpaid_customers' );
75
+
76
+        // If not found, retrieve from the db.
77
+        if ( false === $raw_customer ) {
78
+
79
+            $raw_customer = $wpdb->get_row(
80
+                $wpdb->prepare(
81
+                    "SELECT * FROM {$wpdb->prefix}getpaid_customers WHERE id = %d",
82
+                    $customer->get_id()
83
+                )
84
+            );
85
+
86
+            // Update the cache with our data
87
+            wp_cache_set( $customer->get_id(), $raw_customer, 'getpaid_customers' );
88
+
89
+        }
90
+
91
+        if ( ! $raw_customer ) {
92
+            $raw_customer->last_error = 'Invalid customer.';
93
+            return false;
94
+        }
95
+
96
+        // Loop through raw customer fields.
97
+        foreach ( (array) $raw_customer as $key => $value ) {
98
+            $customer->set( $key, $value );
99
+        }
100
+
101
+        $customer->set_object_read( true );
102
+        do_action( 'getpaid_read_customer', $customer );
103
+
104
+    }
105
+
106
+    /**
107
+     * Method to update a customer in the database.
108
+     *
109
+     * @param GetPaid_Customer $customer Customer object.
110
+     */
111
+    public function update( &$customer ) {
112
+        global $wpdb;
113
+
114
+        do_action( 'getpaid_before_update_customer', $customer, $customer->get_changes() );
115
+
116
+        $changes = $customer->get_changes();
117
+        $values  = array();
118
+        $format  = array();
119
+
120
+        foreach ( self::get_database_fields() as $key => $format ) {
121
+            if ( array_key_exists( $key, $changes ) ) {
122
+                $values[ $key ] = $customer->get( $key, 'edit' );
123
+                $formats[]      = $format;
124
+            }
125
+        }
126
+
127
+        if ( empty( $values ) ) {
128
+            return;
129
+        }
130
+
131
+        $wpdb->update(
132
+            $wpdb->prefix . 'getpaid_customers',
133
+            $values,
134
+            array(
135
+                'id' => $customer->get_id(),
136
+            ),
137
+            $formats,
138
+            '%d'
139
+        );
140
+
141
+        // Apply the changes.
142
+        $customer->apply_changes();
143
+
144
+        // Delete cache.
145
+        $customer->clear_cache();
146
+
147
+        // Fire a hook.
148
+        do_action( 'getpaid_update_customer', $customer );
149
+
150
+    }
151
+
152
+    /**
153
+     * Method to delete a customer from the database.
154
+     *
155
+     * @param GetPaid_Customer $customer
156
+     */
157
+    public function delete( &$customer ) {
158
+        global $wpdb;
159
+
160
+        do_action( 'getpaid_before_delete_customer', $customer );
161
+
162
+        $wpdb->delete(
163
+            $wpdb->prefix . 'getpaid_customers',
164
+            array(
165
+                'id' => $customer->get_id(),
166
+            ),
167
+            '%d'
168
+        );
169
+
170
+        // Delete cache.
171
+        $customer->clear_cache();
172
+
173
+        // Fire a hook.
174
+        do_action( 'getpaid_delete_customer', $customer );
175
+
176
+        $customer->set_id( 0 );
177
+    }
178
+
179
+    /*
180 180
 	|--------------------------------------------------------------------------
181 181
 	| Additional Methods
182 182
 	|--------------------------------------------------------------------------
183 183
 	*/
184
-	public static function get_database_fields() {
185
-
186
-		$fields = array(
187
-			'id'             => '%d',
188
-			'user_id'        => '%d',
189
-			'email'          => '%s',
190
-			'email_cc'       => '%s',
191
-			'status'         => '%s',
192
-			'purchase_value' => '%f',
193
-			'purchase_count' => '%d',
194
-			'date_created'   => '%s',
195
-			'date_modified'  => '%s',
196
-			'uuid'           => '%s',
197
-		);
198
-
199
-		// Add address fields.
200
-		foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
201
-
202
-			// Skip id, user_id and email.
203
-			if ( ! in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) {
204
-				$fields[ $field ] = '%s';
205
-			}
206
-		}
207
-
208
-		return $fields;
209
-	}
184
+    public static function get_database_fields() {
185
+
186
+        $fields = array(
187
+            'id'             => '%d',
188
+            'user_id'        => '%d',
189
+            'email'          => '%s',
190
+            'email_cc'       => '%s',
191
+            'status'         => '%s',
192
+            'purchase_value' => '%f',
193
+            'purchase_count' => '%d',
194
+            'date_created'   => '%s',
195
+            'date_modified'  => '%s',
196
+            'uuid'           => '%s',
197
+        );
198
+
199
+        // Add address fields.
200
+        foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
201
+
202
+            // Skip id, user_id and email.
203
+            if ( ! in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) {
204
+                $fields[ $field ] = '%s';
205
+            }
206
+        }
207
+
208
+        return $fields;
209
+    }
210 210
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * GetPaid_Customer_Data_Store class file.
5 5
  *
6 6
  */
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if (!defined('ABSPATH')) {
8 8
 	exit;
9 9
 }
10 10
 
@@ -26,27 +26,27 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @param GetPaid_Customer $customer customer object.
28 28
 	 */
29
-	public function create( &$customer ) {
29
+	public function create(&$customer) {
30 30
 		global $wpdb;
31 31
 
32 32
 		$values  = array();
33 33
 		$formats = array();
34 34
 
35 35
 		$fields = self::get_database_fields();
36
-		unset( $fields['id'] );
36
+		unset($fields['id']);
37 37
 
38
-		foreach ( $fields as $key => $format ) {
39
-			$values[ $key ] = $customer->get( $key, 'edit' );
38
+		foreach ($fields as $key => $format) {
39
+			$values[$key] = $customer->get($key, 'edit');
40 40
 			$formats[]      = $format;
41 41
 		}
42 42
 
43
-		$result = $wpdb->insert( $wpdb->prefix . 'getpaid_customers', $values, $formats );
43
+		$result = $wpdb->insert($wpdb->prefix . 'getpaid_customers', $values, $formats);
44 44
 
45
-		if ( $result ) {
46
-			$customer->set_id( $wpdb->insert_id );
45
+		if ($result) {
46
+			$customer->set_id($wpdb->insert_id);
47 47
 			$customer->apply_changes();
48 48
 			$customer->clear_cache();
49
-			do_action( 'getpaid_new_customer', $customer );
49
+			do_action('getpaid_new_customer', $customer);
50 50
 			return true;
51 51
 		}
52 52
 
@@ -59,22 +59,22 @@  discard block
 block discarded – undo
59 59
 	 * @param GetPaid_Customer $customer customer object.
60 60
 	 *
61 61
 	 */
62
-	public function read( &$customer ) {
62
+	public function read(&$customer) {
63 63
 		global $wpdb;
64 64
 
65 65
 		$customer->set_defaults();
66 66
 
67
-		if ( ! $customer->get_id() ) {
67
+		if (!$customer->get_id()) {
68 68
 			$customer->last_error = 'Invalid customer.';
69
-			$customer->set_id( 0 );
69
+			$customer->set_id(0);
70 70
 			return false;
71 71
 		}
72 72
 
73 73
 		// Maybe retrieve from the cache.
74
-		$raw_customer = wp_cache_get( $customer->get_id(), 'getpaid_customers' );
74
+		$raw_customer = wp_cache_get($customer->get_id(), 'getpaid_customers');
75 75
 
76 76
 		// If not found, retrieve from the db.
77
-		if ( false === $raw_customer ) {
77
+		if (false === $raw_customer) {
78 78
 
79 79
 			$raw_customer = $wpdb->get_row(
80 80
 				$wpdb->prepare(
@@ -84,22 +84,22 @@  discard block
 block discarded – undo
84 84
 			);
85 85
 
86 86
 			// Update the cache with our data
87
-			wp_cache_set( $customer->get_id(), $raw_customer, 'getpaid_customers' );
87
+			wp_cache_set($customer->get_id(), $raw_customer, 'getpaid_customers');
88 88
 
89 89
 		}
90 90
 
91
-		if ( ! $raw_customer ) {
91
+		if (!$raw_customer) {
92 92
 			$raw_customer->last_error = 'Invalid customer.';
93 93
 			return false;
94 94
 		}
95 95
 
96 96
 		// Loop through raw customer fields.
97
-		foreach ( (array) $raw_customer as $key => $value ) {
98
-			$customer->set( $key, $value );
97
+		foreach ((array) $raw_customer as $key => $value) {
98
+			$customer->set($key, $value);
99 99
 		}
100 100
 
101
-		$customer->set_object_read( true );
102
-		do_action( 'getpaid_read_customer', $customer );
101
+		$customer->set_object_read(true);
102
+		do_action('getpaid_read_customer', $customer);
103 103
 
104 104
 	}
105 105
 
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @param GetPaid_Customer $customer Customer object.
110 110
 	 */
111
-	public function update( &$customer ) {
111
+	public function update(&$customer) {
112 112
 		global $wpdb;
113 113
 
114
-		do_action( 'getpaid_before_update_customer', $customer, $customer->get_changes() );
114
+		do_action('getpaid_before_update_customer', $customer, $customer->get_changes());
115 115
 
116 116
 		$changes = $customer->get_changes();
117 117
 		$values  = array();
118 118
 		$format  = array();
119 119
 
120
-		foreach ( self::get_database_fields() as $key => $format ) {
121
-			if ( array_key_exists( $key, $changes ) ) {
122
-				$values[ $key ] = $customer->get( $key, 'edit' );
120
+		foreach (self::get_database_fields() as $key => $format) {
121
+			if (array_key_exists($key, $changes)) {
122
+				$values[$key] = $customer->get($key, 'edit');
123 123
 				$formats[]      = $format;
124 124
 			}
125 125
 		}
126 126
 
127
-		if ( empty( $values ) ) {
127
+		if (empty($values)) {
128 128
 			return;
129 129
 		}
130 130
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		$customer->clear_cache();
146 146
 
147 147
 		// Fire a hook.
148
-		do_action( 'getpaid_update_customer', $customer );
148
+		do_action('getpaid_update_customer', $customer);
149 149
 
150 150
 	}
151 151
 
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
 	 *
155 155
 	 * @param GetPaid_Customer $customer
156 156
 	 */
157
-	public function delete( &$customer ) {
157
+	public function delete(&$customer) {
158 158
 		global $wpdb;
159 159
 
160
-		do_action( 'getpaid_before_delete_customer', $customer );
160
+		do_action('getpaid_before_delete_customer', $customer);
161 161
 
162 162
 		$wpdb->delete(
163 163
 			$wpdb->prefix . 'getpaid_customers',
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 		$customer->clear_cache();
172 172
 
173 173
 		// Fire a hook.
174
-		do_action( 'getpaid_delete_customer', $customer );
174
+		do_action('getpaid_delete_customer', $customer);
175 175
 
176
-		$customer->set_id( 0 );
176
+		$customer->set_id(0);
177 177
 	}
178 178
 
179 179
 	/*
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
 		);
198 198
 
199 199
 		// Add address fields.
200
-		foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
200
+		foreach (array_keys(getpaid_user_address_fields()) as $field) {
201 201
 
202 202
 			// Skip id, user_id and email.
203
-			if ( ! in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) {
204
-				$fields[ $field ] = '%s';
203
+			if (!in_array($field, array('id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid'), true)) {
204
+				$fields[$field] = '%s';
205 205
 			}
206 206
 		}
207 207
 
Please login to merge, or discard this patch.