Passed
Push — master ( 9f060d...75dadc )
by Brian
04:41
created
includes/wpinv-address-functions.php 1 patch
Spacing   +128 added lines, -128 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' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 
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
 /**
@@ -24,59 +24,59 @@  discard block
 block discarded – undo
24 24
  * @param string $country The country code to sanitize
25 25
  * @return array
26 26
  */
27
-function wpinv_sanitize_country( $country ) {
27
+function wpinv_sanitize_country($country) {
28 28
 
29 29
 	// Enure the country is specified
30
-    if ( empty( $country ) ) {
30
+    if (empty($country)) {
31 31
         $country = wpinv_get_default_country();
32 32
     }
33
-    return trim( wpinv_utf8_strtoupper( $country ) );
33
+    return trim(wpinv_utf8_strtoupper($country));
34 34
 
35 35
 }
36 36
 
37
-function wpinv_is_base_country( $country ) {
37
+function wpinv_is_base_country($country) {
38 38
     $base_country = wpinv_get_default_country();
39 39
     
40
-    if ( $base_country === 'UK' ) {
40
+    if ($base_country === 'UK') {
41 41
         $base_country = 'GB';
42 42
     }
43
-    if ( $country == 'UK' ) {
43
+    if ($country == 'UK') {
44 44
         $country = 'GB';
45 45
     }
46 46
 
47
-    return ( $country && $country === $base_country ) ? true : false;
47
+    return ($country && $country === $base_country) ? true : false;
48 48
 }
49 49
 
50
-function wpinv_country_name( $country_code = '' ) { 
50
+function wpinv_country_name($country_code = '') { 
51 51
     $countries = wpinv_get_country_list();
52 52
     $country_code = $country_code == 'UK' ? 'GB' : $country_code;
53
-    $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code;
53
+    $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code;
54 54
 
55
-    return apply_filters( 'wpinv_country_name', $country, $country_code );
55
+    return apply_filters('wpinv_country_name', $country, $country_code);
56 56
 }
57 57
 
58 58
 function wpinv_get_default_state() {
59
-	$state = wpinv_get_option( 'default_state', '' );
59
+	$state = wpinv_get_option('default_state', '');
60 60
 
61
-	return apply_filters( 'wpinv_default_state', $state );
61
+	return apply_filters('wpinv_default_state', $state);
62 62
 }
63 63
 
64
-function wpinv_state_name( $state_code = '', $country_code = '' ) {
64
+function wpinv_state_name($state_code = '', $country_code = '') {
65 65
     $state = $state_code;
66 66
     
67
-    if ( !empty( $country_code ) ) {
68
-        $states = wpinv_get_country_states( $country_code );
67
+    if (!empty($country_code)) {
68
+        $states = wpinv_get_country_states($country_code);
69 69
         
70
-        $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state;
70
+        $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state;
71 71
     }
72 72
 
73
-    return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code );
73
+    return apply_filters('wpinv_state_name', $state, $state_code, $country_code);
74 74
 }
75 75
 
76 76
 function wpinv_store_address() {
77
-    $address = wpinv_get_option( 'store_address', '' );
77
+    $address = wpinv_get_option('store_address', '');
78 78
 
79
-    return apply_filters( 'wpinv_store_address', $address );
79
+    return apply_filters('wpinv_store_address', $address);
80 80
 }
81 81
 
82 82
 /**
@@ -84,24 +84,24 @@  discard block
 block discarded – undo
84 84
  *
85 85
  * @param WPInv_Invoice $invoice
86 86
  */
87
-function getpaid_maybe_add_default_address( &$invoice ) {
87
+function getpaid_maybe_add_default_address(&$invoice) {
88 88
 
89 89
     $user_id = $invoice->get_user_id();
90 90
 
91 91
     // Abort if the invoice belongs to no one.
92
-    if ( empty( $user_id ) ) {
92
+    if (empty($user_id)) {
93 93
         return;
94 94
     }
95 95
 
96 96
     // Fill in defaults whenever necessary.
97
-    foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) {
97
+    foreach (wpinv_get_user_address($user_id) as $key => $value) {
98 98
 
99
-        if ( is_callable( $invoice, "get_$key" ) ) {
100
-            $current = call_user_func( array( $invoice, "get_$key" ) );
99
+        if (is_callable($invoice, "get_$key")) {
100
+            $current = call_user_func(array($invoice, "get_$key"));
101 101
 
102
-            if ( empty( $current ) ) {
102
+            if (empty($current)) {
103 103
                 $method = "set_$key";
104
-                $invoice->$method( $value );
104
+                $invoice->$method($value);
105 105
             }
106 106
 
107 107
         }
@@ -140,24 +140,24 @@  discard block
 block discarded – undo
140 140
  *
141 141
  * @param WPInv_Invoice $invoice
142 142
  */
143
-function getpaid_save_invoice_user_address( $invoice ) {
143
+function getpaid_save_invoice_user_address($invoice) {
144 144
 
145 145
     // Retrieve the invoice.
146
-    $invoice = wpinv_get_invoice( $invoice );
146
+    $invoice = wpinv_get_invoice($invoice);
147 147
 
148 148
     // Abort if it does not exist.
149
-    if ( empty( $invoice ) ) {
149
+    if (empty($invoice)) {
150 150
         return;
151 151
     }
152 152
 
153
-    foreach ( getpaid_user_address_fields() as $field ) {
153
+    foreach (getpaid_user_address_fields() as $field) {
154 154
 
155
-        if ( is_callable( array( $invoice, "get_$field" ) ) ) {
156
-            $value = call_user_func( array( $invoice, "get_$field" ) );
155
+        if (is_callable(array($invoice, "get_$field"))) {
156
+            $value = call_user_func(array($invoice, "get_$field"));
157 157
 
158 158
             // Only save if it is not empty.
159
-            if ( ! empty( $value ) ) {
160
-                update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value );
159
+            if (!empty($value)) {
160
+                update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value);
161 161
             }
162 162
 
163 163
         }
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
     }
166 166
 
167 167
 }
168
-add_action( 'getpaid_new_invoice', 'getpaid_save_invoice_user_address' );
169
-add_action( 'getpaid_update_invoice', 'getpaid_save_invoice_user_address' );
168
+add_action('getpaid_new_invoice', 'getpaid_save_invoice_user_address');
169
+add_action('getpaid_update_invoice', 'getpaid_save_invoice_user_address');
170 170
 
171 171
 /**
172 172
  * Retrieves a saved user address.
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
  * @param bool $with_default Whether or not we should use the default country and state.
176 176
  * @return array
177 177
  */
178
-function wpinv_get_user_address( $user_id = 0, $with_default = true ) {
178
+function wpinv_get_user_address($user_id = 0, $with_default = true) {
179 179
 
180 180
     // Prepare the user id.
181
-    $user_id   = empty( $user_id ) ? get_current_user_id() : $user_id;
182
-    $user_info = get_userdata( $user_id );
181
+    $user_id   = empty($user_id) ? get_current_user_id() : $user_id;
182
+    $user_info = get_userdata($user_id);
183 183
 
184 184
     // Abort if non exists.
185
-    if ( empty( $user_info ) ) {
185
+    if (empty($user_info)) {
186 186
         return array();
187 187
     }
188 188
 
@@ -192,27 +192,27 @@  discard block
 block discarded – undo
192 192
         'email'   => $user_info->user_email,
193 193
     );
194 194
 
195
-    foreach ( getpaid_user_address_fields() as $field ) {
196
-        $address[$field] = getpaid_get_user_address_field( $user_id, $field );
195
+    foreach (getpaid_user_address_fields() as $field) {
196
+        $address[$field] = getpaid_get_user_address_field($user_id, $field);
197 197
     }
198 198
 
199
-    if ( ! $with_default ) {
199
+    if (!$with_default) {
200 200
         return $address;
201 201
     }
202 202
 
203
-    if ( isset( $address['first_name'] ) && empty( $address['first_name'] ) ) {
203
+    if (isset($address['first_name']) && empty($address['first_name'])) {
204 204
         $address['first_name'] = $user_info->first_name;
205 205
     }
206 206
 
207
-    if ( isset( $address['last_name'] ) && empty( $address['last_name'] ) ) {
207
+    if (isset($address['last_name']) && empty($address['last_name'])) {
208 208
         $address['last_name'] = $user_info->last_name;
209 209
     }
210 210
 
211
-    if ( isset( $address['state'] ) && empty( $address['state'] ) ) {
211
+    if (isset($address['state']) && empty($address['state'])) {
212 212
         $address['state'] = wpinv_get_default_state();
213 213
     }
214 214
 
215
-    if ( isset( $address['country'] ) && empty( $address['country'] ) ) {
215
+    if (isset($address['country']) && empty($address['country'])) {
216 216
         $address['country'] = wpinv_get_default_country();
217 217
     }
218 218
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
  * @param string $field The field to use.
227 227
  * @return string|null
228 228
  */
229
-function getpaid_get_user_address_field( $user_id, $field ) {
229
+function getpaid_get_user_address_field($user_id, $field) {
230 230
 
231 231
     $prefixes = array(
232 232
         '_wpinv_',
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
         ''
235 235
     );
236 236
 
237
-    foreach ( $prefixes as $prefix ) {
237
+    foreach ($prefixes as $prefix) {
238 238
 
239 239
         // Meta table.
240
-        $value = get_user_meta( $user_id, $prefix . $field, true );
240
+        $value = get_user_meta($user_id, $prefix . $field, true);
241 241
         
242 242
         // UWP table.
243
-        $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value;
243
+        $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value;
244 244
 
245
-        if ( ! empty( $value ) ) {
245
+        if (!empty($value)) {
246 246
             return $value;
247 247
         }
248 248
 
@@ -259,16 +259,16 @@  discard block
 block discarded – undo
259 259
  * @param string $return What to return.
260 260
  * @return array
261 261
  */
262
-function wpinv_get_continents( $return = 'all' ) {
262
+function wpinv_get_continents($return = 'all') {
263 263
 
264
-    $continents = wpinv_get_data( 'continents' );
264
+    $continents = wpinv_get_data('continents');
265 265
 
266
-    switch( $return ) {
266
+    switch ($return) {
267 267
         case 'name' :
268
-            return wp_list_pluck( $continents, 'name' );
268
+            return wp_list_pluck($continents, 'name');
269 269
             break;
270 270
         case 'countries' :
271
-            return wp_list_pluck( $continents, 'countries' );
271
+            return wp_list_pluck($continents, 'countries');
272 272
             break;
273 273
         default :
274 274
             return $continents;
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
  * @param string $country Country code. If no code is specified, defaults to the default country.
285 285
  * @return string
286 286
  */
287
-function wpinv_get_continent_code_for_country( $country = false ) {
287
+function wpinv_get_continent_code_for_country($country = false) {
288 288
 
289
-    $country = wpinv_sanitize_country( $country );
289
+    $country = wpinv_sanitize_country($country);
290 290
     
291
-	foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
292
-		if ( false !== array_search( $country, $countries, true ) ) {
291
+	foreach (wpinv_get_continents('countries') as $continent_code => $countries) {
292
+		if (false !== array_search($country, $countries, true)) {
293 293
 			return $continent_code;
294 294
 		}
295 295
 	}
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
  * @param string $country Country code. If no code is specified, defaults to the default country.
306 306
  * @return array
307 307
  */
308
-function wpinv_get_country_calling_code( $country = null) {
308
+function wpinv_get_country_calling_code($country = null) {
309 309
 
310
-    $country = wpinv_sanitize_country( $country );
311
-    $codes   = wpinv_get_data( 'phone-codes' );
312
-    $code    = isset( $codes[ $country ] ) ? $codes[ $country ] : '';
310
+    $country = wpinv_sanitize_country($country);
311
+    $codes   = wpinv_get_data('phone-codes');
312
+    $code    = isset($codes[$country]) ? $codes[$country] : '';
313 313
 
314
-    if ( is_array( $code ) ) {
314
+    if (is_array($code)) {
315 315
         return $code[0];
316 316
     }
317 317
     return $code;
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
  * @param bool $first_empty Whether or not the first item in the list should be empty
325 325
  * @return array
326 326
  */
327
-function wpinv_get_country_list( $first_empty = false ) {
328
-    return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty );
327
+function wpinv_get_country_list($first_empty = false) {
328
+    return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty);
329 329
 }
330 330
 
331 331
 /**
@@ -335,22 +335,22 @@  discard block
 block discarded – undo
335 335
  * @param bool $first_empty Whether or not the first item in the list should be empty
336 336
  * @return array
337 337
  */
338
-function wpinv_get_country_states( $country = null, $first_empty = false ) {
338
+function wpinv_get_country_states($country = null, $first_empty = false) {
339 339
     
340 340
     // Prepare the country.
341
-    $country = wpinv_sanitize_country( $country );
341
+    $country = wpinv_sanitize_country($country);
342 342
 
343 343
     // Fetch all states.
344
-    $all_states = wpinv_get_data( 'states' );
344
+    $all_states = wpinv_get_data('states');
345 345
 
346 346
     // Fetch the specified country's states.
347
-    $states     = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array() ;
348
-    $states     = apply_filters( "wpinv_{$country}_states", $states );
349
-    $states     = apply_filters( 'wpinv_country_states', $states, $country );
347
+    $states     = isset($all_states[$country]) ? $all_states[$country] : array();
348
+    $states     = apply_filters("wpinv_{$country}_states", $states);
349
+    $states     = apply_filters('wpinv_country_states', $states, $country);
350 350
 
351
-    asort( $states );
351
+    asort($states);
352 352
      
353
-    return wpinv_maybe_add_empty_option( $states, $first_empty );
353
+    return wpinv_maybe_add_empty_option($states, $first_empty);
354 354
 }
355 355
 
356 356
 /**
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
  * @return array
361 361
  */
362 362
 function wpinv_get_us_states_list() {
363
-    return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) );
363
+    return apply_filters('wpinv_usa_states', wpinv_get_country_states('US'));
364 364
 }
365 365
 
366 366
 /**
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
  * @return array
371 371
  */
372 372
 function wpinv_get_canada_states_list() {
373
-    return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) );
373
+    return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA'));
374 374
 }
375 375
 
376 376
 /**
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
  * @return array
381 381
  */
382 382
 function wpinv_get_australia_states_list() {
383
-    return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) );
383
+    return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU'));
384 384
 }
385 385
 
386 386
 /**
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
  * @return array
391 391
  */
392 392
 function wpinv_get_bangladesh_states_list() {
393
-    return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) );
393
+    return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD'));
394 394
 }
395 395
 
396 396
 /**
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
  * @return array
401 401
  */
402 402
 function wpinv_get_brazil_states_list() {
403
-    return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) );
403
+    return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR'));
404 404
 }
405 405
 
406 406
 /**
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
  * @return array
411 411
  */
412 412
 function wpinv_get_bulgaria_states_list() {
413
-    return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) );
413
+    return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG'));
414 414
 }
415 415
 
416 416
 /**
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
  * @return array
421 421
  */
422 422
 function wpinv_get_hong_kong_states_list() {
423
-    return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) );
423
+    return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK'));
424 424
 }
425 425
 
426 426
 /**
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
  * @return array
431 431
  */
432 432
 function wpinv_get_hungary_states_list() {
433
-    return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) );
433
+    return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU'));
434 434
 }
435 435
 
436 436
 /**
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
  * @return array
441 441
  */
442 442
 function wpinv_get_japan_states_list() {
443
-    return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) );
443
+    return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP'));
444 444
 }
445 445
 
446 446
 /**
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
  * @return array
451 451
  */
452 452
 function wpinv_get_china_states_list() {
453
-    return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) );
453
+    return apply_filters('wpinv_china_states', wpinv_get_country_states('CN'));
454 454
 }
455 455
 
456 456
 /**
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
  * @return array
461 461
  */
462 462
 function wpinv_get_new_zealand_states_list() {
463
-    return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) );
463
+    return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ'));
464 464
 }
465 465
 
466 466
 /**
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
  * @return array
471 471
  */
472 472
 function wpinv_get_peru_states_list() {
473
-    return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) );
473
+    return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE'));
474 474
 }
475 475
 
476 476
 /**
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
  * @return array
481 481
  */
482 482
 function wpinv_get_indonesia_states_list() {
483
-    return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) );
483
+    return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID'));
484 484
 }
485 485
 
486 486
 /**
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
  * @return array
491 491
  */
492 492
 function wpinv_get_india_states_list() {
493
-    return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) );
493
+    return apply_filters('wpinv_india_states', wpinv_get_country_states('IN'));
494 494
 }
495 495
 
496 496
 /**
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
  * @return array
501 501
  */
502 502
 function wpinv_get_iran_states_list() {
503
-    return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) );
503
+    return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR'));
504 504
 }
505 505
 
506 506
 /**
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
  * @return array
511 511
  */
512 512
 function wpinv_get_italy_states_list() {
513
-    return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) );
513
+    return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT'));
514 514
 }
515 515
 
516 516
 /**
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
  * @return array
521 521
  */
522 522
 function wpinv_get_malaysia_states_list() {
523
-    return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) );
523
+    return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY'));
524 524
 }
525 525
 
526 526
 /**
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
  * @return array
531 531
  */
532 532
 function wpinv_get_mexico_states_list() {
533
-    return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) );
533
+    return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX'));
534 534
 }
535 535
 
536 536
 /**
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
  * @return array
541 541
  */
542 542
 function wpinv_get_nepal_states_list() {
543
-    return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) );
543
+    return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP'));
544 544
 }
545 545
 
546 546
 /**
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
  * @return array
551 551
  */
552 552
 function wpinv_get_south_africa_states_list() {
553
-    return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) );
553
+    return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA'));
554 554
 }
555 555
 
556 556
 /**
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
  * @return array
561 561
  */
562 562
 function wpinv_get_thailand_states_list() {
563
-    return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) );
563
+    return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH'));
564 564
 }
565 565
 
566 566
 /**
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
  * @return array
571 571
  */
572 572
 function wpinv_get_turkey_states_list() {
573
-    return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) );
573
+    return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR'));
574 574
 }
575 575
 
576 576
 /**
@@ -580,28 +580,28 @@  discard block
 block discarded – undo
580 580
  * @return array
581 581
  */
582 582
 function wpinv_get_spain_states_list() {
583
-    return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) );
583
+    return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES'));
584 584
 }
585 585
 
586 586
 function wpinv_get_states_field() {
587
-	if( empty( $_POST['country'] ) ) {
587
+	if (empty($_POST['country'])) {
588 588
 		$_POST['country'] = wpinv_get_default_country();
589 589
 	}
590
-	$states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
590
+	$states = wpinv_get_country_states(sanitize_text_field($_POST['country']));
591 591
 
592
-	if( !empty( $states ) ) {
593
-		$sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
592
+	if (!empty($states)) {
593
+		$sanitized_field_name = sanitize_text_field($_POST['field_name']);
594 594
         
595 595
         $args = array(
596 596
 			'name'    => $sanitized_field_name,
597 597
 			'id'      => $sanitized_field_name,
598 598
 			'class'   => $sanitized_field_name . 'custom-select wpinv-select wpi_select2',
599
-			'options' => array_merge( array( '' => '' ), $states ),
599
+			'options' => array_merge(array('' => ''), $states),
600 600
 			'show_option_all'  => false,
601 601
 			'show_option_none' => false
602 602
 		);
603 603
 
604
-		$response = wpinv_html_select( $args );
604
+		$response = wpinv_html_select($args);
605 605
 
606 606
 	} else {
607 607
 		$response = 'nostates';
@@ -610,10 +610,10 @@  discard block
 block discarded – undo
610 610
 	return $response;
611 611
 }
612 612
 
613
-function wpinv_default_billing_country( $country = '', $user_id = 0 ) {
614
-    $country = !empty( $country ) ? $country : wpinv_get_default_country();
613
+function wpinv_default_billing_country($country = '', $user_id = 0) {
614
+    $country = !empty($country) ? $country : wpinv_get_default_country();
615 615
     
616
-    return apply_filters( 'wpinv_default_billing_country', $country, $user_id );
616
+    return apply_filters('wpinv_default_billing_country', $country, $user_id);
617 617
 }
618 618
 
619 619
 /**
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
  */
626 626
 function wpinv_get_address_formats() {
627 627
 
628
-		return apply_filters( 'wpinv_localisation_address_formats',
628
+		return apply_filters('wpinv_localisation_address_formats',
629 629
 			array(
630 630
 				'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
631 631
 				'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
@@ -674,9 +674,9 @@  discard block
 block discarded – undo
674 674
  * @see `wpinv_get_invoice_address_replacements`
675 675
  * @return string
676 676
  */
677
-function wpinv_get_full_address_format( $country = false) {
677
+function wpinv_get_full_address_format($country = false) {
678 678
 
679
-    if( empty( $country ) ) {
679
+    if (empty($country)) {
680 680
         $country = wpinv_get_default_country();
681 681
     }
682 682
 
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 	$formats = wpinv_get_address_formats();
685 685
 
686 686
 	// Get format for the specified country.
687
-	$format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
687
+	$format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default'];
688 688
     
689 689
     /**
690 690
 	 * Filters the address format to use on Invoices.
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 	 * @param string $format  The address format to use.
697 697
      * @param string $country The country who's address format is being retrieved.
698 698
 	 */
699
-    return apply_filters( 'wpinv_get_full_address_format', $format, $country );
699
+    return apply_filters('wpinv_get_full_address_format', $format, $country);
700 700
 }
701 701
 
702 702
 /**
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
  * @param array $billing_details customer's billing details
708 708
  * @return array
709 709
  */
710
-function wpinv_get_invoice_address_replacements( $billing_details ) {
710
+function wpinv_get_invoice_address_replacements($billing_details) {
711 711
 
712 712
     $default_args = array(
713 713
         'address'           => '',
@@ -720,22 +720,22 @@  discard block
 block discarded – undo
720 720
 		'company'           => '',
721 721
     );
722 722
 
723
-    $args    = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' );
723
+    $args    = map_deep(wp_parse_args($billing_details, $default_args), 'trim');
724 724
     $state   = $args['state'];
725 725
     $country = $args['country'];
726 726
 
727 727
     // Handle full country name.
728
-    $full_country = empty( $country ) ? $country : wpinv_country_name( $country );
728
+    $full_country = empty($country) ? $country : wpinv_country_name($country);
729 729
 
730 730
     // Handle full state name.
731
-    $full_state   = ( $country && $state ) ?  wpinv_state_name( $state, $country ) : $state;
731
+    $full_state   = ($country && $state) ?  wpinv_state_name($state, $country) : $state;
732 732
 
733 733
     $args['postcode']    = $args['zip'];
734 734
     $args['name']        = $args['first_name'] . ' ' . $args['last_name'];
735 735
     $args['state']       = $full_state;
736 736
     $args['state_code']  = $state;
737 737
     $args['country']     = $full_country;
738
-    $args['country_code']= $country;
738
+    $args['country_code'] = $country;
739 739
 
740 740
     /**
741 741
 	 * Filters the address format replacements to use on Invoices.
@@ -746,14 +746,14 @@  discard block
 block discarded – undo
746 746
 	 * @param array $replacements  The address replacements to use.
747 747
      * @param array $billing_details  The billing details to use.
748 748
 	 */
749
-    $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details );
749
+    $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details);
750 750
 
751 751
     $return = array();
752 752
 
753
-    foreach( $replacements as $key => $value ) {
754
-        $value  = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : '';
753
+    foreach ($replacements as $key => $value) {
754
+        $value = is_scalar($value) ? trim(sanitize_text_field($value)) : '';
755 755
         $return['{{' . $key . '}}'] = $value;
756
-        $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper( $value );
756
+        $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value);
757 757
     }
758 758
 
759 759
     return $return;
@@ -767,6 +767,6 @@  discard block
 block discarded – undo
767 767
  * @since 1.0.14
768 768
  * @return string
769 769
  */
770
-function wpinv_trim_formatted_address_line( $line ) {
771
-	return trim( $line, ', ' );
770
+function wpinv_trim_formatted_address_line($line) {
771
+	return trim($line, ', ');
772 772
 }
773 773
\ No newline at end of file
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-data.php 1 patch
Spacing   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  *
9 9
  */
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if (!defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @param int|object|array|string $read ID to load from the DB (optional) or already queried data.
119 119
 	 */
120
-	public function __construct( $read = 0 ) {
121
-		$this->data         = array_merge( $this->data, $this->extra_data );
120
+	public function __construct($read = 0) {
121
+		$this->data         = array_merge($this->data, $this->extra_data);
122 122
 		$this->default_data = $this->data;
123 123
 	}
124 124
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @return array
129 129
 	 */
130 130
 	public function __sleep() {
131
-		return array( 'id' );
131
+		return array('id');
132 132
 	}
133 133
 
134 134
 	/**
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 	 * If the object no longer exists, remove the ID.
138 138
 	 */
139 139
 	public function __wakeup() {
140
-		$this->__construct( absint( $this->id ) );
140
+		$this->__construct(absint($this->id));
141 141
 
142
-		if ( ! empty( $this->last_error ) ) {
143
-			$this->set_id( 0 );
142
+		if (!empty($this->last_error)) {
143
+			$this->set_id(0);
144 144
 		}
145 145
 
146 146
 	}
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function __clone() {
154 154
 		$this->maybe_read_meta_data();
155
-		if ( ! empty( $this->meta_data ) ) {
156
-			foreach ( $this->meta_data as $array_key => $meta ) {
157
-				$this->meta_data[ $array_key ] = clone $meta;
158
-				if ( ! empty( $meta->id ) ) {
159
-					$this->meta_data[ $array_key ]->id = null;
155
+		if (!empty($this->meta_data)) {
156
+			foreach ($this->meta_data as $array_key => $meta) {
157
+				$this->meta_data[$array_key] = clone $meta;
158
+				if (!empty($meta->id)) {
159
+					$this->meta_data[$array_key]->id = null;
160 160
 				}
161 161
 			}
162 162
 		}
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $context View or edit context.
200 200
 	 * @return string
201 201
 	 */
202
-	public function get_status( $context = 'view' ) {
203
-		return $this->get_prop( 'status', $context );
202
+	public function get_status($context = 'view') {
203
+		return $this->get_prop('status', $context);
204 204
     }
205 205
 
206 206
 	/**
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
 	 * @param  bool $force_delete Should the data be deleted permanently.
211 211
 	 * @return bool result
212 212
 	 */
213
-	public function delete( $force_delete = false ) {
214
-		if ( $this->data_store && $this->get_id() ) {
215
-			$this->data_store->delete( $this, array( 'force_delete' => $force_delete ) );
216
-			$this->set_id( 0 );
213
+	public function delete($force_delete = false) {
214
+		if ($this->data_store && $this->get_id()) {
215
+			$this->data_store->delete($this, array('force_delete' => $force_delete));
216
+			$this->set_id(0);
217 217
 			return true;
218 218
 		}
219 219
 		return false;
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 * @return int
227 227
 	 */
228 228
 	public function save() {
229
-		if ( ! $this->data_store ) {
229
+		if (!$this->data_store) {
230 230
 			return $this->get_id();
231 231
 		}
232 232
 
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
 		 * @param GetPaid_Data          $this The object being saved.
237 237
 		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
238 238
 		 */
239
-		do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store );
239
+		do_action('getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store);
240 240
 
241
-		if ( $this->get_id() ) {
242
-			$this->data_store->update( $this );
241
+		if ($this->get_id()) {
242
+			$this->data_store->update($this);
243 243
 		} else {
244
-			$this->data_store->create( $this );
244
+			$this->data_store->create($this);
245 245
 		}
246 246
 
247 247
 		/**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		 * @param GetPaid_Data          $this The object being saved.
251 251
 		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
252 252
 		 */
253
-		do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store );
253
+		do_action('getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store);
254 254
 
255 255
 		return $this->get_id();
256 256
 	}
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 * @return string Data in JSON format.
263 263
 	 */
264 264
 	public function __toString() {
265
-		return wp_json_encode( $this->get_data() );
265
+		return wp_json_encode($this->get_data());
266 266
 	}
267 267
 
268 268
 	/**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @return array
273 273
 	 */
274 274
 	public function get_data() {
275
-		return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) );
275
+		return array_merge(array('id' => $this->get_id()), $this->data, array('meta_data' => $this->get_meta_data()));
276 276
 	}
277 277
 
278 278
 	/**
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @return array
283 283
 	 */
284 284
 	public function get_data_keys() {
285
-		return array_keys( $this->data );
285
+		return array_keys($this->data);
286 286
 	}
287 287
 
288 288
 	/**
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 * @return array
293 293
 	 */
294 294
 	public function get_extra_data_keys() {
295
-		return array_keys( $this->extra_data );
295
+		return array_keys($this->extra_data);
296 296
 	}
297 297
 
298 298
 	/**
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 	 * @param mixed $meta Meta value to check.
303 303
 	 * @return bool
304 304
 	 */
305
-	protected function filter_null_meta( $meta ) {
306
-		return ! is_null( $meta->value );
305
+	protected function filter_null_meta($meta) {
306
+		return !is_null($meta->value);
307 307
 	}
308 308
 
309 309
 	/**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	public function get_meta_data() {
316 316
 		$this->maybe_read_meta_data();
317
-		return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) );
317
+		return array_values(array_filter($this->meta_data, array($this, 'filter_null_meta')));
318 318
 	}
319 319
 
320 320
 	/**
@@ -324,21 +324,21 @@  discard block
 block discarded – undo
324 324
 	 * @param  string $key Key to check.
325 325
 	 * @return bool   true if it's an internal key, false otherwise
326 326
 	 */
327
-	protected function is_internal_meta_key( $key ) {
328
-		$internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true );
327
+	protected function is_internal_meta_key($key) {
328
+		$internal_meta_key = !empty($key) && $this->data_store && in_array($key, $this->data_store->get_internal_meta_keys(), true);
329 329
 
330
-		if ( ! $internal_meta_key ) {
330
+		if (!$internal_meta_key) {
331 331
 			return false;
332 332
 		}
333 333
 
334
-		$has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) );
334
+		$has_setter_or_getter = is_callable(array($this, 'set_' . $key)) || is_callable(array($this, 'get_' . $key));
335 335
 
336
-		if ( ! $has_setter_or_getter ) {
336
+		if (!$has_setter_or_getter) {
337 337
 			return false;
338 338
 		}
339 339
 
340 340
 		/* translators: %s: $key Key to check */
341
-		getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
341
+		getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'getpaid'), $key), '1.0.19');
342 342
 
343 343
 		return true;
344 344
 	}
@@ -352,20 +352,20 @@  discard block
 block discarded – undo
352 352
 	 * @access public
353 353
 	 *
354 354
 	 */
355
-	public function __set( $key, $value ) {
355
+	public function __set($key, $value) {
356 356
 
357
-		if ( 'id' == strtolower( $key ) ) {
358
-			return $this->set_id( $value );
357
+		if ('id' == strtolower($key)) {
358
+			return $this->set_id($value);
359 359
 		}
360 360
 
361
-		if ( method_exists( $this, "set_$key") ) {
361
+		if (method_exists($this, "set_$key")) {
362 362
 
363 363
 			/* translators: %s: $key Key to set */
364
-			getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
364
+			getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid'), $key), '1.0.19');
365 365
 
366
-			call_user_func( array( $this, "set_$key" ), $value );
366
+			call_user_func(array($this, "set_$key"), $value);
367 367
 		} else {
368
-			$this->set_prop( $key, $value );
368
+			$this->set_prop($key, $value);
369 369
 		}
370 370
 
371 371
 	}
@@ -373,25 +373,25 @@  discard block
 block discarded – undo
373 373
 	/**
374 374
      * Margic method for retrieving a property.
375 375
      */
376
-    public function __get( $key ) {
376
+    public function __get($key) {
377 377
 
378 378
         // Check if we have a helper method for that.
379
-        if ( method_exists( $this, 'get_' . $key ) ) {
379
+        if (method_exists($this, 'get_' . $key)) {
380 380
 
381
-			if ( 'post_type' != $key ) {
381
+			if ('post_type' != $key) {
382 382
 				/* translators: %s: $key Key to set */
383
-				getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
383
+				getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid'), $key), '1.0.19');
384 384
 			}
385 385
 
386
-            return call_user_func( array( $this, 'get_' . $key ) );
386
+            return call_user_func(array($this, 'get_' . $key));
387 387
         }
388 388
 
389 389
         // Check if the key is in the associated $post object.
390
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
390
+        if (!empty($this->post) && isset($this->post->$key)) {
391 391
             return $this->post->$key;
392 392
         }
393 393
 
394
-		return $this->get_prop( $key );
394
+		return $this->get_prop($key);
395 395
 
396 396
     }
397 397
 
@@ -404,15 +404,15 @@  discard block
 block discarded – undo
404 404
 	 * @param  string $context What the value is for. Valid values are view and edit.
405 405
 	 * @return mixed
406 406
 	 */
407
-	public function get_meta( $key = '', $single = true, $context = 'view' ) {
407
+	public function get_meta($key = '', $single = true, $context = 'view') {
408 408
 
409 409
 		// Check if this is an internal meta key.
410
-		$_key = str_replace( '_wpinv', '', $key );
411
-		$_key = str_replace( 'wpinv', '', $_key );
412
-		if ( $this->is_internal_meta_key( $_key ) ) {
410
+		$_key = str_replace('_wpinv', '', $key);
411
+		$_key = str_replace('wpinv', '', $_key);
412
+		if ($this->is_internal_meta_key($_key)) {
413 413
 			$function = 'get_' . $_key;
414 414
 
415
-			if ( is_callable( array( $this, $function ) ) ) {
415
+			if (is_callable(array($this, $function))) {
416 416
 				return $this->{$function}();
417 417
 			}
418 418
 		}
@@ -420,20 +420,20 @@  discard block
 block discarded – undo
420 420
 		// Read the meta data if not yet read.
421 421
 		$this->maybe_read_meta_data();
422 422
 		$meta_data  = $this->get_meta_data();
423
-		$array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true );
423
+		$array_keys = array_keys(wp_list_pluck($meta_data, 'key'), $key, true);
424 424
 		$value      = $single ? '' : array();
425 425
 
426
-		if ( ! empty( $array_keys ) ) {
426
+		if (!empty($array_keys)) {
427 427
 			// We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()).
428
-			if ( $single ) {
429
-				$value = $meta_data[ current( $array_keys ) ]->value;
428
+			if ($single) {
429
+				$value = $meta_data[current($array_keys)]->value;
430 430
 			} else {
431
-				$value = array_intersect_key( $meta_data, array_flip( $array_keys ) );
431
+				$value = array_intersect_key($meta_data, array_flip($array_keys));
432 432
 			}
433 433
 		}
434 434
 
435
-		if ( 'view' === $context ) {
436
-			$value = apply_filters( $this->get_hook_prefix() . $key, $value, $this );
435
+		if ('view' === $context) {
436
+			$value = apply_filters($this->get_hook_prefix() . $key, $value, $this);
437 437
 		}
438 438
 
439 439
 		return $value;
@@ -446,10 +446,10 @@  discard block
 block discarded – undo
446 446
 	 * @param  string $key Meta Key.
447 447
 	 * @return boolean
448 448
 	 */
449
-	public function meta_exists( $key = '' ) {
449
+	public function meta_exists($key = '') {
450 450
 		$this->maybe_read_meta_data();
451
-		$array_keys = wp_list_pluck( $this->get_meta_data(), 'key' );
452
-		return in_array( $key, $array_keys, true );
451
+		$array_keys = wp_list_pluck($this->get_meta_data(), 'key');
452
+		return in_array($key, $array_keys, true);
453 453
 	}
454 454
 
455 455
 	/**
@@ -458,12 +458,12 @@  discard block
 block discarded – undo
458 458
 	 * @since 1.0.19
459 459
 	 * @param array $data Key/Value pairs.
460 460
 	 */
461
-	public function set_meta_data( $data ) {
462
-		if ( ! empty( $data ) && is_array( $data ) ) {
461
+	public function set_meta_data($data) {
462
+		if (!empty($data) && is_array($data)) {
463 463
 			$this->maybe_read_meta_data();
464
-			foreach ( $data as $meta ) {
464
+			foreach ($data as $meta) {
465 465
 				$meta = (array) $meta;
466
-				if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) {
466
+				if (isset($meta['key'], $meta['value'], $meta['id'])) {
467 467
 					$this->meta_data[] = new GetPaid_Meta_Data(
468 468
 						array(
469 469
 							'id'    => $meta['id'],
@@ -485,18 +485,18 @@  discard block
 block discarded – undo
485 485
 	 * @param string|array $value Meta value.
486 486
 	 * @param bool         $unique Should this be a unique key?.
487 487
 	 */
488
-	public function add_meta_data( $key, $value, $unique = false ) {
489
-		if ( $this->is_internal_meta_key( $key ) ) {
488
+	public function add_meta_data($key, $value, $unique = false) {
489
+		if ($this->is_internal_meta_key($key)) {
490 490
 			$function = 'set_' . $key;
491 491
 
492
-			if ( is_callable( array( $this, $function ) ) ) {
493
-				return $this->{$function}( $value );
492
+			if (is_callable(array($this, $function))) {
493
+				return $this->{$function}($value);
494 494
 			}
495 495
 		}
496 496
 
497 497
 		$this->maybe_read_meta_data();
498
-		if ( $unique ) {
499
-			$this->delete_meta_data( $key );
498
+		if ($unique) {
499
+			$this->delete_meta_data($key);
500 500
 		}
501 501
 		$this->meta_data[] = new GetPaid_Meta_Data(
502 502
 			array(
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
 	 * @param  string|array $value Meta value.
516 516
 	 * @param  int          $meta_id Meta ID.
517 517
 	 */
518
-	public function update_meta_data( $key, $value, $meta_id = 0 ) {
519
-		if ( $this->is_internal_meta_key( $key ) ) {
518
+	public function update_meta_data($key, $value, $meta_id = 0) {
519
+		if ($this->is_internal_meta_key($key)) {
520 520
 			$function = 'set_' . $key;
521 521
 
522
-			if ( is_callable( array( $this, $function ) ) ) {
523
-				return $this->{$function}( $value );
522
+			if (is_callable(array($this, $function))) {
523
+				return $this->{$function}($value);
524 524
 			}
525 525
 		}
526 526
 
@@ -528,33 +528,33 @@  discard block
 block discarded – undo
528 528
 
529 529
 		$array_key = false;
530 530
 
531
-		if ( $meta_id ) {
532
-			$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true );
533
-			$array_key  = $array_keys ? current( $array_keys ) : false;
531
+		if ($meta_id) {
532
+			$array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), $meta_id, true);
533
+			$array_key  = $array_keys ? current($array_keys) : false;
534 534
 		} else {
535 535
 			// Find matches by key.
536 536
 			$matches = array();
537
-			foreach ( $this->meta_data as $meta_data_array_key => $meta ) {
538
-				if ( $meta->key === $key ) {
537
+			foreach ($this->meta_data as $meta_data_array_key => $meta) {
538
+				if ($meta->key === $key) {
539 539
 					$matches[] = $meta_data_array_key;
540 540
 				}
541 541
 			}
542 542
 
543
-			if ( ! empty( $matches ) ) {
543
+			if (!empty($matches)) {
544 544
 				// Set matches to null so only one key gets the new value.
545
-				foreach ( $matches as $meta_data_array_key ) {
546
-					$this->meta_data[ $meta_data_array_key ]->value = null;
545
+				foreach ($matches as $meta_data_array_key) {
546
+					$this->meta_data[$meta_data_array_key]->value = null;
547 547
 				}
548
-				$array_key = current( $matches );
548
+				$array_key = current($matches);
549 549
 			}
550 550
 		}
551 551
 
552
-		if ( false !== $array_key ) {
553
-			$meta        = $this->meta_data[ $array_key ];
552
+		if (false !== $array_key) {
553
+			$meta        = $this->meta_data[$array_key];
554 554
 			$meta->key   = $key;
555 555
 			$meta->value = $value;
556 556
 		} else {
557
-			$this->add_meta_data( $key, $value, true );
557
+			$this->add_meta_data($key, $value, true);
558 558
 		}
559 559
 	}
560 560
 
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 	 * @since 1.0.19
565 565
 	 * @param string $key Meta key.
566 566
 	 */
567
-	public function delete_meta_data( $key ) {
567
+	public function delete_meta_data($key) {
568 568
 		$this->maybe_read_meta_data();
569
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true );
569
+		$array_keys = array_keys(wp_list_pluck($this->meta_data, 'key'), $key, true);
570 570
 
571
-		if ( $array_keys ) {
572
-			foreach ( $array_keys as $array_key ) {
573
-				$this->meta_data[ $array_key ]->value = null;
571
+		if ($array_keys) {
572
+			foreach ($array_keys as $array_key) {
573
+				$this->meta_data[$array_key]->value = null;
574 574
 			}
575 575
 		}
576 576
 	}
@@ -581,13 +581,13 @@  discard block
 block discarded – undo
581 581
 	 * @since 1.0.19
582 582
 	 * @param int $mid Meta ID.
583 583
 	 */
584
-	public function delete_meta_data_by_mid( $mid ) {
584
+	public function delete_meta_data_by_mid($mid) {
585 585
 		$this->maybe_read_meta_data();
586
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true );
586
+		$array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), (int) $mid, true);
587 587
 
588
-		if ( $array_keys ) {
589
-			foreach ( $array_keys as $array_key ) {
590
-				$this->meta_data[ $array_key ]->value = null;
588
+		if ($array_keys) {
589
+			foreach ($array_keys as $array_key) {
590
+				$this->meta_data[$array_key]->value = null;
591 591
 			}
592 592
 		}
593 593
 	}
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 	 * @since 1.0.19
599 599
 	 */
600 600
 	protected function maybe_read_meta_data() {
601
-		if ( is_null( $this->meta_data ) ) {
601
+		if (is_null($this->meta_data)) {
602 602
 			$this->read_meta_data();
603 603
 		}
604 604
 	}
@@ -610,42 +610,42 @@  discard block
 block discarded – undo
610 610
 	 * @since 1.0.19
611 611
 	 * @param bool $force_read True to force a new DB read (and update cache).
612 612
 	 */
613
-	public function read_meta_data( $force_read = false ) {
613
+	public function read_meta_data($force_read = false) {
614 614
 
615 615
 		// Reset meta data.
616 616
 		$this->meta_data = array();
617 617
 
618 618
 		// Maybe abort early.
619
-		if ( ! $this->get_id() || ! $this->data_store ) {
619
+		if (!$this->get_id() || !$this->data_store) {
620 620
 			return;
621 621
 		}
622 622
 
623 623
 		// Only read from cache if the cache key is set.
624 624
 		$cache_key = null;
625
-		if ( ! $force_read && ! empty( $this->cache_group ) ) {
626
-			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
627
-			$raw_meta_data = wp_cache_get( $cache_key, $this->cache_group );
625
+		if (!$force_read && !empty($this->cache_group)) {
626
+			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id();
627
+			$raw_meta_data = wp_cache_get($cache_key, $this->cache_group);
628 628
 		}
629 629
 
630 630
 		// Should we force read?
631
-		if ( empty( $raw_meta_data ) ) {
632
-			$raw_meta_data = $this->data_store->read_meta( $this );
631
+		if (empty($raw_meta_data)) {
632
+			$raw_meta_data = $this->data_store->read_meta($this);
633 633
 
634
-			if ( ! empty( $cache_key ) ) {
635
-				wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
634
+			if (!empty($cache_key)) {
635
+				wp_cache_set($cache_key, $raw_meta_data, $this->cache_group);
636 636
 			}
637 637
 
638 638
 		}
639 639
 
640 640
 		// Set meta data.
641
-		if ( is_array( $raw_meta_data ) ) {
641
+		if (is_array($raw_meta_data)) {
642 642
 
643
-			foreach ( $raw_meta_data as $meta ) {
643
+			foreach ($raw_meta_data as $meta) {
644 644
 				$this->meta_data[] = new GetPaid_Meta_Data(
645 645
 					array(
646 646
 						'id'    => (int) $meta->meta_id,
647 647
 						'key'   => $meta->meta_key,
648
-						'value' => maybe_unserialize( $meta->meta_value ),
648
+						'value' => maybe_unserialize($meta->meta_value),
649 649
 					)
650 650
 				);
651 651
 			}
@@ -660,28 +660,28 @@  discard block
 block discarded – undo
660 660
 	 * @since 1.0.19
661 661
 	 */
662 662
 	public function save_meta_data() {
663
-		if ( ! $this->data_store || is_null( $this->meta_data ) ) {
663
+		if (!$this->data_store || is_null($this->meta_data)) {
664 664
 			return;
665 665
 		}
666
-		foreach ( $this->meta_data as $array_key => $meta ) {
667
-			if ( is_null( $meta->value ) ) {
668
-				if ( ! empty( $meta->id ) ) {
669
-					$this->data_store->delete_meta( $this, $meta );
670
-					unset( $this->meta_data[ $array_key ] );
666
+		foreach ($this->meta_data as $array_key => $meta) {
667
+			if (is_null($meta->value)) {
668
+				if (!empty($meta->id)) {
669
+					$this->data_store->delete_meta($this, $meta);
670
+					unset($this->meta_data[$array_key]);
671 671
 				}
672
-			} elseif ( empty( $meta->id ) ) {
673
-				$meta->id = $this->data_store->add_meta( $this, $meta );
672
+			} elseif (empty($meta->id)) {
673
+				$meta->id = $this->data_store->add_meta($this, $meta);
674 674
 				$meta->apply_changes();
675 675
 			} else {
676
-				if ( $meta->get_changes() ) {
677
-					$this->data_store->update_meta( $this, $meta );
676
+				if ($meta->get_changes()) {
677
+					$this->data_store->update_meta($this, $meta);
678 678
 					$meta->apply_changes();
679 679
 				}
680 680
 			}
681 681
 		}
682
-		if ( ! empty( $this->cache_group ) ) {
683
-			$cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
684
-			wp_cache_delete( $cache_key, $this->cache_group );
682
+		if (!empty($this->cache_group)) {
683
+			$cache_key = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id();
684
+			wp_cache_delete($cache_key, $this->cache_group);
685 685
 		}
686 686
 	}
687 687
 
@@ -691,8 +691,8 @@  discard block
 block discarded – undo
691 691
 	 * @since 1.0.19
692 692
 	 * @param int $id ID.
693 693
 	 */
694
-	public function set_id( $id ) {
695
-		$this->id = absint( $id );
694
+	public function set_id($id) {
695
+		$this->id = absint($id);
696 696
 	}
697 697
 
698 698
 	/**
@@ -702,10 +702,10 @@  discard block
 block discarded – undo
702 702
 	 * @param string $status New status.
703 703
 	 * @return array details of change.
704 704
 	 */
705
-	public function set_status( $status ) {
705
+	public function set_status($status) {
706 706
         $old_status = $this->get_status();
707 707
 
708
-		$this->set_prop( 'status', $status );
708
+		$this->set_prop('status', $status);
709 709
 
710 710
 		return array(
711 711
 			'from' => $old_status,
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 	public function set_defaults() {
722 722
 		$this->data    = $this->default_data;
723 723
 		$this->changes = array();
724
-		$this->set_object_read( false );
724
+		$this->set_object_read(false);
725 725
 	}
726 726
 
727 727
 	/**
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 	 * @since 1.0.19
731 731
 	 * @param boolean $read Should read?.
732 732
 	 */
733
-	public function set_object_read( $read = true ) {
733
+	public function set_object_read($read = true) {
734 734
 		$this->object_read = (bool) $read;
735 735
 	}
736 736
 
@@ -755,32 +755,32 @@  discard block
 block discarded – undo
755 755
 	 *
756 756
 	 * @return bool|WP_Error
757 757
 	 */
758
-	public function set_props( $props, $context = 'set' ) {
758
+	public function set_props($props, $context = 'set') {
759 759
 		$errors = false;
760 760
 
761
-		foreach ( $props as $prop => $value ) {
761
+		foreach ($props as $prop => $value) {
762 762
 			try {
763 763
 				/**
764 764
 				 * Checks if the prop being set is allowed, and the value is not null.
765 765
 				 */
766
-				if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
766
+				if (is_null($value) || in_array($prop, array('prop', 'date_prop', 'meta_data'), true)) {
767 767
 					continue;
768 768
 				}
769 769
 				$setter = "set_$prop";
770 770
 
771
-				if ( is_callable( array( $this, $setter ) ) ) {
772
-					$this->{$setter}( $value );
771
+				if (is_callable(array($this, $setter))) {
772
+					$this->{$setter}($value);
773 773
 				}
774
-			} catch ( Exception $e ) {
775
-				if ( ! $errors ) {
774
+			} catch (Exception $e) {
775
+				if (!$errors) {
776 776
 					$errors = new WP_Error();
777 777
 				}
778
-				$errors->add( $e->getCode(), $e->getMessage() );
778
+				$errors->add($e->getCode(), $e->getMessage());
779 779
 				$this->last_error = $e->getMessage();
780 780
 			}
781 781
 		}
782 782
 
783
-		return $errors && count( $errors->get_error_codes() ) ? $errors : true;
783
+		return $errors && count($errors->get_error_codes()) ? $errors : true;
784 784
 	}
785 785
 
786 786
 	/**
@@ -793,14 +793,14 @@  discard block
 block discarded – undo
793 793
 	 * @param string $prop Name of prop to set.
794 794
 	 * @param mixed  $value Value of the prop.
795 795
 	 */
796
-	protected function set_prop( $prop, $value ) {
797
-		if ( array_key_exists( $prop, $this->data ) ) {
798
-			if ( true === $this->object_read ) {
799
-				if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
800
-					$this->changes[ $prop ] = $value;
796
+	protected function set_prop($prop, $value) {
797
+		if (array_key_exists($prop, $this->data)) {
798
+			if (true === $this->object_read) {
799
+				if ($value !== $this->data[$prop] || array_key_exists($prop, $this->changes)) {
800
+					$this->changes[$prop] = $value;
801 801
 				}
802 802
 			} else {
803
-				$this->data[ $prop ] = $value;
803
+				$this->data[$prop] = $value;
804 804
 			}
805 805
 		}
806 806
 	}
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 	 * @since 1.0.19
822 822
 	 */
823 823
 	public function apply_changes() {
824
-		$this->data    = array_replace_recursive( $this->data, $this->changes );
824
+		$this->data    = array_replace_recursive($this->data, $this->changes);
825 825
 		$this->changes = array();
826 826
 	}
827 827
 
@@ -846,14 +846,14 @@  discard block
 block discarded – undo
846 846
 	 * @param  string $context What the value is for. Valid values are view and edit.
847 847
 	 * @return mixed
848 848
 	 */
849
-	protected function get_prop( $prop, $context = 'view' ) {
849
+	protected function get_prop($prop, $context = 'view') {
850 850
 		$value = null;
851 851
 
852
-		if ( array_key_exists( $prop, $this->data ) ) {
853
-			$value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
852
+		if (array_key_exists($prop, $this->data)) {
853
+			$value = array_key_exists($prop, $this->changes) ? $this->changes[$prop] : $this->data[$prop];
854 854
 
855
-			if ( 'view' === $context ) {
856
-				$value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
855
+			if ('view' === $context) {
856
+				$value = apply_filters($this->get_hook_prefix() . $prop, $value, $this);
857 857
 			}
858 858
 		}
859 859
 
@@ -867,13 +867,13 @@  discard block
 block discarded – undo
867 867
 	 * @param string         $prop Name of prop to set.
868 868
 	 * @param string|integer $value Value of the prop.
869 869
 	 */
870
-	protected function set_date_prop( $prop, $value ) {
870
+	protected function set_date_prop($prop, $value) {
871 871
 
872
-		if ( empty( $value ) ) {
873
-			$this->set_prop( $prop, null );
872
+		if (empty($value)) {
873
+			$this->set_prop($prop, null);
874 874
 			return;
875 875
 		}
876
-		$this->set_prop( $prop, $value );
876
+		$this->set_prop($prop, $value);
877 877
 
878 878
 	}
879 879
 
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 	 * @param string $code             Error code.
885 885
 	 * @param string $message          Error message.
886 886
 	 */
887
-	protected function error( $code, $message ) {
887
+	protected function error($code, $message) {
888 888
 		$this->last_error = $message;
889 889
 	}
890 890
 
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 	 */
897 897
 	public function exists() {
898 898
 		$id = $this->get_id();
899
-		return ! empty( $id );
899
+		return !empty($id);
900 900
 	}
901 901
 
902 902
 }
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 1 patch
Spacing   +740 added lines, -740 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.
@@ -135,40 +135,40 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
137 137
 	 */
138
-    public function __construct( $invoice = 0 ) {
138
+    public function __construct($invoice = 0) {
139 139
 
140
-        parent::__construct( $invoice );
140
+        parent::__construct($invoice);
141 141
 
142
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
143
-			$this->set_id( (int) $invoice );
144
-		} elseif ( $invoice instanceof self ) {
145
-			$this->set_id( $invoice->get_id() );
146
-		} elseif ( ! empty( $invoice->ID ) ) {
147
-			$this->set_id( $invoice->ID );
148
-		} elseif ( is_array( $invoice ) ) {
149
-			$this->set_props( $invoice );
142
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) {
143
+			$this->set_id((int) $invoice);
144
+		} elseif ($invoice instanceof self) {
145
+			$this->set_id($invoice->get_id());
146
+		} elseif (!empty($invoice->ID)) {
147
+			$this->set_id($invoice->ID);
148
+		} elseif (is_array($invoice)) {
149
+			$this->set_props($invoice);
150 150
 
151
-			if ( isset( $invoice['ID'] ) ) {
152
-				$this->set_id( $invoice['ID'] );
151
+			if (isset($invoice['ID'])) {
152
+				$this->set_id($invoice['ID']);
153 153
 			}
154 154
 
155
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
156
-			$this->set_id( $invoice_id );
157
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
158
-			$this->set_id( $invoice_id );
159
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
160
-			$this->set_id( $invoice_id );
161
-		}else {
162
-			$this->set_object_read( true );
155
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
156
+			$this->set_id($invoice_id);
157
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
158
+			$this->set_id($invoice_id);
159
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
160
+			$this->set_id($invoice_id);
161
+		} else {
162
+			$this->set_object_read(true);
163 163
 		}
164 164
 
165 165
         // Load the datastore.
166
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
166
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
167 167
 
168
-		if ( $this->get_id() > 0 ) {
169
-            $this->post = get_post( $this->get_id() );
168
+		if ($this->get_id() > 0) {
169
+            $this->post = get_post($this->get_id());
170 170
             $this->ID   = $this->get_id();
171
-			$this->data_store->read( $this );
171
+			$this->data_store->read($this);
172 172
         }
173 173
 
174 174
     }
@@ -183,38 +183,38 @@  discard block
 block discarded – undo
183 183
 	 * @since 1.0.15
184 184
 	 * @return int
185 185
 	 */
186
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
186
+	public static function get_invoice_id_by_field($value, $field = 'key') {
187 187
         global $wpdb;
188 188
 
189 189
 		// Trim the value.
190
-		$value = trim( $value );
190
+		$value = trim($value);
191 191
 
192
-		if ( empty( $value ) ) {
192
+		if (empty($value)) {
193 193
 			return 0;
194 194
 		}
195 195
 
196 196
         // Valid fields.
197
-        $fields = array( 'key', 'number', 'transaction_id' );
197
+        $fields = array('key', 'number', 'transaction_id');
198 198
 
199 199
 		// Ensure a field has been passed.
200
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
200
+		if (empty($field) || !in_array($field, $fields)) {
201 201
 			return 0;
202 202
 		}
203 203
 
204 204
 		// Maybe retrieve from the cache.
205
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
206
-		if ( false !== $invoice_id ) {
205
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
206
+		if (false !== $invoice_id) {
207 207
 			return $invoice_id;
208 208
 		}
209 209
 
210 210
         // Fetch from the db.
211 211
         $table       = $wpdb->prefix . 'getpaid_invoices';
212 212
         $invoice_id  = (int) $wpdb->get_var(
213
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
213
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
214 214
         );
215 215
 
216 216
 		// Update the cache with our data
217
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
217
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
218 218
 
219 219
 		return $invoice_id;
220 220
     }
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
     /**
223 223
      * Checks if an invoice key is set.
224 224
      */
225
-    public function _isset( $key ) {
226
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
225
+    public function _isset($key) {
226
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
227 227
     }
228 228
 
229 229
     /*
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param  string $context View or edit context.
249 249
 	 * @return int
250 250
 	 */
251
-	public function get_parent_id( $context = 'view' ) {
252
-		return (int) $this->get_prop( 'parent_id', $context );
251
+	public function get_parent_id($context = 'view') {
252
+		return (int) $this->get_prop('parent_id', $context);
253 253
     }
254 254
 
255 255
     /**
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 * @return WPInv_Invoice
260 260
 	 */
261 261
     public function get_parent_payment() {
262
-        return new WPInv_Invoice( $this->get_parent_id() );
262
+        return new WPInv_Invoice($this->get_parent_id());
263 263
     }
264 264
 
265 265
     /**
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 	 * @param  string $context View or edit context.
280 280
 	 * @return string
281 281
 	 */
282
-	public function get_status( $context = 'view' ) {
283
-		return $this->get_prop( 'status', $context );
282
+	public function get_status($context = 'view') {
283
+		return $this->get_prop('status', $context);
284 284
 	}
285 285
 	
286 286
 	/**
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * @return array
291 291
 	 */
292 292
 	public function get_all_statuses() {
293
-		return wpinv_get_invoice_statuses( true, true, $this );
293
+		return wpinv_get_invoice_statuses(true, true, $this);
294 294
     }
295 295
 
296 296
     /**
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
     public function get_status_nicename() {
303 303
 		$statuses = $this->get_all_statuses();
304 304
 
305
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
305
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
306 306
 
307
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
307
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
308 308
     }
309 309
 
310 310
 	/**
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
      */
316 316
     public function get_status_label_html() {
317 317
 
318
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
319
-		$status       = sanitize_html_class( $this->get_status() );
318
+		$status_label = sanitize_text_field($this->get_status_nicename());
319
+		$status       = sanitize_html_class($this->get_status());
320 320
 
321 321
 		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
322 322
 	}
@@ -328,23 +328,23 @@  discard block
 block discarded – undo
328 328
 	 * @param  string $context View or edit context.
329 329
 	 * @return string
330 330
 	 */
331
-	public function get_version( $context = 'view' ) {
332
-		return $this->get_prop( 'version', $context );
331
+	public function get_version($context = 'view') {
332
+		return $this->get_prop('version', $context);
333 333
 	}
334 334
 
335 335
 	/**
336 336
 	 * @deprecated
337 337
 	 */
338
-	public function get_invoice_date( $format = true ) {
339
-		$date      = getpaid_format_date( $this->get_date_completed() );
340
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
341
-		$formatted = getpaid_format_date( $date );
338
+	public function get_invoice_date($format = true) {
339
+		$date      = getpaid_format_date($this->get_date_completed());
340
+		$date      = empty($date) ? $this->get_date_created() : $this->get_date_completed();
341
+		$formatted = getpaid_format_date($date);
342 342
 
343
-		if ( $format ) {
343
+		if ($format) {
344 344
 			return $formatted;
345 345
 		}
346 346
 
347
-		return empty( $formatted ) ? '' : $date;
347
+		return empty($formatted) ? '' : $date;
348 348
 
349 349
     }
350 350
 
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 	 * @param  string $context View or edit context.
356 356
 	 * @return string
357 357
 	 */
358
-	public function get_date_created( $context = 'view' ) {
359
-		return $this->get_prop( 'date_created', $context );
358
+	public function get_date_created($context = 'view') {
359
+		return $this->get_prop('date_created', $context);
360 360
 	}
361 361
 	
362 362
 	/**
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 	 * @param  string $context View or edit context.
367 367
 	 * @return string
368 368
 	 */
369
-	public function get_created_date( $context = 'view' ) {
370
-		return $this->get_date_created( $context );
369
+	public function get_created_date($context = 'view') {
370
+		return $this->get_date_created($context);
371 371
     }
372 372
 
373 373
     /**
@@ -377,11 +377,11 @@  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_gmt( $context = 'view' ) {
381
-        $date = $this->get_date_created( $context );
380
+	public function get_date_created_gmt($context = 'view') {
381
+        $date = $this->get_date_created($context);
382 382
 
383
-        if ( $date ) {
384
-            $date = get_gmt_from_date( $date );
383
+        if ($date) {
384
+            $date = get_gmt_from_date($date);
385 385
         }
386 386
 		return $date;
387 387
     }
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	 * @param  string $context View or edit context.
394 394
 	 * @return string
395 395
 	 */
396
-	public function get_date_modified( $context = 'view' ) {
397
-		return $this->get_prop( 'date_modified', $context );
396
+	public function get_date_modified($context = 'view') {
397
+		return $this->get_prop('date_modified', $context);
398 398
 	}
399 399
 
400 400
 	/**
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	 * @param  string $context View or edit context.
405 405
 	 * @return string
406 406
 	 */
407
-	public function get_modified_date( $context = 'view' ) {
408
-		return $this->get_date_modified( $context );
407
+	public function get_modified_date($context = 'view') {
408
+		return $this->get_date_modified($context);
409 409
     }
410 410
 
411 411
     /**
@@ -415,11 +415,11 @@  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_gmt( $context = 'view' ) {
419
-        $date = $this->get_date_modified( $context );
418
+	public function get_date_modified_gmt($context = 'view') {
419
+        $date = $this->get_date_modified($context);
420 420
 
421
-        if ( $date ) {
422
-            $date = get_gmt_from_date( $date );
421
+        if ($date) {
422
+            $date = get_gmt_from_date($date);
423 423
         }
424 424
 		return $date;
425 425
     }
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @param  string $context View or edit context.
432 432
 	 * @return string
433 433
 	 */
434
-	public function get_due_date( $context = 'view' ) {
435
-		return $this->get_prop( 'due_date', $context );
434
+	public function get_due_date($context = 'view') {
435
+		return $this->get_prop('due_date', $context);
436 436
     }
437 437
 
438 438
     /**
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	 * @param  string $context View or edit context.
443 443
 	 * @return string
444 444
 	 */
445
-	public function get_date_due( $context = 'view' ) {
446
-		return $this->get_due_date( $context );
445
+	public function get_date_due($context = 'view') {
446
+		return $this->get_due_date($context);
447 447
     }
448 448
 
449 449
     /**
@@ -453,11 +453,11 @@  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_gmt( $context = 'view' ) {
457
-        $date = $this->get_due_date( $context );
456
+	public function get_due_date_gmt($context = 'view') {
457
+        $date = $this->get_due_date($context);
458 458
 
459
-        if ( $date ) {
460
-            $date = get_gmt_from_date( $date );
459
+        if ($date) {
460
+            $date = get_gmt_from_date($date);
461 461
         }
462 462
 		return $date;
463 463
     }
@@ -469,8 +469,8 @@  discard block
 block discarded – undo
469 469
 	 * @param  string $context View or edit context.
470 470
 	 * @return string
471 471
 	 */
472
-	public function get_gmt_date_due( $context = 'view' ) {
473
-		return $this->get_due_date_gmt( $context );
472
+	public function get_gmt_date_due($context = 'view') {
473
+		return $this->get_due_date_gmt($context);
474 474
     }
475 475
 
476 476
     /**
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 	 * @param  string $context View or edit context.
481 481
 	 * @return string
482 482
 	 */
483
-	public function get_completed_date( $context = 'view' ) {
484
-		return $this->get_prop( 'completed_date', $context );
483
+	public function get_completed_date($context = 'view') {
484
+		return $this->get_prop('completed_date', $context);
485 485
     }
486 486
 
487 487
     /**
@@ -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_date_completed( $context = 'view' ) {
495
-		return $this->get_completed_date( $context );
494
+	public function get_date_completed($context = 'view') {
495
+		return $this->get_completed_date($context);
496 496
     }
497 497
 
498 498
     /**
@@ -502,11 +502,11 @@  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_gmt( $context = 'view' ) {
506
-        $date = $this->get_completed_date( $context );
505
+	public function get_completed_date_gmt($context = 'view') {
506
+        $date = $this->get_completed_date($context);
507 507
 
508
-        if ( $date ) {
509
-            $date = get_gmt_from_date( $date );
508
+        if ($date) {
509
+            $date = get_gmt_from_date($date);
510 510
         }
511 511
 		return $date;
512 512
     }
@@ -518,8 +518,8 @@  discard block
 block discarded – undo
518 518
 	 * @param  string $context View or edit context.
519 519
 	 * @return string
520 520
 	 */
521
-	public function get_gmt_completed_date( $context = 'view' ) {
522
-		return $this->get_completed_date_gmt( $context );
521
+	public function get_gmt_completed_date($context = 'view') {
522
+		return $this->get_completed_date_gmt($context);
523 523
     }
524 524
 
525 525
     /**
@@ -529,12 +529,12 @@  discard block
 block discarded – undo
529 529
 	 * @param  string $context View or edit context.
530 530
 	 * @return string
531 531
 	 */
532
-	public function get_number( $context = 'view' ) {
533
-		$number = $this->get_prop( 'number', $context );
532
+	public function get_number($context = 'view') {
533
+		$number = $this->get_prop('number', $context);
534 534
 
535
-		if ( empty( $number ) ) {
535
+		if (empty($number)) {
536 536
 			$number = $this->generate_number();
537
-			$this->set_number( $this->generate_number() );
537
+			$this->set_number($this->generate_number());
538 538
 		}
539 539
 
540 540
 		return $number;
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
 	public function maybe_set_number() {
549 549
         $number = $this->get_number();
550 550
 
551
-        if ( empty( $number ) || $this->get_id() == $number ) {
552
-			$this->set_number( $this->generate_number() );
551
+        if (empty($number) || $this->get_id() == $number) {
552
+			$this->set_number($this->generate_number());
553 553
         }
554 554
 
555 555
 	}
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * @param  string $context View or edit context.
562 562
 	 * @return string
563 563
 	 */
564
-	public function get_key( $context = 'view' ) {
565
-        return $this->get_prop( 'key', $context );
564
+	public function get_key($context = 'view') {
565
+        return $this->get_prop('key', $context);
566 566
 	}
567 567
 
568 568
 	/**
@@ -573,9 +573,9 @@  discard block
 block discarded – undo
573 573
 	public function maybe_set_key() {
574 574
         $key = $this->get_key();
575 575
 
576
-        if ( empty( $key ) ) {
577
-            $key = $this->generate_key( $this->get_type() . '_' );
578
-            $this->set_key( $key );
576
+        if (empty($key)) {
577
+            $key = $this->generate_key($this->get_type() . '_');
578
+            $this->set_key($key);
579 579
         }
580 580
 
581 581
     }
@@ -587,15 +587,15 @@  discard block
 block discarded – undo
587 587
 	 * @param  string $context View or edit context.
588 588
 	 * @return string
589 589
 	 */
590
-	public function get_type( $context = 'view' ) {
591
-        return $this->get_prop( 'type', $context );
590
+	public function get_type($context = 'view') {
591
+        return $this->get_prop('type', $context);
592 592
 	}
593 593
 
594 594
 	/**
595 595
 	 * @deprecated
596 596
 	 */
597 597
 	public function get_invoice_quote_type() {
598
-        ucfirst( $this->get_type() );
598
+        ucfirst($this->get_type());
599 599
     }
600 600
 
601 601
     /**
@@ -605,8 +605,8 @@  discard block
 block discarded – undo
605 605
 	 * @param  string $context View or edit context.
606 606
 	 * @return string
607 607
 	 */
608
-	public function get_post_type( $context = 'view' ) {
609
-        return $this->get_prop( 'post_type', $context );
608
+	public function get_post_type($context = 'view') {
609
+        return $this->get_prop('post_type', $context);
610 610
     }
611 611
 
612 612
     /**
@@ -616,8 +616,8 @@  discard block
 block discarded – undo
616 616
 	 * @param  string $context View or edit context.
617 617
 	 * @return string
618 618
 	 */
619
-	public function get_mode( $context = 'view' ) {
620
-        return $this->get_prop( 'mode', $context );
619
+	public function get_mode($context = 'view') {
620
+        return $this->get_prop('mode', $context);
621 621
     }
622 622
 
623 623
     /**
@@ -627,13 +627,13 @@  discard block
 block discarded – undo
627 627
 	 * @param  string $context View or edit context.
628 628
 	 * @return string
629 629
 	 */
630
-	public function get_path( $context = 'view' ) {
631
-        $path   = $this->get_prop( 'path', $context );
630
+	public function get_path($context = 'view') {
631
+        $path = $this->get_prop('path', $context);
632 632
 		$prefix = $this->get_type();
633 633
 
634
-		if ( 0 !== strpos( $path, $prefix ) ) {
635
-			$path = sanitize_title(  $prefix . '-' . $this->get_id()  );
636
-			$this->set_path( $path );
634
+		if (0 !== strpos($path, $prefix)) {
635
+			$path = sanitize_title($prefix . '-' . $this->get_id());
636
+			$this->set_path($path);
637 637
 		}
638 638
 
639 639
 		return $path;
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
 	 * @param  string $context View or edit context.
647 647
 	 * @return string
648 648
 	 */
649
-	public function get_name( $context = 'view' ) {
650
-        return $this->get_prop( 'title', $context );
649
+	public function get_name($context = 'view') {
650
+        return $this->get_prop('title', $context);
651 651
     }
652 652
 
653 653
     /**
@@ -657,8 +657,8 @@  discard block
 block discarded – undo
657 657
 	 * @param  string $context View or edit context.
658 658
 	 * @return string
659 659
 	 */
660
-	public function get_title( $context = 'view' ) {
661
-		return $this->get_name( $context );
660
+	public function get_title($context = 'view') {
661
+		return $this->get_name($context);
662 662
     }
663 663
 
664 664
     /**
@@ -668,8 +668,8 @@  discard block
 block discarded – undo
668 668
 	 * @param  string $context View or edit context.
669 669
 	 * @return string
670 670
 	 */
671
-	public function get_description( $context = 'view' ) {
672
-		return $this->get_prop( 'description', $context );
671
+	public function get_description($context = 'view') {
672
+		return $this->get_prop('description', $context);
673 673
     }
674 674
 
675 675
     /**
@@ -679,8 +679,8 @@  discard block
 block discarded – undo
679 679
 	 * @param  string $context View or edit context.
680 680
 	 * @return string
681 681
 	 */
682
-	public function get_excerpt( $context = 'view' ) {
683
-		return $this->get_description( $context );
682
+	public function get_excerpt($context = 'view') {
683
+		return $this->get_description($context);
684 684
     }
685 685
 
686 686
     /**
@@ -690,8 +690,8 @@  discard block
 block discarded – undo
690 690
 	 * @param  string $context View or edit context.
691 691
 	 * @return string
692 692
 	 */
693
-	public function get_summary( $context = 'view' ) {
694
-		return $this->get_description( $context );
693
+	public function get_summary($context = 'view') {
694
+		return $this->get_description($context);
695 695
     }
696 696
 
697 697
     /**
@@ -701,25 +701,25 @@  discard block
 block discarded – undo
701 701
      * @param  string $context View or edit context.
702 702
 	 * @return array
703 703
 	 */
704
-    public function get_user_info( $context = 'view' ) {
704
+    public function get_user_info($context = 'view') {
705 705
 
706 706
         $user_info = array(
707
-            'user_id'    => $this->get_user_id( $context ),
708
-            'email'      => $this->get_email( $context ),
709
-            'first_name' => $this->get_first_name( $context ),
710
-            'last_name'  => $this->get_last_name( $context ),
711
-            'address'    => $this->get_address( $context ),
712
-            'phone'      => $this->get_phone( $context ),
713
-            'city'       => $this->get_city( $context ),
714
-            'country'    => $this->get_country( $context ),
715
-            'state'      => $this->get_state( $context ),
716
-            'zip'        => $this->get_zip( $context ),
717
-            'company'    => $this->get_company( $context ),
718
-            'vat_number' => $this->get_vat_number( $context ),
719
-            'discount'   => $this->get_discount_code( $context ),
707
+            'user_id'    => $this->get_user_id($context),
708
+            'email'      => $this->get_email($context),
709
+            'first_name' => $this->get_first_name($context),
710
+            'last_name'  => $this->get_last_name($context),
711
+            'address'    => $this->get_address($context),
712
+            'phone'      => $this->get_phone($context),
713
+            'city'       => $this->get_city($context),
714
+            'country'    => $this->get_country($context),
715
+            'state'      => $this->get_state($context),
716
+            'zip'        => $this->get_zip($context),
717
+            'company'    => $this->get_company($context),
718
+            'vat_number' => $this->get_vat_number($context),
719
+            'discount'   => $this->get_discount_code($context),
720 720
 		);
721 721
 
722
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
722
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
723 723
 
724 724
     }
725 725
 
@@ -730,8 +730,8 @@  discard block
 block discarded – undo
730 730
 	 * @param  string $context View or edit context.
731 731
 	 * @return int
732 732
 	 */
733
-	public function get_author( $context = 'view' ) {
734
-		return (int) $this->get_prop( 'author', $context );
733
+	public function get_author($context = 'view') {
734
+		return (int) $this->get_prop('author', $context);
735 735
     }
736 736
 
737 737
     /**
@@ -741,8 +741,8 @@  discard block
 block discarded – undo
741 741
 	 * @param  string $context View or edit context.
742 742
 	 * @return int
743 743
 	 */
744
-	public function get_user_id( $context = 'view' ) {
745
-		return $this->get_author( $context );
744
+	public function get_user_id($context = 'view') {
745
+		return $this->get_author($context);
746 746
     }
747 747
 
748 748
      /**
@@ -752,8 +752,8 @@  discard block
 block discarded – undo
752 752
 	 * @param  string $context View or edit context.
753 753
 	 * @return int
754 754
 	 */
755
-	public function get_customer_id( $context = 'view' ) {
756
-		return $this->get_author( $context );
755
+	public function get_customer_id($context = 'view') {
756
+		return $this->get_author($context);
757 757
     }
758 758
 
759 759
     /**
@@ -763,8 +763,8 @@  discard block
 block discarded – undo
763 763
 	 * @param  string $context View or edit context.
764 764
 	 * @return string
765 765
 	 */
766
-	public function get_ip( $context = 'view' ) {
767
-		return $this->get_prop( 'user_ip', $context );
766
+	public function get_ip($context = 'view') {
767
+		return $this->get_prop('user_ip', $context);
768 768
     }
769 769
 
770 770
     /**
@@ -774,8 +774,8 @@  discard block
 block discarded – undo
774 774
 	 * @param  string $context View or edit context.
775 775
 	 * @return string
776 776
 	 */
777
-	public function get_user_ip( $context = 'view' ) {
778
-		return $this->get_ip( $context );
777
+	public function get_user_ip($context = 'view') {
778
+		return $this->get_ip($context);
779 779
     }
780 780
 
781 781
      /**
@@ -785,8 +785,8 @@  discard block
 block discarded – undo
785 785
 	 * @param  string $context View or edit context.
786 786
 	 * @return string
787 787
 	 */
788
-	public function get_customer_ip( $context = 'view' ) {
789
-		return $this->get_ip( $context );
788
+	public function get_customer_ip($context = 'view') {
789
+		return $this->get_ip($context);
790 790
     }
791 791
 
792 792
     /**
@@ -796,8 +796,8 @@  discard block
 block discarded – undo
796 796
 	 * @param  string $context View or edit context.
797 797
 	 * @return string
798 798
 	 */
799
-	public function get_first_name( $context = 'view' ) {
800
-		return $this->get_prop( 'first_name', $context );
799
+	public function get_first_name($context = 'view') {
800
+		return $this->get_prop('first_name', $context);
801 801
     }
802 802
 
803 803
     /**
@@ -807,8 +807,8 @@  discard block
 block discarded – undo
807 807
 	 * @param  string $context View or edit context.
808 808
 	 * @return string
809 809
 	 */
810
-	public function get_user_first_name( $context = 'view' ) {
811
-		return $this->get_first_name( $context );
810
+	public function get_user_first_name($context = 'view') {
811
+		return $this->get_first_name($context);
812 812
     }
813 813
 
814 814
      /**
@@ -818,8 +818,8 @@  discard block
 block discarded – undo
818 818
 	 * @param  string $context View or edit context.
819 819
 	 * @return string
820 820
 	 */
821
-	public function get_customer_first_name( $context = 'view' ) {
822
-		return $this->get_first_name( $context );
821
+	public function get_customer_first_name($context = 'view') {
822
+		return $this->get_first_name($context);
823 823
     }
824 824
 
825 825
     /**
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
 	 * @param  string $context View or edit context.
830 830
 	 * @return string
831 831
 	 */
832
-	public function get_last_name( $context = 'view' ) {
833
-		return $this->get_prop( 'last_name', $context );
832
+	public function get_last_name($context = 'view') {
833
+		return $this->get_prop('last_name', $context);
834 834
     }
835 835
 
836 836
     /**
@@ -840,8 +840,8 @@  discard block
 block discarded – undo
840 840
 	 * @param  string $context View or edit context.
841 841
 	 * @return string
842 842
 	 */
843
-	public function get_user_last_name( $context = 'view' ) {
844
-		return $this->get_last_name( $context );
843
+	public function get_user_last_name($context = 'view') {
844
+		return $this->get_last_name($context);
845 845
     }
846 846
 
847 847
     /**
@@ -851,8 +851,8 @@  discard block
 block discarded – undo
851 851
 	 * @param  string $context View or edit context.
852 852
 	 * @return string
853 853
 	 */
854
-	public function get_customer_last_name( $context = 'view' ) {
855
-		return $this->get_last_name( $context );
854
+	public function get_customer_last_name($context = 'view') {
855
+		return $this->get_last_name($context);
856 856
     }
857 857
 
858 858
     /**
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
 	 * @param  string $context View or edit context.
863 863
 	 * @return string
864 864
 	 */
865
-	public function get_full_name( $context = 'view' ) {
866
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
865
+	public function get_full_name($context = 'view') {
866
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
867 867
     }
868 868
 
869 869
     /**
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
 	 * @param  string $context View or edit context.
874 874
 	 * @return string
875 875
 	 */
876
-	public function get_user_full_name( $context = 'view' ) {
877
-		return $this->get_full_name( $context );
876
+	public function get_user_full_name($context = 'view') {
877
+		return $this->get_full_name($context);
878 878
     }
879 879
 
880 880
     /**
@@ -884,8 +884,8 @@  discard block
 block discarded – undo
884 884
 	 * @param  string $context View or edit context.
885 885
 	 * @return string
886 886
 	 */
887
-	public function get_customer_full_name( $context = 'view' ) {
888
-		return $this->get_full_name( $context );
887
+	public function get_customer_full_name($context = 'view') {
888
+		return $this->get_full_name($context);
889 889
     }
890 890
 
891 891
     /**
@@ -895,8 +895,8 @@  discard block
 block discarded – undo
895 895
 	 * @param  string $context View or edit context.
896 896
 	 * @return string
897 897
 	 */
898
-	public function get_phone( $context = 'view' ) {
899
-		return $this->get_prop( 'phone', $context );
898
+	public function get_phone($context = 'view') {
899
+		return $this->get_prop('phone', $context);
900 900
     }
901 901
 
902 902
     /**
@@ -906,8 +906,8 @@  discard block
 block discarded – undo
906 906
 	 * @param  string $context View or edit context.
907 907
 	 * @return string
908 908
 	 */
909
-	public function get_phone_number( $context = 'view' ) {
910
-		return $this->get_phone( $context );
909
+	public function get_phone_number($context = 'view') {
910
+		return $this->get_phone($context);
911 911
     }
912 912
 
913 913
     /**
@@ -917,8 +917,8 @@  discard block
 block discarded – undo
917 917
 	 * @param  string $context View or edit context.
918 918
 	 * @return string
919 919
 	 */
920
-	public function get_user_phone( $context = 'view' ) {
921
-		return $this->get_phone( $context );
920
+	public function get_user_phone($context = 'view') {
921
+		return $this->get_phone($context);
922 922
     }
923 923
 
924 924
     /**
@@ -928,8 +928,8 @@  discard block
 block discarded – undo
928 928
 	 * @param  string $context View or edit context.
929 929
 	 * @return string
930 930
 	 */
931
-	public function get_customer_phone( $context = 'view' ) {
932
-		return $this->get_phone( $context );
931
+	public function get_customer_phone($context = 'view') {
932
+		return $this->get_phone($context);
933 933
     }
934 934
 
935 935
     /**
@@ -939,8 +939,8 @@  discard block
 block discarded – undo
939 939
 	 * @param  string $context View or edit context.
940 940
 	 * @return string
941 941
 	 */
942
-	public function get_email( $context = 'view' ) {
943
-		return $this->get_prop( 'email', $context );
942
+	public function get_email($context = 'view') {
943
+		return $this->get_prop('email', $context);
944 944
     }
945 945
 
946 946
     /**
@@ -950,8 +950,8 @@  discard block
 block discarded – undo
950 950
 	 * @param  string $context View or edit context.
951 951
 	 * @return string
952 952
 	 */
953
-	public function get_email_address( $context = 'view' ) {
954
-		return $this->get_email( $context );
953
+	public function get_email_address($context = 'view') {
954
+		return $this->get_email($context);
955 955
     }
956 956
 
957 957
     /**
@@ -961,8 +961,8 @@  discard block
 block discarded – undo
961 961
 	 * @param  string $context View or edit context.
962 962
 	 * @return string
963 963
 	 */
964
-	public function get_user_email( $context = 'view' ) {
965
-		return $this->get_email( $context );
964
+	public function get_user_email($context = 'view') {
965
+		return $this->get_email($context);
966 966
     }
967 967
 
968 968
     /**
@@ -972,8 +972,8 @@  discard block
 block discarded – undo
972 972
 	 * @param  string $context View or edit context.
973 973
 	 * @return string
974 974
 	 */
975
-	public function get_customer_email( $context = 'view' ) {
976
-		return $this->get_email( $context );
975
+	public function get_customer_email($context = 'view') {
976
+		return $this->get_email($context);
977 977
     }
978 978
 
979 979
     /**
@@ -983,9 +983,9 @@  discard block
 block discarded – undo
983 983
 	 * @param  string $context View or edit context.
984 984
 	 * @return string
985 985
 	 */
986
-	public function get_country( $context = 'view' ) {
987
-		$country = $this->get_prop( 'country', $context );
988
-		return empty( $country ) ? wpinv_get_default_country() : $country;
986
+	public function get_country($context = 'view') {
987
+		$country = $this->get_prop('country', $context);
988
+		return empty($country) ? wpinv_get_default_country() : $country;
989 989
     }
990 990
 
991 991
     /**
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
 	 * @param  string $context View or edit context.
996 996
 	 * @return string
997 997
 	 */
998
-	public function get_user_country( $context = 'view' ) {
999
-		return $this->get_country( $context );
998
+	public function get_user_country($context = 'view') {
999
+		return $this->get_country($context);
1000 1000
     }
1001 1001
 
1002 1002
     /**
@@ -1006,8 +1006,8 @@  discard block
 block discarded – undo
1006 1006
 	 * @param  string $context View or edit context.
1007 1007
 	 * @return string
1008 1008
 	 */
1009
-	public function get_customer_country( $context = 'view' ) {
1010
-		return $this->get_country( $context );
1009
+	public function get_customer_country($context = 'view') {
1010
+		return $this->get_country($context);
1011 1011
     }
1012 1012
 
1013 1013
     /**
@@ -1017,9 +1017,9 @@  discard block
 block discarded – undo
1017 1017
 	 * @param  string $context View or edit context.
1018 1018
 	 * @return string
1019 1019
 	 */
1020
-	public function get_state( $context = 'view' ) {
1021
-		$state = $this->get_prop( 'state', $context );
1022
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1020
+	public function get_state($context = 'view') {
1021
+		$state = $this->get_prop('state', $context);
1022
+		return empty($state) ? wpinv_get_default_state() : $state;
1023 1023
     }
1024 1024
 
1025 1025
     /**
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
 	 * @param  string $context View or edit context.
1030 1030
 	 * @return string
1031 1031
 	 */
1032
-	public function get_user_state( $context = 'view' ) {
1033
-		return $this->get_state( $context );
1032
+	public function get_user_state($context = 'view') {
1033
+		return $this->get_state($context);
1034 1034
     }
1035 1035
 
1036 1036
     /**
@@ -1040,8 +1040,8 @@  discard block
 block discarded – undo
1040 1040
 	 * @param  string $context View or edit context.
1041 1041
 	 * @return string
1042 1042
 	 */
1043
-	public function get_customer_state( $context = 'view' ) {
1044
-		return $this->get_state( $context );
1043
+	public function get_customer_state($context = 'view') {
1044
+		return $this->get_state($context);
1045 1045
     }
1046 1046
 
1047 1047
     /**
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
 	 * @param  string $context View or edit context.
1052 1052
 	 * @return string
1053 1053
 	 */
1054
-	public function get_city( $context = 'view' ) {
1055
-		return $this->get_prop( 'city', $context );
1054
+	public function get_city($context = 'view') {
1055
+		return $this->get_prop('city', $context);
1056 1056
     }
1057 1057
 
1058 1058
     /**
@@ -1062,8 +1062,8 @@  discard block
 block discarded – undo
1062 1062
 	 * @param  string $context View or edit context.
1063 1063
 	 * @return string
1064 1064
 	 */
1065
-	public function get_user_city( $context = 'view' ) {
1066
-		return $this->get_city( $context );
1065
+	public function get_user_city($context = 'view') {
1066
+		return $this->get_city($context);
1067 1067
     }
1068 1068
 
1069 1069
     /**
@@ -1073,8 +1073,8 @@  discard block
 block discarded – undo
1073 1073
 	 * @param  string $context View or edit context.
1074 1074
 	 * @return string
1075 1075
 	 */
1076
-	public function get_customer_city( $context = 'view' ) {
1077
-		return $this->get_city( $context );
1076
+	public function get_customer_city($context = 'view') {
1077
+		return $this->get_city($context);
1078 1078
     }
1079 1079
 
1080 1080
     /**
@@ -1084,8 +1084,8 @@  discard block
 block discarded – undo
1084 1084
 	 * @param  string $context View or edit context.
1085 1085
 	 * @return string
1086 1086
 	 */
1087
-	public function get_zip( $context = 'view' ) {
1088
-		return $this->get_prop( 'zip', $context );
1087
+	public function get_zip($context = 'view') {
1088
+		return $this->get_prop('zip', $context);
1089 1089
     }
1090 1090
 
1091 1091
     /**
@@ -1095,8 +1095,8 @@  discard block
 block discarded – undo
1095 1095
 	 * @param  string $context View or edit context.
1096 1096
 	 * @return string
1097 1097
 	 */
1098
-	public function get_user_zip( $context = 'view' ) {
1099
-		return $this->get_zip( $context );
1098
+	public function get_user_zip($context = 'view') {
1099
+		return $this->get_zip($context);
1100 1100
     }
1101 1101
 
1102 1102
     /**
@@ -1106,8 +1106,8 @@  discard block
 block discarded – undo
1106 1106
 	 * @param  string $context View or edit context.
1107 1107
 	 * @return string
1108 1108
 	 */
1109
-	public function get_customer_zip( $context = 'view' ) {
1110
-		return $this->get_zip( $context );
1109
+	public function get_customer_zip($context = 'view') {
1110
+		return $this->get_zip($context);
1111 1111
     }
1112 1112
 
1113 1113
     /**
@@ -1117,8 +1117,8 @@  discard block
 block discarded – undo
1117 1117
 	 * @param  string $context View or edit context.
1118 1118
 	 * @return string
1119 1119
 	 */
1120
-	public function get_company( $context = 'view' ) {
1121
-		return $this->get_prop( 'company', $context );
1120
+	public function get_company($context = 'view') {
1121
+		return $this->get_prop('company', $context);
1122 1122
     }
1123 1123
 
1124 1124
     /**
@@ -1128,8 +1128,8 @@  discard block
 block discarded – undo
1128 1128
 	 * @param  string $context View or edit context.
1129 1129
 	 * @return string
1130 1130
 	 */
1131
-	public function get_user_company( $context = 'view' ) {
1132
-		return $this->get_company( $context );
1131
+	public function get_user_company($context = 'view') {
1132
+		return $this->get_company($context);
1133 1133
     }
1134 1134
 
1135 1135
     /**
@@ -1139,8 +1139,8 @@  discard block
 block discarded – undo
1139 1139
 	 * @param  string $context View or edit context.
1140 1140
 	 * @return string
1141 1141
 	 */
1142
-	public function get_customer_company( $context = 'view' ) {
1143
-		return $this->get_company( $context );
1142
+	public function get_customer_company($context = 'view') {
1143
+		return $this->get_company($context);
1144 1144
     }
1145 1145
 
1146 1146
     /**
@@ -1150,8 +1150,8 @@  discard block
 block discarded – undo
1150 1150
 	 * @param  string $context View or edit context.
1151 1151
 	 * @return string
1152 1152
 	 */
1153
-	public function get_vat_number( $context = 'view' ) {
1154
-		return $this->get_prop( 'vat_number', $context );
1153
+	public function get_vat_number($context = 'view') {
1154
+		return $this->get_prop('vat_number', $context);
1155 1155
     }
1156 1156
 
1157 1157
     /**
@@ -1161,8 +1161,8 @@  discard block
 block discarded – undo
1161 1161
 	 * @param  string $context View or edit context.
1162 1162
 	 * @return string
1163 1163
 	 */
1164
-	public function get_user_vat_number( $context = 'view' ) {
1165
-		return $this->get_vat_number( $context );
1164
+	public function get_user_vat_number($context = 'view') {
1165
+		return $this->get_vat_number($context);
1166 1166
     }
1167 1167
 
1168 1168
     /**
@@ -1172,8 +1172,8 @@  discard block
 block discarded – undo
1172 1172
 	 * @param  string $context View or edit context.
1173 1173
 	 * @return string
1174 1174
 	 */
1175
-	public function get_customer_vat_number( $context = 'view' ) {
1176
-		return $this->get_vat_number( $context );
1175
+	public function get_customer_vat_number($context = 'view') {
1176
+		return $this->get_vat_number($context);
1177 1177
     }
1178 1178
 
1179 1179
     /**
@@ -1183,8 +1183,8 @@  discard block
 block discarded – undo
1183 1183
 	 * @param  string $context View or edit context.
1184 1184
 	 * @return string
1185 1185
 	 */
1186
-	public function get_vat_rate( $context = 'view' ) {
1187
-		return $this->get_prop( 'vat_rate', $context );
1186
+	public function get_vat_rate($context = 'view') {
1187
+		return $this->get_prop('vat_rate', $context);
1188 1188
     }
1189 1189
 
1190 1190
     /**
@@ -1194,8 +1194,8 @@  discard block
 block discarded – undo
1194 1194
 	 * @param  string $context View or edit context.
1195 1195
 	 * @return string
1196 1196
 	 */
1197
-	public function get_user_vat_rate( $context = 'view' ) {
1198
-		return $this->get_vat_rate( $context );
1197
+	public function get_user_vat_rate($context = 'view') {
1198
+		return $this->get_vat_rate($context);
1199 1199
     }
1200 1200
 
1201 1201
     /**
@@ -1205,8 +1205,8 @@  discard block
 block discarded – undo
1205 1205
 	 * @param  string $context View or edit context.
1206 1206
 	 * @return string
1207 1207
 	 */
1208
-	public function get_customer_vat_rate( $context = 'view' ) {
1209
-		return $this->get_vat_rate( $context );
1208
+	public function get_customer_vat_rate($context = 'view') {
1209
+		return $this->get_vat_rate($context);
1210 1210
     }
1211 1211
 
1212 1212
     /**
@@ -1216,8 +1216,8 @@  discard block
 block discarded – undo
1216 1216
 	 * @param  string $context View or edit context.
1217 1217
 	 * @return string
1218 1218
 	 */
1219
-	public function get_address( $context = 'view' ) {
1220
-		return $this->get_prop( 'address', $context );
1219
+	public function get_address($context = 'view') {
1220
+		return $this->get_prop('address', $context);
1221 1221
     }
1222 1222
 
1223 1223
     /**
@@ -1227,8 +1227,8 @@  discard block
 block discarded – undo
1227 1227
 	 * @param  string $context View or edit context.
1228 1228
 	 * @return string
1229 1229
 	 */
1230
-	public function get_user_address( $context = 'view' ) {
1231
-		return $this->get_address( $context );
1230
+	public function get_user_address($context = 'view') {
1231
+		return $this->get_address($context);
1232 1232
     }
1233 1233
 
1234 1234
     /**
@@ -1238,8 +1238,8 @@  discard block
 block discarded – undo
1238 1238
 	 * @param  string $context View or edit context.
1239 1239
 	 * @return string
1240 1240
 	 */
1241
-	public function get_customer_address( $context = 'view' ) {
1242
-		return $this->get_address( $context );
1241
+	public function get_customer_address($context = 'view') {
1242
+		return $this->get_address($context);
1243 1243
     }
1244 1244
 
1245 1245
     /**
@@ -1249,8 +1249,8 @@  discard block
 block discarded – undo
1249 1249
 	 * @param  string $context View or edit context.
1250 1250
 	 * @return bool
1251 1251
 	 */
1252
-	public function get_is_viewed( $context = 'view' ) {
1253
-		return (bool) $this->get_prop( 'is_viewed', $context );
1252
+	public function get_is_viewed($context = 'view') {
1253
+		return (bool) $this->get_prop('is_viewed', $context);
1254 1254
 	}
1255 1255
 
1256 1256
 	/**
@@ -1260,8 +1260,8 @@  discard block
 block discarded – undo
1260 1260
 	 * @param  string $context View or edit context.
1261 1261
 	 * @return bool
1262 1262
 	 */
1263
-	public function get_email_cc( $context = 'view' ) {
1264
-		return $this->get_prop( 'email_cc', $context );
1263
+	public function get_email_cc($context = 'view') {
1264
+		return $this->get_prop('email_cc', $context);
1265 1265
 	}
1266 1266
 
1267 1267
 	/**
@@ -1271,8 +1271,8 @@  discard block
 block discarded – undo
1271 1271
 	 * @param  string $context View or edit context.
1272 1272
 	 * @return bool
1273 1273
 	 */
1274
-	public function get_template( $context = 'view' ) {
1275
-		return $this->get_prop( 'template', $context );
1274
+	public function get_template($context = 'view') {
1275
+		return $this->get_prop('template', $context);
1276 1276
 	}
1277 1277
 
1278 1278
 	/**
@@ -1282,8 +1282,8 @@  discard block
 block discarded – undo
1282 1282
 	 * @param  string $context View or edit context.
1283 1283
 	 * @return bool
1284 1284
 	 */
1285
-	public function get_created_via( $context = 'view' ) {
1286
-		return $this->get_prop( 'created_via', $context );
1285
+	public function get_created_via($context = 'view') {
1286
+		return $this->get_prop('created_via', $context);
1287 1287
 	}
1288 1288
 
1289 1289
 	/**
@@ -1293,8 +1293,8 @@  discard block
 block discarded – undo
1293 1293
 	 * @param  string $context View or edit context.
1294 1294
 	 * @return bool
1295 1295
 	 */
1296
-	public function get_address_confirmed( $context = 'view' ) {
1297
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1296
+	public function get_address_confirmed($context = 'view') {
1297
+		return (bool) $this->get_prop('address_confirmed', $context);
1298 1298
     }
1299 1299
 
1300 1300
     /**
@@ -1304,8 +1304,8 @@  discard block
 block discarded – undo
1304 1304
 	 * @param  string $context View or edit context.
1305 1305
 	 * @return bool
1306 1306
 	 */
1307
-	public function get_user_address_confirmed( $context = 'view' ) {
1308
-		return $this->get_address_confirmed( $context );
1307
+	public function get_user_address_confirmed($context = 'view') {
1308
+		return $this->get_address_confirmed($context);
1309 1309
     }
1310 1310
 
1311 1311
     /**
@@ -1315,8 +1315,8 @@  discard block
 block discarded – undo
1315 1315
 	 * @param  string $context View or edit context.
1316 1316
 	 * @return bool
1317 1317
 	 */
1318
-	public function get_customer_address_confirmed( $context = 'view' ) {
1319
-		return $this->get_address_confirmed( $context );
1318
+	public function get_customer_address_confirmed($context = 'view') {
1319
+		return $this->get_address_confirmed($context);
1320 1320
     }
1321 1321
 
1322 1322
     /**
@@ -1326,12 +1326,12 @@  discard block
 block discarded – undo
1326 1326
 	 * @param  string $context View or edit context.
1327 1327
 	 * @return float
1328 1328
 	 */
1329
-	public function get_subtotal( $context = 'view' ) {
1330
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1329
+	public function get_subtotal($context = 'view') {
1330
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1331 1331
 
1332 1332
         // Backwards compatibility.
1333
-        if ( is_bool( $context ) && $context ) {
1334
-            return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() );
1333
+        if (is_bool($context) && $context) {
1334
+            return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency());
1335 1335
         }
1336 1336
 
1337 1337
         return $subtotal;
@@ -1344,8 +1344,8 @@  discard block
 block discarded – undo
1344 1344
 	 * @param  string $context View or edit context.
1345 1345
 	 * @return float
1346 1346
 	 */
1347
-	public function get_total_discount( $context = 'view' ) {
1348
-		return (float) $this->get_prop( 'total_discount', $context );
1347
+	public function get_total_discount($context = 'view') {
1348
+		return (float) $this->get_prop('total_discount', $context);
1349 1349
     }
1350 1350
 
1351 1351
     /**
@@ -1355,18 +1355,18 @@  discard block
 block discarded – undo
1355 1355
 	 * @param  string $context View or edit context.
1356 1356
 	 * @return float
1357 1357
 	 */
1358
-	public function get_total_tax( $context = 'view' ) {
1359
-		return (float) $this->get_prop( 'total_tax', $context );
1358
+	public function get_total_tax($context = 'view') {
1359
+		return (float) $this->get_prop('total_tax', $context);
1360 1360
 	}
1361 1361
 
1362 1362
 	/**
1363 1363
 	 * @deprecated
1364 1364
 	 */
1365
-	public function get_final_tax( $currency = false ) {
1365
+	public function get_final_tax($currency = false) {
1366 1366
 		$tax = $this->get_total_tax();
1367 1367
 
1368
-        if ( $currency ) {
1369
-			return wpinv_price( $tax, $this->get_currency() );
1368
+        if ($currency) {
1369
+			return wpinv_price($tax, $this->get_currency());
1370 1370
         }
1371 1371
 
1372 1372
         return $tax;
@@ -1379,8 +1379,8 @@  discard block
 block discarded – undo
1379 1379
 	 * @param  string $context View or edit context.
1380 1380
 	 * @return float
1381 1381
 	 */
1382
-	public function get_total_fees( $context = 'view' ) {
1383
-		return (float) $this->get_prop( 'total_fees', $context );
1382
+	public function get_total_fees($context = 'view') {
1383
+		return (float) $this->get_prop('total_fees', $context);
1384 1384
     }
1385 1385
 
1386 1386
     /**
@@ -1390,8 +1390,8 @@  discard block
 block discarded – undo
1390 1390
 	 * @param  string $context View or edit context.
1391 1391
 	 * @return float
1392 1392
 	 */
1393
-	public function get_fees_total( $context = 'view' ) {
1394
-		return $this->get_total_fees( $context );
1393
+	public function get_fees_total($context = 'view') {
1394
+		return $this->get_total_fees($context);
1395 1395
     }
1396 1396
 
1397 1397
     /**
@@ -1402,7 +1402,7 @@  discard block
 block discarded – undo
1402 1402
 	 */
1403 1403
 	public function get_total() {
1404 1404
 		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1405
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1405
+		return apply_filters('getpaid_get_invoice_total_amount', $total, $this);
1406 1406
 	}
1407 1407
 	
1408 1408
 	/**
@@ -1424,7 +1424,7 @@  discard block
 block discarded – undo
1424 1424
 	 */
1425 1425
     public function get_initial_total() {
1426 1426
 
1427
-		if ( empty( $this->totals ) ) {
1427
+		if (empty($this->totals)) {
1428 1428
 			$this->recalculate_total();
1429 1429
 		}
1430 1430
 
@@ -1434,11 +1434,11 @@  discard block
 block discarded – undo
1434 1434
 		$subtotal = $this->totals['subtotal']['initial'];
1435 1435
 		$total    = $tax + $fee - $discount + $subtotal;
1436 1436
 
1437
-		if ( 0 > $total ) {
1437
+		if (0 > $total) {
1438 1438
 			$total = 0;
1439 1439
 		}
1440 1440
 
1441
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1441
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1442 1442
 	}
1443 1443
 
1444 1444
 	/**
@@ -1450,7 +1450,7 @@  discard block
 block discarded – undo
1450 1450
 	 */
1451 1451
     public function get_recurring_total() {
1452 1452
 
1453
-		if ( empty( $this->totals ) ) {
1453
+		if (empty($this->totals)) {
1454 1454
 			$this->recalculate_total();
1455 1455
 		}
1456 1456
 
@@ -1460,11 +1460,11 @@  discard block
 block discarded – undo
1460 1460
 		$subtotal = $this->totals['subtotal']['recurring'];
1461 1461
 		$total    = $tax + $fee - $discount + $subtotal;
1462 1462
 
1463
-		if ( 0 > $total ) {
1463
+		if (0 > $total) {
1464 1464
 			$total = 0;
1465 1465
 		}
1466 1466
 
1467
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1467
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1468 1468
 	}
1469 1469
 
1470 1470
 	/**
@@ -1475,10 +1475,10 @@  discard block
 block discarded – undo
1475 1475
 	 * @param string $currency Whether to include the currency.
1476 1476
      * @return float|string
1477 1477
 	 */
1478
-    public function get_recurring_details( $field = '', $currency = false ) {
1478
+    public function get_recurring_details($field = '', $currency = false) {
1479 1479
 
1480 1480
 		// Maybe recalculate totals.
1481
-		if ( empty( $this->totals ) ) {
1481
+		if (empty($this->totals)) {
1482 1482
 			$this->recalculate_total();
1483 1483
 		}
1484 1484
 
@@ -1498,8 +1498,8 @@  discard block
 block discarded – undo
1498 1498
 			$currency
1499 1499
 		);
1500 1500
 
1501
-        if ( isset( $data[$field] ) ) {
1502
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1501
+        if (isset($data[$field])) {
1502
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1503 1503
         }
1504 1504
 
1505 1505
         return $data;
@@ -1512,8 +1512,8 @@  discard block
 block discarded – undo
1512 1512
 	 * @param  string $context View or edit context.
1513 1513
 	 * @return array
1514 1514
 	 */
1515
-	public function get_fees( $context = 'view' ) {
1516
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1515
+	public function get_fees($context = 'view') {
1516
+		return wpinv_parse_list($this->get_prop('fees', $context));
1517 1517
     }
1518 1518
 
1519 1519
     /**
@@ -1523,8 +1523,8 @@  discard block
 block discarded – undo
1523 1523
 	 * @param  string $context View or edit context.
1524 1524
 	 * @return array
1525 1525
 	 */
1526
-	public function get_discounts( $context = 'view' ) {
1527
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1526
+	public function get_discounts($context = 'view') {
1527
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1528 1528
     }
1529 1529
 
1530 1530
     /**
@@ -1534,8 +1534,8 @@  discard block
 block discarded – undo
1534 1534
 	 * @param  string $context View or edit context.
1535 1535
 	 * @return array
1536 1536
 	 */
1537
-	public function get_taxes( $context = 'view' ) {
1538
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1537
+	public function get_taxes($context = 'view') {
1538
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1539 1539
     }
1540 1540
 
1541 1541
     /**
@@ -1545,8 +1545,8 @@  discard block
 block discarded – undo
1545 1545
 	 * @param  string $context View or edit context.
1546 1546
 	 * @return GetPaid_Form_Item[]
1547 1547
 	 */
1548
-	public function get_items( $context = 'view' ) {
1549
-        return $this->get_prop( 'items', $context );
1548
+	public function get_items($context = 'view') {
1549
+        return $this->get_prop('items', $context);
1550 1550
     }
1551 1551
 
1552 1552
     /**
@@ -1556,8 +1556,8 @@  discard block
 block discarded – undo
1556 1556
 	 * @param  string $context View or edit context.
1557 1557
 	 * @return int
1558 1558
 	 */
1559
-	public function get_payment_form( $context = 'view' ) {
1560
-		return intval( $this->get_prop( 'payment_form', $context ) );
1559
+	public function get_payment_form($context = 'view') {
1560
+		return intval($this->get_prop('payment_form', $context));
1561 1561
     }
1562 1562
 
1563 1563
     /**
@@ -1567,8 +1567,8 @@  discard block
 block discarded – undo
1567 1567
 	 * @param  string $context View or edit context.
1568 1568
 	 * @return string
1569 1569
 	 */
1570
-	public function get_submission_id( $context = 'view' ) {
1571
-		return $this->get_prop( 'submission_id', $context );
1570
+	public function get_submission_id($context = 'view') {
1571
+		return $this->get_prop('submission_id', $context);
1572 1572
     }
1573 1573
 
1574 1574
     /**
@@ -1578,8 +1578,8 @@  discard block
 block discarded – undo
1578 1578
 	 * @param  string $context View or edit context.
1579 1579
 	 * @return string
1580 1580
 	 */
1581
-	public function get_discount_code( $context = 'view' ) {
1582
-		return $this->get_prop( 'discount_code', $context );
1581
+	public function get_discount_code($context = 'view') {
1582
+		return $this->get_prop('discount_code', $context);
1583 1583
     }
1584 1584
 
1585 1585
     /**
@@ -1589,8 +1589,8 @@  discard block
 block discarded – undo
1589 1589
 	 * @param  string $context View or edit context.
1590 1590
 	 * @return string
1591 1591
 	 */
1592
-	public function get_gateway( $context = 'view' ) {
1593
-		return $this->get_prop( 'gateway', $context );
1592
+	public function get_gateway($context = 'view') {
1593
+		return $this->get_prop('gateway', $context);
1594 1594
     }
1595 1595
 
1596 1596
     /**
@@ -1600,8 +1600,8 @@  discard block
 block discarded – undo
1600 1600
 	 * @return string
1601 1601
 	 */
1602 1602
     public function get_gateway_title() {
1603
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1604
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1603
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1604
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1605 1605
     }
1606 1606
 
1607 1607
     /**
@@ -1611,8 +1611,8 @@  discard block
 block discarded – undo
1611 1611
 	 * @param  string $context View or edit context.
1612 1612
 	 * @return string
1613 1613
 	 */
1614
-	public function get_transaction_id( $context = 'view' ) {
1615
-		return $this->get_prop( 'transaction_id', $context );
1614
+	public function get_transaction_id($context = 'view') {
1615
+		return $this->get_prop('transaction_id', $context);
1616 1616
     }
1617 1617
 
1618 1618
     /**
@@ -1622,9 +1622,9 @@  discard block
 block discarded – undo
1622 1622
 	 * @param  string $context View or edit context.
1623 1623
 	 * @return string
1624 1624
 	 */
1625
-	public function get_currency( $context = 'view' ) {
1626
-        $currency = $this->get_prop( 'currency', $context );
1627
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1625
+	public function get_currency($context = 'view') {
1626
+        $currency = $this->get_prop('currency', $context);
1627
+        return empty($currency) ? wpinv_get_currency() : $currency;
1628 1628
     }
1629 1629
 
1630 1630
     /**
@@ -1634,8 +1634,8 @@  discard block
 block discarded – undo
1634 1634
 	 * @param  string $context View or edit context.
1635 1635
 	 * @return bool
1636 1636
 	 */
1637
-	public function get_disable_taxes( $context = 'view' ) {
1638
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1637
+	public function get_disable_taxes($context = 'view') {
1638
+        return (bool) $this->get_prop('disable_taxes', $context);
1639 1639
     }
1640 1640
 
1641 1641
     /**
@@ -1645,8 +1645,8 @@  discard block
 block discarded – undo
1645 1645
 	 * @param  string $context View or edit context.
1646 1646
 	 * @return int
1647 1647
 	 */
1648
-    public function get_subscription_id( $context = 'view' ) {
1649
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1648
+    public function get_subscription_id($context = 'view') {
1649
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1650 1650
 	}
1651 1651
 
1652 1652
 	/**
@@ -1656,12 +1656,12 @@  discard block
 block discarded – undo
1656 1656
 	 * @param  string $context View or edit context.
1657 1657
 	 * @return int
1658 1658
 	 */
1659
-    public function get_remote_subscription_id( $context = 'view' ) {
1660
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1659
+    public function get_remote_subscription_id($context = 'view') {
1660
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1661 1661
 
1662
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1662
+        if (empty($subscription_id) && $this->is_renewal()) {
1663 1663
             $parent = $this->get_parent();
1664
-            return $parent->get_subscription_id( $context );
1664
+            return $parent->get_subscription_id($context);
1665 1665
         }
1666 1666
 
1667 1667
         return $subscription_id;
@@ -1674,20 +1674,20 @@  discard block
 block discarded – undo
1674 1674
 	 * @param  string $context View or edit context.
1675 1675
 	 * @return array
1676 1676
 	 */
1677
-    public function get_payment_meta( $context = 'view' ) {
1677
+    public function get_payment_meta($context = 'view') {
1678 1678
 
1679 1679
         return array(
1680
-            'price'        => $this->get_total( $context ),
1681
-            'date'         => $this->get_date_created( $context ),
1682
-            'user_email'   => $this->get_email( $context ),
1683
-            'invoice_key'  => $this->get_key( $context ),
1684
-            'currency'     => $this->get_currency( $context ),
1685
-            'items'        => $this->get_items( $context ),
1686
-            'user_info'    => $this->get_user_info( $context ),
1680
+            'price'        => $this->get_total($context),
1681
+            'date'         => $this->get_date_created($context),
1682
+            'user_email'   => $this->get_email($context),
1683
+            'invoice_key'  => $this->get_key($context),
1684
+            'currency'     => $this->get_currency($context),
1685
+            'items'        => $this->get_items($context),
1686
+            'user_info'    => $this->get_user_info($context),
1687 1687
             'cart_details' => $this->get_cart_details(),
1688
-            'status'       => $this->get_status( $context ),
1689
-            'fees'         => $this->get_fees( $context ),
1690
-            'taxes'        => $this->get_taxes( $context ),
1688
+            'status'       => $this->get_status($context),
1689
+            'fees'         => $this->get_fees($context),
1690
+            'taxes'        => $this->get_taxes($context),
1691 1691
         );
1692 1692
 
1693 1693
     }
@@ -1702,9 +1702,9 @@  discard block
 block discarded – undo
1702 1702
         $items        = $this->get_items();
1703 1703
         $cart_details = array();
1704 1704
 
1705
-        foreach ( $items as $item_id => $item ) {
1705
+        foreach ($items as $item_id => $item) {
1706 1706
 			$item->invoice_id = $this->get_id();
1707
-            $cart_details[]   = $item->prepare_data_for_saving();
1707
+            $cart_details[] = $item->prepare_data_for_saving();
1708 1708
         }
1709 1709
 
1710 1710
         return $cart_details;
@@ -1715,11 +1715,11 @@  discard block
 block discarded – undo
1715 1715
 	 *
1716 1716
 	 * @return null|GetPaid_Form_Item|int
1717 1717
 	 */
1718
-	public function get_recurring( $object = false ) {
1718
+	public function get_recurring($object = false) {
1719 1719
 
1720 1720
 		// Are we returning an object?
1721
-        if ( $object ) {
1722
-            return $this->get_item( $this->recurring_item );
1721
+        if ($object) {
1722
+            return $this->get_item($this->recurring_item);
1723 1723
         }
1724 1724
 
1725 1725
         return $this->recurring_item;
@@ -1734,15 +1734,15 @@  discard block
 block discarded – undo
1734 1734
 	public function get_subscription_name() {
1735 1735
 
1736 1736
 		// Retrieve the recurring name
1737
-        $item = $this->get_recurring( true );
1737
+        $item = $this->get_recurring(true);
1738 1738
 
1739 1739
 		// Abort if it does not exist.
1740
-        if ( empty( $item ) ) {
1740
+        if (empty($item)) {
1741 1741
             return '';
1742 1742
         }
1743 1743
 
1744 1744
 		// Return the item name.
1745
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1745
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1746 1746
 	}
1747 1747
 
1748 1748
 	/**
@@ -1752,9 +1752,9 @@  discard block
 block discarded – undo
1752 1752
 	 * @return string
1753 1753
 	 */
1754 1754
 	public function get_view_url() {
1755
-        $invoice_url = get_permalink( $this->get_id() );
1756
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1757
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1755
+        $invoice_url = get_permalink($this->get_id());
1756
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1757
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1758 1758
 	}
1759 1759
 
1760 1760
 	/**
@@ -1763,25 +1763,25 @@  discard block
 block discarded – undo
1763 1763
 	 * @since 1.0.19
1764 1764
 	 * @return string
1765 1765
 	 */
1766
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1766
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1767 1767
 
1768 1768
 		// Retrieve the checkout url.
1769 1769
         $pay_url = wpinv_get_checkout_uri();
1770 1770
 
1771 1771
 		// Maybe force ssl.
1772
-        if ( is_ssl() ) {
1773
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1772
+        if (is_ssl()) {
1773
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1774 1774
         }
1775 1775
 
1776 1776
 		// Add the invoice key.
1777
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1777
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1778 1778
 
1779 1779
 		// (Maybe?) add a secret
1780
-        if ( $secret ) {
1781
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1780
+        if ($secret) {
1781
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1782 1782
         }
1783 1783
 
1784
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1784
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1785 1785
 	}
1786 1786
 	
1787 1787
 	/**
@@ -1796,14 +1796,14 @@  discard block
 block discarded – undo
1796 1796
         $receipt_url = wpinv_get_success_page_uri();
1797 1797
 
1798 1798
 		// Maybe force ssl.
1799
-        if ( is_ssl() ) {
1800
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1799
+        if (is_ssl()) {
1800
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1801 1801
         }
1802 1802
 
1803 1803
 		// Add the invoice key.
1804
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1804
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1805 1805
 
1806
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1806
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1807 1807
 	}
1808 1808
 	
1809 1809
 	/**
@@ -1816,7 +1816,7 @@  discard block
 block discarded – undo
1816 1816
 
1817 1817
 		$type   = $this->get_type();
1818 1818
 		$status = "wpi-$type-pending";
1819
-		return str_replace( '-invoice', '', $status );
1819
+		return str_replace('-invoice', '', $status);
1820 1820
 
1821 1821
 	}
1822 1822
 
@@ -1830,8 +1830,8 @@  discard block
 block discarded – undo
1830 1830
 	 * @param  string $context View or edit context.
1831 1831
 	 * @return mixed Value of the given invoice property (if set).
1832 1832
 	 */
1833
-	public function get( $key, $context = 'view' ) {
1834
-        return $this->get_prop( $key, $context );
1833
+	public function get($key, $context = 'view') {
1834
+        return $this->get_prop($key, $context);
1835 1835
 	}
1836 1836
 
1837 1837
     /*
@@ -1854,11 +1854,11 @@  discard block
 block discarded – undo
1854 1854
 	 * @param  mixed $value new value.
1855 1855
 	 * @return mixed Value of the given invoice property (if set).
1856 1856
 	 */
1857
-	public function set( $key, $value ) {
1857
+	public function set($key, $value) {
1858 1858
 
1859 1859
         $setter = "set_$key";
1860
-        if ( is_callable( array( $this, $setter ) ) ) {
1861
-            $this->{$setter}( $value );
1860
+        if (is_callable(array($this, $setter))) {
1861
+            $this->{$setter}($value);
1862 1862
         }
1863 1863
 
1864 1864
 	}
@@ -1872,47 +1872,47 @@  discard block
 block discarded – undo
1872 1872
 	 * @param bool   $manual_update Is this a manual status change?.
1873 1873
 	 * @return array details of change.
1874 1874
 	 */
1875
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1875
+	public function set_status($new_status, $note = '', $manual_update = false) {
1876 1876
 		$old_status = $this->get_status();
1877 1877
 
1878 1878
 		$statuses = $this->get_all_statuses();
1879 1879
 
1880
-		if ( isset( $statuses[ 'draft' ] ) ) {
1881
-			unset( $statuses[ 'draft' ] );
1880
+		if (isset($statuses['draft'])) {
1881
+			unset($statuses['draft']);
1882 1882
 		}
1883 1883
 
1884
-		$this->set_prop( 'status', $new_status );
1884
+		$this->set_prop('status', $new_status);
1885 1885
 
1886 1886
 		// If setting the status, ensure it's set to a valid status.
1887
-		if ( true === $this->object_read ) {
1887
+		if (true === $this->object_read) {
1888 1888
 
1889 1889
 			// Only allow valid new status.
1890
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1890
+			if (!array_key_exists($new_status, $statuses)) {
1891 1891
 				$new_status = $this->get_default_status();
1892 1892
 			}
1893 1893
 
1894 1894
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1895
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1895
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1896 1896
 				$old_status = $this->get_default_status();
1897 1897
 			}
1898 1898
 
1899 1899
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1900
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1900
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
1901 1901
 				$old_status = 'wpi-pending';
1902 1902
 			}
1903 1903
 
1904 1904
 		}
1905 1905
 
1906
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1906
+		if (true === $this->object_read && $old_status !== $new_status) {
1907 1907
 			$this->status_transition = array(
1908
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1908
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1909 1909
 				'to'     => $new_status,
1910 1910
 				'note'   => $note,
1911 1911
 				'manual' => (bool) $manual_update,
1912 1912
 			);
1913 1913
 
1914
-			if ( $manual_update ) {
1915
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1914
+			if ($manual_update) {
1915
+				do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1916 1916
 			}
1917 1917
 
1918 1918
 			$this->maybe_set_date_paid();
@@ -1935,8 +1935,8 @@  discard block
 block discarded – undo
1935 1935
 	 */
1936 1936
 	public function maybe_set_date_paid() {
1937 1937
 
1938
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1939
-			$this->set_date_completed( current_time( 'mysql' ) );
1938
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
1939
+			$this->set_date_completed(current_time('mysql'));
1940 1940
 		}
1941 1941
 	}
1942 1942
 
@@ -1945,11 +1945,11 @@  discard block
 block discarded – undo
1945 1945
 	 *
1946 1946
 	 * @since 1.0.19
1947 1947
 	 */
1948
-	public function set_parent_id( $value ) {
1949
-		if ( $value && ( $value === $this->get_id() ) ) {
1948
+	public function set_parent_id($value) {
1949
+		if ($value && ($value === $this->get_id())) {
1950 1950
 			return;
1951 1951
 		}
1952
-		$this->set_prop( 'parent_id', absint( $value ) );
1952
+		$this->set_prop('parent_id', absint($value));
1953 1953
     }
1954 1954
 
1955 1955
     /**
@@ -1957,8 +1957,8 @@  discard block
 block discarded – undo
1957 1957
 	 *
1958 1958
 	 * @since 1.0.19
1959 1959
 	 */
1960
-	public function set_version( $value ) {
1961
-		$this->set_prop( 'version', $value );
1960
+	public function set_version($value) {
1961
+		$this->set_prop('version', $value);
1962 1962
     }
1963 1963
 
1964 1964
     /**
@@ -1968,15 +1968,15 @@  discard block
 block discarded – undo
1968 1968
 	 * @param string $value Value to set.
1969 1969
      * @return bool Whether or not the date was set.
1970 1970
 	 */
1971
-	public function set_date_created( $value ) {
1972
-        $date = strtotime( $value );
1971
+	public function set_date_created($value) {
1972
+        $date = strtotime($value);
1973 1973
 
1974
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1975
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
1974
+        if ($date && $value !== '0000-00-00 00:00:00') {
1975
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
1976 1976
             return true;
1977 1977
         }
1978 1978
 
1979
-		$this->set_prop( 'date_created', '' );
1979
+		$this->set_prop('date_created', '');
1980 1980
 		return false;
1981 1981
 
1982 1982
     }
@@ -1988,15 +1988,15 @@  discard block
 block discarded – undo
1988 1988
 	 * @param string $value Value to set.
1989 1989
      * @return bool Whether or not the date was set.
1990 1990
 	 */
1991
-	public function set_due_date( $value ) {
1992
-        $date = strtotime( $value );
1991
+	public function set_due_date($value) {
1992
+        $date = strtotime($value);
1993 1993
 
1994
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1995
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
1994
+        if ($date && $value !== '0000-00-00 00:00:00') {
1995
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
1996 1996
             return true;
1997 1997
         }
1998 1998
 
1999
-		$this->set_prop( 'due_date', '' );
1999
+		$this->set_prop('due_date', '');
2000 2000
         return false;
2001 2001
 
2002 2002
     }
@@ -2007,8 +2007,8 @@  discard block
 block discarded – undo
2007 2007
 	 * @since 1.0.19
2008 2008
 	 * @param  string $value New name.
2009 2009
 	 */
2010
-	public function set_date_due( $value ) {
2011
-		$this->set_due_date( $value );
2010
+	public function set_date_due($value) {
2011
+		$this->set_due_date($value);
2012 2012
     }
2013 2013
 
2014 2014
     /**
@@ -2018,15 +2018,15 @@  discard block
 block discarded – undo
2018 2018
 	 * @param string $value Value to set.
2019 2019
      * @return bool Whether or not the date was set.
2020 2020
 	 */
2021
-	public function set_completed_date( $value ) {
2022
-        $date = strtotime( $value );
2021
+	public function set_completed_date($value) {
2022
+        $date = strtotime($value);
2023 2023
 
2024
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
2025
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2024
+        if ($date && $value !== '0000-00-00 00:00:00') {
2025
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2026 2026
             return true;
2027 2027
         }
2028 2028
 
2029
-		$this->set_prop( 'completed_date', '' );
2029
+		$this->set_prop('completed_date', '');
2030 2030
         return false;
2031 2031
 
2032 2032
     }
@@ -2037,8 +2037,8 @@  discard block
 block discarded – undo
2037 2037
 	 * @since 1.0.19
2038 2038
 	 * @param  string $value New name.
2039 2039
 	 */
2040
-	public function set_date_completed( $value ) {
2041
-		$this->set_completed_date( $value );
2040
+	public function set_date_completed($value) {
2041
+		$this->set_completed_date($value);
2042 2042
     }
2043 2043
 
2044 2044
     /**
@@ -2048,15 +2048,15 @@  discard block
 block discarded – undo
2048 2048
 	 * @param string $value Value to set.
2049 2049
      * @return bool Whether or not the date was set.
2050 2050
 	 */
2051
-	public function set_date_modified( $value ) {
2052
-        $date = strtotime( $value );
2051
+	public function set_date_modified($value) {
2052
+        $date = strtotime($value);
2053 2053
 
2054
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2055
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2054
+        if ($date && $value !== '0000-00-00 00:00:00') {
2055
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2056 2056
             return true;
2057 2057
         }
2058 2058
 
2059
-		$this->set_prop( 'date_modified', '' );
2059
+		$this->set_prop('date_modified', '');
2060 2060
         return false;
2061 2061
 
2062 2062
     }
@@ -2067,9 +2067,9 @@  discard block
 block discarded – undo
2067 2067
 	 * @since 1.0.19
2068 2068
 	 * @param  string $value New number.
2069 2069
 	 */
2070
-	public function set_number( $value ) {
2071
-        $number = sanitize_text_field( $value );
2072
-		$this->set_prop( 'number', $number );
2070
+	public function set_number($value) {
2071
+        $number = sanitize_text_field($value);
2072
+		$this->set_prop('number', $number);
2073 2073
     }
2074 2074
 
2075 2075
     /**
@@ -2078,9 +2078,9 @@  discard block
 block discarded – undo
2078 2078
 	 * @since 1.0.19
2079 2079
 	 * @param  string $value Type.
2080 2080
 	 */
2081
-	public function set_type( $value ) {
2082
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2083
-		$this->set_prop( 'type', $type );
2081
+	public function set_type($value) {
2082
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2083
+		$this->set_prop('type', $type);
2084 2084
 	}
2085 2085
 
2086 2086
     /**
@@ -2089,10 +2089,10 @@  discard block
 block discarded – undo
2089 2089
 	 * @since 1.0.19
2090 2090
 	 * @param  string $value Post type.
2091 2091
 	 */
2092
-	public function set_post_type( $value ) {
2093
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2094
-			$this->set_type( $value );
2095
-            $this->set_prop( 'post_type', $value );
2092
+	public function set_post_type($value) {
2093
+        if (getpaid_is_invoice_post_type($value)) {
2094
+			$this->set_type($value);
2095
+            $this->set_prop('post_type', $value);
2096 2096
         }
2097 2097
     }
2098 2098
 
@@ -2102,9 +2102,9 @@  discard block
 block discarded – undo
2102 2102
 	 * @since 1.0.19
2103 2103
 	 * @param  string $value New key.
2104 2104
 	 */
2105
-	public function set_key( $value ) {
2106
-        $key = sanitize_text_field( $value );
2107
-		$this->set_prop( 'key', $key );
2105
+	public function set_key($value) {
2106
+        $key = sanitize_text_field($value);
2107
+		$this->set_prop('key', $key);
2108 2108
     }
2109 2109
 
2110 2110
     /**
@@ -2113,9 +2113,9 @@  discard block
 block discarded – undo
2113 2113
 	 * @since 1.0.19
2114 2114
 	 * @param  string $value mode.
2115 2115
 	 */
2116
-	public function set_mode( $value ) {
2117
-        if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2118
-            $this->set_prop( 'value', $value );
2116
+	public function set_mode($value) {
2117
+        if (!in_array($value, array('live', 'test'))) {
2118
+            $this->set_prop('value', $value);
2119 2119
         }
2120 2120
     }
2121 2121
 
@@ -2125,8 +2125,8 @@  discard block
 block discarded – undo
2125 2125
 	 * @since 1.0.19
2126 2126
 	 * @param  string $value path.
2127 2127
 	 */
2128
-	public function set_path( $value ) {
2129
-        $this->set_prop( 'path', $value );
2128
+	public function set_path($value) {
2129
+        $this->set_prop('path', $value);
2130 2130
     }
2131 2131
 
2132 2132
     /**
@@ -2135,9 +2135,9 @@  discard block
 block discarded – undo
2135 2135
 	 * @since 1.0.19
2136 2136
 	 * @param  string $value New name.
2137 2137
 	 */
2138
-	public function set_name( $value ) {
2139
-        $name = sanitize_text_field( $value );
2140
-		$this->set_prop( 'name', $name );
2138
+	public function set_name($value) {
2139
+        $name = sanitize_text_field($value);
2140
+		$this->set_prop('name', $name);
2141 2141
     }
2142 2142
 
2143 2143
     /**
@@ -2146,8 +2146,8 @@  discard block
 block discarded – undo
2146 2146
 	 * @since 1.0.19
2147 2147
 	 * @param  string $value New name.
2148 2148
 	 */
2149
-	public function set_title( $value ) {
2150
-		$this->set_name( $value );
2149
+	public function set_title($value) {
2150
+		$this->set_name($value);
2151 2151
     }
2152 2152
 
2153 2153
     /**
@@ -2156,9 +2156,9 @@  discard block
 block discarded – undo
2156 2156
 	 * @since 1.0.19
2157 2157
 	 * @param  string $value New description.
2158 2158
 	 */
2159
-	public function set_description( $value ) {
2160
-        $description = wp_kses_post( $value );
2161
-		$this->set_prop( 'description', $description );
2159
+	public function set_description($value) {
2160
+        $description = wp_kses_post($value);
2161
+		$this->set_prop('description', $description);
2162 2162
     }
2163 2163
 
2164 2164
     /**
@@ -2167,8 +2167,8 @@  discard block
 block discarded – undo
2167 2167
 	 * @since 1.0.19
2168 2168
 	 * @param  string $value New description.
2169 2169
 	 */
2170
-	public function set_excerpt( $value ) {
2171
-		$this->set_description( $value );
2170
+	public function set_excerpt($value) {
2171
+		$this->set_description($value);
2172 2172
     }
2173 2173
 
2174 2174
     /**
@@ -2177,8 +2177,8 @@  discard block
 block discarded – undo
2177 2177
 	 * @since 1.0.19
2178 2178
 	 * @param  string $value New description.
2179 2179
 	 */
2180
-	public function set_summary( $value ) {
2181
-		$this->set_description( $value );
2180
+	public function set_summary($value) {
2181
+		$this->set_description($value);
2182 2182
     }
2183 2183
 
2184 2184
     /**
@@ -2187,12 +2187,12 @@  discard block
 block discarded – undo
2187 2187
 	 * @since 1.0.19
2188 2188
 	 * @param  int $value New author.
2189 2189
 	 */
2190
-	public function set_author( $value ) {
2191
-		$user = get_user_by( 'id', (int) $value );
2190
+	public function set_author($value) {
2191
+		$user = get_user_by('id', (int) $value);
2192 2192
 
2193
-		if ( $user && $user->ID ) {
2194
-			$this->set_prop( 'author', $user->ID );
2195
-			$this->set_prop( 'email', $user->user_email );
2193
+		if ($user && $user->ID) {
2194
+			$this->set_prop('author', $user->ID);
2195
+			$this->set_prop('email', $user->user_email);
2196 2196
 		}
2197 2197
 
2198 2198
     }
@@ -2203,8 +2203,8 @@  discard block
 block discarded – undo
2203 2203
 	 * @since 1.0.19
2204 2204
 	 * @param  int $value New user id.
2205 2205
 	 */
2206
-	public function set_user_id( $value ) {
2207
-		$this->set_author( $value );
2206
+	public function set_user_id($value) {
2207
+		$this->set_author($value);
2208 2208
     }
2209 2209
 
2210 2210
     /**
@@ -2213,8 +2213,8 @@  discard block
 block discarded – undo
2213 2213
 	 * @since 1.0.19
2214 2214
 	 * @param  int $value New user id.
2215 2215
 	 */
2216
-	public function set_customer_id( $value ) {
2217
-		$this->set_author( $value );
2216
+	public function set_customer_id($value) {
2217
+		$this->set_author($value);
2218 2218
     }
2219 2219
 
2220 2220
     /**
@@ -2223,8 +2223,8 @@  discard block
 block discarded – undo
2223 2223
 	 * @since 1.0.19
2224 2224
 	 * @param  string $value ip address.
2225 2225
 	 */
2226
-	public function set_ip( $value ) {
2227
-		$this->set_prop( 'ip', $value );
2226
+	public function set_ip($value) {
2227
+		$this->set_prop('ip', $value);
2228 2228
     }
2229 2229
 
2230 2230
     /**
@@ -2233,8 +2233,8 @@  discard block
 block discarded – undo
2233 2233
 	 * @since 1.0.19
2234 2234
 	 * @param  string $value ip address.
2235 2235
 	 */
2236
-	public function set_user_ip( $value ) {
2237
-		$this->set_ip( $value );
2236
+	public function set_user_ip($value) {
2237
+		$this->set_ip($value);
2238 2238
     }
2239 2239
 
2240 2240
     /**
@@ -2243,8 +2243,8 @@  discard block
 block discarded – undo
2243 2243
 	 * @since 1.0.19
2244 2244
 	 * @param  string $value first name.
2245 2245
 	 */
2246
-	public function set_first_name( $value ) {
2247
-		$this->set_prop( 'first_name', $value );
2246
+	public function set_first_name($value) {
2247
+		$this->set_prop('first_name', $value);
2248 2248
     }
2249 2249
 
2250 2250
     /**
@@ -2253,8 +2253,8 @@  discard block
 block discarded – undo
2253 2253
 	 * @since 1.0.19
2254 2254
 	 * @param  string $value first name.
2255 2255
 	 */
2256
-	public function set_user_first_name( $value ) {
2257
-		$this->set_first_name( $value );
2256
+	public function set_user_first_name($value) {
2257
+		$this->set_first_name($value);
2258 2258
     }
2259 2259
 
2260 2260
     /**
@@ -2263,8 +2263,8 @@  discard block
 block discarded – undo
2263 2263
 	 * @since 1.0.19
2264 2264
 	 * @param  string $value first name.
2265 2265
 	 */
2266
-	public function set_customer_first_name( $value ) {
2267
-		$this->set_first_name( $value );
2266
+	public function set_customer_first_name($value) {
2267
+		$this->set_first_name($value);
2268 2268
     }
2269 2269
 
2270 2270
     /**
@@ -2273,8 +2273,8 @@  discard block
 block discarded – undo
2273 2273
 	 * @since 1.0.19
2274 2274
 	 * @param  string $value last name.
2275 2275
 	 */
2276
-	public function set_last_name( $value ) {
2277
-		$this->set_prop( 'last_name', $value );
2276
+	public function set_last_name($value) {
2277
+		$this->set_prop('last_name', $value);
2278 2278
     }
2279 2279
 
2280 2280
     /**
@@ -2283,8 +2283,8 @@  discard block
 block discarded – undo
2283 2283
 	 * @since 1.0.19
2284 2284
 	 * @param  string $value last name.
2285 2285
 	 */
2286
-	public function set_user_last_name( $value ) {
2287
-		$this->set_last_name( $value );
2286
+	public function set_user_last_name($value) {
2287
+		$this->set_last_name($value);
2288 2288
     }
2289 2289
 
2290 2290
     /**
@@ -2293,8 +2293,8 @@  discard block
 block discarded – undo
2293 2293
 	 * @since 1.0.19
2294 2294
 	 * @param  string $value last name.
2295 2295
 	 */
2296
-	public function set_customer_last_name( $value ) {
2297
-		$this->set_last_name( $value );
2296
+	public function set_customer_last_name($value) {
2297
+		$this->set_last_name($value);
2298 2298
     }
2299 2299
 
2300 2300
     /**
@@ -2303,8 +2303,8 @@  discard block
 block discarded – undo
2303 2303
 	 * @since 1.0.19
2304 2304
 	 * @param  string $value phone.
2305 2305
 	 */
2306
-	public function set_phone( $value ) {
2307
-		$this->set_prop( 'phone', $value );
2306
+	public function set_phone($value) {
2307
+		$this->set_prop('phone', $value);
2308 2308
     }
2309 2309
 
2310 2310
     /**
@@ -2313,8 +2313,8 @@  discard block
 block discarded – undo
2313 2313
 	 * @since 1.0.19
2314 2314
 	 * @param  string $value phone.
2315 2315
 	 */
2316
-	public function set_user_phone( $value ) {
2317
-		$this->set_phone( $value );
2316
+	public function set_user_phone($value) {
2317
+		$this->set_phone($value);
2318 2318
     }
2319 2319
 
2320 2320
     /**
@@ -2323,8 +2323,8 @@  discard block
 block discarded – undo
2323 2323
 	 * @since 1.0.19
2324 2324
 	 * @param  string $value phone.
2325 2325
 	 */
2326
-	public function set_customer_phone( $value ) {
2327
-		$this->set_phone( $value );
2326
+	public function set_customer_phone($value) {
2327
+		$this->set_phone($value);
2328 2328
     }
2329 2329
 
2330 2330
     /**
@@ -2333,8 +2333,8 @@  discard block
 block discarded – undo
2333 2333
 	 * @since 1.0.19
2334 2334
 	 * @param  string $value phone.
2335 2335
 	 */
2336
-	public function set_phone_number( $value ) {
2337
-		$this->set_phone( $value );
2336
+	public function set_phone_number($value) {
2337
+		$this->set_phone($value);
2338 2338
     }
2339 2339
 
2340 2340
     /**
@@ -2343,8 +2343,8 @@  discard block
 block discarded – undo
2343 2343
 	 * @since 1.0.19
2344 2344
 	 * @param  string $value email address.
2345 2345
 	 */
2346
-	public function set_email( $value ) {
2347
-		$this->set_prop( 'email', $value );
2346
+	public function set_email($value) {
2347
+		$this->set_prop('email', $value);
2348 2348
     }
2349 2349
 
2350 2350
     /**
@@ -2353,8 +2353,8 @@  discard block
 block discarded – undo
2353 2353
 	 * @since 1.0.19
2354 2354
 	 * @param  string $value email address.
2355 2355
 	 */
2356
-	public function set_user_email( $value ) {
2357
-		$this->set_email( $value );
2356
+	public function set_user_email($value) {
2357
+		$this->set_email($value);
2358 2358
     }
2359 2359
 
2360 2360
     /**
@@ -2363,8 +2363,8 @@  discard block
 block discarded – undo
2363 2363
 	 * @since 1.0.19
2364 2364
 	 * @param  string $value email address.
2365 2365
 	 */
2366
-	public function set_email_address( $value ) {
2367
-		$this->set_email( $value );
2366
+	public function set_email_address($value) {
2367
+		$this->set_email($value);
2368 2368
     }
2369 2369
 
2370 2370
     /**
@@ -2373,8 +2373,8 @@  discard block
 block discarded – undo
2373 2373
 	 * @since 1.0.19
2374 2374
 	 * @param  string $value email address.
2375 2375
 	 */
2376
-	public function set_customer_email( $value ) {
2377
-		$this->set_email( $value );
2376
+	public function set_customer_email($value) {
2377
+		$this->set_email($value);
2378 2378
     }
2379 2379
 
2380 2380
     /**
@@ -2383,8 +2383,8 @@  discard block
 block discarded – undo
2383 2383
 	 * @since 1.0.19
2384 2384
 	 * @param  string $value country.
2385 2385
 	 */
2386
-	public function set_country( $value ) {
2387
-		$this->set_prop( 'country', $value );
2386
+	public function set_country($value) {
2387
+		$this->set_prop('country', $value);
2388 2388
     }
2389 2389
 
2390 2390
     /**
@@ -2393,8 +2393,8 @@  discard block
 block discarded – undo
2393 2393
 	 * @since 1.0.19
2394 2394
 	 * @param  string $value country.
2395 2395
 	 */
2396
-	public function set_user_country( $value ) {
2397
-		$this->set_country( $value );
2396
+	public function set_user_country($value) {
2397
+		$this->set_country($value);
2398 2398
     }
2399 2399
 
2400 2400
     /**
@@ -2403,8 +2403,8 @@  discard block
 block discarded – undo
2403 2403
 	 * @since 1.0.19
2404 2404
 	 * @param  string $value country.
2405 2405
 	 */
2406
-	public function set_customer_country( $value ) {
2407
-		$this->set_country( $value );
2406
+	public function set_customer_country($value) {
2407
+		$this->set_country($value);
2408 2408
     }
2409 2409
 
2410 2410
     /**
@@ -2413,8 +2413,8 @@  discard block
 block discarded – undo
2413 2413
 	 * @since 1.0.19
2414 2414
 	 * @param  string $value state.
2415 2415
 	 */
2416
-	public function set_state( $value ) {
2417
-		$this->set_prop( 'state', $value );
2416
+	public function set_state($value) {
2417
+		$this->set_prop('state', $value);
2418 2418
     }
2419 2419
 
2420 2420
     /**
@@ -2423,8 +2423,8 @@  discard block
 block discarded – undo
2423 2423
 	 * @since 1.0.19
2424 2424
 	 * @param  string $value state.
2425 2425
 	 */
2426
-	public function set_user_state( $value ) {
2427
-		$this->set_state( $value );
2426
+	public function set_user_state($value) {
2427
+		$this->set_state($value);
2428 2428
     }
2429 2429
 
2430 2430
     /**
@@ -2433,8 +2433,8 @@  discard block
 block discarded – undo
2433 2433
 	 * @since 1.0.19
2434 2434
 	 * @param  string $value state.
2435 2435
 	 */
2436
-	public function set_customer_state( $value ) {
2437
-		$this->set_state( $value );
2436
+	public function set_customer_state($value) {
2437
+		$this->set_state($value);
2438 2438
     }
2439 2439
 
2440 2440
     /**
@@ -2443,8 +2443,8 @@  discard block
 block discarded – undo
2443 2443
 	 * @since 1.0.19
2444 2444
 	 * @param  string $value city.
2445 2445
 	 */
2446
-	public function set_city( $value ) {
2447
-		$this->set_prop( 'city', $value );
2446
+	public function set_city($value) {
2447
+		$this->set_prop('city', $value);
2448 2448
     }
2449 2449
 
2450 2450
     /**
@@ -2453,8 +2453,8 @@  discard block
 block discarded – undo
2453 2453
 	 * @since 1.0.19
2454 2454
 	 * @param  string $value city.
2455 2455
 	 */
2456
-	public function set_user_city( $value ) {
2457
-		$this->set_city( $value );
2456
+	public function set_user_city($value) {
2457
+		$this->set_city($value);
2458 2458
     }
2459 2459
 
2460 2460
     /**
@@ -2463,8 +2463,8 @@  discard block
 block discarded – undo
2463 2463
 	 * @since 1.0.19
2464 2464
 	 * @param  string $value city.
2465 2465
 	 */
2466
-	public function set_customer_city( $value ) {
2467
-		$this->set_city( $value );
2466
+	public function set_customer_city($value) {
2467
+		$this->set_city($value);
2468 2468
     }
2469 2469
 
2470 2470
     /**
@@ -2473,8 +2473,8 @@  discard block
 block discarded – undo
2473 2473
 	 * @since 1.0.19
2474 2474
 	 * @param  string $value zip.
2475 2475
 	 */
2476
-	public function set_zip( $value ) {
2477
-		$this->set_prop( 'zip', $value );
2476
+	public function set_zip($value) {
2477
+		$this->set_prop('zip', $value);
2478 2478
     }
2479 2479
 
2480 2480
     /**
@@ -2483,8 +2483,8 @@  discard block
 block discarded – undo
2483 2483
 	 * @since 1.0.19
2484 2484
 	 * @param  string $value zip.
2485 2485
 	 */
2486
-	public function set_user_zip( $value ) {
2487
-		$this->set_zip( $value );
2486
+	public function set_user_zip($value) {
2487
+		$this->set_zip($value);
2488 2488
     }
2489 2489
 
2490 2490
     /**
@@ -2493,8 +2493,8 @@  discard block
 block discarded – undo
2493 2493
 	 * @since 1.0.19
2494 2494
 	 * @param  string $value zip.
2495 2495
 	 */
2496
-	public function set_customer_zip( $value ) {
2497
-		$this->set_zip( $value );
2496
+	public function set_customer_zip($value) {
2497
+		$this->set_zip($value);
2498 2498
     }
2499 2499
 
2500 2500
     /**
@@ -2503,8 +2503,8 @@  discard block
 block discarded – undo
2503 2503
 	 * @since 1.0.19
2504 2504
 	 * @param  string $value company.
2505 2505
 	 */
2506
-	public function set_company( $value ) {
2507
-		$this->set_prop( 'company', $value );
2506
+	public function set_company($value) {
2507
+		$this->set_prop('company', $value);
2508 2508
     }
2509 2509
 
2510 2510
     /**
@@ -2513,8 +2513,8 @@  discard block
 block discarded – undo
2513 2513
 	 * @since 1.0.19
2514 2514
 	 * @param  string $value company.
2515 2515
 	 */
2516
-	public function set_user_company( $value ) {
2517
-		$this->set_company( $value );
2516
+	public function set_user_company($value) {
2517
+		$this->set_company($value);
2518 2518
     }
2519 2519
 
2520 2520
     /**
@@ -2523,8 +2523,8 @@  discard block
 block discarded – undo
2523 2523
 	 * @since 1.0.19
2524 2524
 	 * @param  string $value company.
2525 2525
 	 */
2526
-	public function set_customer_company( $value ) {
2527
-		$this->set_company( $value );
2526
+	public function set_customer_company($value) {
2527
+		$this->set_company($value);
2528 2528
     }
2529 2529
 
2530 2530
     /**
@@ -2533,8 +2533,8 @@  discard block
 block discarded – undo
2533 2533
 	 * @since 1.0.19
2534 2534
 	 * @param  string $value var number.
2535 2535
 	 */
2536
-	public function set_vat_number( $value ) {
2537
-		$this->set_prop( 'vat_number', $value );
2536
+	public function set_vat_number($value) {
2537
+		$this->set_prop('vat_number', $value);
2538 2538
     }
2539 2539
 
2540 2540
     /**
@@ -2543,8 +2543,8 @@  discard block
 block discarded – undo
2543 2543
 	 * @since 1.0.19
2544 2544
 	 * @param  string $value var number.
2545 2545
 	 */
2546
-	public function set_user_vat_number( $value ) {
2547
-		$this->set_vat_number( $value );
2546
+	public function set_user_vat_number($value) {
2547
+		$this->set_vat_number($value);
2548 2548
     }
2549 2549
 
2550 2550
     /**
@@ -2553,8 +2553,8 @@  discard block
 block discarded – undo
2553 2553
 	 * @since 1.0.19
2554 2554
 	 * @param  string $value var number.
2555 2555
 	 */
2556
-	public function set_customer_vat_number( $value ) {
2557
-		$this->set_vat_number( $value );
2556
+	public function set_customer_vat_number($value) {
2557
+		$this->set_vat_number($value);
2558 2558
     }
2559 2559
 
2560 2560
     /**
@@ -2563,8 +2563,8 @@  discard block
 block discarded – undo
2563 2563
 	 * @since 1.0.19
2564 2564
 	 * @param  string $value var rate.
2565 2565
 	 */
2566
-	public function set_vat_rate( $value ) {
2567
-		$this->set_prop( 'vat_rate', $value );
2566
+	public function set_vat_rate($value) {
2567
+		$this->set_prop('vat_rate', $value);
2568 2568
     }
2569 2569
 
2570 2570
     /**
@@ -2573,8 +2573,8 @@  discard block
 block discarded – undo
2573 2573
 	 * @since 1.0.19
2574 2574
 	 * @param  string $value var number.
2575 2575
 	 */
2576
-	public function set_user_vat_rate( $value ) {
2577
-		$this->set_vat_rate( $value );
2576
+	public function set_user_vat_rate($value) {
2577
+		$this->set_vat_rate($value);
2578 2578
     }
2579 2579
 
2580 2580
     /**
@@ -2583,8 +2583,8 @@  discard block
 block discarded – undo
2583 2583
 	 * @since 1.0.19
2584 2584
 	 * @param  string $value var number.
2585 2585
 	 */
2586
-	public function set_customer_vat_rate( $value ) {
2587
-		$this->set_vat_rate( $value );
2586
+	public function set_customer_vat_rate($value) {
2587
+		$this->set_vat_rate($value);
2588 2588
     }
2589 2589
 
2590 2590
     /**
@@ -2593,8 +2593,8 @@  discard block
 block discarded – undo
2593 2593
 	 * @since 1.0.19
2594 2594
 	 * @param  string $value address.
2595 2595
 	 */
2596
-	public function set_address( $value ) {
2597
-		$this->set_prop( 'address', $value );
2596
+	public function set_address($value) {
2597
+		$this->set_prop('address', $value);
2598 2598
     }
2599 2599
 
2600 2600
     /**
@@ -2603,8 +2603,8 @@  discard block
 block discarded – undo
2603 2603
 	 * @since 1.0.19
2604 2604
 	 * @param  string $value address.
2605 2605
 	 */
2606
-	public function set_user_address( $value ) {
2607
-		$this->set_address( $value );
2606
+	public function set_user_address($value) {
2607
+		$this->set_address($value);
2608 2608
     }
2609 2609
 
2610 2610
     /**
@@ -2613,8 +2613,8 @@  discard block
 block discarded – undo
2613 2613
 	 * @since 1.0.19
2614 2614
 	 * @param  string $value address.
2615 2615
 	 */
2616
-	public function set_customer_address( $value ) {
2617
-		$this->set_address( $value );
2616
+	public function set_customer_address($value) {
2617
+		$this->set_address($value);
2618 2618
     }
2619 2619
 
2620 2620
     /**
@@ -2623,8 +2623,8 @@  discard block
 block discarded – undo
2623 2623
 	 * @since 1.0.19
2624 2624
 	 * @param  int|bool $value confirmed.
2625 2625
 	 */
2626
-	public function set_is_viewed( $value ) {
2627
-		$this->set_prop( 'is_viewed', $value );
2626
+	public function set_is_viewed($value) {
2627
+		$this->set_prop('is_viewed', $value);
2628 2628
 	}
2629 2629
 
2630 2630
 	/**
@@ -2633,8 +2633,8 @@  discard block
 block discarded – undo
2633 2633
 	 * @since 1.0.19
2634 2634
 	 * @param  string $value email recipients.
2635 2635
 	 */
2636
-	public function set_email_cc( $value ) {
2637
-		$this->set_prop( 'email_cc', $value );
2636
+	public function set_email_cc($value) {
2637
+		$this->set_prop('email_cc', $value);
2638 2638
 	}
2639 2639
 
2640 2640
 	/**
@@ -2643,9 +2643,9 @@  discard block
 block discarded – undo
2643 2643
 	 * @since 1.0.19
2644 2644
 	 * @param  string $value template.
2645 2645
 	 */
2646
-	public function set_template( $value ) {
2647
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2648
-			$this->set_prop( 'template', $value );
2646
+	public function set_template($value) {
2647
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2648
+			$this->set_prop('template', $value);
2649 2649
 		}
2650 2650
 	}
2651 2651
 
@@ -2655,8 +2655,8 @@  discard block
 block discarded – undo
2655 2655
 	 * @since 1.0.19
2656 2656
 	 * @param  string $value email recipients.
2657 2657
 	 */
2658
-	public function created_via( $value ) {
2659
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2658
+	public function created_via($value) {
2659
+		$this->set_prop('created_via', sanitize_text_field($value));
2660 2660
 	}
2661 2661
 
2662 2662
 	/**
@@ -2665,8 +2665,8 @@  discard block
 block discarded – undo
2665 2665
 	 * @since 1.0.19
2666 2666
 	 * @param  int|bool $value confirmed.
2667 2667
 	 */
2668
-	public function set_address_confirmed( $value ) {
2669
-		$this->set_prop( 'address_confirmed', $value );
2668
+	public function set_address_confirmed($value) {
2669
+		$this->set_prop('address_confirmed', $value);
2670 2670
     }
2671 2671
 
2672 2672
     /**
@@ -2675,8 +2675,8 @@  discard block
 block discarded – undo
2675 2675
 	 * @since 1.0.19
2676 2676
 	 * @param  int|bool $value confirmed.
2677 2677
 	 */
2678
-	public function set_user_address_confirmed( $value ) {
2679
-		$this->set_address_confirmed( $value );
2678
+	public function set_user_address_confirmed($value) {
2679
+		$this->set_address_confirmed($value);
2680 2680
     }
2681 2681
 
2682 2682
     /**
@@ -2685,8 +2685,8 @@  discard block
 block discarded – undo
2685 2685
 	 * @since 1.0.19
2686 2686
 	 * @param  int|bool $value confirmed.
2687 2687
 	 */
2688
-	public function set_customer_address_confirmed( $value ) {
2689
-		$this->set_address_confirmed( $value );
2688
+	public function set_customer_address_confirmed($value) {
2689
+		$this->set_address_confirmed($value);
2690 2690
     }
2691 2691
 
2692 2692
     /**
@@ -2695,8 +2695,8 @@  discard block
 block discarded – undo
2695 2695
 	 * @since 1.0.19
2696 2696
 	 * @param  float $value sub total.
2697 2697
 	 */
2698
-	public function set_subtotal( $value ) {
2699
-		$this->set_prop( 'subtotal', $value );
2698
+	public function set_subtotal($value) {
2699
+		$this->set_prop('subtotal', $value);
2700 2700
     }
2701 2701
 
2702 2702
     /**
@@ -2705,8 +2705,8 @@  discard block
 block discarded – undo
2705 2705
 	 * @since 1.0.19
2706 2706
 	 * @param  float $value discount total.
2707 2707
 	 */
2708
-	public function set_total_discount( $value ) {
2709
-		$this->set_prop( 'total_discount', $value );
2708
+	public function set_total_discount($value) {
2709
+		$this->set_prop('total_discount', $value);
2710 2710
     }
2711 2711
 
2712 2712
     /**
@@ -2715,8 +2715,8 @@  discard block
 block discarded – undo
2715 2715
 	 * @since 1.0.19
2716 2716
 	 * @param  float $value discount total.
2717 2717
 	 */
2718
-	public function set_discount( $value ) {
2719
-		$this->set_total_discount( $value );
2718
+	public function set_discount($value) {
2719
+		$this->set_total_discount($value);
2720 2720
     }
2721 2721
 
2722 2722
     /**
@@ -2725,8 +2725,8 @@  discard block
 block discarded – undo
2725 2725
 	 * @since 1.0.19
2726 2726
 	 * @param  float $value tax total.
2727 2727
 	 */
2728
-	public function set_total_tax( $value ) {
2729
-		$this->set_prop( 'total_tax', $value );
2728
+	public function set_total_tax($value) {
2729
+		$this->set_prop('total_tax', $value);
2730 2730
     }
2731 2731
 
2732 2732
     /**
@@ -2735,8 +2735,8 @@  discard block
 block discarded – undo
2735 2735
 	 * @since 1.0.19
2736 2736
 	 * @param  float $value tax total.
2737 2737
 	 */
2738
-	public function set_tax_total( $value ) {
2739
-		$this->set_total_tax( $value );
2738
+	public function set_tax_total($value) {
2739
+		$this->set_total_tax($value);
2740 2740
     }
2741 2741
 
2742 2742
     /**
@@ -2745,8 +2745,8 @@  discard block
 block discarded – undo
2745 2745
 	 * @since 1.0.19
2746 2746
 	 * @param  float $value fees total.
2747 2747
 	 */
2748
-	public function set_total_fees( $value ) {
2749
-		$this->set_prop( 'total_fees', $value );
2748
+	public function set_total_fees($value) {
2749
+		$this->set_prop('total_fees', $value);
2750 2750
     }
2751 2751
 
2752 2752
     /**
@@ -2755,8 +2755,8 @@  discard block
 block discarded – undo
2755 2755
 	 * @since 1.0.19
2756 2756
 	 * @param  float $value fees total.
2757 2757
 	 */
2758
-	public function set_fees_total( $value ) {
2759
-		$this->set_total_fees( $value );
2758
+	public function set_fees_total($value) {
2759
+		$this->set_total_fees($value);
2760 2760
     }
2761 2761
 
2762 2762
     /**
@@ -2765,13 +2765,13 @@  discard block
 block discarded – undo
2765 2765
 	 * @since 1.0.19
2766 2766
 	 * @param  array $value fees.
2767 2767
 	 */
2768
-	public function set_fees( $value ) {
2768
+	public function set_fees($value) {
2769 2769
 
2770
-		if ( ! is_array( $value ) ) {
2770
+		if (!is_array($value)) {
2771 2771
 			$value = array();
2772 2772
 		}
2773 2773
 
2774
-		$this->set_prop( 'fees', $value );
2774
+		$this->set_prop('fees', $value);
2775 2775
 
2776 2776
     }
2777 2777
 
@@ -2781,13 +2781,13 @@  discard block
 block discarded – undo
2781 2781
 	 * @since 1.0.19
2782 2782
 	 * @param  array $value taxes.
2783 2783
 	 */
2784
-	public function set_taxes( $value ) {
2784
+	public function set_taxes($value) {
2785 2785
 
2786
-		if ( ! is_array( $value ) ) {
2786
+		if (!is_array($value)) {
2787 2787
 			$value = array();
2788 2788
 		}
2789 2789
 
2790
-		$this->set_prop( 'taxes', $value );
2790
+		$this->set_prop('taxes', $value);
2791 2791
 
2792 2792
     }
2793 2793
 
@@ -2797,13 +2797,13 @@  discard block
 block discarded – undo
2797 2797
 	 * @since 1.0.19
2798 2798
 	 * @param  array $value discounts.
2799 2799
 	 */
2800
-	public function set_discounts( $value ) {
2800
+	public function set_discounts($value) {
2801 2801
 
2802
-		if ( ! is_array( $value ) ) {
2802
+		if (!is_array($value)) {
2803 2803
 			$value = array();
2804 2804
 		}
2805 2805
 
2806
-		$this->set_prop( 'discounts', $value );
2806
+		$this->set_prop('discounts', $value);
2807 2807
     }
2808 2808
 
2809 2809
     /**
@@ -2812,18 +2812,18 @@  discard block
 block discarded – undo
2812 2812
 	 * @since 1.0.19
2813 2813
 	 * @param  GetPaid_Form_Item[] $value items.
2814 2814
 	 */
2815
-	public function set_items( $value ) {
2815
+	public function set_items($value) {
2816 2816
 
2817 2817
         // Remove existing items.
2818
-        $this->set_prop( 'items', array() );
2818
+        $this->set_prop('items', array());
2819 2819
 
2820 2820
         // Ensure that we have an array.
2821
-        if ( ! is_array( $value ) ) {
2821
+        if (!is_array($value)) {
2822 2822
             return;
2823 2823
         }
2824 2824
 
2825
-        foreach ( $value as $item ) {
2826
-            $this->add_item( $item );
2825
+        foreach ($value as $item) {
2826
+            $this->add_item($item);
2827 2827
         }
2828 2828
 
2829 2829
     }
@@ -2834,8 +2834,8 @@  discard block
 block discarded – undo
2834 2834
 	 * @since 1.0.19
2835 2835
 	 * @param  int $value payment form.
2836 2836
 	 */
2837
-	public function set_payment_form( $value ) {
2838
-		$this->set_prop( 'payment_form', $value );
2837
+	public function set_payment_form($value) {
2838
+		$this->set_prop('payment_form', $value);
2839 2839
     }
2840 2840
 
2841 2841
     /**
@@ -2844,8 +2844,8 @@  discard block
 block discarded – undo
2844 2844
 	 * @since 1.0.19
2845 2845
 	 * @param  string $value submission id.
2846 2846
 	 */
2847
-	public function set_submission_id( $value ) {
2848
-		$this->set_prop( 'submission_id', $value );
2847
+	public function set_submission_id($value) {
2848
+		$this->set_prop('submission_id', $value);
2849 2849
     }
2850 2850
 
2851 2851
     /**
@@ -2854,8 +2854,8 @@  discard block
 block discarded – undo
2854 2854
 	 * @since 1.0.19
2855 2855
 	 * @param  string $value discount code.
2856 2856
 	 */
2857
-	public function set_discount_code( $value ) {
2858
-		$this->set_prop( 'discount_code', $value );
2857
+	public function set_discount_code($value) {
2858
+		$this->set_prop('discount_code', $value);
2859 2859
     }
2860 2860
 
2861 2861
     /**
@@ -2864,8 +2864,8 @@  discard block
 block discarded – undo
2864 2864
 	 * @since 1.0.19
2865 2865
 	 * @param  string $value gateway.
2866 2866
 	 */
2867
-	public function set_gateway( $value ) {
2868
-		$this->set_prop( 'gateway', $value );
2867
+	public function set_gateway($value) {
2868
+		$this->set_prop('gateway', $value);
2869 2869
     }
2870 2870
 
2871 2871
     /**
@@ -2874,9 +2874,9 @@  discard block
 block discarded – undo
2874 2874
 	 * @since 1.0.19
2875 2875
 	 * @param  string $value transaction id.
2876 2876
 	 */
2877
-	public function set_transaction_id( $value ) {
2878
-		if ( ! empty( $value ) ) {
2879
-			$this->set_prop( 'transaction_id', $value );
2877
+	public function set_transaction_id($value) {
2878
+		if (!empty($value)) {
2879
+			$this->set_prop('transaction_id', $value);
2880 2880
 		}
2881 2881
     }
2882 2882
 
@@ -2886,8 +2886,8 @@  discard block
 block discarded – undo
2886 2886
 	 * @since 1.0.19
2887 2887
 	 * @param  string $value currency id.
2888 2888
 	 */
2889
-	public function set_currency( $value ) {
2890
-		$this->set_prop( 'currency', $value );
2889
+	public function set_currency($value) {
2890
+		$this->set_prop('currency', $value);
2891 2891
     }
2892 2892
 
2893 2893
 	/**
@@ -2896,8 +2896,8 @@  discard block
 block discarded – undo
2896 2896
 	 * @since 1.0.19
2897 2897
 	 * @param  bool $value value.
2898 2898
 	 */
2899
-	public function set_disable_taxes( $value ) {
2900
-		$this->set_prop( 'disable_taxes', (bool) $value );
2899
+	public function set_disable_taxes($value) {
2900
+		$this->set_prop('disable_taxes', (bool) $value);
2901 2901
 	}
2902 2902
 
2903 2903
     /**
@@ -2906,8 +2906,8 @@  discard block
 block discarded – undo
2906 2906
 	 * @since 1.0.19
2907 2907
 	 * @param  string $value subscription id.
2908 2908
 	 */
2909
-	public function set_subscription_id( $value ) {
2910
-		$this->set_prop( 'subscription_id', $value );
2909
+	public function set_subscription_id($value) {
2910
+		$this->set_prop('subscription_id', $value);
2911 2911
 	}
2912 2912
 	
2913 2913
 	/**
@@ -2916,8 +2916,8 @@  discard block
 block discarded – undo
2916 2916
 	 * @since 1.0.19
2917 2917
 	 * @param  string $value subscription id.
2918 2918
 	 */
2919
-	public function set_remote_subscription_id( $value ) {
2920
-		$this->set_prop( 'remote_subscription_id', $value );
2919
+	public function set_remote_subscription_id($value) {
2920
+		$this->set_prop('remote_subscription_id', $value);
2921 2921
     }
2922 2922
 
2923 2923
     /*
@@ -2934,28 +2934,28 @@  discard block
 block discarded – undo
2934 2934
      */
2935 2935
     public function is_parent() {
2936 2936
         $parent = $this->get_parent_id();
2937
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
2937
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
2938 2938
     }
2939 2939
 
2940 2940
     /**
2941 2941
      * Checks if this is a renewal invoice.
2942 2942
      */
2943 2943
     public function is_renewal() {
2944
-        return ! $this->is_parent();
2944
+        return !$this->is_parent();
2945 2945
     }
2946 2946
 
2947 2947
     /**
2948 2948
      * Checks if this is a recurring invoice.
2949 2949
      */
2950 2950
     public function is_recurring() {
2951
-        return $this->is_renewal() || ! empty( $this->recurring_item );
2951
+        return $this->is_renewal() || !empty($this->recurring_item);
2952 2952
     }
2953 2953
 
2954 2954
     /**
2955 2955
      * Checks if this is a taxable invoice.
2956 2956
      */
2957 2957
     public function is_taxable() {
2958
-        return ! $this->get_disable_taxes();
2958
+        return !$this->get_disable_taxes();
2959 2959
 	}
2960 2960
 
2961 2961
 	/**
@@ -2969,45 +2969,45 @@  discard block
 block discarded – undo
2969 2969
 	 * Checks to see if the invoice requires payment.
2970 2970
 	 */
2971 2971
 	public function is_free() {
2972
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2972
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
2973 2973
 
2974
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2974
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
2975 2975
 			$is_free = false;
2976 2976
 		}
2977 2977
 
2978
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2978
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2979 2979
     }
2980 2980
 
2981 2981
     /**
2982 2982
      * Checks if the invoice is paid.
2983 2983
      */
2984 2984
     public function is_paid() {
2985
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2986
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2985
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2986
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2987 2987
 	}
2988 2988
 
2989 2989
 	/**
2990 2990
      * Checks if the invoice needs payment.
2991 2991
      */
2992 2992
 	public function needs_payment() {
2993
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2994
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2993
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
2994
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
2995 2995
     }
2996 2996
   
2997 2997
 	/**
2998 2998
      * Checks if the invoice is refunded.
2999 2999
      */
3000 3000
 	public function is_refunded() {
3001
-        $is_refunded = $this->has_status( 'wpi-refunded' );
3002
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3001
+        $is_refunded = $this->has_status('wpi-refunded');
3002
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
3003 3003
 	}
3004 3004
 
3005 3005
 	/**
3006 3006
      * Checks if the invoice is held.
3007 3007
      */
3008 3008
 	public function is_held() {
3009
-        $is_held = $this->has_status( 'wpi-onhold' );
3010
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3009
+        $is_held = $this->has_status('wpi-onhold');
3010
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
3011 3011
 	}
3012 3012
 
3013 3013
 	/**
@@ -3015,30 +3015,30 @@  discard block
 block discarded – undo
3015 3015
      */
3016 3016
 	public function is_due() {
3017 3017
 		$due_date = $this->get_due_date();
3018
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3018
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3019 3019
 	}
3020 3020
 
3021 3021
 	/**
3022 3022
      * Checks if the invoice is draft.
3023 3023
      */
3024 3024
 	public function is_draft() {
3025
-        return $this->has_status( 'draft, auto-draft' );
3025
+        return $this->has_status('draft, auto-draft');
3026 3026
 	}
3027 3027
 
3028 3028
     /**
3029 3029
      * Checks if the invoice has a given status.
3030 3030
      */
3031
-    public function has_status( $status ) {
3032
-        $status = wpinv_parse_list( $status );
3033
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3031
+    public function has_status($status) {
3032
+        $status = wpinv_parse_list($status);
3033
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3034 3034
 	}
3035 3035
 
3036 3036
 	/**
3037 3037
      * Checks if the invoice is of a given type.
3038 3038
      */
3039
-    public function is_type( $type ) {
3040
-        $type = wpinv_parse_list( $type );
3041
-        return in_array( $this->get_type(), $type );
3039
+    public function is_type($type) {
3040
+        $type = wpinv_parse_list($type);
3041
+        return in_array($this->get_type(), $type);
3042 3042
     }
3043 3043
 
3044 3044
     /**
@@ -3070,8 +3070,8 @@  discard block
 block discarded – undo
3070 3070
      *
3071 3071
      */
3072 3072
 	public function is_initial_free() {
3073
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3074
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3073
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3074
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3075 3075
     }
3076 3076
 	
3077 3077
 	/**
@@ -3081,11 +3081,11 @@  discard block
 block discarded – undo
3081 3081
     public function item_has_free_trial() {
3082 3082
 
3083 3083
         // Ensure we have a recurring item.
3084
-        if ( ! $this->is_recurring() ) {
3084
+        if (!$this->is_recurring()) {
3085 3085
             return false;
3086 3086
         }
3087 3087
 
3088
-        $item = $this->get_recurring( true );
3088
+        $item = $this->get_recurring(true);
3089 3089
         return $item->has_free_trial();
3090 3090
 	}
3091 3091
 
@@ -3093,7 +3093,7 @@  discard block
 block discarded – undo
3093 3093
      * Check if the free trial is a result of a discount.
3094 3094
      */
3095 3095
     public function is_free_trial_from_discount() {
3096
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3096
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3097 3097
 	}
3098 3098
 	
3099 3099
 	/**
@@ -3101,12 +3101,12 @@  discard block
 block discarded – undo
3101 3101
      */
3102 3102
     public function discount_first_payment_only() {
3103 3103
 
3104
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3105
-        if ( ! $discount->exists() || ! $this->is_recurring() ) {
3104
+		$discount = wpinv_get_discount_obj($this->get_discount_code());
3105
+        if (!$discount->exists() || !$this->is_recurring()) {
3106 3106
             return true;
3107 3107
         }
3108 3108
 
3109
-        return ! $discount->get_is_recurring();
3109
+        return !$discount->get_is_recurring();
3110 3110
     }
3111 3111
 
3112 3112
     /*
@@ -3124,27 +3124,27 @@  discard block
 block discarded – undo
3124 3124
      * @param GetPaid_Form_Item|array $item
3125 3125
      * @return WP_Error|Bool
3126 3126
      */
3127
-    public function add_item( $item ) {
3127
+    public function add_item($item) {
3128 3128
 
3129
-		if ( is_array( $item ) ) {
3130
-			$item = $this->process_array_item( $item );
3129
+		if (is_array($item)) {
3130
+			$item = $this->process_array_item($item);
3131 3131
 		}
3132 3132
 
3133
-		if ( is_numeric( $item ) ) {
3134
-			$item = new GetPaid_Form_Item( $item );
3133
+		if (is_numeric($item)) {
3134
+			$item = new GetPaid_Form_Item($item);
3135 3135
 		}
3136 3136
 
3137 3137
         // Make sure that it is available for purchase.
3138
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3139
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3138
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3139
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3140 3140
         }
3141 3141
 
3142 3142
         // Do we have a recurring item?
3143
-		if ( $item->is_recurring() ) {
3143
+		if ($item->is_recurring()) {
3144 3144
 
3145 3145
 			// An invoice can only contain one recurring item.
3146
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3147
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3146
+			if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) {
3147
+				return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing'));
3148 3148
 			}
3149 3149
 
3150 3150
 			$this->recurring_item = $item->get_id();
@@ -3155,9 +3155,9 @@  discard block
 block discarded – undo
3155 3155
 
3156 3156
         // Retrieve all items.
3157 3157
         $items = $this->get_items();
3158
-        $items[ (int) $item->get_id() ] = $item;
3158
+        $items[(int) $item->get_id()] = $item;
3159 3159
 
3160
-        $this->set_prop( 'items', $items );
3160
+        $this->set_prop('items', $items);
3161 3161
 		return true;
3162 3162
 	}
3163 3163
 
@@ -3167,26 +3167,26 @@  discard block
 block discarded – undo
3167 3167
 	 * @since 1.0.19
3168 3168
 	 * @return GetPaid_Form_Item
3169 3169
 	 */
3170
-	protected function process_array_item( $array ) {
3170
+	protected function process_array_item($array) {
3171 3171
 
3172
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3173
-		$item    = new GetPaid_Form_Item( $item_id );
3172
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3173
+		$item    = new GetPaid_Form_Item($item_id);
3174 3174
 
3175 3175
 		// Set item data.
3176
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3177
-			if ( isset( $array[ "item_$key" ] ) ) {
3176
+		foreach (array('name', 'price', 'description') as $key) {
3177
+			if (isset($array["item_$key"])) {
3178 3178
 				$method = "set_$key";
3179
-				$item->$method( $array[ "item_$key" ] );
3179
+				$item->$method($array["item_$key"]);
3180 3180
 			}
3181 3181
 		}
3182 3182
 
3183
-		if ( isset( $array['quantity'] ) ) {
3184
-			$item->set_quantity( $array['quantity'] );
3183
+		if (isset($array['quantity'])) {
3184
+			$item->set_quantity($array['quantity']);
3185 3185
 		}
3186 3186
 
3187 3187
 		// Set item meta.
3188
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3189
-			$item->set_item_meta( $array['meta'] );
3188
+		if (isset($array['meta']) && is_array($array['meta'])) {
3189
+			$item->set_item_meta($array['meta']);
3190 3190
 		}
3191 3191
 
3192 3192
 		return $item;
@@ -3198,10 +3198,10 @@  discard block
 block discarded – undo
3198 3198
 	 *
3199 3199
 	 * @since 1.0.19
3200 3200
 	 */
3201
-	public function get_item( $item_id ) {
3201
+	public function get_item($item_id) {
3202 3202
 		$items   = $this->get_items();
3203 3203
 		$item_id = (int) $item_id;
3204
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3204
+		return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null;
3205 3205
     }
3206 3206
 
3207 3207
     /**
@@ -3209,17 +3209,17 @@  discard block
 block discarded – undo
3209 3209
 	 *
3210 3210
 	 * @since 1.0.19
3211 3211
 	 */
3212
-	public function remove_item( $item_id ) {
3212
+	public function remove_item($item_id) {
3213 3213
 		$items   = $this->get_items();
3214 3214
 		$item_id = (int) $item_id;
3215 3215
 
3216
-        if ( $item_id == $this->recurring_item ) {
3216
+        if ($item_id == $this->recurring_item) {
3217 3217
             $this->recurring_item = null;
3218 3218
         }
3219 3219
 
3220
-        if ( isset( $items[ $item_id ] ) ) {
3221
-            unset( $items[ $item_id ] );
3222
-            $this->set_prop( 'items', $items );
3220
+        if (isset($items[$item_id])) {
3221
+            unset($items[$item_id]);
3222
+            $this->set_prop('items', $items);
3223 3223
         }
3224 3224
     }
3225 3225
 
@@ -3229,11 +3229,11 @@  discard block
 block discarded – undo
3229 3229
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3230 3230
 	 * @since 1.0.19
3231 3231
 	 */
3232
-    public function add_fee( $fee ) {
3232
+    public function add_fee($fee) {
3233 3233
 
3234 3234
 		$fees                 = $this->get_fees();
3235
-		$fees[ $fee['name'] ] = $fee;
3236
-		$this->set_prop( 'fees', $fees );
3235
+		$fees[$fee['name']] = $fee;
3236
+		$this->set_prop('fees', $fees);
3237 3237
 
3238 3238
     }
3239 3239
 
@@ -3242,9 +3242,9 @@  discard block
 block discarded – undo
3242 3242
 	 *
3243 3243
 	 * @since 1.0.19
3244 3244
 	 */
3245
-	public function get_fee( $fee ) {
3245
+	public function get_fee($fee) {
3246 3246
         $fees = $this->get_fees();
3247
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3247
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3248 3248
     }
3249 3249
 
3250 3250
     /**
@@ -3252,11 +3252,11 @@  discard block
 block discarded – undo
3252 3252
 	 *
3253 3253
 	 * @since 1.0.19
3254 3254
 	 */
3255
-	public function remove_fee( $fee ) {
3255
+	public function remove_fee($fee) {
3256 3256
         $fees = $this->get_fees();
3257
-        if ( isset( $fees[ $fee ] ) ) {
3258
-            unset( $fees[ $fee ] );
3259
-            $this->set_prop( 'fees', $fees );
3257
+        if (isset($fees[$fee])) {
3258
+            unset($fees[$fee]);
3259
+            $this->set_prop('fees', $fees);
3260 3260
         }
3261 3261
     }
3262 3262
 
@@ -3266,11 +3266,11 @@  discard block
 block discarded – undo
3266 3266
 	 * @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.
3267 3267
 	 * @since 1.0.19
3268 3268
 	 */
3269
-	public function add_discount( $discount ) {
3269
+	public function add_discount($discount) {
3270 3270
 
3271 3271
 		$discounts = $this->get_discounts();
3272
-		$discounts[ $discount['name'] ] = $discount;
3273
-		$this->set_prop( 'discounts', $discounts );
3272
+		$discounts[$discount['name']] = $discount;
3273
+		$this->set_prop('discounts', $discounts);
3274 3274
 
3275 3275
 	}
3276 3276
 
@@ -3280,15 +3280,15 @@  discard block
 block discarded – undo
3280 3280
 	 * @since 1.0.19
3281 3281
 	 * @return float
3282 3282
 	 */
3283
-	public function get_discount( $discount = false ) {
3283
+	public function get_discount($discount = false) {
3284 3284
 
3285 3285
 		// Backwards compatibilty.
3286
-		if ( empty( $discount ) ) {
3286
+		if (empty($discount)) {
3287 3287
 			return $this->get_total_discount();
3288 3288
 		}
3289 3289
 
3290 3290
         $discounts = $this->get_discounts();
3291
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3291
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3292 3292
     }
3293 3293
 
3294 3294
     /**
@@ -3296,11 +3296,11 @@  discard block
 block discarded – undo
3296 3296
 	 *
3297 3297
 	 * @since 1.0.19
3298 3298
 	 */
3299
-	public function remove_discount( $discount ) {
3299
+	public function remove_discount($discount) {
3300 3300
         $discounts = $this->get_discounts();
3301
-        if ( isset( $discounts[ $discount ] ) ) {
3302
-            unset( $discounts[ $discount ] );
3303
-            $this->set_prop( 'discounts', $discounts );
3301
+        if (isset($discounts[$discount])) {
3302
+            unset($discounts[$discount]);
3303
+            $this->set_prop('discounts', $discounts);
3304 3304
         }
3305 3305
     }
3306 3306
 
@@ -3309,12 +3309,12 @@  discard block
 block discarded – undo
3309 3309
      *
3310 3310
      * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
3311 3311
      */
3312
-    public function add_tax( $tax ) {
3313
-        if ( $this->is_taxable() ) {
3312
+    public function add_tax($tax) {
3313
+        if ($this->is_taxable()) {
3314 3314
 
3315
-            $taxes                 = $this->get_taxes();
3316
-			$taxes[ $tax['name'] ] = $tax;
3317
-			$this->set_prop( 'taxes', $tax );
3315
+            $taxes = $this->get_taxes();
3316
+			$taxes[$tax['name']] = $tax;
3317
+			$this->set_prop('taxes', $tax);
3318 3318
 
3319 3319
         }
3320 3320
     }
@@ -3324,15 +3324,15 @@  discard block
 block discarded – undo
3324 3324
 	 *
3325 3325
 	 * @since 1.0.19
3326 3326
 	 */
3327
-	public function get_tax( $tax = null ) {
3327
+	public function get_tax($tax = null) {
3328 3328
 
3329 3329
 		// Backwards compatility.
3330
-		if ( empty( $tax ) ) {
3330
+		if (empty($tax)) {
3331 3331
 			return $this->get_total_tax();
3332 3332
 		}
3333 3333
 
3334 3334
         $taxes = $this->get_taxes();
3335
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3335
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3336 3336
     }
3337 3337
 
3338 3338
     /**
@@ -3340,11 +3340,11 @@  discard block
 block discarded – undo
3340 3340
 	 *
3341 3341
 	 * @since 1.0.19
3342 3342
 	 */
3343
-	public function remove_tax( $tax ) {
3343
+	public function remove_tax($tax) {
3344 3344
         $taxes = $this->get_taxes();
3345
-        if ( isset( $taxes[ $tax ] ) ) {
3346
-            unset( $taxes[ $tax ] );
3347
-            $this->set_prop( 'taxes', $taxes );
3345
+        if (isset($taxes[$tax])) {
3346
+            unset($taxes[$tax]);
3347
+            $this->set_prop('taxes', $taxes);
3348 3348
         }
3349 3349
     }
3350 3350
 
@@ -3355,17 +3355,17 @@  discard block
 block discarded – undo
3355 3355
 	 * @return float The recalculated subtotal
3356 3356
 	 */
3357 3357
 	public function recalculate_subtotal() {
3358
-        $items     = $this->get_items();
3358
+        $items = $this->get_items();
3359 3359
 		$subtotal  = 0;
3360 3360
 		$recurring = 0;
3361 3361
 
3362
-        foreach ( $items as $item ) {
3362
+        foreach ($items as $item) {
3363 3363
 			$subtotal  += $item->get_sub_total();
3364 3364
 			$recurring += $item->get_recurring_sub_total();
3365 3365
         }
3366 3366
 
3367 3367
 		$current = $this->is_renewal() ? $recurring : $subtotal;
3368
-		$this->set_subtotal( $current );
3368
+		$this->set_subtotal($current);
3369 3369
 
3370 3370
 		$this->totals['subtotal'] = array(
3371 3371
 			'initial'   => $subtotal,
@@ -3386,14 +3386,14 @@  discard block
 block discarded – undo
3386 3386
 		$discount  = 0;
3387 3387
 		$recurring = 0;
3388 3388
 
3389
-        foreach ( $discounts as $data ) {
3390
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3391
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3389
+        foreach ($discounts as $data) {
3390
+			$discount  += wpinv_sanitize_amount($data['initial_discount']);
3391
+			$recurring += wpinv_sanitize_amount($data['recurring_discount']);
3392 3392
 		}
3393 3393
 
3394 3394
 		$current = $this->is_renewal() ? $recurring : $discount;
3395 3395
 
3396
-		$this->set_total_discount( $current );
3396
+		$this->set_total_discount($current);
3397 3397
 
3398 3398
 		$this->totals['discount'] = array(
3399 3399
 			'initial'   => $discount,
@@ -3411,17 +3411,17 @@  discard block
 block discarded – undo
3411 3411
 	 * @return float The recalculated tax
3412 3412
 	 */
3413 3413
 	public function recalculate_total_tax() {
3414
-        $taxes     = $this->get_taxes();
3414
+        $taxes = $this->get_taxes();
3415 3415
 		$tax       = 0;
3416 3416
 		$recurring = 0;
3417 3417
 
3418
-        foreach ( $taxes as $data ) {
3419
-			$tax       += wpinv_sanitize_amount( $data['initial_tax'] );
3420
-			$recurring += wpinv_sanitize_amount( $data['recurring_tax'] );
3418
+        foreach ($taxes as $data) {
3419
+			$tax       += wpinv_sanitize_amount($data['initial_tax']);
3420
+			$recurring += wpinv_sanitize_amount($data['recurring_tax']);
3421 3421
 		}
3422 3422
 
3423 3423
 		$current = $this->is_renewal() ? $recurring : $tax;
3424
-		$this->set_total_tax( $current );
3424
+		$this->set_total_tax($current);
3425 3425
 
3426 3426
 		$this->totals['tax'] = array(
3427 3427
 			'initial'   => $tax,
@@ -3443,20 +3443,20 @@  discard block
 block discarded – undo
3443 3443
 		$fee       = 0;
3444 3444
 		$recurring = 0;
3445 3445
 
3446
-        foreach ( $fees as $data ) {
3447
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3448
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3446
+        foreach ($fees as $data) {
3447
+			$fee       += wpinv_sanitize_amount($data['initial_fee']);
3448
+			$recurring += wpinv_sanitize_amount($data['recurring_fee']);
3449 3449
 		}
3450 3450
 
3451 3451
 		$current = $this->is_renewal() ? $recurring : $fee;
3452
-		$this->set_total_fees( $current );
3452
+		$this->set_total_fees($current);
3453 3453
 
3454 3454
 		$this->totals['fee'] = array(
3455 3455
 			'initial'   => $fee,
3456 3456
 			'recurring' => $recurring,
3457 3457
 		);
3458 3458
 
3459
-        $this->set_total_fees( $fee );
3459
+        $this->set_total_fees($fee);
3460 3460
         return $current;
3461 3461
     }
3462 3462
 
@@ -3477,9 +3477,9 @@  discard block
 block discarded – undo
3477 3477
 	/**
3478 3478
 	 * @deprecated
3479 3479
 	 */
3480
-    public function recalculate_totals( $temp = false ) {
3481
-        $this->update_items( $temp );
3482
-        $this->save( true );
3480
+    public function recalculate_totals($temp = false) {
3481
+        $this->update_items($temp);
3482
+        $this->save(true);
3483 3483
         return $this;
3484 3484
     }
3485 3485
 
@@ -3497,10 +3497,10 @@  discard block
 block discarded – undo
3497 3497
 	 * @return int|false The new note's ID on success, false on failure.
3498 3498
      *
3499 3499
      */
3500
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3500
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3501 3501
 
3502 3502
         // Bail if no note specified or this invoice is not yet saved.
3503
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3503
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3504 3504
             return false;
3505 3505
         }
3506 3506
 
@@ -3508,23 +3508,23 @@  discard block
 block discarded – undo
3508 3508
 		$author_email = '[email protected]';
3509 3509
 
3510 3510
 		// If this is an admin comment or it has been added by the user.
3511
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3512
-			$user         = get_user_by( 'id', get_current_user_id() );
3511
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3512
+			$user = get_user_by('id', get_current_user_id());
3513 3513
             $author       = $user->display_name;
3514 3514
             $author_email = $user->user_email;
3515 3515
 		}
3516 3516
 
3517
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3517
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3518 3518
 
3519 3519
 	}
3520 3520
 
3521 3521
 	/**
3522 3522
      * Generates a unique key for the invoice.
3523 3523
      */
3524
-    public function generate_key( $string = '' ) {
3525
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3524
+    public function generate_key($string = '') {
3525
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3526 3526
         return strtolower(
3527
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3527
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3528 3528
         );
3529 3529
     }
3530 3530
 
@@ -3534,11 +3534,11 @@  discard block
 block discarded – undo
3534 3534
     public function generate_number() {
3535 3535
         $number = $this->get_id();
3536 3536
 
3537
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3538
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3537
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3538
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3539 3539
         }
3540 3540
 
3541
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3541
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3542 3542
 
3543 3543
 	}
3544 3544
 
@@ -3551,55 +3551,55 @@  discard block
 block discarded – undo
3551 3551
 		// Reset status transition variable.
3552 3552
 		$this->status_transition = false;
3553 3553
 
3554
-		if ( $status_transition ) {
3554
+		if ($status_transition) {
3555 3555
 			try {
3556 3556
 
3557 3557
 				// Fire a hook for the status change.
3558
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3558
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3559 3559
 
3560 3560
 				// @deprecated this is deprecated and will be removed in the future.
3561
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3561
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3562 3562
 
3563
-				if ( ! empty( $status_transition['from'] ) ) {
3563
+				if (!empty($status_transition['from'])) {
3564 3564
 
3565 3565
 					/* translators: 1: old invoice status 2: new invoice status */
3566
-					$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  ) );
3566
+					$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));
3567 3567
 
3568 3568
 					// Fire another hook.
3569
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3570
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3569
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3570
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3571 3571
 
3572 3572
 					// @deprecated this is deprecated and will be removed in the future.
3573
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3573
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3574 3574
 
3575 3575
 					// Note the transition occurred.
3576
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3576
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']);
3577 3577
 
3578 3578
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3579 3579
 					if (
3580
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3581
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3580
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3581
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3582 3582
 					) {
3583
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3583
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3584 3584
 					}
3585 3585
 
3586 3586
 					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3587 3587
 					if (
3588
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3589
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3588
+						in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3589
+						&& in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3590 3590
 					) {
3591
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3591
+						do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition);
3592 3592
 					}
3593 3593
 				} else {
3594 3594
 					/* translators: %s: new invoice status */
3595
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3595
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this));
3596 3596
 
3597 3597
 					// Note the transition occurred.
3598
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3598
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3599 3599
 
3600 3600
 				}
3601
-			} catch ( Exception $e ) {
3602
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3601
+			} catch (Exception $e) {
3602
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3603 3603
 			}
3604 3604
 		}
3605 3605
 	}
@@ -3607,13 +3607,13 @@  discard block
 block discarded – undo
3607 3607
 	/**
3608 3608
 	 * Updates an invoice status.
3609 3609
 	 */
3610
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3610
+	public function update_status($new_status = false, $note = '', $manual = false) {
3611 3611
 
3612 3612
 		// Fires before updating a status.
3613
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3613
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3614 3614
 
3615 3615
 		// Update the status.
3616
-		$this->set_status( $new_status, $note, $manual );
3616
+		$this->set_status($new_status, $note, $manual);
3617 3617
 
3618 3618
 		// Save the order.
3619 3619
 		return $this->save();
@@ -3624,18 +3624,18 @@  discard block
 block discarded – undo
3624 3624
 	 * @deprecated
3625 3625
 	 */
3626 3626
 	public function refresh_item_ids() {
3627
-        $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3628
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3627
+        $item_ids = implode(',', array_unique(array_keys($this->get_items())));
3628
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3629 3629
 	}
3630 3630
 
3631 3631
 	/**
3632 3632
 	 * @deprecated
3633 3633
 	 */
3634
-	public function update_items( $temp = false ) {
3634
+	public function update_items($temp = false) {
3635 3635
 
3636
-		$this->set_items( $this->get_items() );
3636
+		$this->set_items($this->get_items());
3637 3637
 
3638
-		if ( ! $temp ) {
3638
+		if (!$temp) {
3639 3639
 			$this->save();
3640 3640
 		}
3641 3641
 
@@ -3649,11 +3649,11 @@  discard block
 block discarded – undo
3649 3649
 
3650 3650
         $discount_code = $this->get_discount_code();
3651 3651
 
3652
-        if ( empty( $discount_code ) ) {
3652
+        if (empty($discount_code)) {
3653 3653
             return false;
3654 3654
         }
3655 3655
 
3656
-        $discount = wpinv_get_discount_obj( $discount_code );
3656
+        $discount = wpinv_get_discount_obj($discount_code);
3657 3657
 
3658 3658
         // Ensure it is active.
3659 3659
         return $discount->exists();
@@ -3664,7 +3664,7 @@  discard block
 block discarded – undo
3664 3664
 	 * Refunds an invoice.
3665 3665
 	 */
3666 3666
     public function refund() {
3667
-		$this->set_status( 'wpi-refunded' );
3667
+		$this->set_status('wpi-refunded');
3668 3668
         $this->save();
3669 3669
 	}
3670 3670
 
@@ -3673,56 +3673,56 @@  discard block
 block discarded – undo
3673 3673
 	 * 
3674 3674
 	 * @param string $transaction_id
3675 3675
 	 */
3676
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3676
+    public function mark_paid($transaction_id = null, $note = '') {
3677 3677
 
3678 3678
 		// Set the transaction id.
3679
-		if ( empty( $transaction_id ) ) {
3679
+		if (empty($transaction_id)) {
3680 3680
 			$transaction_id = $this->generate_key('trans_');
3681 3681
 		}
3682 3682
 
3683
-		if ( ! $this->get_transaction_id() ) {
3684
-			$this->set_transaction_id( $transaction_id );
3683
+		if (!$this->get_transaction_id()) {
3684
+			$this->set_transaction_id($transaction_id);
3685 3685
 		}
3686 3686
 
3687
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3687
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3688 3688
 			return $this->save();
3689 3689
 		}
3690 3690
 
3691 3691
 		// Set the completed date.
3692
-		$this->set_date_completed( current_time( 'mysql' ) );
3692
+		$this->set_date_completed(current_time('mysql'));
3693 3693
 
3694 3694
 		// Set the new status.
3695
-		if ( $this->is_renewal() ) {
3695
+		if ($this->is_renewal()) {
3696 3696
 
3697 3697
 			$_note = sprintf(
3698
-				__( 'Renewed via %s', 'invoicing' ),
3699
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3698
+				__('Renewed via %s', 'invoicing'),
3699
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3700 3700
 			);
3701 3701
 
3702
-			if ( 'none' == $this->get_gateway() ) {
3702
+			if ('none' == $this->get_gateway()) {
3703 3703
 				$_note = $note;
3704 3704
 			}
3705 3705
 
3706
-			$this->set_status( 'wpi-renewal', $_note );
3706
+			$this->set_status('wpi-renewal', $_note);
3707 3707
 
3708 3708
 		} else {
3709 3709
 
3710 3710
 			$_note = sprintf(
3711
-				__( 'Paid via %s', 'invoicing' ),
3712
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3711
+				__('Paid via %s', 'invoicing'),
3712
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3713 3713
 			);
3714 3714
 
3715
-			if ( 'none' == $this->get_gateway() ) {
3715
+			if ('none' == $this->get_gateway()) {
3716 3716
 				$_note = $note;
3717 3717
 			}
3718 3718
 
3719
-			$this->set_status( 'publish',$_note );
3719
+			$this->set_status('publish', $_note);
3720 3720
 
3721 3721
 		}
3722 3722
 
3723 3723
 		// Set checkout mode.
3724
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3725
-		$this->set_mode( $mode );
3724
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3725
+		$this->set_mode($mode);
3726 3726
 
3727 3727
 		// Save the invoice.
3728 3728
         $this->save();
@@ -3748,9 +3748,9 @@  discard block
 block discarded – undo
3748 3748
      * Clears the subscription's cache.
3749 3749
      */
3750 3750
     public function clear_cache() {
3751
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3752
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3753
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3751
+		wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
3752
+		wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
3753
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
3754 3754
 	}
3755 3755
 
3756 3756
 }
Please login to merge, or discard this patch.
includes/wpinv-discount-functions.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Returns an array of discount type.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
     return apply_filters(
18 18
         'wpinv_discount_types',
19 19
         array(
20
-            'percent'   => __( 'Percentage', 'invoicing' ),
21
-            'flat'     => __( 'Flat Amount', 'invoicing' ),
20
+            'percent'   => __('Percentage', 'invoicing'),
21
+            'flat'     => __('Flat Amount', 'invoicing'),
22 22
         )
23 23
     );
24 24
 }
@@ -28,46 +28,46 @@  discard block
 block discarded – undo
28 28
  * 
29 29
  * @return string
30 30
  */
31
-function wpinv_get_discount_type_name( $type = '' ) {
31
+function wpinv_get_discount_type_name($type = '') {
32 32
     $types = wpinv_get_discount_types();
33
-    return isset( $types[ $type ] ) ? $types[ $type ] : $type;
33
+    return isset($types[$type]) ? $types[$type] : $type;
34 34
 }
35 35
 
36 36
 /**
37 37
  * Deletes a discount via the admin page.
38 38
  * 
39 39
  */
40
-function wpinv_delete_discount( $data ) {
40
+function wpinv_delete_discount($data) {
41 41
 
42
-    $discount = new WPInv_Discount( absint( $data['discount'] ) );
43
-    $discount->delete( true );
42
+    $discount = new WPInv_Discount(absint($data['discount']));
43
+    $discount->delete(true);
44 44
 
45 45
 }
46
-add_action( 'getpaid_authenticated_admin_action_delete_discount', 'wpinv_delete_discount' );
46
+add_action('getpaid_authenticated_admin_action_delete_discount', 'wpinv_delete_discount');
47 47
 
48 48
 /**
49 49
  * Deactivates a discount via the admin page.
50 50
  */
51
-function wpinv_activate_discount( $data ) {
51
+function wpinv_activate_discount($data) {
52 52
 
53
-    $discount = new WPInv_Discount( absint( $data['discount'] ) );
54
-    $discount->set_status( 'publish' );
53
+    $discount = new WPInv_Discount(absint($data['discount']));
54
+    $discount->set_status('publish');
55 55
     $discount->save();
56 56
 
57 57
 }
58
-add_action( 'getpaid_authenticated_admin_action_activate_discount', 'wpinv_activate_discount' );
58
+add_action('getpaid_authenticated_admin_action_activate_discount', 'wpinv_activate_discount');
59 59
 
60 60
 /**
61 61
  * Activates a discount via the admin page.
62 62
  */
63
-function wpinv_deactivate_discount( $data ) {
63
+function wpinv_deactivate_discount($data) {
64 64
 
65
-    $discount = new WPInv_Discount( absint( $data['discount'] ) );
66
-    $discount->set_status( 'pending' );
65
+    $discount = new WPInv_Discount(absint($data['discount']));
66
+    $discount->set_status('pending');
67 67
     $discount->save();
68 68
 
69 69
 }
70
-add_action( 'getpaid_authenticated_admin_action_deactivate_discount', 'wpinv_deactivate_discount' );
70
+add_action('getpaid_authenticated_admin_action_deactivate_discount', 'wpinv_deactivate_discount');
71 71
 
72 72
 /**
73 73
  * Fetches a discount object.
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
  * @since 1.0.15
77 77
  * @return WPInv_Discount
78 78
  */
79
-function wpinv_get_discount( $discount ) {
80
-    return new WPInv_Discount( $discount );
79
+function wpinv_get_discount($discount) {
80
+    return new WPInv_Discount($discount);
81 81
 }
82 82
 
83 83
 /**
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
  * @since 1.0.15
88 88
  * @return WPInv_Discount
89 89
  */
90
-function wpinv_get_discount_obj( $discount = 0 ) {
91
-    return new WPInv_Discount( $discount );
90
+function wpinv_get_discount_obj($discount = 0) {
91
+    return new WPInv_Discount($discount);
92 92
 }
93 93
 
94 94
 /**
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
  * @param string|int $value The field value
99 99
  * @return bool|WPInv_Discount
100 100
  */
101
-function wpinv_get_discount_by( $deprecated = null, $value = '' ) {
102
-    $discount = new WPInv_Discount( $value );
101
+function wpinv_get_discount_by($deprecated = null, $value = '') {
102
+    $discount = new WPInv_Discount($value);
103 103
 
104
-    if ( $discount->get_id() != 0 ) {
104
+    if ($discount->get_id() != 0) {
105 105
         return $discount;
106 106
     }
107 107
 
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 function wpinv_get_discount_statuses() {
117 117
 
118 118
     return array(
119
-        'expired'  => __( 'Expired', 'invoicing' ),
120
-        'publish'  => __( 'Active', 'invoicing' ),
121
-        'inactive' => __( 'Inactive', 'invoicing' ),
119
+        'expired'  => __('Expired', 'invoicing'),
120
+        'publish'  => __('Active', 'invoicing'),
121
+        'inactive' => __('Inactive', 'invoicing'),
122 122
     );
123 123
 
124 124
 }
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 /**
127 127
  * Retrieves an invoice status label.
128 128
  */
129
-function wpinv_discount_status( $status ) {
129
+function wpinv_discount_status($status) {
130 130
     $statuses = wpinv_get_discount_statuses();
131
-    return isset( $statuses[ $status ] ) ? $statuses[ $status ] : __( 'Inactive', 'invoicing' );
131
+    return isset($statuses[$status]) ? $statuses[$status] : __('Inactive', 'invoicing');
132 132
 }
133 133
 
134 134
 /**
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
  * @param int|array|string|WPInv_Discount $code discount data, object, ID or code.
139 139
  * @return bool
140 140
  */
141
-function wpinv_discount_is_recurring( $discount = 0, $code = 0 ) {
141
+function wpinv_discount_is_recurring($discount = 0, $code = 0) {
142 142
 
143
-    if( ! empty( $discount ) ) {
144
-        $discount    = wpinv_get_discount_obj( $discount );
143
+    if (!empty($discount)) {
144
+        $discount    = wpinv_get_discount_obj($discount);
145 145
     } else {
146
-        $discount    = wpinv_get_discount_obj( $code );
146
+        $discount    = wpinv_get_discount_obj($code);
147 147
     }
148 148
 
149 149
     return $discount->get_is_recurring();
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 1 patch
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
     /**
31 31
 	 * Class constructor.
32 32
 	 */
33
-	public function __construct(){
33
+	public function __construct() {
34 34
 
35
-        $this->admin_path  = plugin_dir_path( __FILE__ );
36
-        $this->admin_url   = plugins_url( '/', __FILE__ );
35
+        $this->admin_path  = plugin_dir_path(__FILE__);
36
+        $this->admin_url   = plugins_url('/', __FILE__);
37 37
 
38
-        if ( is_admin() ) {
38
+        if (is_admin()) {
39 39
 			$this->init_admin_hooks();
40 40
         }
41 41
 
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 */
48 48
 	private function init_admin_hooks() {
49
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
50
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
51
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
52
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
53
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
54
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
55
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
56
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
57
-		do_action( 'getpaid_init_admin_hooks', $this );
49
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
50
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
51
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
52
+        add_action('admin_init', array($this, 'activation_redirect'));
53
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
54
+		add_action('admin_notices', array($this, 'show_notices'));
55
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
56
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
57
+		do_action('getpaid_init_admin_hooks', $this);
58 58
 
59 59
     }
60 60
 
@@ -65,49 +65,49 @@  discard block
 block discarded – undo
65 65
 	public function enqeue_scripts() {
66 66
         global $current_screen, $pagenow;
67 67
 
68
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
68
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
69 69
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
70 70
 
71
-        if ( ! empty( $current_screen->post_type ) ) {
71
+        if (!empty($current_screen->post_type)) {
72 72
 			$page = $current_screen->post_type;
73 73
         }
74 74
 
75 75
         // General styles.
76
-        if ( false !== stripos( $page, 'wpi' ) ) {
76
+        if (false !== stripos($page, 'wpi')) {
77 77
 
78 78
             // Styles.
79
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
80
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
81
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
82
-            wp_enqueue_style( 'wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
83
-            wp_enqueue_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16' );
79
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
80
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
81
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
82
+            wp_enqueue_style('wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
83
+            wp_enqueue_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16');
84 84
 
85 85
             // Scripts.
86
-            wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '4.0.13', true );
87
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
86
+            wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '4.0.13', true);
87
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
88 88
 
89
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
90
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker' ),  $version );
91
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
89
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
90
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker'), $version);
91
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
92 92
 
93 93
         }
94 94
 
95 95
         // Payment form scripts.
96
-		if ( 'wpi_payment_form' == $page && $editing ) {
96
+		if ('wpi_payment_form' == $page && $editing) {
97 97
             $this->load_payment_form_scripts();
98 98
         }
99 99
 
100
-        if ( $page == 'wpinv-subscriptions' ) {
101
-			wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
102
-			wp_enqueue_script( 'wpinv-sub-admin-script' );
100
+        if ($page == 'wpinv-subscriptions') {
101
+			wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
102
+			wp_enqueue_script('wpinv-sub-admin-script');
103 103
 		}
104 104
 
105
-		if ( $page == 'wpinv-reports' ) {
106
-			wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
105
+		if ($page == 'wpinv-reports') {
106
+			wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7');
107 107
 		}
108 108
 
109
-		if ( $page == 'wpinv-subscriptions' ) {
110
-			wp_enqueue_script( 'postbox' );
109
+		if ($page == 'wpinv-subscriptions') {
110
+			wp_enqueue_script('postbox');
111 111
 		}
112 112
 
113 113
     }
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
         global $post;
121 121
 
122 122
         $i18n = array(
123
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
124
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
125
-            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
126
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
127
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
128
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
129
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
123
+            'ajax_url'                  => admin_url('admin-ajax.php'),
124
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
125
+            'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
126
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
127
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
128
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
129
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
130 130
             'tax'                       => wpinv_tax_amount(),
131 131
             'discount'                  => 0,
132 132
             'currency_symbol'           => wpinv_currency_symbol(),
@@ -134,35 +134,35 @@  discard block
 block discarded – undo
134 134
             'thousand_sep'              => wpinv_thousands_separator(),
135 135
             'decimal_sep'               => wpinv_decimal_separator(),
136 136
             'decimals'                  => wpinv_decimals(),
137
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
138
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
139
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
140
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
141
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
142
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
143
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
144
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
145
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
146
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
147
-            'action_edit'               => __( 'Edit', 'invoicing' ),
148
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
149
-            'item_description'          => __( 'Item Description', 'invoicing' ),
150
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
151
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
152
-            'searching'                 => __( 'Searching', 'invoicing' ),
137
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
138
+            'status_publish'            => wpinv_status_nicename('publish'),
139
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
140
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
141
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
142
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
143
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
144
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
145
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
146
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
147
+            'action_edit'               => __('Edit', 'invoicing'),
148
+            'action_cancel'             => __('Cancel', 'invoicing'),
149
+            'item_description'          => __('Item Description', 'invoicing'),
150
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
151
+            'discount_description'      => __('Discount Description', 'invoicing'),
152
+            'searching'                 => __('Searching', 'invoicing'),
153 153
         );
154 154
 
155
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
155
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
156 156
 
157
-			$invoice              = new WPInv_Invoice( $post );
157
+			$invoice              = new WPInv_Invoice($post);
158 158
 			$i18n['save_invoice'] = sprintf(
159
-				__( 'Save %s', 'invoicing' ),
160
-				ucfirst( $invoice->get_type() )
159
+				__('Save %s', 'invoicing'),
160
+				ucfirst($invoice->get_type())
161 161
 			);
162 162
 
163 163
 			$i18n['invoice_description'] = sprintf(
164
-				__( '%s Description', 'invoicing' ),
165
-				ucfirst( $invoice->get_type() )
164
+				__('%s Description', 'invoicing'),
165
+				ucfirst($invoice->get_type())
166 166
 			);
167 167
 
168 168
 		}
@@ -176,30 +176,30 @@  discard block
 block discarded – undo
176 176
 	protected function load_payment_form_scripts() {
177 177
         global $post;
178 178
 
179
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
180
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
181
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
179
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
180
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
181
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
182 182
 
183
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
184
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
183
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
184
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
185 185
 
186 186
 		wp_localize_script(
187 187
             'wpinv-admin-payment-form-script',
188 188
             'wpinvPaymentFormAdmin',
189 189
             array(
190
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
191
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
190
+				'elements'      => wpinv_get_data('payment-form-elements'),
191
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
192 192
 				'currency'      => wpinv_currency_symbol(),
193 193
 				'position'      => wpinv_currency_position(),
194 194
 				'decimals'      => (int) wpinv_decimals(),
195 195
 				'thousands_sep' => wpinv_thousands_separator(),
196 196
 				'decimals_sep'  => wpinv_decimal_separator(),
197
-				'form_items'    => gepaid_get_form_items( $post->ID ),
197
+				'form_items'    => gepaid_get_form_items($post->ID),
198 198
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
199 199
             )
200 200
         );
201 201
 
202
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
202
+        wp_enqueue_script('wpinv-admin-payment-form-script');
203 203
 
204 204
     }
205 205
 
@@ -210,29 +210,29 @@  discard block
 block discarded – undo
210 210
      * @return string
211 211
 	 *
212 212
 	 */
213
-    public function admin_body_class( $classes ) {
213
+    public function admin_body_class($classes) {
214 214
 		global $pagenow, $post, $current_screen;
215 215
 
216 216
 
217
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
217
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
218 218
 
219
-        if ( ! empty( $current_screen->post_type ) ) {
219
+        if (!empty($current_screen->post_type)) {
220 220
 			$page = $current_screen->post_type;
221 221
         }
222 222
 
223
-        if ( false !== stripos( $page, 'wpi' ) ) {
224
-            $classes .= ' wpi-' . sanitize_key( $page );
223
+        if (false !== stripos($page, 'wpi')) {
224
+            $classes .= ' wpi-' . sanitize_key($page);
225 225
         }
226 226
 
227
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
227
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
228 228
             $classes .= ' wpinv-cpt wpinv';
229 229
 		}
230 230
 		
231
-		if ( getpaid_is_invoice_post_type( $page ) ) {
231
+		if (getpaid_is_invoice_post_type($page)) {
232 232
             $classes .= ' getpaid-is-invoice-cpt';
233 233
         }
234 234
 
235
-		if ( $pagenow == 'post.php' && $page == 'wpi_item' && ! empty( $post ) && ! wpinv_item_is_editable( $post ) ) {
235
+		if ($pagenow == 'post.php' && $page == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
236 236
 			$classes .= ' wpi-editable-n';
237 237
 		}
238 238
 
@@ -242,19 +242,19 @@  discard block
 block discarded – undo
242 242
     /**
243 243
 	 * Maybe show the AyeCode Connect Notice.
244 244
 	 */
245
-	public function init_ayecode_connect_helper(){
245
+	public function init_ayecode_connect_helper() {
246 246
 
247 247
         new AyeCode_Connect_Helper(
248 248
             array(
249
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
250
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
251
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
252
-				'connect_button'    => __("Connect Site","invoicing"),
253
-				'connecting_button'    => __("Connecting...","invoicing"),
254
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
255
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
249
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
250
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
251
+				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
252
+				'connect_button'    => __("Connect Site", "invoicing"),
253
+				'connecting_button'    => __("Connecting...", "invoicing"),
254
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
255
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
256 256
             ),
257
-            array( 'wpi-addons' )
257
+            array('wpi-addons')
258 258
         );
259 259
 
260 260
     }
@@ -265,19 +265,19 @@  discard block
 block discarded – undo
265 265
     public function activation_redirect() {
266 266
 
267 267
 		// Bail if no activation redirect.
268
-		if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) {
268
+		if (!get_transient('_wpinv_activation_redirect') || wp_doing_ajax()) {
269 269
 			return;
270 270
 		}
271 271
 
272 272
 		// Delete the redirect transient.
273
-		delete_transient( '_wpinv_activation_redirect' );
273
+		delete_transient('_wpinv_activation_redirect');
274 274
 
275 275
 		// Bail if activating from network, or bulk
276
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
276
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
277 277
 			return;
278 278
 		}
279 279
 
280
-		wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
280
+		wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
281 281
 		exit;
282 282
     }
283 283
 
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
      */
287 287
     public function maybe_do_admin_action() {
288 288
 
289
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
290
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
291
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
289
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
290
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
291
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
292 292
         }
293 293
 
294 294
     }
@@ -298,16 +298,16 @@  discard block
 block discarded – undo
298 298
 	 * 
299 299
 	 * @param array $args
300 300
      */
301
-    public function send_customer_invoice( $args ) {
302
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
301
+    public function send_customer_invoice($args) {
302
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']));
303 303
 
304
-		if ( $sent ) {
305
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
304
+		if ($sent) {
305
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
306 306
 		} else {
307
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
307
+			$this->show_error(__('Could not sent the invoice to the customer', 'invoicing'));
308 308
 		}
309 309
 
310
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
310
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
311 311
 		exit;
312 312
 	}
313 313
 
@@ -316,16 +316,16 @@  discard block
 block discarded – undo
316 316
 	 * 
317 317
 	 * @param array $args
318 318
      */
319
-    public function send_customer_payment_reminder( $args ) {
320
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
319
+    public function send_customer_payment_reminder($args) {
320
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
321 321
 
322
-		if ( $sent ) {
323
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
322
+		if ($sent) {
323
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
324 324
 		} else {
325
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
325
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
326 326
 		}
327 327
 
328
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
328
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
329 329
 		exit;
330 330
 	}
331 331
 
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
      * @return array
337 337
 	 */
338 338
 	public function get_notices() {
339
-		$notices = get_option( 'wpinv_admin_notices' );
340
-        return is_array( $notices ) ? $notices : array();
339
+		$notices = get_option('wpinv_admin_notices');
340
+        return is_array($notices) ? $notices : array();
341 341
 	}
342 342
 
343 343
 	/**
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 * @since       1.0.19
348 348
 	 */
349 349
 	public function clear_notices() {
350
-		delete_option( 'wpinv_admin_notices' );
350
+		delete_option('wpinv_admin_notices');
351 351
 	}
352 352
 
353 353
 	/**
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 	 * @access      public
357 357
 	 * @since       1.0.19
358 358
 	 */
359
-	public function save_notice( $type, $message ) {
359
+	public function save_notice($type, $message) {
360 360
 		$notices = $this->get_notices();
361 361
 
362
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
363
-			$notices[ $type ] = array();
362
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
363
+			$notices[$type] = array();
364 364
 		}
365 365
 
366
-		$notices[ $type ][] = $message;
366
+		$notices[$type][] = $message;
367 367
 
368
-		update_option( 'wpinv_admin_notices', $notices );
368
+		update_option('wpinv_admin_notices', $notices);
369 369
 	}
370 370
 
371 371
 	/**
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 	 * @access      public
376 376
 	 * @since       1.0.19
377 377
 	 */
378
-	public function show_success( $msg ) {
379
-		$this->save_notice( 'success', $msg );
378
+	public function show_success($msg) {
379
+		$this->save_notice('success', $msg);
380 380
 	}
381 381
 
382 382
 	/**
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
 	 * @param       string $msg The message to qeue.
387 387
 	 * @since       1.0.19
388 388
 	 */
389
-	public function show_error( $msg ) {
390
-		$this->save_notice( 'error', $msg );
389
+	public function show_error($msg) {
390
+		$this->save_notice('error', $msg);
391 391
 	}
392 392
 
393 393
 	/**
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
 	 * @param       string $msg The message to qeue.
398 398
 	 * @since       1.0.19
399 399
 	 */
400
-	public function show_warning( $msg ) {
401
-		$this->save_notice( 'warning', $msg );
400
+	public function show_warning($msg) {
401
+		$this->save_notice('warning', $msg);
402 402
 	}
403 403
 
404 404
 	/**
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 	 * @param       string $msg The message to qeue.
409 409
 	 * @since       1.0.19
410 410
 	 */
411
-	public function show_info( $msg ) {
412
-		$this->save_notice( 'info', $msg );
411
+	public function show_info($msg) {
412
+		$this->save_notice('info', $msg);
413 413
 	}
414 414
 
415 415
 	/**
@@ -423,15 +423,15 @@  discard block
 block discarded – undo
423 423
         $notices = $this->get_notices();
424 424
         $this->clear_notices();
425 425
 
426
-		foreach ( $notices as $type => $messages ) {
426
+		foreach ($notices as $type => $messages) {
427 427
 
428
-			if ( ! is_array( $messages ) ) {
428
+			if (!is_array($messages)) {
429 429
 				continue;
430 430
 			}
431 431
 
432
-            $type  = sanitize_key( $type );
433
-			foreach ( $messages as $message ) {
434
-                $message = wp_kses_post( $message );
432
+            $type = sanitize_key($type);
433
+			foreach ($messages as $message) {
434
+                $message = wp_kses_post($message);
435 435
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
436 436
             }
437 437
 
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
8
-function wpinv_discount_custom_column( $column ) {
7
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
8
+function wpinv_discount_custom_column($column) {
9 9
     global $post;
10 10
 
11
-    $discount = new WPInv_Discount( $post );
11
+    $discount = new WPInv_Discount($post);
12 12
 
13
-    switch ( $column ) {
13
+    switch ($column) {
14 14
         case 'code' :
15 15
             echo $discount->get_code();
16 16
         break;
@@ -21,37 +21,37 @@  discard block
 block discarded – undo
21 21
             echo $discount->get_usage();
22 22
         break;
23 23
         case 'start_date' :
24
-            echo getpaid_format_date_value( $discount->get_start_date() );
24
+            echo getpaid_format_date_value($discount->get_start_date());
25 25
         break;
26 26
         case 'expiry_date' :
27
-            echo getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) );
27
+            echo getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing'));
28 28
         break;
29 29
     }
30 30
 }
31 31
 
32
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 );
33
-function wpinv_post_row_actions( $actions, $post ) {
34
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
32
+add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2);
33
+function wpinv_post_row_actions($actions, $post) {
34
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
35 35
 
36
-    if ( $post_type == 'wpi_invoice' ) {
36
+    if ($post_type == 'wpi_invoice') {
37 37
         $actions = array();
38 38
     }
39 39
 
40
-    if ( $post_type == 'wpi_discount' ) {
41
-        $actions = wpinv_discount_row_actions( $post, $actions );
40
+    if ($post_type == 'wpi_discount') {
41
+        $actions = wpinv_discount_row_actions($post, $actions);
42 42
     }
43 43
 
44 44
     return $actions;
45 45
 }
46 46
 
47
-function wpinv_discount_row_actions( $discount, $row_actions ) {
48
-    $row_actions  = array();
49
-    $edit_link = get_edit_post_link( $discount->ID );
50
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
47
+function wpinv_discount_row_actions($discount, $row_actions) {
48
+    $row_actions = array();
49
+    $edit_link = get_edit_post_link($discount->ID);
50
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
51 51
 
52
-    if ( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
52
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
53 53
 
54
-        $url    = esc_url(
54
+        $url = esc_url(
55 55
                     wp_nonce_url(
56 56
                         add_query_arg(
57 57
                             array(
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
                         'getpaid-nonce'
64 64
                     )
65 65
                 );
66
-		$anchor = __( 'Deactivate', 'invoicing' );
67
-		$title  = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' );
66
+		$anchor = __('Deactivate', 'invoicing');
67
+		$title  = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing');
68 68
         $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
69 69
 
70
-    } else if( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
70
+    } else if (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
71 71
 
72
-        $url    = esc_url(
72
+        $url = esc_url(
73 73
             wp_nonce_url(
74 74
                 add_query_arg(
75 75
                     array(
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
                 'getpaid-nonce'
82 82
             )
83 83
         );
84
-		$anchor = __( 'Activate', 'invoicing' );
85
-		$title  = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' );
84
+		$anchor = __('Activate', 'invoicing');
85
+		$title  = esc_attr__('Are you sure you want to activate this discount?', 'invoicing');
86 86
         $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
87 87
 
88 88
     }
89 89
 
90
-    $url    = esc_url(
90
+    $url = esc_url(
91 91
         wp_nonce_url(
92 92
             add_query_arg(
93 93
                 array(
@@ -99,81 +99,81 @@  discard block
 block discarded – undo
99 99
             'getpaid-nonce'
100 100
         )
101 101
     );
102
-	$anchor = __( 'Delete', 'invoicing' );
103
-	$title  = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' );
102
+	$anchor = __('Delete', 'invoicing');
103
+	$title  = esc_attr__('Are you sure you want to delete this discount?', 'invoicing');
104 104
     $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
105 105
 
106
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
106
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
107 107
 
108 108
     return $row_actions;
109 109
 }
110 110
 
111
-add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 );
112
-function wpinv_table_primary_column( $default, $screen_id ) {
113
-    if ( 'edit-wpi_invoice' === $screen_id ) {
111
+add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2);
112
+function wpinv_table_primary_column($default, $screen_id) {
113
+    if ('edit-wpi_invoice' === $screen_id) {
114 114
         return 'name';
115 115
     }
116 116
 
117 117
     return $default;
118 118
 }
119 119
 
120
-function wpinv_disable_months_dropdown( $disable, $post_type ) {
121
-    if ( $post_type == 'wpi_discount' ) {
120
+function wpinv_disable_months_dropdown($disable, $post_type) {
121
+    if ($post_type == 'wpi_discount') {
122 122
         $disable = true;
123 123
     }
124 124
 
125 125
     return $disable;
126 126
 }
127
-add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 );
127
+add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2);
128 128
 
129 129
 function wpinv_restrict_manage_posts() {
130 130
     global $typenow;
131 131
 
132
-    if( 'wpi_discount' == $typenow ) {
132
+    if ('wpi_discount' == $typenow) {
133 133
         wpinv_discount_filters();
134 134
     }
135 135
 }
136
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
136
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
137 137
 
138 138
 function wpinv_discount_filters() {
139 139
 
140 140
     ?>
141 141
     <select name="discount_type" id="dropdown_wpinv_discount_type">
142
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
142
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
143 143
         <?php
144 144
             $types = wpinv_get_discount_types();
145 145
 
146
-            foreach ( $types as $name => $type ) {
147
-                echo '<option value="' . esc_attr( $name ) . '"';
146
+            foreach ($types as $name => $type) {
147
+                echo '<option value="' . esc_attr($name) . '"';
148 148
 
149
-                if ( isset( $_GET['discount_type'] ) )
150
-                    selected( $name, $_GET['discount_type'] );
149
+                if (isset($_GET['discount_type']))
150
+                    selected($name, $_GET['discount_type']);
151 151
 
152
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
152
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
153 153
             }
154 154
         ?>
155 155
     </select>
156 156
     <?php
157 157
 }
158 158
 
159
-function wpinv_request( $vars ) {
159
+function wpinv_request($vars) {
160 160
     global $typenow, $wp_query, $wp_post_statuses;
161 161
 
162
-    if ( getpaid_is_invoice_post_type( $typenow ) ) {
163
-        if ( !isset( $vars['post_status'] ) ) {
164
-            $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow );
162
+    if (getpaid_is_invoice_post_type($typenow)) {
163
+        if (!isset($vars['post_status'])) {
164
+            $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow);
165 165
 
166
-            foreach ( $post_statuses as $status => $value ) {
167
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
168
-                    unset( $post_statuses[ $status ] );
166
+            foreach ($post_statuses as $status => $value) {
167
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
168
+                    unset($post_statuses[$status]);
169 169
                 }
170 170
             }
171 171
 
172
-            $vars['post_status'] = array_keys( $post_statuses );
172
+            $vars['post_status'] = array_keys($post_statuses);
173 173
         }
174 174
 
175
-        if ( isset( $vars['orderby'] ) ) {
176
-            if ( 'amount' == $vars['orderby'] ) {
175
+        if (isset($vars['orderby'])) {
176
+            if ('amount' == $vars['orderby']) {
177 177
                 $vars = array_merge(
178 178
                     $vars,
179 179
                     array(
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
                         'orderby'  => 'meta_value_num'
182 182
                     )
183 183
                 );
184
-            } else if ( 'customer' == $vars['orderby'] ) {
184
+            } else if ('customer' == $vars['orderby']) {
185 185
                 $vars = array_merge(
186 186
                     $vars,
187 187
                     array(
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                         'orderby'  => 'meta_value'
190 190
                     )
191 191
                 );
192
-            } else if ( 'number' == $vars['orderby'] ) {
192
+            } else if ('number' == $vars['orderby']) {
193 193
                 $vars = array_merge(
194 194
                     $vars,
195 195
                     array(
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
                         'orderby'  => 'meta_value'
198 198
                     )
199 199
                 );
200
-            } else if ( 'payment_date' == $vars['orderby'] ) {
200
+            } else if ('payment_date' == $vars['orderby']) {
201 201
                 $vars = array_merge(
202 202
                     $vars,
203 203
                     array(
@@ -207,73 +207,73 @@  discard block
 block discarded – undo
207 207
                 );
208 208
             }
209 209
         }
210
-    } else if ( 'wpi_discount' == $typenow ) {
211
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
210
+    } else if ('wpi_discount' == $typenow) {
211
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
212 212
         // Filter vat rule type
213
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
213
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
214 214
             $meta_query[] = array(
215 215
                     'key'   => '_wpi_discount_type',
216
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
216
+                    'value' => sanitize_text_field($_GET['discount_type']),
217 217
                     'compare' => '='
218 218
                 );
219 219
         }
220 220
 
221
-        if ( !empty( $meta_query ) ) {
221
+        if (!empty($meta_query)) {
222 222
             $vars['meta_query'] = $meta_query;
223 223
         }
224 224
     }
225 225
 
226 226
     return $vars;
227 227
 }
228
-add_filter( 'request', 'wpinv_request' );
228
+add_filter('request', 'wpinv_request');
229 229
 
230
-function wpinv_item_type_class( $classes, $class, $post_id ) {
230
+function wpinv_item_type_class($classes, $class, $post_id) {
231 231
     global $pagenow, $typenow;
232 232
 
233
-    if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) {
234
-        if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) {
235
-            $classes[] = 'wpi-type-' . sanitize_html_class( $type );
233
+    if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) {
234
+        if ($type = get_post_meta($post_id, '_wpinv_type', true)) {
235
+            $classes[] = 'wpi-type-' . sanitize_html_class($type);
236 236
         }
237 237
 
238
-        if ( !wpinv_item_is_editable( $post_id ) ) {
238
+        if (!wpinv_item_is_editable($post_id)) {
239 239
             $classes[] = 'wpi-editable-n';
240 240
         }
241 241
     }
242 242
     return $classes;
243 243
 }
244
-add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 );
244
+add_filter('post_class', 'wpinv_item_type_class', 10, 3);
245 245
 
246 246
 function wpinv_check_quick_edit() {
247 247
     global $pagenow, $current_screen, $wpinv_item_screen;
248 248
 
249
-    if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) {
250
-        if ( empty( $wpinv_item_screen ) ) {
251
-            if ( $current_screen->post_type == 'wpi_item' ) {
249
+    if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) {
250
+        if (empty($wpinv_item_screen)) {
251
+            if ($current_screen->post_type == 'wpi_item') {
252 252
                 $wpinv_item_screen = 'y';
253 253
             } else {
254 254
                 $wpinv_item_screen = 'n';
255 255
             }
256 256
         }
257 257
 
258
-        if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) {
259
-            add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
260
-            add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
258
+        if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') {
259
+            add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
260
+            add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
261 261
         }
262 262
     }
263 263
 }
264
-add_action( 'admin_head', 'wpinv_check_quick_edit', 10 );
264
+add_action('admin_head', 'wpinv_check_quick_edit', 10);
265 265
 
266
-function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) {
267
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
268
-        unset( $actions['inline hide-if-no-js'] );
266
+function wpinv_item_disable_quick_edit($actions = array(), $row = null) {
267
+    if (isset($actions['inline hide-if-no-js'])) {
268
+        unset($actions['inline hide-if-no-js']);
269 269
     }
270 270
 
271
-    if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) {
272
-        if ( isset( $actions['trash'] ) ) {
273
-            unset( $actions['trash'] );
271
+    if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) {
272
+        if (isset($actions['trash'])) {
273
+            unset($actions['trash']);
274 274
         }
275
-        if ( isset( $actions['delete'] ) ) {
276
-            unset( $actions['delete'] );
275
+        if (isset($actions['delete'])) {
276
+            unset($actions['delete']);
277 277
         }
278 278
     }
279 279
 
@@ -290,19 +290,19 @@  discard block
 block discarded – undo
290 290
  * @param int $post_parent (default: 0) Parent for the new page
291 291
  * @return int page ID
292 292
  */
293
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
293
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
294 294
     global $wpdb;
295 295
 
296
-    $option_value = wpinv_get_option( $option );
296
+    $option_value = wpinv_get_option($option);
297 297
 
298
-    if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) {
299
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
298
+    if ($option_value > 0 && ($page_object = get_post($option_value))) {
299
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
300 300
             // Valid page is already in place
301 301
             return $page_object->ID;
302 302
         }
303 303
     }
304 304
 
305
-    if(!empty($post_parent)){
305
+    if (!empty($post_parent)) {
306 306
         $page = get_page_by_path($post_parent);
307 307
         if ($page) {
308 308
             $post_parent = $page->ID;
@@ -311,40 +311,40 @@  discard block
 block discarded – undo
311 311
         }
312 312
     }
313 313
 
314
-    if ( strlen( $page_content ) > 0 ) {
314
+    if (strlen($page_content) > 0) {
315 315
         // Search for an existing page with the specified page content (typically a shortcode)
316
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
316
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
317 317
     } else {
318 318
         // Search for an existing page with the specified page slug
319
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
319
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
320 320
     }
321 321
 
322
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
322
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
323 323
 
324
-    if ( $valid_page_found ) {
325
-        if ( $option ) {
326
-            wpinv_update_option( $option, $valid_page_found );
324
+    if ($valid_page_found) {
325
+        if ($option) {
326
+            wpinv_update_option($option, $valid_page_found);
327 327
         }
328 328
         return $valid_page_found;
329 329
     }
330 330
 
331 331
     // Search for a matching valid trashed page
332
-    if ( strlen( $page_content ) > 0 ) {
332
+    if (strlen($page_content) > 0) {
333 333
         // Search for an existing page with the specified page content (typically a shortcode)
334
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
334
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
335 335
     } else {
336 336
         // Search for an existing page with the specified page slug
337
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
337
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
338 338
     }
339 339
 
340
-    if ( $trashed_page_found ) {
340
+    if ($trashed_page_found) {
341 341
         $page_id   = $trashed_page_found;
342 342
         $page_data = array(
343 343
             'ID'             => $page_id,
344 344
             'post_status'    => 'publish',
345 345
             'post_parent'    => $post_parent,
346 346
         );
347
-        wp_update_post( $page_data );
347
+        wp_update_post($page_data);
348 348
     } else {
349 349
         $page_data = array(
350 350
             'post_status'    => 'publish',
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
             'post_parent'    => $post_parent,
357 357
             'comment_status' => 'closed',
358 358
         );
359
-        $page_id = wp_insert_post( $page_data );
359
+        $page_id = wp_insert_post($page_data);
360 360
     }
361 361
 
362
-    if ( $option ) {
363
-        wpinv_update_option( $option, (int)$page_id );
362
+    if ($option) {
363
+        wpinv_update_option($option, (int) $page_id);
364 364
     }
365 365
 
366 366
     return $page_id;
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 1 patch
Spacing   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Post types Admin Class
@@ -21,69 +21,69 @@  discard block
 block discarded – undo
21 21
 		GetPaid_Metaboxes::init();
22 22
 
23 23
 		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
24
+		add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages');
25 25
 
26 26
 		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
27
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2);
28 28
 
29 29
 		// Invoice table columns.
30
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
31
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
30
+		add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100);
31
+		add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2);
32 32
 
33 33
 		// Items table columns.
34
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
35
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
36
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
37
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
38
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
39
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
34
+		add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100);
35
+		add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20);
36
+		add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2);
37
+		add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100);
38
+		add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100);
39
+		add_action('request', array(__CLASS__, 'reorder_items'), 100);
40 40
 
41 41
 		// Payment forms columns.
42
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
43
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
44
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
42
+		add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100);
43
+		add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2);
44
+		add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2);
45 45
 
46 46
 		// Discount table columns.
47
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
48
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
47
+		add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100);
48
+		add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100);
49 49
 
50 50
 		// Deleting posts.
51
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
52
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
51
+		add_action('delete_post', array(__CLASS__, 'delete_post'));
52
+		add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2);
53 53
 	}
54 54
 
55 55
 	/**
56 56
 	 * Post updated messages.
57 57
 	 */
58
-	public static function post_updated_messages( $messages ) {
58
+	public static function post_updated_messages($messages) {
59 59
 		global $post;
60 60
 
61 61
 		$messages['wpi_discount'] = array(
62 62
 			0   => '',
63
-			1   => __( 'Discount updated.', 'invoicing' ),
64
-			2   => __( 'Custom field updated.', 'invoicing' ),
65
-			3   => __( 'Custom field deleted.', 'invoicing' ),
66
-			4   => __( 'Discount updated.', 'invoicing' ),
67
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
68
-			6   => __( 'Discount updated.', 'invoicing' ),
69
-			7   => __( 'Discount saved.', 'invoicing' ),
70
-			8   => __( 'Discount submitted.', 'invoicing' ),
71
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
72
-			10  => __( 'Discount draft updated.', 'invoicing' ),
63
+			1   => __('Discount updated.', 'invoicing'),
64
+			2   => __('Custom field updated.', 'invoicing'),
65
+			3   => __('Custom field deleted.', 'invoicing'),
66
+			4   => __('Discount updated.', 'invoicing'),
67
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
68
+			6   => __('Discount updated.', 'invoicing'),
69
+			7   => __('Discount saved.', 'invoicing'),
70
+			8   => __('Discount submitted.', 'invoicing'),
71
+			9   => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
72
+			10  => __('Discount draft updated.', 'invoicing'),
73 73
 		);
74 74
 
75 75
 		$messages['wpi_payment_form'] = array(
76 76
 			0   => '',
77
-			1   => __( 'Payment Form updated.', 'invoicing' ),
78
-			2   => __( 'Custom field updated.', 'invoicing' ),
79
-			3   => __( 'Custom field deleted.', 'invoicing' ),
80
-			4   => __( 'Payment Form updated.', 'invoicing' ),
81
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
82
-			6   => __( 'Payment Form updated.', 'invoicing' ),
83
-			7   => __( 'Payment Form saved.', 'invoicing' ),
84
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
85
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
86
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
77
+			1   => __('Payment Form updated.', 'invoicing'),
78
+			2   => __('Custom field updated.', 'invoicing'),
79
+			3   => __('Custom field deleted.', 'invoicing'),
80
+			4   => __('Payment Form updated.', 'invoicing'),
81
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
82
+			6   => __('Payment Form updated.', 'invoicing'),
83
+			7   => __('Payment Form saved.', 'invoicing'),
84
+			8   => __('Payment Form submitted.', 'invoicing'),
85
+			9   => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
86
+			10  => __('Payment Form draft updated.', 'invoicing'),
87 87
 		);
88 88
 
89 89
 		return $messages;
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
 	/**
94 94
 	 * Post row actions.
95 95
 	 */
96
-	public static function post_row_actions( $actions, $post ) {
96
+	public static function post_row_actions($actions, $post) {
97 97
 
98
-		$post = get_post( $post );
98
+		$post = get_post($post);
99 99
 
100 100
 		// We do not want to edit the default payment form.
101
-		if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
102
-			unset( $actions['trash'] );
103
-			unset( $actions['inline hide-if-no-js'] );
101
+		if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) {
102
+			unset($actions['trash']);
103
+			unset($actions['inline hide-if-no-js']);
104 104
 		}
105 105
 
106 106
 		return $actions;
@@ -109,51 +109,51 @@  discard block
 block discarded – undo
109 109
 	/**
110 110
 	 * Returns an array of invoice table columns.
111 111
 	 */
112
-	public static function invoice_columns( $columns ) {
112
+	public static function invoice_columns($columns) {
113 113
 
114 114
 		$columns = array(
115 115
 			'cb'                => $columns['cb'],
116
-			'number'            => __( 'Invoice', 'invoicing' ),
117
-			'customer'          => __( 'Customer', 'invoicing' ),
118
-			'invoice_date'      => __( 'Date', 'invoicing' ),
119
-			'amount'            => __( 'Amount', 'invoicing' ),
120
-			'recurring'         => __( 'Recurring', 'invoicing' ),
121
-			'status'            => __( 'Status', 'invoicing' ),
122
-			'wpi_actions'       => __( 'Actions', 'invoicing' ),
116
+			'number'            => __('Invoice', 'invoicing'),
117
+			'customer'          => __('Customer', 'invoicing'),
118
+			'invoice_date'      => __('Date', 'invoicing'),
119
+			'amount'            => __('Amount', 'invoicing'),
120
+			'recurring'         => __('Recurring', 'invoicing'),
121
+			'status'            => __('Status', 'invoicing'),
122
+			'wpi_actions'       => __('Actions', 'invoicing'),
123 123
 		);
124 124
 
125
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
125
+		return apply_filters('wpi_invoice_table_columns', $columns);
126 126
 	}
127 127
 
128 128
 	/**
129 129
 	 * Displays invoice table columns.
130 130
 	 */
131
-	public static function display_invoice_columns( $column_name, $post_id ) {
131
+	public static function display_invoice_columns($column_name, $post_id) {
132 132
 
133
-		$invoice = new WPInv_Invoice( $post_id );
133
+		$invoice = new WPInv_Invoice($post_id);
134 134
 
135
-		switch ( $column_name ) {
135
+		switch ($column_name) {
136 136
 
137 137
 			case 'invoice_date' :
138
-				$date_time = esc_attr( $invoice->get_created_date() );
139
-				$date      = getpaid_format_date_value( $date_time );
138
+				$date_time = esc_attr($invoice->get_created_date());
139
+				$date      = getpaid_format_date_value($date_time);
140 140
 				echo "<span title='$date_time'>$date</span>";
141 141
 				break;
142 142
 
143 143
 			case 'amount' :
144 144
 
145 145
 				$amount = $invoice->get_total();
146
-				$formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() );
146
+				$formated_amount = wpinv_price(wpinv_format_amount($amount), $invoice->get_currency());
147 147
 
148
-				if ( $invoice->is_refunded() ) {
149
-					$refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() );
148
+				if ($invoice->is_refunded()) {
149
+					$refunded_amount = wpinv_price(wpinv_format_amount(0), $invoice->get_currency());
150 150
 					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
151 151
 				} else {
152 152
 
153 153
 					$discount = $invoice->get_total_discount();
154 154
 
155
-					if ( ! empty( $discount ) ) {
156
-						$new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() );
155
+					if (!empty($discount)) {
156
+						$new_amount = wpinv_price(wpinv_format_amount($amount + $discount), $invoice->get_currency());
157 157
 						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
158 158
 					} else {
159 159
 						echo $formated_amount;
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
 				break;
165 165
 
166 166
 			case 'status' :
167
-				$status       = sanitize_text_field( $invoice->get_status() );
168
-				$status_label = sanitize_text_field( $invoice->get_status_nicename() );
167
+				$status       = sanitize_text_field($invoice->get_status());
168
+				$status_label = sanitize_text_field($invoice->get_status_nicename());
169 169
 
170 170
 				// If it is paid, show the gateway title.
171
-				if ( $invoice->is_paid() ) {
172
-					$gateway = sanitize_text_field( $invoice->get_gateway_title() );
173
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
171
+				if ($invoice->is_paid()) {
172
+					$gateway = sanitize_text_field($invoice->get_gateway_title());
173
+					$gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway);
174 174
 
175 175
 					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
176 176
 				} else {
@@ -178,22 +178,22 @@  discard block
 block discarded – undo
178 178
 				}
179 179
 
180 180
 				// If it is not paid, display the overdue and view status.
181
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
181
+				if (!$invoice->is_paid() && !$invoice->is_refunded()) {
182 182
 
183 183
 					// Invoice view status.
184
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
185
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
184
+					if (wpinv_is_invoice_viewed($invoice->get_id())) {
185
+						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>';
186 186
 					} else {
187
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
187
+						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>';
188 188
 					}
189 189
 
190 190
 					// Display the overview status.
191
-					if ( wpinv_get_option( 'overdue_active' ) ) {
191
+					if (wpinv_get_option('overdue_active')) {
192 192
 						$due_date = $invoice->get_due_date();
193
-						$fomatted = getpaid_format_date( $due_date );
193
+						$fomatted = getpaid_format_date($due_date);
194 194
 
195
-						if ( ! empty( $fomatted ) ) {
196
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
195
+						if (!empty($fomatted)) {
196
+							$date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted);
197 197
 							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
198 198
 						}
199 199
 					}
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
 			case 'recurring':
206 206
 
207
-				if ( $invoice->is_recurring() ) {
207
+				if ($invoice->is_recurring()) {
208 208
 					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
209 209
 				} else {
210 210
 					echo '<i class="fa fa-times" style="color:#616161;"></i>';
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 
214 214
 			case 'number' :
215 215
 
216
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
217
-				$invoice_number  = sanitize_text_field( $invoice->get_number() );
218
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
216
+				$edit_link       = esc_url(get_edit_post_link($invoice->get_id()));
217
+				$invoice_number  = sanitize_text_field($invoice->get_number());
218
+				$invoice_details = esc_attr__('View Invoice Details', 'invoicing');
219 219
 
220 220
 				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
221 221
 
@@ -225,13 +225,13 @@  discard block
 block discarded – undo
225 225
 	
226 226
 				$customer_name = $invoice->get_user_full_name();
227 227
 	
228
-				if ( empty( $customer_name ) ) {
228
+				if (empty($customer_name)) {
229 229
 					$customer_name = $invoice->get_email();
230 230
 				}
231 231
 	
232
-				if ( ! empty( $customer_name ) ) {
233
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
234
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
232
+				if (!empty($customer_name)) {
233
+					$customer_details = esc_attr__('View Customer Details', 'invoicing');
234
+					$view_link        = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php')));
235 235
 					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
236 236
 				} else {
237 237
 					echo '<div>&mdash;</div>';
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
 
242 242
 			case 'wpi_actions' :
243 243
 
244
-				if ( $invoice->is_draft() ) {
244
+				if ($invoice->is_draft()) {
245 245
 					return;
246 246
 				}
247 247
 
248
-				$url    = esc_url( $invoice->get_view_url() );
249
-				$print  = esc_attr__( 'Print invoice', 'invoicing' );
248
+				$url    = esc_url($invoice->get_view_url());
249
+				$print  = esc_attr__('Print invoice', 'invoicing');
250 250
 				echo "&nbsp;<a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>";
251 251
 
252 252
 				$url    = esc_url(
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 					)
263 263
 				);
264 264
 
265
-				$send   = esc_attr__( 'Send invoice to customer', 'invoicing' );
265
+				$send = esc_attr__('Send invoice to customer', 'invoicing');
266 266
 				echo "&nbsp;&nbsp;<a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>";
267 267
 
268 268
 				break;
@@ -273,50 +273,50 @@  discard block
 block discarded – undo
273 273
 	/**
274 274
 	 * Returns an array of payment forms table columns.
275 275
 	 */
276
-	public static function payment_form_columns( $columns ) {
276
+	public static function payment_form_columns($columns) {
277 277
 
278 278
 		$columns = array(
279 279
 			'cb'                => $columns['cb'],
280
-			'title'             => __( 'Name', 'invoicing' ),
281
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
282
-			'earnings'          => __( 'Revenue', 'invoicing' ),
283
-			'refunds'           => __( 'Refunded', 'invoicing' ),
284
-			'items'             => __( 'Items', 'invoicing' ),
285
-			'date'              => __( 'Date', 'invoicing' ),
280
+			'title'             => __('Name', 'invoicing'),
281
+			'shortcode'         => __('Shortcode', 'invoicing'),
282
+			'earnings'          => __('Revenue', 'invoicing'),
283
+			'refunds'           => __('Refunded', 'invoicing'),
284
+			'items'             => __('Items', 'invoicing'),
285
+			'date'              => __('Date', 'invoicing'),
286 286
 		);
287 287
 
288
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
288
+		return apply_filters('wpi_payment_form_table_columns', $columns);
289 289
 
290 290
 	}
291 291
 
292 292
 	/**
293 293
 	 * Displays payment form table columns.
294 294
 	 */
295
-	public static function display_payment_form_columns( $column_name, $post_id ) {
295
+	public static function display_payment_form_columns($column_name, $post_id) {
296 296
 
297 297
 		// Retrieve the payment form.
298
-		$form = new GetPaid_Payment_Form( $post_id );
298
+		$form = new GetPaid_Payment_Form($post_id);
299 299
 
300
-		switch ( $column_name ) {
300
+		switch ($column_name) {
301 301
 
302 302
 			case 'earnings' :
303
-				echo wpinv_price( wpinv_format_amount( $form->get_earned() ) );
303
+				echo wpinv_price(wpinv_format_amount($form->get_earned()));
304 304
 				break;
305 305
 
306 306
 			case 'refunds' :
307
-				echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
307
+				echo wpinv_price(wpinv_format_amount($form->get_refunded()));
308 308
 				break;
309 309
 
310 310
 			case 'refunds' :
311
-				echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
311
+				echo wpinv_price(wpinv_format_amount($form->get_refunded()));
312 312
 				break;
313 313
 
314 314
 			case 'shortcode' :
315 315
 
316
-				if ( $form->is_default() ) {
316
+				if ($form->is_default()) {
317 317
 					echo '&mdash;';
318 318
 				} else {
319
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
319
+					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>';
320 320
 				}
321 321
 
322 322
 				break;
@@ -325,29 +325,29 @@  discard block
 block discarded – undo
325 325
 
326 326
 				$items = $form->get_items();
327 327
 
328
-				if ( $form->is_default() || empty( $items ) ) {
328
+				if ($form->is_default() || empty($items)) {
329 329
 					echo '&mdash;';
330 330
 					return;
331 331
 				}
332 332
 
333 333
 				$_items = array();
334 334
 
335
-				foreach ( $items as $item ) {
335
+				foreach ($items as $item) {
336 336
 					$url = $item->get_edit_url();
337 337
 
338
-					if ( empty( $url ) ) {
339
-						$_items[] = sanitize_text_field( $item->get_name() );
338
+					if (empty($url)) {
339
+						$_items[] = sanitize_text_field($item->get_name());
340 340
 					} else {
341 341
 						$_items[] = sprintf(
342 342
 							'<a href="%s">%s</a>',
343
-							esc_url( $url ),
344
-							sanitize_text_field( $item->get_name() )
343
+							esc_url($url),
344
+							sanitize_text_field($item->get_name())
345 345
 						);
346 346
 					}
347 347
 
348 348
 				}
349 349
 
350
-				echo implode( '<br>', $_items );
350
+				echo implode('<br>', $_items);
351 351
 
352 352
 				break;
353 353
 
@@ -358,10 +358,10 @@  discard block
 block discarded – undo
358 358
 	/**
359 359
 	 * Filters post states.
360 360
 	 */
361
-	public static function filter_payment_form_state( $post_states, $post ) {
361
+	public static function filter_payment_form_state($post_states, $post) {
362 362
 
363
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
364
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
363
+		if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) {
364
+			$post_states['default_form'] = __('Default Payment Form', 'invoicing');
365 365
 		}
366 366
 	
367 367
 		return $post_states;
@@ -371,35 +371,35 @@  discard block
 block discarded – undo
371 371
 	/**
372 372
 	 * Returns an array of coupon table columns.
373 373
 	 */
374
-	public static function discount_columns( $columns ) {
374
+	public static function discount_columns($columns) {
375 375
 
376 376
 		$columns = array(
377 377
 			'cb'                => $columns['cb'],
378
-			'title'             => __( 'Name', 'invoicing' ),
379
-			'code'              => __( 'Code', 'invoicing' ),
380
-			'amount'            => __( 'Amount', 'invoicing' ),
381
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
382
-			'start_date'        => __( 'Start Date', 'invoicing' ),
383
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
378
+			'title'             => __('Name', 'invoicing'),
379
+			'code'              => __('Code', 'invoicing'),
380
+			'amount'            => __('Amount', 'invoicing'),
381
+			'usage'             => __('Usage / Limit', 'invoicing'),
382
+			'start_date'        => __('Start Date', 'invoicing'),
383
+			'expiry_date'       => __('Expiry Date', 'invoicing'),
384 384
 		);
385 385
 
386
-		return apply_filters( 'wpi_discount_table_columns', $columns );
386
+		return apply_filters('wpi_discount_table_columns', $columns);
387 387
 	}
388 388
 
389 389
 	/**
390 390
 	 * Filters post states.
391 391
 	 */
392
-	public static function filter_discount_state( $post_states, $post ) {
392
+	public static function filter_discount_state($post_states, $post) {
393 393
 
394
-		if ( 'wpi_discount' == $post->post_type ) {
394
+		if ('wpi_discount' == $post->post_type) {
395 395
 
396
-			$discount = new WPInv_Discount( $post );
396
+			$discount = new WPInv_Discount($post);
397 397
 
398 398
 			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
399 399
 
400
-			if ( $status != 'publish' ) {
400
+			if ($status != 'publish') {
401 401
 				return array(
402
-					'discount_status' => wpinv_discount_status( $status ),
402
+					'discount_status' => wpinv_discount_status($status),
403 403
 				);
404 404
 			}
405 405
 
@@ -414,34 +414,34 @@  discard block
 block discarded – undo
414 414
 	/**
415 415
 	 * Returns an array of items table columns.
416 416
 	 */
417
-	public static function item_columns( $columns ) {
417
+	public static function item_columns($columns) {
418 418
 		global $wpinv_euvat;
419 419
 
420 420
 		$columns = array(
421 421
 			'cb'                => $columns['cb'],
422
-			'title'             => __( 'Name', 'invoicing' ),
423
-			'price'             => __( 'Price', 'invoicing' ),
424
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
425
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
426
-			'type'              => __( 'Type', 'invoicing' ),
427
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
422
+			'title'             => __('Name', 'invoicing'),
423
+			'price'             => __('Price', 'invoicing'),
424
+			'vat_rule'          => __('VAT rule', 'invoicing'),
425
+			'vat_class'         => __('VAT class', 'invoicing'),
426
+			'type'              => __('Type', 'invoicing'),
427
+			'shortcode'         => __('Shortcode', 'invoicing'),
428 428
 		);
429 429
 
430
-		if ( ! $wpinv_euvat->allow_vat_rules() ) {
431
-			unset( $columns['vat_rule'] );
430
+		if (!$wpinv_euvat->allow_vat_rules()) {
431
+			unset($columns['vat_rule']);
432 432
 		}
433 433
 
434
-		if ( ! $wpinv_euvat->allow_vat_classes() ) {
435
-			unset( $columns['vat_class'] );
434
+		if (!$wpinv_euvat->allow_vat_classes()) {
435
+			unset($columns['vat_class']);
436 436
 		}
437 437
 
438
-		return apply_filters( 'wpi_item_table_columns', $columns );
438
+		return apply_filters('wpi_item_table_columns', $columns);
439 439
 	}
440 440
 
441 441
 	/**
442 442
 	 * Returns an array of sortable items table columns.
443 443
 	 */
444
-	public static function sortable_item_columns( $columns ) {
444
+	public static function sortable_item_columns($columns) {
445 445
 
446 446
 		return array_merge(
447 447
 			$columns,
@@ -458,50 +458,50 @@  discard block
 block discarded – undo
458 458
 	/**
459 459
 	 * Displays items table columns.
460 460
 	 */
461
-	public static function display_item_columns( $column_name, $post_id ) {
461
+	public static function display_item_columns($column_name, $post_id) {
462 462
 		global $wpinv_euvat;
463 463
 
464
-		$item = new WPInv_Item( $post_id );
464
+		$item = new WPInv_Item($post_id);
465 465
 
466
-		switch ( $column_name ) {
466
+		switch ($column_name) {
467 467
 
468 468
 			case 'price' :
469 469
 
470
-				if ( ! $item->is_recurring() ) {
470
+				if (!$item->is_recurring()) {
471 471
 					echo $item->get_the_price();
472 472
 					break;
473 473
 				}
474 474
 
475 475
 				$price = wp_sprintf(
476
-					__( '%s / %s', 'invoicing' ),
476
+					__('%s / %s', 'invoicing'),
477 477
 					$item->get_the_price(),
478
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
478
+					getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '')
479 479
 				);
480 480
 
481
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
481
+				if ($item->get_the_price() == $item->get_the_initial_price()) {
482 482
 					echo $price;
483 483
 					break;
484 484
 				}
485 485
 
486 486
 				echo $item->get_the_initial_price();
487 487
 
488
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
488
+				echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>';
489 489
 				break;
490 490
 
491 491
 			case 'vat_rule' :
492
-				echo $wpinv_euvat->item_rule_label( $item->get_id() );
492
+				echo $wpinv_euvat->item_rule_label($item->get_id());
493 493
 				break;
494 494
 
495 495
 			case 'vat_class' :
496
-				echo $wpinv_euvat->item_class_label( $item->get_id() );
496
+				echo $wpinv_euvat->item_class_label($item->get_id());
497 497
 				break;
498 498
 
499 499
 			case 'shortcode' :
500
-				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
500
+				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
501 501
 				break;
502 502
 
503 503
 			case 'type' :
504
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
504
+				echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
505 505
 				break;
506 506
 
507 507
 		}
@@ -511,22 +511,22 @@  discard block
 block discarded – undo
511 511
 	/**
512 512
 	 * Lets users filter items using taxes.
513 513
 	 */
514
-	public static function add_item_filters( $post_type ) {
514
+	public static function add_item_filters($post_type) {
515 515
 		$wpinv_euvat = getpaid_tax();
516 516
 
517 517
 		// Abort if we're not dealing with items.
518
-		if ( $post_type != 'wpi_item' ) {
518
+		if ($post_type != 'wpi_item') {
519 519
 			return;
520 520
 		}
521 521
 
522 522
 		// Filter by vat rules.
523
-		if ( $wpinv_euvat->allow_vat_rules() ) {
523
+		if ($wpinv_euvat->allow_vat_rules()) {
524 524
 	
525 525
 			// Sanitize selected vat rule.
526 526
 			$vat_rule   = '';
527 527
 			$vat_rules  = $wpinv_euvat->get_rules();
528
-			if ( isset( $_GET['vat_rule'] ) ) {
529
-				$vat_rule   =  $_GET['vat_rule'];
528
+			if (isset($_GET['vat_rule'])) {
529
+				$vat_rule = $_GET['vat_rule'];
530 530
 			}
531 531
 
532 532
 			// Filter by VAT rule.
@@ -534,13 +534,13 @@  discard block
 block discarded – undo
534 534
 				array(
535 535
 					'options'          => array_merge(
536 536
 						array(
537
-							'' => __( 'All VAT rules', 'invoicing' )
537
+							'' => __('All VAT rules', 'invoicing')
538 538
 						),
539 539
 						$vat_rules
540 540
 					),
541 541
 					'name'             => 'vat_rule',
542 542
 					'id'               => 'vat_rule',
543
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
543
+					'selected'         => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '',
544 544
 					'show_option_all'  => false,
545 545
 					'show_option_none' => false,
546 546
 					'class'            => 'gdmbx2-text-medium',
@@ -551,26 +551,26 @@  discard block
 block discarded – undo
551 551
 		}
552 552
 
553 553
 		// Filter by vat class.
554
-		if ( $wpinv_euvat->allow_vat_classes() ) {
554
+		if ($wpinv_euvat->allow_vat_classes()) {
555 555
 	
556 556
 			// Sanitize selected vat rule.
557 557
 			$vat_class   = '';
558 558
 			$vat_classes = $wpinv_euvat->get_all_classes();
559
-			if ( isset( $_GET['vat_class'] ) ) {
560
-				$vat_class   =  $_GET['vat_class'];
559
+			if (isset($_GET['vat_class'])) {
560
+				$vat_class = $_GET['vat_class'];
561 561
 			}
562 562
 
563 563
 			echo wpinv_html_select(
564 564
 				array(
565 565
 					'options'          => array_merge(
566 566
 						array(
567
-							'' => __( 'All VAT classes', 'invoicing' )
567
+							'' => __('All VAT classes', 'invoicing')
568 568
 						),
569 569
 						$vat_classes
570 570
 					),
571 571
 					'name'             => 'vat_class',
572 572
 					'id'               => 'vat_class',
573
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
573
+					'selected'         => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '',
574 574
 					'show_option_all'  => false,
575 575
 					'show_option_none' => false,
576 576
 					'class'            => 'gdmbx2-text-medium',
@@ -580,22 +580,22 @@  discard block
 block discarded – undo
580 580
 		}
581 581
 
582 582
 		// Filter by item type.
583
-		$type   = '';
584
-		if ( isset( $_GET['type'] ) ) {
585
-			$type   =  $_GET['type'];
583
+		$type = '';
584
+		if (isset($_GET['type'])) {
585
+			$type = $_GET['type'];
586 586
 		}
587 587
 
588 588
 		echo wpinv_html_select(
589 589
 			array(
590 590
 				'options'          => array_merge(
591 591
 					array(
592
-						'' => __( 'All item types', 'invoicing' )
592
+						'' => __('All item types', 'invoicing')
593 593
 					),
594 594
 					wpinv_get_item_types()
595 595
 				),
596 596
 				'name'             => 'type',
597 597
 				'id'               => 'type',
598
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
598
+				'selected'         => in_array($type, wpinv_item_types()) ? $type : '',
599 599
 				'show_option_all'  => false,
600 600
 				'show_option_none' => false,
601 601
 				'class'            => 'gdmbx2-text-medium',
@@ -607,45 +607,45 @@  discard block
 block discarded – undo
607 607
 	/**
608 608
 	 * Filters the item query.
609 609
 	 */
610
-	public static function filter_item_query( $query ) {
610
+	public static function filter_item_query($query) {
611 611
 
612 612
 		// modify the query only if it admin and main query.
613
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
613
+		if (!(is_admin() && $query->is_main_query())) { 
614 614
 			return $query;
615 615
 		}
616 616
 
617 617
 		// we want to modify the query for our items.
618
-		if ( 'wpi_item' != $query->query['post_type'] ){
618
+		if ('wpi_item' != $query->query['post_type']) {
619 619
 			return $query;
620 620
 		}
621 621
 
622
-		if ( empty( $query->query_vars['meta_query'] ) ) {
622
+		if (empty($query->query_vars['meta_query'])) {
623 623
 			$query->query_vars['meta_query'] = array();
624 624
 		}
625 625
 
626 626
 		// Filter vat rule type
627
-        if ( ! empty( $_GET['vat_rule'] ) ) {
627
+        if (!empty($_GET['vat_rule'])) {
628 628
             $query->query_vars['meta_query'][] = array(
629 629
                 'key'     => '_wpinv_vat_rule',
630
-                'value'   => sanitize_text_field( $_GET['vat_rule'] ),
630
+                'value'   => sanitize_text_field($_GET['vat_rule']),
631 631
                 'compare' => '='
632 632
             );
633 633
         }
634 634
 
635 635
         // Filter vat class
636
-        if ( ! empty( $_GET['vat_class'] ) ) {
636
+        if (!empty($_GET['vat_class'])) {
637 637
             $query->query_vars['meta_query'][] = array(
638 638
                 'key'     => '_wpinv_vat_class',
639
-                'value'   => sanitize_text_field( $_GET['vat_class'] ),
639
+                'value'   => sanitize_text_field($_GET['vat_class']),
640 640
                 'compare' => '='
641 641
             );
642 642
         }
643 643
 
644 644
         // Filter item type
645
-        if ( ! empty( $_GET['type'] ) ) {
645
+        if (!empty($_GET['type'])) {
646 646
             $query->query_vars['meta_query'][] = array(
647 647
                 'key'     => '_wpinv_type',
648
-                'value'   => sanitize_text_field( $_GET['type'] ),
648
+                'value'   => sanitize_text_field($_GET['type']),
649 649
                 'compare' => '='
650 650
             );
651 651
 		}
@@ -655,15 +655,15 @@  discard block
 block discarded – undo
655 655
 	/**
656 656
 	 * Reorders items.
657 657
 	 */
658
-	public static function reorder_items( $vars ) {
658
+	public static function reorder_items($vars) {
659 659
 		global $typenow;
660 660
 
661
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
661
+		if ('wpi_item' !== $typenow || empty($vars['orderby'])) {
662 662
 			return $vars;
663 663
 		}
664 664
 
665 665
 		// By item type.
666
-		if ( 'type' == $vars['orderby'] ) {
666
+		if ('type' == $vars['orderby']) {
667 667
 			return array_merge(
668 668
 				$vars,
669 669
 				array(
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 		}
675 675
 
676 676
 		// By vat class.
677
-		if ( 'vat_class' == $vars['orderby'] ) {
677
+		if ('vat_class' == $vars['orderby']) {
678 678
 			return array_merge(
679 679
 				$vars,
680 680
 				array(
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 		}
686 686
 
687 687
 		// By vat rule.
688
-		if ( 'vat_rule' == $vars['orderby'] ) {
688
+		if ('vat_rule' == $vars['orderby']) {
689 689
 			return array_merge(
690 690
 				$vars,
691 691
 				array(
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 		}
697 697
 
698 698
 		// By price.
699
-		if ( 'price' == $vars['orderby'] ) {
699
+		if ('price' == $vars['orderby']) {
700 700
 			return array_merge(
701 701
 				$vars,
702 702
 				array(
@@ -713,27 +713,27 @@  discard block
 block discarded – undo
713 713
 	/**
714 714
 	 * Fired when deleting a post.
715 715
 	 */
716
-	public static function delete_post( $post_id ) {
716
+	public static function delete_post($post_id) {
717 717
 
718
-		switch ( get_post_type( $post_id ) ) {
718
+		switch (get_post_type($post_id)) {
719 719
 
720 720
 			case 'wpi_item' :
721
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
721
+				do_action("getpaid_before_delete_item", new WPInv_Item($post_id));
722 722
 				break;
723 723
 
724 724
 			case 'wpi_payment_form' :
725
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
725
+				do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id));
726 726
 				break;
727 727
 
728 728
 			case 'wpi_discount' :
729
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
729
+				do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id));
730 730
 				break;
731 731
 
732 732
 			case 'wpi_invoice' :
733
-				$invoice = new WPInv_Invoice( $post_id );
734
-				do_action( "getpaid_before_delete_invoice", $invoice );
735
-				$invoice->get_data_store()->delete_items( $invoice );
736
-				$invoice->get_data_store()->delete_special_fields( $invoice );
733
+				$invoice = new WPInv_Invoice($post_id);
734
+				do_action("getpaid_before_delete_invoice", $invoice);
735
+				$invoice->get_data_store()->delete_items($invoice);
736
+				$invoice->get_data_store()->delete_special_fields($invoice);
737 737
 				break;
738 738
 		}
739 739
 	}
Please login to merge, or discard this patch.
includes/class-wpinv-legacy-invoice.php 1 patch
Spacing   +519 added lines, -519 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 final class WPInv_Legacy_Invoice {
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     /**
17 17
      * Invoice id.
18 18
      */
19
-    public $ID  = 0;
19
+    public $ID = 0;
20 20
 
21 21
     /**
22 22
      * The title of the invoice. Usually the invoice number.
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     /**
133 133
      * The invoice status.
134 134
      */
135
-    public $status      = 'wpi-pending';
135
+    public $status = 'wpi-pending';
136 136
 
137 137
     /**
138 138
      * Same as self::$status.
@@ -259,17 +259,17 @@  discard block
 block discarded – undo
259 259
      */
260 260
     public $parent_invoice = 0;
261 261
     
262
-    public function __construct( $invoice_id = false ) {
263
-        if( empty( $invoice_id ) ) {
262
+    public function __construct($invoice_id = false) {
263
+        if (empty($invoice_id)) {
264 264
             return false;
265 265
         }
266 266
 
267
-        $this->setup_invoice( $invoice_id );
267
+        $this->setup_invoice($invoice_id);
268 268
     }
269 269
 
270
-    public function get( $key ) {
271
-        if ( method_exists( $this, 'get_' . $key ) ) {
272
-            $value = call_user_func( array( $this, 'get_' . $key ) );
270
+    public function get($key) {
271
+        if (method_exists($this, 'get_' . $key)) {
272
+            $value = call_user_func(array($this, 'get_' . $key));
273 273
         } else {
274 274
             $value = $this->$key;
275 275
         }
@@ -277,51 +277,51 @@  discard block
 block discarded – undo
277 277
         return $value;
278 278
     }
279 279
 
280
-    public function set( $key, $value ) {
281
-        $ignore = array( 'items', 'cart_details', 'fees', '_ID' );
280
+    public function set($key, $value) {
281
+        $ignore = array('items', 'cart_details', 'fees', '_ID');
282 282
 
283
-        if ( $key === 'status' ) {
283
+        if ($key === 'status') {
284 284
             $this->old_status = $this->status;
285 285
         }
286 286
 
287
-        if ( ! in_array( $key, $ignore ) ) {
288
-            $this->pending[ $key ] = $value;
287
+        if (!in_array($key, $ignore)) {
288
+            $this->pending[$key] = $value;
289 289
         }
290 290
 
291
-        if( '_ID' !== $key ) {
291
+        if ('_ID' !== $key) {
292 292
             $this->$key = $value;
293 293
         }
294 294
     }
295 295
 
296
-    public function _isset( $name ) {
297
-        if ( property_exists( $this, $name) ) {
298
-            return false === empty( $this->$name );
296
+    public function _isset($name) {
297
+        if (property_exists($this, $name)) {
298
+            return false === empty($this->$name);
299 299
         } else {
300 300
             return null;
301 301
         }
302 302
     }
303 303
 
304
-    private function setup_invoice( $invoice_id ) {
304
+    private function setup_invoice($invoice_id) {
305 305
         $this->pending = array();
306 306
 
307
-        if ( empty( $invoice_id ) ) {
307
+        if (empty($invoice_id)) {
308 308
             return false;
309 309
         }
310 310
 
311
-        $invoice = get_post( $invoice_id );
311
+        $invoice = get_post($invoice_id);
312 312
 
313
-        if( !$invoice || is_wp_error( $invoice ) ) {
313
+        if (!$invoice || is_wp_error($invoice)) {
314 314
             return false;
315 315
         }
316 316
 
317
-        if( !('wpi_invoice' == $invoice->post_type OR 'wpi_quote' == $invoice->post_type) ) {
317
+        if (!('wpi_invoice' == $invoice->post_type OR 'wpi_quote' == $invoice->post_type)) {
318 318
             return false;
319 319
         }
320 320
 
321
-        do_action( 'wpinv_pre_setup_invoice', $this, $invoice_id );
321
+        do_action('wpinv_pre_setup_invoice', $this, $invoice_id);
322 322
 
323 323
         // Primary Identifier
324
-        $this->ID              = absint( $invoice_id );
324
+        $this->ID              = absint($invoice_id);
325 325
         $this->post_type       = $invoice->post_type;
326 326
 
327 327
         // We have a payment, get the generic payment_meta item to reduce calls to it
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
         $this->completed_date  = $this->setup_completed_date();
332 332
         $this->status          = $invoice->post_status;
333 333
 
334
-        if ( 'future' == $this->status ) {
334
+        if ('future' == $this->status) {
335 335
             $this->status = 'publish';
336 336
         }
337 337
 
338 338
         $this->post_status     = $this->status;
339 339
         $this->mode            = $this->setup_mode();
340 340
         $this->parent_invoice  = $invoice->post_parent;
341
-        $this->post_name       = $this->setup_post_name( $invoice );
341
+        $this->post_name       = $this->setup_post_name($invoice);
342 342
         $this->status_nicename = $this->setup_status_nicename($invoice->post_status);
343 343
 
344 344
         // Items
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
         
362 362
         // User based
363 363
         $this->ip              = $this->setup_ip();
364
-        $this->user_id         = !empty( $invoice->post_author ) ? $invoice->post_author : get_current_user_id();///$this->setup_user_id();
365
-        $this->email           = get_the_author_meta( 'email', $this->user_id );
364
+        $this->user_id         = !empty($invoice->post_author) ? $invoice->post_author : get_current_user_id(); ///$this->setup_user_id();
365
+        $this->email           = get_the_author_meta('email', $this->user_id);
366 366
 
367 367
         $this->user_info       = $this->setup_user_info();
368 368
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         $this->company         = $this->user_info['company'];
372 372
         $this->vat_number      = $this->user_info['vat_number'];
373 373
         $this->vat_rate        = $this->user_info['vat_rate'];
374
-        $this->adddress_confirmed  = $this->user_info['adddress_confirmed'];
374
+        $this->adddress_confirmed = $this->user_info['adddress_confirmed'];
375 375
         $this->address         = $this->user_info['address'];
376 376
         $this->city            = $this->user_info['city'];
377 377
         $this->country         = $this->user_info['country'];
@@ -386,39 +386,39 @@  discard block
 block discarded – undo
386 386
         // Other Identifiers
387 387
         $this->key             = $this->setup_invoice_key();
388 388
         $this->number          = $this->setup_invoice_number();
389
-        $this->title           = !empty( $invoice->post_title ) ? $invoice->post_title : $this->number;
389
+        $this->title           = !empty($invoice->post_title) ? $invoice->post_title : $this->number;
390 390
         
391
-        $this->full_name       = trim( $this->first_name . ' '. $this->last_name );
391
+        $this->full_name       = trim($this->first_name . ' ' . $this->last_name);
392 392
         
393 393
         // Allow extensions to add items to this object via hook
394
-        do_action( 'wpinv_setup_invoice', $this, $invoice_id );
394
+        do_action('wpinv_setup_invoice', $this, $invoice_id);
395 395
 
396 396
         return true;
397 397
     }
398 398
 
399
-    private function setup_status_nicename( $status ) {
400
-        $all_invoice_statuses  = wpinv_get_invoice_statuses( true, true, $this );
399
+    private function setup_status_nicename($status) {
400
+        $all_invoice_statuses = wpinv_get_invoice_statuses(true, true, $this);
401 401
 
402
-        if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
403
-            $all_invoice_statuses  = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
402
+        if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) {
403
+            $all_invoice_statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
404 404
         }
405
-        $status   = isset( $all_invoice_statuses[$status] ) ? $all_invoice_statuses[$status] : __( $status, 'invoicing' );
405
+        $status = isset($all_invoice_statuses[$status]) ? $all_invoice_statuses[$status] : __($status, 'invoicing');
406 406
 
407
-        return apply_filters( 'setup_status_nicename', $status );
407
+        return apply_filters('setup_status_nicename', $status);
408 408
     }
409 409
 
410
-    private function setup_post_name( $post = NULL ) {
410
+    private function setup_post_name($post = NULL) {
411 411
         global $wpdb;
412 412
         
413 413
         $post_name = '';
414 414
         
415
-        if ( !empty( $post ) ) {
416
-            if( !empty( $post->post_name ) ) {
415
+        if (!empty($post)) {
416
+            if (!empty($post->post_name)) {
417 417
                 $post_name = $post->post_name;
418
-            } else if ( !empty( $post->ID ) ) {
419
-                $post_name = wpinv_generate_post_name( $post->ID );
418
+            } else if (!empty($post->ID)) {
419
+                $post_name = wpinv_generate_post_name($post->ID);
420 420
 
421
-                $wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), array( 'ID' => $post->ID ) );
421
+                $wpdb->update($wpdb->posts, array('post_name' => $post_name), array('ID' => $post->ID));
422 422
             }
423 423
         }
424 424
 
@@ -426,12 +426,12 @@  discard block
 block discarded – undo
426 426
     }
427 427
     
428 428
     private function setup_due_date() {
429
-        $due_date = $this->get_meta( '_wpinv_due_date' );
429
+        $due_date = $this->get_meta('_wpinv_due_date');
430 430
         
431
-        if ( empty( $due_date ) ) {
432
-            $overdue_time = strtotime( $this->date ) + ( DAY_IN_SECONDS * absint( wpinv_get_option( 'overdue_days' ) ) );
433
-            $due_date = date_i18n( 'Y-m-d', $overdue_time );
434
-        } else if ( $due_date == 'none' ) {
431
+        if (empty($due_date)) {
432
+            $overdue_time = strtotime($this->date) + (DAY_IN_SECONDS * absint(wpinv_get_option('overdue_days')));
433
+            $due_date = date_i18n('Y-m-d', $overdue_time);
434
+        } else if ($due_date == 'none') {
435 435
             $due_date = '';
436 436
         }
437 437
         
@@ -439,67 +439,67 @@  discard block
 block discarded – undo
439 439
     }
440 440
     
441 441
     private function setup_completed_date() {
442
-        $invoice = get_post( $this->ID );
442
+        $invoice = get_post($this->ID);
443 443
 
444
-        if ( 'wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status ) {
444
+        if ('wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status) {
445 445
             return false; // This invoice was never paid
446 446
         }
447 447
 
448
-        $date = ( $date = $this->get_meta( '_wpinv_completed_date', true ) ) ? $date : $invoice->modified_date;
448
+        $date = ($date = $this->get_meta('_wpinv_completed_date', true)) ? $date : $invoice->modified_date;
449 449
 
450 450
         return $date;
451 451
     }
452 452
     
453 453
     private function setup_cart_details() {
454
-        $cart_details = isset( $this->payment_meta['cart_details'] ) ? maybe_unserialize( $this->payment_meta['cart_details'] ) : array();
454
+        $cart_details = isset($this->payment_meta['cart_details']) ? maybe_unserialize($this->payment_meta['cart_details']) : array();
455 455
         return $cart_details;
456 456
     }
457 457
     
458 458
     public function array_convert() {
459
-        return get_object_vars( $this );
459
+        return get_object_vars($this);
460 460
     }
461 461
     
462 462
     private function setup_items() {
463
-        $items = isset( $this->payment_meta['items'] ) ? maybe_unserialize( $this->payment_meta['items'] ) : array();
463
+        $items = isset($this->payment_meta['items']) ? maybe_unserialize($this->payment_meta['items']) : array();
464 464
         return $items;
465 465
     }
466 466
     
467 467
     private function setup_fees() {
468
-        $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
468
+        $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
469 469
         return $payment_fees;
470 470
     }
471 471
         
472 472
     private function setup_currency() {
473
-        $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'wpinv_currency_default', wpinv_get_currency(), $this );
473
+        $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('wpinv_currency_default', wpinv_get_currency(), $this);
474 474
         return $currency;
475 475
     }
476 476
     
477 477
     private function setup_discount() {
478 478
         //$discount = $this->get_meta( '_wpinv_discount', true );
479
-        $discount = (float)$this->subtotal - ( (float)$this->total - (float)$this->tax - (float)$this->fees_total );
480
-        if ( $discount < 0 ) {
479
+        $discount = (float) $this->subtotal - ((float) $this->total - (float) $this->tax - (float) $this->fees_total);
480
+        if ($discount < 0) {
481 481
             $discount = 0;
482 482
         }
483
-        $discount = wpinv_round_amount( $discount );
483
+        $discount = wpinv_round_amount($discount);
484 484
         
485 485
         return $discount;
486 486
     }
487 487
     
488 488
     private function setup_discount_code() {
489
-        $discount_code = !empty( $this->discounts ) ? $this->discounts : $this->get_meta( '_wpinv_discount_code', true );
489
+        $discount_code = !empty($this->discounts) ? $this->discounts : $this->get_meta('_wpinv_discount_code', true);
490 490
         return $discount_code;
491 491
     }
492 492
     
493 493
     private function setup_tax() {
494 494
 
495
-        $tax = $this->get_meta( '_wpinv_tax', true );
495
+        $tax = $this->get_meta('_wpinv_tax', true);
496 496
 
497 497
         // We don't have tax as it's own meta and no meta was passed
498
-        if ( '' === $tax ) {            
499
-            $tax = isset( $this->payment_meta['tax'] ) ? $this->payment_meta['tax'] : 0;
498
+        if ('' === $tax) {            
499
+            $tax = isset($this->payment_meta['tax']) ? $this->payment_meta['tax'] : 0;
500 500
         }
501 501
         
502
-        if ( $tax < 0 || ! $this->is_taxable() ) {
502
+        if ($tax < 0 || !$this->is_taxable()) {
503 503
             $tax = 0;
504 504
         }
505 505
 
@@ -510,16 +510,16 @@  discard block
 block discarded – undo
510 510
      * If taxes are enabled, allow users to enable/disable taxes per invoice.
511 511
      */
512 512
     private function setup_is_taxable() {
513
-        return (int) $this->get_meta( '_wpinv_disable_taxes', true );
513
+        return (int) $this->get_meta('_wpinv_disable_taxes', true);
514 514
     }
515 515
 
516 516
     private function setup_subtotal() {
517 517
         $subtotal     = 0;
518 518
         $cart_details = $this->cart_details;
519 519
 
520
-        if ( is_array( $cart_details ) ) {
521
-            foreach ( $cart_details as $item ) {
522
-                if ( isset( $item['subtotal'] ) ) {
520
+        if (is_array($cart_details)) {
521
+            foreach ($cart_details as $item) {
522
+                if (isset($item['subtotal'])) {
523 523
                     $subtotal += $item['subtotal'];
524 524
                 }
525 525
             }
@@ -533,23 +533,23 @@  discard block
 block discarded – undo
533 533
     }
534 534
 
535 535
     private function setup_discounts() {
536
-        $discounts = ! empty( $this->payment_meta['user_info']['discount'] ) ? $this->payment_meta['user_info']['discount'] : array();
536
+        $discounts = !empty($this->payment_meta['user_info']['discount']) ? $this->payment_meta['user_info']['discount'] : array();
537 537
         return $discounts;
538 538
     }
539 539
     
540 540
     private function setup_total() {
541
-        $amount = $this->get_meta( '_wpinv_total', true );
541
+        $amount = $this->get_meta('_wpinv_total', true);
542 542
 
543
-        if ( empty( $amount ) && '0.00' != $amount ) {
544
-            $meta   = $this->get_meta( '_wpinv_payment_meta', true );
545
-            $meta   = maybe_unserialize( $meta );
543
+        if (empty($amount) && '0.00' != $amount) {
544
+            $meta   = $this->get_meta('_wpinv_payment_meta', true);
545
+            $meta   = maybe_unserialize($meta);
546 546
 
547
-            if ( isset( $meta['amount'] ) ) {
547
+            if (isset($meta['amount'])) {
548 548
                 $amount = $meta['amount'];
549 549
             }
550 550
         }
551 551
 
552
-        if($amount < 0){
552
+        if ($amount < 0) {
553 553
             $amount = 0;
554 554
         }
555 555
 
@@ -557,13 +557,13 @@  discard block
 block discarded – undo
557 557
     }
558 558
     
559 559
     private function setup_mode() {
560
-        return $this->get_meta( '_wpinv_mode' );
560
+        return $this->get_meta('_wpinv_mode');
561 561
     }
562 562
 
563 563
     private function setup_gateway() {
564
-        $gateway = $this->get_meta( '_wpinv_gateway' );
564
+        $gateway = $this->get_meta('_wpinv_gateway');
565 565
         
566
-        if ( empty( $gateway ) && 'publish' === $this->status ) {
566
+        if (empty($gateway) && 'publish' === $this->status) {
567 567
             $gateway = 'manual';
568 568
         }
569 569
         
@@ -571,23 +571,23 @@  discard block
 block discarded – undo
571 571
     }
572 572
 
573 573
     private function setup_gateway_title() {
574
-        $gateway_title = wpinv_get_gateway_checkout_label( $this->gateway );
574
+        $gateway_title = wpinv_get_gateway_checkout_label($this->gateway);
575 575
         return $gateway_title;
576 576
     }
577 577
 
578 578
     private function setup_transaction_id() {
579
-        $transaction_id = $this->get_meta( '_wpinv_transaction_id' );
579
+        $transaction_id = $this->get_meta('_wpinv_transaction_id');
580 580
 
581
-        if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) {
581
+        if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) {
582 582
             $gateway        = $this->gateway;
583
-            $transaction_id = apply_filters( 'wpinv_get_invoice_transaction_id-' . $gateway, $this->ID );
583
+            $transaction_id = apply_filters('wpinv_get_invoice_transaction_id-' . $gateway, $this->ID);
584 584
         }
585 585
 
586 586
         return $transaction_id;
587 587
     }
588 588
 
589 589
     private function setup_ip() {
590
-        $ip = $this->get_meta( '_wpinv_user_ip' );
590
+        $ip = $this->get_meta('_wpinv_user_ip');
591 591
         return $ip;
592 592
     }
593 593
 
@@ -597,62 +597,62 @@  discard block
 block discarded – undo
597 597
     ///}
598 598
         
599 599
     private function setup_first_name() {
600
-        $first_name = $this->get_meta( '_wpinv_first_name' );
600
+        $first_name = $this->get_meta('_wpinv_first_name');
601 601
         return $first_name;
602 602
     }
603 603
     
604 604
     private function setup_last_name() {
605
-        $last_name = $this->get_meta( '_wpinv_last_name' );
605
+        $last_name = $this->get_meta('_wpinv_last_name');
606 606
         return $last_name;
607 607
     }
608 608
     
609 609
     private function setup_company() {
610
-        $company = $this->get_meta( '_wpinv_company' );
610
+        $company = $this->get_meta('_wpinv_company');
611 611
         return $company;
612 612
     }
613 613
     
614 614
     private function setup_vat_number() {
615
-        $vat_number = $this->get_meta( '_wpinv_vat_number' );
615
+        $vat_number = $this->get_meta('_wpinv_vat_number');
616 616
         return $vat_number;
617 617
     }
618 618
     
619 619
     private function setup_vat_rate() {
620
-        $vat_rate = $this->get_meta( '_wpinv_vat_rate' );
620
+        $vat_rate = $this->get_meta('_wpinv_vat_rate');
621 621
         return $vat_rate;
622 622
     }
623 623
     
624 624
     private function setup_adddress_confirmed() {
625
-        $adddress_confirmed = $this->get_meta( '_wpinv_adddress_confirmed' );
625
+        $adddress_confirmed = $this->get_meta('_wpinv_adddress_confirmed');
626 626
         return $adddress_confirmed;
627 627
     }
628 628
     
629 629
     private function setup_phone() {
630
-        $phone = $this->get_meta( '_wpinv_phone' );
630
+        $phone = $this->get_meta('_wpinv_phone');
631 631
         return $phone;
632 632
     }
633 633
     
634 634
     private function setup_address() {
635
-        $address = $this->get_meta( '_wpinv_address', true );
635
+        $address = $this->get_meta('_wpinv_address', true);
636 636
         return $address;
637 637
     }
638 638
     
639 639
     private function setup_city() {
640
-        $city = $this->get_meta( '_wpinv_city', true );
640
+        $city = $this->get_meta('_wpinv_city', true);
641 641
         return $city;
642 642
     }
643 643
     
644 644
     private function setup_country() {
645
-        $country = $this->get_meta( '_wpinv_country', true );
645
+        $country = $this->get_meta('_wpinv_country', true);
646 646
         return $country;
647 647
     }
648 648
     
649 649
     private function setup_state() {
650
-        $state = $this->get_meta( '_wpinv_state', true );
650
+        $state = $this->get_meta('_wpinv_state', true);
651 651
         return $state;
652 652
     }
653 653
     
654 654
     private function setup_zip() {
655
-        $zip = $this->get_meta( '_wpinv_zip', true );
655
+        $zip = $this->get_meta('_wpinv_zip', true);
656 656
         return $zip;
657 657
     }
658 658
 
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
             'user_id'        => $this->user_id,
662 662
             'first_name'     => $this->first_name,
663 663
             'last_name'      => $this->last_name,
664
-            'email'          => get_the_author_meta( 'email', $this->user_id ),
664
+            'email'          => get_the_author_meta('email', $this->user_id),
665 665
             'phone'          => $this->phone,
666 666
             'address'        => $this->address,
667 667
             'city'           => $this->city,
@@ -676,12 +676,12 @@  discard block
 block discarded – undo
676 676
         );
677 677
         
678 678
         $user_info = array();
679
-        if ( isset( $this->payment_meta['user_info'] ) ) {
680
-            $user_info = maybe_unserialize( $this->payment_meta['user_info'] );
679
+        if (isset($this->payment_meta['user_info'])) {
680
+            $user_info = maybe_unserialize($this->payment_meta['user_info']);
681 681
             
682
-            if ( !empty( $user_info ) && isset( $user_info['user_id'] ) && $post = get_post( $this->ID ) ) {
682
+            if (!empty($user_info) && isset($user_info['user_id']) && $post = get_post($this->ID)) {
683 683
                 $this->user_id = $post->post_author;
684
-                $this->email = get_the_author_meta( 'email', $this->user_id );
684
+                $this->email = get_the_author_meta('email', $this->user_id);
685 685
                 
686 686
                 $user_info['user_id'] = $this->user_id;
687 687
                 $user_info['email'] = $this->email;
@@ -690,13 +690,13 @@  discard block
 block discarded – undo
690 690
             }
691 691
         }
692 692
         
693
-        $user_info    = wp_parse_args( $user_info, $defaults );
693
+        $user_info = wp_parse_args($user_info, $defaults);
694 694
         
695 695
         // Get the user, but only if it's been created
696
-        $user = get_userdata( $this->user_id );
696
+        $user = get_userdata($this->user_id);
697 697
         
698
-        if ( !empty( $user ) && $user->ID > 0 ) {
699
-            if ( empty( $user_info ) ) {
698
+        if (!empty($user) && $user->ID > 0) {
699
+            if (empty($user_info)) {
700 700
                 $user_info = array(
701 701
                     'user_id'    => $user->ID,
702 702
                     'first_name' => $user->first_name,
@@ -705,23 +705,23 @@  discard block
 block discarded – undo
705 705
                     'discount'   => '',
706 706
                 );
707 707
             } else {
708
-                foreach ( $user_info as $key => $value ) {
709
-                    if ( ! empty( $value ) ) {
708
+                foreach ($user_info as $key => $value) {
709
+                    if (!empty($value)) {
710 710
                         continue;
711 711
                     }
712 712
 
713
-                    switch( $key ) {
713
+                    switch ($key) {
714 714
                         case 'user_id':
715
-                            $user_info[ $key ] = $user->ID;
715
+                            $user_info[$key] = $user->ID;
716 716
                             break;
717 717
                         case 'first_name':
718
-                            $user_info[ $key ] = $user->first_name;
718
+                            $user_info[$key] = $user->first_name;
719 719
                             break;
720 720
                         case 'last_name':
721
-                            $user_info[ $key ] = $user->last_name;
721
+                            $user_info[$key] = $user->last_name;
722 722
                             break;
723 723
                         case 'email':
724
-                            $user_info[ $key ] = $user->user_email;
724
+                            $user_info[$key] = $user->user_email;
725 725
                             break;
726 726
                     }
727 727
                 }
@@ -732,25 +732,25 @@  discard block
 block discarded – undo
732 732
     }
733 733
 
734 734
     private function setup_invoice_key() {
735
-        $key = $this->get_meta( '_wpinv_key', true );
735
+        $key = $this->get_meta('_wpinv_key', true);
736 736
         
737 737
         return $key;
738 738
     }
739 739
 
740 740
     private function setup_invoice_number() {
741
-        $number = $this->get_meta( '_wpinv_number', true );
741
+        $number = $this->get_meta('_wpinv_number', true);
742 742
 
743
-        if ( !$number ) {
743
+        if (!$number) {
744 744
             $number = $this->ID;
745 745
 
746
-            if ( $this->status == 'auto-draft' ) {
747
-                if ( wpinv_sequential_number_active( $this->post_type ) ) {
748
-                    $next_number = wpinv_get_next_invoice_number( $this->post_type );
746
+            if ($this->status == 'auto-draft') {
747
+                if (wpinv_sequential_number_active($this->post_type)) {
748
+                    $next_number = wpinv_get_next_invoice_number($this->post_type);
749 749
                     $number      = $next_number;
750 750
                 }
751 751
             }
752 752
             
753
-            $number = wpinv_format_invoice_number( $number, $this->post_type );
753
+            $number = wpinv_format_invoice_number($number, $this->post_type);
754 754
         }
755 755
 
756 756
         return $number;
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 
759 759
     public function save() {}
760 760
     
761
-    public function add_fee( $args ) {
761
+    public function add_fee($args) {
762 762
         $default_args = array(
763 763
             'label'       => '',
764 764
             'amount'      => 0,
@@ -768,75 +768,75 @@  discard block
 block discarded – undo
768 768
             'item_id'     => 0,
769 769
         );
770 770
 
771
-        $fee = wp_parse_args( $args, $default_args );
771
+        $fee = wp_parse_args($args, $default_args);
772 772
         
773
-        if ( empty( $fee['label'] ) ) {
773
+        if (empty($fee['label'])) {
774 774
             return false;
775 775
         }
776 776
         
777
-        $fee['id']  = sanitize_title( $fee['label'] );
777
+        $fee['id'] = sanitize_title($fee['label']);
778 778
         
779
-        $this->fees[]               = $fee;
779
+        $this->fees[] = $fee;
780 780
         
781 781
         $added_fee               = $fee;
782 782
         $added_fee['action']     = 'add';
783 783
         $this->pending['fees'][] = $added_fee;
784
-        reset( $this->fees );
784
+        reset($this->fees);
785 785
 
786
-        $this->increase_fees( $fee['amount'] );
786
+        $this->increase_fees($fee['amount']);
787 787
         return true;
788 788
     }
789 789
 
790
-    public function remove_fee( $key ) {
790
+    public function remove_fee($key) {
791 791
         $removed = false;
792 792
 
793
-        if ( is_numeric( $key ) ) {
794
-            $removed = $this->remove_fee_by( 'index', $key );
793
+        if (is_numeric($key)) {
794
+            $removed = $this->remove_fee_by('index', $key);
795 795
         }
796 796
 
797 797
         return $removed;
798 798
     }
799 799
 
800
-    public function remove_fee_by( $key, $value, $global = false ) {
801
-        $allowed_fee_keys = apply_filters( 'wpinv_fee_keys', array(
800
+    public function remove_fee_by($key, $value, $global = false) {
801
+        $allowed_fee_keys = apply_filters('wpinv_fee_keys', array(
802 802
             'index', 'label', 'amount', 'type',
803
-        ) );
803
+        ));
804 804
 
805
-        if ( ! in_array( $key, $allowed_fee_keys ) ) {
805
+        if (!in_array($key, $allowed_fee_keys)) {
806 806
             return false;
807 807
         }
808 808
 
809 809
         $removed = false;
810
-        if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) {
811
-            $removed_fee             = $this->fees[ $value ];
810
+        if ('index' === $key && array_key_exists($value, $this->fees)) {
811
+            $removed_fee             = $this->fees[$value];
812 812
             $removed_fee['action']   = 'remove';
813 813
             $this->pending['fees'][] = $removed_fee;
814 814
 
815
-            $this->decrease_fees( $removed_fee['amount'] );
815
+            $this->decrease_fees($removed_fee['amount']);
816 816
 
817
-            unset( $this->fees[ $value ] );
817
+            unset($this->fees[$value]);
818 818
             $removed = true;
819
-        } else if ( 'index' !== $key ) {
820
-            foreach ( $this->fees as $index => $fee ) {
821
-                if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) {
819
+        } else if ('index' !== $key) {
820
+            foreach ($this->fees as $index => $fee) {
821
+                if (isset($fee[$key]) && $fee[$key] == $value) {
822 822
                     $removed_fee             = $fee;
823 823
                     $removed_fee['action']   = 'remove';
824 824
                     $this->pending['fees'][] = $removed_fee;
825 825
 
826
-                    $this->decrease_fees( $removed_fee['amount'] );
826
+                    $this->decrease_fees($removed_fee['amount']);
827 827
 
828
-                    unset( $this->fees[ $index ] );
828
+                    unset($this->fees[$index]);
829 829
                     $removed = true;
830 830
 
831
-                    if ( false === $global ) {
831
+                    if (false === $global) {
832 832
                         break;
833 833
                     }
834 834
                 }
835 835
             }
836 836
         }
837 837
 
838
-        if ( true === $removed ) {
839
-            $this->fees = array_values( $this->fees );
838
+        if (true === $removed) {
839
+            $this->fees = array_values($this->fees);
840 840
         }
841 841
 
842 842
         return $removed;
@@ -844,35 +844,35 @@  discard block
 block discarded – undo
844 844
 
845 845
     
846 846
 
847
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
847
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
848 848
         // Bail if no note specified
849
-        if( !$note ) {
849
+        if (!$note) {
850 850
             return false;
851 851
         }
852 852
 
853
-        if ( empty( $this->ID ) )
853
+        if (empty($this->ID))
854 854
             return false;
855 855
         
856
-        if ( ( ( is_user_logged_in() && wpinv_current_user_can_manage_invoicing() ) || $added_by_user ) && !$system ) {
857
-            $user                 = get_user_by( 'id', get_current_user_id() );
856
+        if (((is_user_logged_in() && wpinv_current_user_can_manage_invoicing()) || $added_by_user) && !$system) {
857
+            $user                 = get_user_by('id', get_current_user_id());
858 858
             $comment_author       = $user->display_name;
859 859
             $comment_author_email = $user->user_email;
860 860
         } else {
861 861
             $comment_author       = 'System';
862 862
             $comment_author_email = 'system@';
863
-            $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) : 'noreply.com';
864
-            $comment_author_email = sanitize_email( $comment_author_email );
863
+            $comment_author_email .= isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : 'noreply.com';
864
+            $comment_author_email = sanitize_email($comment_author_email);
865 865
         }
866 866
 
867
-        do_action( 'wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type );
867
+        do_action('wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type);
868 868
 
869
-        $note_id = wp_insert_comment( wp_filter_comment( array(
869
+        $note_id = wp_insert_comment(wp_filter_comment(array(
870 870
             'comment_post_ID'      => $this->ID,
871 871
             'comment_content'      => $note,
872 872
             'comment_agent'        => 'WPInvoicing',
873 873
             'user_id'              => is_admin() ? get_current_user_id() : 0,
874
-            'comment_date'         => current_time( 'mysql' ),
875
-            'comment_date_gmt'     => current_time( 'mysql', 1 ),
874
+            'comment_date'         => current_time('mysql'),
875
+            'comment_date_gmt'     => current_time('mysql', 1),
876 876
             'comment_approved'     => 1,
877 877
             'comment_parent'       => 0,
878 878
             'comment_author'       => $comment_author,
@@ -880,53 +880,53 @@  discard block
 block discarded – undo
880 880
             'comment_author_url'   => '',
881 881
             'comment_author_email' => $comment_author_email,
882 882
             'comment_type'         => 'wpinv_note'
883
-        ) ) );
883
+        )));
884 884
 
885
-        do_action( 'wpinv_insert_payment_note', $note_id, $this->ID, $note );
885
+        do_action('wpinv_insert_payment_note', $note_id, $this->ID, $note);
886 886
         
887
-        if ( $customer_type ) {
888
-            add_comment_meta( $note_id, '_wpi_customer_note', 1 );
887
+        if ($customer_type) {
888
+            add_comment_meta($note_id, '_wpi_customer_note', 1);
889 889
 
890
-            do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $this->ID, 'user_note' => $note ) );
890
+            do_action('wpinv_new_customer_note', array('invoice_id' => $this->ID, 'user_note' => $note));
891 891
         }
892 892
 
893 893
         return $note_id;
894 894
     }
895 895
 
896
-    private function increase_subtotal( $amount = 0.00 ) {
896
+    private function increase_subtotal($amount = 0.00) {
897 897
         $amount          = (float) $amount;
898 898
         $this->subtotal += $amount;
899
-        $this->subtotal  = wpinv_round_amount( $this->subtotal );
899
+        $this->subtotal  = wpinv_round_amount($this->subtotal);
900 900
 
901 901
         $this->recalculate_total();
902 902
     }
903 903
 
904
-    private function decrease_subtotal( $amount = 0.00 ) {
904
+    private function decrease_subtotal($amount = 0.00) {
905 905
         $amount          = (float) $amount;
906 906
         $this->subtotal -= $amount;
907
-        $this->subtotal  = wpinv_round_amount( $this->subtotal );
907
+        $this->subtotal  = wpinv_round_amount($this->subtotal);
908 908
 
909
-        if ( $this->subtotal < 0 ) {
909
+        if ($this->subtotal < 0) {
910 910
             $this->subtotal = 0;
911 911
         }
912 912
 
913 913
         $this->recalculate_total();
914 914
     }
915 915
 
916
-    private function increase_fees( $amount = 0.00 ) {
917
-        $amount            = (float)$amount;
916
+    private function increase_fees($amount = 0.00) {
917
+        $amount            = (float) $amount;
918 918
         $this->fees_total += $amount;
919
-        $this->fees_total  = wpinv_round_amount( $this->fees_total );
919
+        $this->fees_total  = wpinv_round_amount($this->fees_total);
920 920
 
921 921
         $this->recalculate_total();
922 922
     }
923 923
 
924
-    private function decrease_fees( $amount = 0.00 ) {
924
+    private function decrease_fees($amount = 0.00) {
925 925
         $amount            = (float) $amount;
926 926
         $this->fees_total -= $amount;
927
-        $this->fees_total  = wpinv_round_amount( $this->fees_total );
927
+        $this->fees_total  = wpinv_round_amount($this->fees_total);
928 928
 
929
-        if ( $this->fees_total < 0 ) {
929
+        if ($this->fees_total < 0) {
930 930
             $this->fees_total = 0;
931 931
         }
932 932
 
@@ -937,56 +937,56 @@  discard block
 block discarded – undo
937 937
         global $wpi_nosave;
938 938
         
939 939
         $this->total = $this->subtotal + $this->tax + $this->fees_total;
940
-        $this->total = wpinv_round_amount( $this->total );
940
+        $this->total = wpinv_round_amount($this->total);
941 941
         
942
-        do_action( 'wpinv_invoice_recalculate_total', $this, $wpi_nosave );
942
+        do_action('wpinv_invoice_recalculate_total', $this, $wpi_nosave);
943 943
     }
944 944
     
945
-    public function increase_tax( $amount = 0.00 ) {
945
+    public function increase_tax($amount = 0.00) {
946 946
         $amount       = (float) $amount;
947 947
         $this->tax   += $amount;
948 948
 
949 949
         $this->recalculate_total();
950 950
     }
951 951
 
952
-    public function decrease_tax( $amount = 0.00 ) {
952
+    public function decrease_tax($amount = 0.00) {
953 953
         $amount     = (float) $amount;
954 954
         $this->tax -= $amount;
955 955
 
956
-        if ( $this->tax < 0 ) {
956
+        if ($this->tax < 0) {
957 957
             $this->tax = 0;
958 958
         }
959 959
 
960 960
         $this->recalculate_total();
961 961
     }
962 962
 
963
-    public function update_status( $new_status = false, $note = '', $manual = false ) {
964
-        $old_status = ! empty( $this->old_status ) ? $this->old_status : get_post_status( $this->ID );
963
+    public function update_status($new_status = false, $note = '', $manual = false) {
964
+        $old_status = !empty($this->old_status) ? $this->old_status : get_post_status($this->ID);
965 965
 
966
-        if ( $old_status === $new_status && in_array( $new_status, array_keys( wpinv_get_invoice_statuses( true ) ) ) ) {
966
+        if ($old_status === $new_status && in_array($new_status, array_keys(wpinv_get_invoice_statuses(true)))) {
967 967
             return false; // Don't permit status changes that aren't changes
968 968
         }
969 969
 
970
-        $do_change = apply_filters( 'wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status );
970
+        $do_change = apply_filters('wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status);
971 971
         $updated = false;
972 972
 
973
-        if ( $do_change ) {
974
-            do_action( 'wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status );
973
+        if ($do_change) {
974
+            do_action('wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status);
975 975
 
976 976
             $update_post_data                   = array();
977 977
             $update_post_data['ID']             = $this->ID;
978 978
             $update_post_data['post_status']    = $new_status;
979
-            $update_post_data['edit_date']      = current_time( 'mysql', 0 );
980
-            $update_post_data['edit_date_gmt']  = current_time( 'mysql', 1 );
979
+            $update_post_data['edit_date']      = current_time('mysql', 0);
980
+            $update_post_data['edit_date_gmt']  = current_time('mysql', 1);
981 981
             
982
-            $update_post_data = apply_filters( 'wpinv_update_invoice_status_fields', $update_post_data, $this->ID );
982
+            $update_post_data = apply_filters('wpinv_update_invoice_status_fields', $update_post_data, $this->ID);
983 983
 
984
-            $updated = wp_update_post( $update_post_data );
984
+            $updated = wp_update_post($update_post_data);
985 985
             
986 986
             // Status was changed.
987
-            do_action( 'wpinv_status_' . $new_status, $this->ID, $old_status );
988
-            do_action( 'wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status );
989
-            do_action( 'wpinv_update_status', $this->ID, $new_status, $old_status );
987
+            do_action('wpinv_status_' . $new_status, $this->ID, $old_status);
988
+            do_action('wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status);
989
+            do_action('wpinv_update_status', $this->ID, $new_status, $old_status);
990 990
         }
991 991
 
992 992
         return $updated;
@@ -1000,20 +1000,20 @@  discard block
 block discarded – undo
1000 1000
         $this->save();
1001 1001
     }
1002 1002
 
1003
-    public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1004
-        if ( empty( $meta_key ) ) {
1003
+    public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1004
+        if (empty($meta_key)) {
1005 1005
             return false;
1006 1006
         }
1007 1007
 
1008
-        if ( $meta_key == 'key' || $meta_key == 'date' ) {
1008
+        if ($meta_key == 'key' || $meta_key == 'date') {
1009 1009
             $current_meta = $this->get_meta();
1010
-            $current_meta[ $meta_key ] = $meta_value;
1010
+            $current_meta[$meta_key] = $meta_value;
1011 1011
 
1012 1012
             $meta_key     = '_wpinv_payment_meta';
1013 1013
             $meta_value   = $current_meta;
1014 1014
         }
1015 1015
 
1016
-        $meta_value = apply_filters( 'wpinv_update_payment_meta_' . $meta_key, $meta_value, $this->ID );
1016
+        $meta_value = apply_filters('wpinv_update_payment_meta_' . $meta_key, $meta_value, $this->ID);
1017 1017
         
1018 1018
         // Do not update created date on invoice marked as paid.
1019 1019
         /*if ( $meta_key == '_wpinv_completed_date' && !empty( $meta_value ) ) {
@@ -1028,76 +1028,76 @@  discard block
 block discarded – undo
1028 1028
             wp_update_post( $args );
1029 1029
         }*/
1030 1030
         
1031
-        return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1031
+        return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value);
1032 1032
     }
1033 1033
 
1034 1034
     // get data
1035
-    public function get_meta( $meta_key = '_wpinv_payment_meta', $single = true ) {
1036
-        $meta = get_post_meta( $this->ID, $meta_key, $single );
1035
+    public function get_meta($meta_key = '_wpinv_payment_meta', $single = true) {
1036
+        $meta = get_post_meta($this->ID, $meta_key, $single);
1037 1037
 
1038
-        if ( $meta_key === '_wpinv_payment_meta' ) {
1038
+        if ($meta_key === '_wpinv_payment_meta') {
1039 1039
 
1040
-            if(!is_array($meta)){$meta = array();} // we need this to be an array so make sure it is.
1040
+            if (!is_array($meta)) {$meta = array(); } // we need this to be an array so make sure it is.
1041 1041
 
1042
-            if ( empty( $meta['key'] ) ) {
1042
+            if (empty($meta['key'])) {
1043 1043
                 $meta['key'] = $this->setup_invoice_key();
1044 1044
             }
1045 1045
 
1046
-            if ( empty( $meta['date'] ) ) {
1047
-                $meta['date'] = get_post_field( 'post_date', $this->ID );
1046
+            if (empty($meta['date'])) {
1047
+                $meta['date'] = get_post_field('post_date', $this->ID);
1048 1048
             }
1049 1049
         }
1050 1050
 
1051
-        $meta = apply_filters( 'wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID );
1051
+        $meta = apply_filters('wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID);
1052 1052
 
1053
-        return apply_filters( 'wpinv_get_invoice_meta', $meta, $this->ID, $meta_key );
1053
+        return apply_filters('wpinv_get_invoice_meta', $meta, $this->ID, $meta_key);
1054 1054
     }
1055 1055
     
1056 1056
     public function get_description() {
1057
-        $post = get_post( $this->ID );
1057
+        $post = get_post($this->ID);
1058 1058
         
1059
-        $description = !empty( $post ) ? $post->post_content : '';
1060
-        return apply_filters( 'wpinv_get_description', $description, $this->ID, $this );
1059
+        $description = !empty($post) ? $post->post_content : '';
1060
+        return apply_filters('wpinv_get_description', $description, $this->ID, $this);
1061 1061
     }
1062 1062
     
1063
-    public function get_status( $nicename = false ) {
1064
-        if ( !$nicename ) {
1063
+    public function get_status($nicename = false) {
1064
+        if (!$nicename) {
1065 1065
             $status = $this->status;
1066 1066
         } else {
1067 1067
             $status = $this->status_nicename;
1068 1068
         }
1069 1069
         
1070
-        return apply_filters( 'wpinv_get_status', $status, $nicename, $this->ID, $this );
1070
+        return apply_filters('wpinv_get_status', $status, $nicename, $this->ID, $this);
1071 1071
     }
1072 1072
     
1073 1073
     public function get_cart_details() {
1074
-        return apply_filters( 'wpinv_cart_details', $this->cart_details, $this->ID, $this );
1074
+        return apply_filters('wpinv_cart_details', $this->cart_details, $this->ID, $this);
1075 1075
     }
1076 1076
     
1077
-    public function get_subtotal( $currency = false ) {
1078
-        $subtotal = wpinv_round_amount( $this->subtotal );
1077
+    public function get_subtotal($currency = false) {
1078
+        $subtotal = wpinv_round_amount($this->subtotal);
1079 1079
         
1080
-        if ( $currency ) {
1081
-            $subtotal = wpinv_price( wpinv_format_amount( $subtotal, NULL, !$currency ), $this->get_currency() );
1080
+        if ($currency) {
1081
+            $subtotal = wpinv_price(wpinv_format_amount($subtotal, NULL, !$currency), $this->get_currency());
1082 1082
         }
1083 1083
         
1084
-        return apply_filters( 'wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency );
1084
+        return apply_filters('wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency);
1085 1085
     }
1086 1086
     
1087
-    public function get_total( $currency = false ) {        
1088
-        if ( $this->is_free_trial() ) {
1089
-            $total = wpinv_round_amount( 0 );
1087
+    public function get_total($currency = false) {        
1088
+        if ($this->is_free_trial()) {
1089
+            $total = wpinv_round_amount(0);
1090 1090
         } else {
1091
-            $total = wpinv_round_amount( $this->total );
1091
+            $total = wpinv_round_amount($this->total);
1092 1092
         }
1093
-        if ( $currency ) {
1094
-            $total = wpinv_price( wpinv_format_amount( $total, NULL, !$currency ), $this->get_currency() );
1093
+        if ($currency) {
1094
+            $total = wpinv_price(wpinv_format_amount($total, NULL, !$currency), $this->get_currency());
1095 1095
         }
1096 1096
         
1097
-        return apply_filters( 'wpinv_get_invoice_total', $total, $this->ID, $this, $currency );
1097
+        return apply_filters('wpinv_get_invoice_total', $total, $this->ID, $this, $currency);
1098 1098
     }
1099 1099
     
1100
-    public function get_recurring_details( $field = '', $currency = false ) {        
1100
+    public function get_recurring_details($field = '', $currency = false) {        
1101 1101
         $data                 = array();
1102 1102
         $data['cart_details'] = $this->cart_details;
1103 1103
         $data['subtotal']     = $this->get_subtotal();
@@ -1105,119 +1105,119 @@  discard block
 block discarded – undo
1105 1105
         $data['tax']          = $this->get_tax();
1106 1106
         $data['total']        = $this->get_total();
1107 1107
     
1108
-        if ( !empty( $this->cart_details ) && ( $this->is_parent() || $this->is_renewal() ) ) {
1108
+        if (!empty($this->cart_details) && ($this->is_parent() || $this->is_renewal())) {
1109 1109
             $is_free_trial = $this->is_free_trial();
1110
-            $discounts = $this->get_discounts( true );
1110
+            $discounts = $this->get_discounts(true);
1111 1111
             
1112
-            if ( $is_free_trial || !empty( $discounts ) ) {
1112
+            if ($is_free_trial || !empty($discounts)) {
1113 1113
                 $first_use_only = false;
1114 1114
                 
1115
-                if ( !empty( $discounts ) ) {
1116
-                    foreach ( $discounts as $key => $code ) {
1117
-                        if ( wpinv_discount_is_recurring( $code, true ) && !$this->is_renewal() ) {
1115
+                if (!empty($discounts)) {
1116
+                    foreach ($discounts as $key => $code) {
1117
+                        if (wpinv_discount_is_recurring($code, true) && !$this->is_renewal()) {
1118 1118
                             $first_use_only = true;
1119 1119
                             break;
1120 1120
                         }
1121 1121
                     }
1122 1122
                 }
1123 1123
                     
1124
-                if ( !$first_use_only ) {
1125
-                    $data['subtotal'] = wpinv_round_amount( $this->subtotal );
1126
-                    $data['discount'] = wpinv_round_amount( $this->discount );
1127
-                    $data['tax']      = wpinv_round_amount( $this->tax );
1128
-                    $data['total']    = wpinv_round_amount( $this->total );
1124
+                if (!$first_use_only) {
1125
+                    $data['subtotal'] = wpinv_round_amount($this->subtotal);
1126
+                    $data['discount'] = wpinv_round_amount($this->discount);
1127
+                    $data['tax']      = wpinv_round_amount($this->tax);
1128
+                    $data['total']    = wpinv_round_amount($this->total);
1129 1129
                 } else {
1130 1130
                     $cart_subtotal   = 0;
1131 1131
                     $cart_discount   = $this->discount;
1132 1132
                     $cart_tax        = 0;
1133 1133
 
1134
-                    foreach ( $this->cart_details as $key => $item ) {
1135
-                        $item_quantity  = $item['quantity'] > 0 ? absint( $item['quantity'] ) : 1;
1136
-                        $item_subtotal  = !empty( $item['subtotal'] ) ? $item['subtotal'] : $item['item_price'] * $item_quantity;
1134
+                    foreach ($this->cart_details as $key => $item) {
1135
+                        $item_quantity  = $item['quantity'] > 0 ? absint($item['quantity']) : 1;
1136
+                        $item_subtotal  = !empty($item['subtotal']) ? $item['subtotal'] : $item['item_price'] * $item_quantity;
1137 1137
                         $item_discount  = 0;
1138
-                        $item_tax       = $item_subtotal > 0 && !empty( $item['vat_rate'] ) ? ( $item_subtotal * 0.01 * (float)$item['vat_rate'] ) : 0;
1138
+                        $item_tax       = $item_subtotal > 0 && !empty($item['vat_rate']) ? ($item_subtotal * 0.01 * (float) $item['vat_rate']) : 0;
1139 1139
                         
1140
-                        if ( wpinv_prices_include_tax() ) {
1141
-                            $item_subtotal -= wpinv_round_amount( $item_tax );
1140
+                        if (wpinv_prices_include_tax()) {
1141
+                            $item_subtotal -= wpinv_round_amount($item_tax);
1142 1142
                         }
1143 1143
                         
1144 1144
                         $item_total     = $item_subtotal - $item_discount + $item_tax;
1145 1145
                         // Do not allow totals to go negative
1146
-                        if ( $item_total < 0 ) {
1146
+                        if ($item_total < 0) {
1147 1147
                             $item_total = 0;
1148 1148
                         }
1149 1149
                         
1150
-                        $cart_subtotal  += (float)($item_subtotal);
1151
-                        $cart_discount  += (float)($item_discount);
1152
-                        $cart_tax       += (float)($item_tax);
1150
+                        $cart_subtotal  += (float) ($item_subtotal);
1151
+                        $cart_discount  += (float) ($item_discount);
1152
+                        $cart_tax       += (float) ($item_tax);
1153 1153
                         
1154
-                        $data['cart_details'][$key]['discount']   = wpinv_round_amount( $item_discount );
1155
-                        $data['cart_details'][$key]['tax']        = wpinv_round_amount( $item_tax );
1156
-                        $data['cart_details'][$key]['price']      = wpinv_round_amount( $item_total );
1154
+                        $data['cart_details'][$key]['discount']   = wpinv_round_amount($item_discount);
1155
+                        $data['cart_details'][$key]['tax']        = wpinv_round_amount($item_tax);
1156
+                        $data['cart_details'][$key]['price']      = wpinv_round_amount($item_total);
1157 1157
                     }
1158 1158
 
1159 1159
 	                $total = $data['subtotal'] - $data['discount'] + $data['tax'];
1160
-	                if ( $total < 0 ) {
1160
+	                if ($total < 0) {
1161 1161
 		                $total = 0;
1162 1162
 	                }
1163 1163
 
1164
-                    $data['subtotal'] = wpinv_round_amount( $cart_subtotal );
1165
-                    $data['discount'] = wpinv_round_amount( $cart_discount );
1166
-                    $data['tax']      = wpinv_round_amount( $cart_tax );
1167
-                    $data['total']    = wpinv_round_amount( $total );
1164
+                    $data['subtotal'] = wpinv_round_amount($cart_subtotal);
1165
+                    $data['discount'] = wpinv_round_amount($cart_discount);
1166
+                    $data['tax']      = wpinv_round_amount($cart_tax);
1167
+                    $data['total']    = wpinv_round_amount($total);
1168 1168
                 }
1169 1169
             }
1170 1170
         }
1171 1171
         
1172
-        $data = apply_filters( 'wpinv_get_invoice_recurring_details', $data, $this, $field, $currency );
1172
+        $data = apply_filters('wpinv_get_invoice_recurring_details', $data, $this, $field, $currency);
1173 1173
 
1174
-        if ( isset( $data[$field] ) ) {
1175
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1174
+        if (isset($data[$field])) {
1175
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1176 1176
         }
1177 1177
         
1178 1178
         return $data;
1179 1179
     }
1180 1180
     
1181
-    public function get_final_tax( $currency = false ) {        
1182
-        $final_total = wpinv_round_amount( $this->tax );
1183
-        if ( $currency ) {
1184
-            $final_total = wpinv_price( wpinv_format_amount( $final_total, NULL, !$currency ), $this->get_currency() );
1181
+    public function get_final_tax($currency = false) {        
1182
+        $final_total = wpinv_round_amount($this->tax);
1183
+        if ($currency) {
1184
+            $final_total = wpinv_price(wpinv_format_amount($final_total, NULL, !$currency), $this->get_currency());
1185 1185
         }
1186 1186
         
1187
-        return apply_filters( 'wpinv_get_invoice_final_total', $final_total, $this, $currency );
1187
+        return apply_filters('wpinv_get_invoice_final_total', $final_total, $this, $currency);
1188 1188
     }
1189 1189
     
1190
-    public function get_discounts( $array = false ) {
1190
+    public function get_discounts($array = false) {
1191 1191
         $discounts = $this->discounts;
1192
-        if ( $array && $discounts ) {
1193
-            $discounts = explode( ',', $discounts );
1192
+        if ($array && $discounts) {
1193
+            $discounts = explode(',', $discounts);
1194 1194
         }
1195
-        return apply_filters( 'wpinv_payment_discounts', $discounts, $this->ID, $this, $array );
1195
+        return apply_filters('wpinv_payment_discounts', $discounts, $this->ID, $this, $array);
1196 1196
     }
1197 1197
     
1198
-    public function get_discount( $currency = false, $dash = false ) {
1199
-        if ( !empty( $this->discounts ) ) {
1198
+    public function get_discount($currency = false, $dash = false) {
1199
+        if (!empty($this->discounts)) {
1200 1200
             global $ajax_cart_details;
1201 1201
             $ajax_cart_details = $this->get_cart_details();
1202 1202
             
1203
-            if ( !empty( $ajax_cart_details ) && count( $ajax_cart_details ) == count( $this->items ) ) {
1203
+            if (!empty($ajax_cart_details) && count($ajax_cart_details) == count($this->items)) {
1204 1204
                 $cart_items = $ajax_cart_details;
1205 1205
             } else {
1206 1206
                 $cart_items = $this->items;
1207 1207
             }
1208 1208
 
1209
-            $this->discount = wpinv_get_cart_items_discount_amount( $cart_items , $this->discounts );
1209
+            $this->discount = wpinv_get_cart_items_discount_amount($cart_items, $this->discounts);
1210 1210
         }
1211
-        $discount   = wpinv_round_amount( $this->discount );
1211
+        $discount   = wpinv_round_amount($this->discount);
1212 1212
         $dash       = $dash && $discount > 0 ? '&ndash;' : '';
1213 1213
         
1214
-        if ( $currency ) {
1215
-            $discount = wpinv_price( wpinv_format_amount( $discount, NULL, !$currency ), $this->get_currency() );
1214
+        if ($currency) {
1215
+            $discount = wpinv_price(wpinv_format_amount($discount, NULL, !$currency), $this->get_currency());
1216 1216
         }
1217 1217
         
1218
-        $discount   = $dash . $discount;
1218
+        $discount = $dash . $discount;
1219 1219
         
1220
-        return apply_filters( 'wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash );
1220
+        return apply_filters('wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash);
1221 1221
     }
1222 1222
     
1223 1223
     public function get_discount_code() {
@@ -1229,49 +1229,49 @@  discard block
 block discarded – undo
1229 1229
         return (int) $this->disable_taxes === 0;
1230 1230
     }
1231 1231
 
1232
-    public function get_tax( $currency = false ) {
1233
-        $tax = wpinv_round_amount( $this->tax );
1232
+    public function get_tax($currency = false) {
1233
+        $tax = wpinv_round_amount($this->tax);
1234 1234
 
1235
-        if ( $currency ) {
1236
-            $tax = wpinv_price( wpinv_format_amount( $tax, NULL, !$currency ), $this->get_currency() );
1235
+        if ($currency) {
1236
+            $tax = wpinv_price(wpinv_format_amount($tax, NULL, !$currency), $this->get_currency());
1237 1237
         }
1238 1238
 
1239
-        if ( ! $this->is_taxable() ) {
1240
-            $tax = wpinv_round_amount( 0.00 );
1239
+        if (!$this->is_taxable()) {
1240
+            $tax = wpinv_round_amount(0.00);
1241 1241
         }
1242 1242
 
1243
-        return apply_filters( 'wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency );
1243
+        return apply_filters('wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency);
1244 1244
     }
1245 1245
     
1246
-    public function get_fees( $type = 'all' ) {
1247
-        $fees    = array();
1246
+    public function get_fees($type = 'all') {
1247
+        $fees = array();
1248 1248
 
1249
-        if ( ! empty( $this->fees ) && is_array( $this->fees ) ) {
1250
-            foreach ( $this->fees as $fee ) {
1251
-                if( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1249
+        if (!empty($this->fees) && is_array($this->fees)) {
1250
+            foreach ($this->fees as $fee) {
1251
+                if ('all' != $type && !empty($fee['type']) && $type != $fee['type']) {
1252 1252
                     continue;
1253 1253
                 }
1254 1254
 
1255
-                $fee['label'] = stripslashes( $fee['label'] );
1256
-                $fee['amount_display'] = wpinv_price( $fee['amount'], $this->get_currency() );
1257
-                $fees[]    = $fee;
1255
+                $fee['label'] = stripslashes($fee['label']);
1256
+                $fee['amount_display'] = wpinv_price($fee['amount'], $this->get_currency());
1257
+                $fees[] = $fee;
1258 1258
             }
1259 1259
         }
1260 1260
 
1261
-        return apply_filters( 'wpinv_get_invoice_fees', $fees, $this->ID, $this );
1261
+        return apply_filters('wpinv_get_invoice_fees', $fees, $this->ID, $this);
1262 1262
     }
1263 1263
     
1264
-    public function get_fees_total( $type = 'all' ) {
1264
+    public function get_fees_total($type = 'all') {
1265 1265
         $fees_total = (float) 0.00;
1266 1266
 
1267
-        $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1268
-        if ( ! empty( $payment_fees ) ) {
1269
-            foreach ( $payment_fees as $fee ) {
1267
+        $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1268
+        if (!empty($payment_fees)) {
1269
+            foreach ($payment_fees as $fee) {
1270 1270
                 $fees_total += (float) $fee['amount'];
1271 1271
             }
1272 1272
         }
1273 1273
 
1274
-        return apply_filters( 'wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this );
1274
+        return apply_filters('wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this);
1275 1275
         /*
1276 1276
         $fees = $this->get_fees( $type );
1277 1277
 
@@ -1291,116 +1291,116 @@  discard block
 block discarded – undo
1291 1291
     }
1292 1292
 
1293 1293
     public function get_user_id() {
1294
-        return apply_filters( 'wpinv_user_id', $this->user_id, $this->ID, $this );
1294
+        return apply_filters('wpinv_user_id', $this->user_id, $this->ID, $this);
1295 1295
     }
1296 1296
     
1297 1297
     public function get_first_name() {
1298
-        return apply_filters( 'wpinv_first_name', $this->first_name, $this->ID, $this );
1298
+        return apply_filters('wpinv_first_name', $this->first_name, $this->ID, $this);
1299 1299
     }
1300 1300
     
1301 1301
     public function get_last_name() {
1302
-        return apply_filters( 'wpinv_last_name', $this->last_name, $this->ID, $this );
1302
+        return apply_filters('wpinv_last_name', $this->last_name, $this->ID, $this);
1303 1303
     }
1304 1304
     
1305 1305
     public function get_user_full_name() {
1306
-        return apply_filters( 'wpinv_user_full_name', $this->full_name, $this->ID, $this );
1306
+        return apply_filters('wpinv_user_full_name', $this->full_name, $this->ID, $this);
1307 1307
     }
1308 1308
     
1309 1309
     public function get_user_info() {
1310
-        return apply_filters( 'wpinv_user_info', $this->user_info, $this->ID, $this );
1310
+        return apply_filters('wpinv_user_info', $this->user_info, $this->ID, $this);
1311 1311
     }
1312 1312
     
1313 1313
     public function get_email() {
1314
-        return apply_filters( 'wpinv_user_email', $this->email, $this->ID, $this );
1314
+        return apply_filters('wpinv_user_email', $this->email, $this->ID, $this);
1315 1315
     }
1316 1316
     
1317 1317
     public function get_address() {
1318
-        return apply_filters( 'wpinv_address', $this->address, $this->ID, $this );
1318
+        return apply_filters('wpinv_address', $this->address, $this->ID, $this);
1319 1319
     }
1320 1320
     
1321 1321
     public function get_phone() {
1322
-        return apply_filters( 'wpinv_phone', $this->phone, $this->ID, $this );
1322
+        return apply_filters('wpinv_phone', $this->phone, $this->ID, $this);
1323 1323
     }
1324 1324
     
1325 1325
     public function get_number() {
1326
-        return apply_filters( 'wpinv_number', $this->number, $this->ID, $this );
1326
+        return apply_filters('wpinv_number', $this->number, $this->ID, $this);
1327 1327
     }
1328 1328
     
1329 1329
     public function get_items() {
1330
-        return apply_filters( 'wpinv_payment_meta_items', $this->items, $this->ID, $this );
1330
+        return apply_filters('wpinv_payment_meta_items', $this->items, $this->ID, $this);
1331 1331
     }
1332 1332
     
1333 1333
     public function get_key() {
1334
-        return apply_filters( 'wpinv_key', $this->key, $this->ID, $this );
1334
+        return apply_filters('wpinv_key', $this->key, $this->ID, $this);
1335 1335
     }
1336 1336
     
1337 1337
     public function get_transaction_id() {
1338
-        return apply_filters( 'wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this );
1338
+        return apply_filters('wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this);
1339 1339
     }
1340 1340
     
1341 1341
     public function get_gateway() {
1342
-        return apply_filters( 'wpinv_gateway', $this->gateway, $this->ID, $this );
1342
+        return apply_filters('wpinv_gateway', $this->gateway, $this->ID, $this);
1343 1343
     }
1344 1344
     
1345 1345
     public function get_gateway_title() {
1346
-        $this->gateway_title = !empty( $this->gateway_title ) ? $this->gateway_title : wpinv_get_gateway_checkout_label( $this->gateway );
1346
+        $this->gateway_title = !empty($this->gateway_title) ? $this->gateway_title : wpinv_get_gateway_checkout_label($this->gateway);
1347 1347
         
1348
-        return apply_filters( 'wpinv_gateway_title', $this->gateway_title, $this->ID, $this );
1348
+        return apply_filters('wpinv_gateway_title', $this->gateway_title, $this->ID, $this);
1349 1349
     }
1350 1350
     
1351 1351
     public function get_currency() {
1352
-        return apply_filters( 'wpinv_currency_code', $this->currency, $this->ID, $this );
1352
+        return apply_filters('wpinv_currency_code', $this->currency, $this->ID, $this);
1353 1353
     }
1354 1354
     
1355 1355
     public function get_created_date() {
1356
-        return apply_filters( 'wpinv_created_date', $this->date, $this->ID, $this );
1356
+        return apply_filters('wpinv_created_date', $this->date, $this->ID, $this);
1357 1357
     }
1358 1358
     
1359
-    public function get_due_date( $display = false ) {
1360
-        $due_date = apply_filters( 'wpinv_due_date', $this->due_date, $this->ID, $this );
1359
+    public function get_due_date($display = false) {
1360
+        $due_date = apply_filters('wpinv_due_date', $this->due_date, $this->ID, $this);
1361 1361
 
1362
-        if ( ! $display ) {
1362
+        if (!$display) {
1363 1363
             return $due_date;
1364 1364
         }
1365 1365
         
1366
-        return getpaid_format_date( $this->due_date );
1366
+        return getpaid_format_date($this->due_date);
1367 1367
     }
1368 1368
     
1369 1369
     public function get_completed_date() {
1370
-        return apply_filters( 'wpinv_completed_date', $this->completed_date, $this->ID, $this );
1370
+        return apply_filters('wpinv_completed_date', $this->completed_date, $this->ID, $this);
1371 1371
     }
1372 1372
     
1373
-    public function get_invoice_date( $formatted = true ) {
1373
+    public function get_invoice_date($formatted = true) {
1374 1374
         $date_completed = $this->completed_date;
1375 1375
         $invoice_date   = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
1376 1376
         
1377
-        if ( $invoice_date == '' ) {
1377
+        if ($invoice_date == '') {
1378 1378
             $date_created   = $this->date;
1379 1379
             $invoice_date   = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? $date_created : '';
1380 1380
         }
1381 1381
         
1382
-        if ( $formatted && $invoice_date ) {
1383
-            $invoice_date   = getpaid_format_date( $invoice_date );
1382
+        if ($formatted && $invoice_date) {
1383
+            $invoice_date = getpaid_format_date($invoice_date);
1384 1384
         }
1385 1385
 
1386
-        return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this );
1386
+        return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this);
1387 1387
     }
1388 1388
     
1389 1389
     public function get_ip() {
1390
-        return apply_filters( 'wpinv_user_ip', $this->ip, $this->ID, $this );
1390
+        return apply_filters('wpinv_user_ip', $this->ip, $this->ID, $this);
1391 1391
     }
1392 1392
         
1393
-    public function has_status( $status ) {
1394
-        return apply_filters( 'wpinv_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status ) ) || $this->get_status() === $status ? true : false, $this, $status );
1393
+    public function has_status($status) {
1394
+        return apply_filters('wpinv_has_status', (is_array($status) && in_array($this->get_status(), $status)) || $this->get_status() === $status ? true : false, $this, $status);
1395 1395
     }
1396 1396
     
1397
-    public function add_item( $item_id = 0, $args = array() ) {
1397
+    public function add_item($item_id = 0, $args = array()) {
1398 1398
         global $wpi_current_id, $wpi_item_id;
1399 1399
         
1400
-        $item = new WPInv_Item( $item_id );
1400
+        $item = new WPInv_Item($item_id);
1401 1401
 
1402 1402
         // Bail if this post isn't a item
1403
-        if( !$item || $item->post_type !== 'wpi_item' ) {
1403
+        if (!$item || $item->post_type !== 'wpi_item') {
1404 1404
             return false;
1405 1405
         }
1406 1406
         
@@ -1419,8 +1419,8 @@  discard block
 block discarded – undo
1419 1419
             'fees'          => array()
1420 1420
         );
1421 1421
 
1422
-        $args = wp_parse_args( apply_filters( 'wpinv_add_item_args', $args, $item->ID ), $defaults );
1423
-        $args['quantity']   = $has_quantities && $args['quantity'] > 0 ? absint( $args['quantity'] ) : 1;
1422
+        $args = wp_parse_args(apply_filters('wpinv_add_item_args', $args, $item->ID), $defaults);
1423
+        $args['quantity'] = $has_quantities && $args['quantity'] > 0 ? absint($args['quantity']) : 1;
1424 1424
 
1425 1425
         $wpi_current_id         = $this->ID;
1426 1426
         $wpi_item_id            = $item->ID;
@@ -1432,19 +1432,19 @@  discard block
 block discarded – undo
1432 1432
         $found_cart_key         = false;
1433 1433
         
1434 1434
         if ($has_quantities) {
1435
-            $this->cart_details = !empty( $this->cart_details ) ? array_values( $this->cart_details ) : $this->cart_details;
1435
+            $this->cart_details = !empty($this->cart_details) ? array_values($this->cart_details) : $this->cart_details;
1436 1436
             
1437
-            foreach ( $this->items as $key => $cart_item ) {
1438
-                if ( (int)$item_id !== (int)$cart_item['id'] ) {
1437
+            foreach ($this->items as $key => $cart_item) {
1438
+                if ((int) $item_id !== (int) $cart_item['id']) {
1439 1439
                     continue;
1440 1440
                 }
1441 1441
 
1442
-                $this->items[ $key ]['quantity'] += $args['quantity'];
1442
+                $this->items[$key]['quantity'] += $args['quantity'];
1443 1443
                 break;
1444 1444
             }
1445 1445
             
1446
-            foreach ( $this->cart_details as $cart_key => $cart_item ) {
1447
-                if ( $item_id != $cart_item['id'] ) {
1446
+            foreach ($this->cart_details as $cart_key => $cart_item) {
1447
+                if ($item_id != $cart_item['id']) {
1448 1448
                     continue;
1449 1449
                 }
1450 1450
 
@@ -1456,29 +1456,29 @@  discard block
 block discarded – undo
1456 1456
         if ($has_quantities && $found_cart_key !== false) {
1457 1457
             $cart_item          = $this->cart_details[$found_cart_key];
1458 1458
             $item_price         = $cart_item['item_price'];
1459
-            $quantity           = !empty( $cart_item['quantity'] ) ? $cart_item['quantity'] : 1;
1460
-            $tax_rate           = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : 0;
1459
+            $quantity           = !empty($cart_item['quantity']) ? $cart_item['quantity'] : 1;
1460
+            $tax_rate           = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : 0;
1461 1461
             
1462 1462
             $new_quantity       = $quantity + $args['quantity'];
1463 1463
             $subtotal           = $item_price * $new_quantity;
1464 1464
             
1465 1465
             $args['quantity']   = $new_quantity;
1466
-            $discount           = !empty( $args['discount'] ) ? $args['discount'] : 0;
1467
-            $tax                = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
1466
+            $discount           = !empty($args['discount']) ? $args['discount'] : 0;
1467
+            $tax                = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
1468 1468
             
1469
-            $discount_increased = $discount > 0 && $subtotal > 0 && $discount > (float)$cart_item['discount'] ? $discount - (float)$cart_item['discount'] : 0;
1470
-            $tax_increased      = $tax > 0 && $subtotal > 0 && $tax > (float)$cart_item['tax'] ? $tax - (float)$cart_item['tax'] : 0;
1469
+            $discount_increased = $discount > 0 && $subtotal > 0 && $discount > (float) $cart_item['discount'] ? $discount - (float) $cart_item['discount'] : 0;
1470
+            $tax_increased      = $tax > 0 && $subtotal > 0 && $tax > (float) $cart_item['tax'] ? $tax - (float) $cart_item['tax'] : 0;
1471 1471
             // The total increase equals the number removed * the item_price
1472
-            $total_increased    = wpinv_round_amount( $item_price );
1472
+            $total_increased    = wpinv_round_amount($item_price);
1473 1473
             
1474
-            if ( wpinv_prices_include_tax() ) {
1475
-                $subtotal -= wpinv_round_amount( $tax );
1474
+            if (wpinv_prices_include_tax()) {
1475
+                $subtotal -= wpinv_round_amount($tax);
1476 1476
             }
1477 1477
 
1478
-            $total              = $subtotal - $discount + $tax;
1478
+            $total = $subtotal - $discount + $tax;
1479 1479
 
1480 1480
             // Do not allow totals to go negative
1481
-            if( $total < 0 ) {
1481
+            if ($total < 0) {
1482 1482
                 $total = 0;
1483 1483
             }
1484 1484
             
@@ -1494,25 +1494,25 @@  discard block
 block discarded – undo
1494 1494
             $this->cart_details[$found_cart_key] = $cart_item;
1495 1495
         } else {
1496 1496
             // Set custom price.
1497
-            if ( $args['custom_price'] !== '' ) {
1497
+            if ($args['custom_price'] !== '') {
1498 1498
                 $item_price = $args['custom_price'];
1499 1499
             } else {
1500 1500
                 // Allow overriding the price
1501
-                if ( false !== $args['item_price'] ) {
1501
+                if (false !== $args['item_price']) {
1502 1502
                     $item_price = $args['item_price'];
1503 1503
                 } else {
1504
-                    $item_price = wpinv_get_item_price( $item->ID );
1504
+                    $item_price = wpinv_get_item_price($item->ID);
1505 1505
                 }
1506 1506
             }
1507 1507
 
1508 1508
             // Sanitizing the price here so we don't have a dozen calls later
1509
-            $item_price = wpinv_sanitize_amount( $item_price );
1510
-            $subtotal   = wpinv_round_amount( $item_price * $args['quantity'] );
1509
+            $item_price = wpinv_sanitize_amount($item_price);
1510
+            $subtotal   = wpinv_round_amount($item_price * $args['quantity']);
1511 1511
         
1512
-            $discount   = !empty( $args['discount'] ) ? $args['discount'] : 0;
1513
-            $tax_class  = !empty( $args['vat_class'] ) ? $args['vat_class'] : '';
1514
-            $tax_rate   = !empty( $args['vat_rate'] ) ? $args['vat_rate'] : 0;
1515
-            $tax        = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
1512
+            $discount   = !empty($args['discount']) ? $args['discount'] : 0;
1513
+            $tax_class  = !empty($args['vat_class']) ? $args['vat_class'] : '';
1514
+            $tax_rate   = !empty($args['vat_rate']) ? $args['vat_rate'] : 0;
1515
+            $tax        = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
1516 1516
 
1517 1517
             // Setup the items meta item
1518 1518
             $new_item = array(
@@ -1520,29 +1520,29 @@  discard block
 block discarded – undo
1520 1520
                 'quantity' => $args['quantity'],
1521 1521
             );
1522 1522
 
1523
-            $this->items[]  = $new_item;
1523
+            $this->items[] = $new_item;
1524 1524
 
1525
-            if ( wpinv_prices_include_tax() ) {
1526
-                $subtotal -= wpinv_round_amount( $tax );
1525
+            if (wpinv_prices_include_tax()) {
1526
+                $subtotal -= wpinv_round_amount($tax);
1527 1527
             }
1528 1528
 
1529
-            $total      = $subtotal - $discount + $tax;
1529
+            $total = $subtotal - $discount + $tax;
1530 1530
 
1531 1531
             // Do not allow totals to go negative
1532
-            if( $total < 0 ) {
1532
+            if ($total < 0) {
1533 1533
                 $total = 0;
1534 1534
             }
1535 1535
         
1536 1536
             $this->cart_details[] = array(
1537 1537
                 'name'          => !empty($args['name']) ? $args['name'] : $item->get_name(),
1538 1538
                 'id'            => $item->ID,
1539
-                'item_price'    => wpinv_round_amount( $item_price ),
1540
-                'custom_price'  => ( $args['custom_price'] !== '' ? wpinv_round_amount( $args['custom_price'] ) : '' ),
1539
+                'item_price'    => wpinv_round_amount($item_price),
1540
+                'custom_price'  => ($args['custom_price'] !== '' ? wpinv_round_amount($args['custom_price']) : ''),
1541 1541
                 'quantity'      => $args['quantity'],
1542 1542
                 'discount'      => $discount,
1543
-                'subtotal'      => wpinv_round_amount( $subtotal ),
1544
-                'tax'           => wpinv_round_amount( $tax ),
1545
-                'price'         => wpinv_round_amount( $total ),
1543
+                'subtotal'      => wpinv_round_amount($subtotal),
1544
+                'tax'           => wpinv_round_amount($tax),
1545
+                'price'         => wpinv_round_amount($total),
1546 1546
                 'vat_rate'      => $tax_rate,
1547 1547
                 'vat_class'     => $tax_class,
1548 1548
                 'meta'          => $args['meta'],
@@ -1552,18 +1552,18 @@  discard block
 block discarded – undo
1552 1552
             $subtotal = $subtotal - $discount;
1553 1553
         }
1554 1554
         
1555
-        $added_item = end( $this->cart_details );
1556
-        $added_item['action']  = 'add';
1555
+        $added_item = end($this->cart_details);
1556
+        $added_item['action'] = 'add';
1557 1557
         
1558 1558
         $this->pending['items'][] = $added_item;
1559 1559
         
1560
-        $this->increase_subtotal( $subtotal );
1561
-        $this->increase_tax( $tax );
1560
+        $this->increase_subtotal($subtotal);
1561
+        $this->increase_tax($tax);
1562 1562
 
1563 1563
         return true;
1564 1564
     }
1565 1565
     
1566
-    public function remove_item( $item_id, $args = array() ) {
1566
+    public function remove_item($item_id, $args = array()) {
1567 1567
         // Set some defaults
1568 1568
         $defaults = array(
1569 1569
             'quantity'      => 1,
@@ -1571,51 +1571,51 @@  discard block
 block discarded – undo
1571 1571
             'custom_price'  => '',
1572 1572
             'cart_index'    => false,
1573 1573
         );
1574
-        $args = wp_parse_args( $args, $defaults );
1574
+        $args = wp_parse_args($args, $defaults);
1575 1575
 
1576 1576
         // Bail if this post isn't a item
1577
-        if ( get_post_type( $item_id ) !== 'wpi_item' ) {
1577
+        if (get_post_type($item_id) !== 'wpi_item') {
1578 1578
             return false;
1579 1579
         }
1580 1580
         
1581
-        $this->cart_details = !empty( $this->cart_details ) ? array_values( $this->cart_details ) : $this->cart_details;
1581
+        $this->cart_details = !empty($this->cart_details) ? array_values($this->cart_details) : $this->cart_details;
1582 1582
 
1583
-        foreach ( $this->items as $key => $item ) {
1584
-            if ( !empty($item['id']) && (int)$item_id !== (int)$item['id'] ) {
1583
+        foreach ($this->items as $key => $item) {
1584
+            if (!empty($item['id']) && (int) $item_id !== (int) $item['id']) {
1585 1585
                 continue;
1586 1586
             }
1587 1587
 
1588
-            if ( false !== $args['cart_index'] ) {
1589
-                $cart_index = absint( $args['cart_index'] );
1590
-                $cart_item  = ! empty( $this->cart_details[ $cart_index ] ) ? $this->cart_details[ $cart_index ] : false;
1588
+            if (false !== $args['cart_index']) {
1589
+                $cart_index = absint($args['cart_index']);
1590
+                $cart_item  = !empty($this->cart_details[$cart_index]) ? $this->cart_details[$cart_index] : false;
1591 1591
 
1592
-                if ( ! empty( $cart_item ) ) {
1592
+                if (!empty($cart_item)) {
1593 1593
                     // If the cart index item isn't the same item ID, don't remove it
1594
-                    if ( !empty($cart_item['id']) && $cart_item['id'] != $item['id'] ) {
1594
+                    if (!empty($cart_item['id']) && $cart_item['id'] != $item['id']) {
1595 1595
                         continue;
1596 1596
                     }
1597 1597
                 }
1598 1598
             }
1599 1599
 
1600
-            $item_quantity = $this->items[ $key ]['quantity'];
1601
-            if ( $item_quantity > $args['quantity'] ) {
1602
-                $this->items[ $key ]['quantity'] -= $args['quantity'];
1600
+            $item_quantity = $this->items[$key]['quantity'];
1601
+            if ($item_quantity > $args['quantity']) {
1602
+                $this->items[$key]['quantity'] -= $args['quantity'];
1603 1603
                 break;
1604 1604
             } else {
1605
-                unset( $this->items[ $key ] );
1605
+                unset($this->items[$key]);
1606 1606
                 break;
1607 1607
             }
1608 1608
         }
1609 1609
 
1610 1610
         $found_cart_key = false;
1611
-        if ( false === $args['cart_index'] ) {
1612
-            foreach ( $this->cart_details as $cart_key => $item ) {
1613
-                if ( $item_id != $item['id'] ) {
1611
+        if (false === $args['cart_index']) {
1612
+            foreach ($this->cart_details as $cart_key => $item) {
1613
+                if ($item_id != $item['id']) {
1614 1614
                     continue;
1615 1615
                 }
1616 1616
 
1617
-                if ( false !== $args['item_price'] ) {
1618
-                    if ( isset( $item['item_price'] ) && (float) $args['item_price'] != (float) $item['item_price'] ) {
1617
+                if (false !== $args['item_price']) {
1618
+                    if (isset($item['item_price']) && (float) $args['item_price'] != (float) $item['item_price']) {
1619 1619
                         continue;
1620 1620
                     }
1621 1621
                 }
@@ -1624,13 +1624,13 @@  discard block
 block discarded – undo
1624 1624
                 break;
1625 1625
             }
1626 1626
         } else {
1627
-            $cart_index = absint( $args['cart_index'] );
1627
+            $cart_index = absint($args['cart_index']);
1628 1628
 
1629
-            if ( ! array_key_exists( $cart_index, $this->cart_details ) ) {
1629
+            if (!array_key_exists($cart_index, $this->cart_details)) {
1630 1630
                 return false; // Invalid cart index passed.
1631 1631
             }
1632 1632
 
1633
-            if ( (int) $this->cart_details[ $cart_index ]['id'] > 0 && (int) $this->cart_details[ $cart_index ]['id'] !== (int) $item_id ) {
1633
+            if ((int) $this->cart_details[$cart_index]['id'] > 0 && (int) $this->cart_details[$cart_index]['id'] !== (int) $item_id) {
1634 1634
                 return false; // We still need the proper Item ID to be sure.
1635 1635
             }
1636 1636
 
@@ -1638,41 +1638,41 @@  discard block
 block discarded – undo
1638 1638
         }
1639 1639
         
1640 1640
         $cart_item  = $this->cart_details[$found_cart_key];
1641
-        $quantity   = !empty( $cart_item['quantity'] ) ? $cart_item['quantity'] : 1;
1641
+        $quantity   = !empty($cart_item['quantity']) ? $cart_item['quantity'] : 1;
1642 1642
         
1643
-        if ( count( $this->cart_details ) == 1 && ( $quantity - $args['quantity'] ) < 1 ) {
1643
+        if (count($this->cart_details) == 1 && ($quantity - $args['quantity']) < 1) {
1644 1644
             //return false; // Invoice must contain at least one item.
1645 1645
         }
1646 1646
         
1647
-        $discounts  = $this->get_discounts();
1647
+        $discounts = $this->get_discounts();
1648 1648
         
1649
-        if ( $quantity > $args['quantity'] ) {
1649
+        if ($quantity > $args['quantity']) {
1650 1650
             $item_price         = $cart_item['item_price'];
1651
-            $tax_rate           = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : 0;
1651
+            $tax_rate           = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : 0;
1652 1652
             
1653
-            $new_quantity       = max( $quantity - $args['quantity'], 1);
1653
+            $new_quantity       = max($quantity - $args['quantity'], 1);
1654 1654
             $subtotal           = $item_price * $new_quantity;
1655 1655
             
1656 1656
             $args['quantity']   = $new_quantity;
1657
-            $discount           = !empty( $cart_item['discount'] ) ? $cart_item['discount'] : 0;
1658
-            $tax                = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
1657
+            $discount           = !empty($cart_item['discount']) ? $cart_item['discount'] : 0;
1658
+            $tax                = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
1659 1659
             
1660
-            $discount_decrease  = (float)$cart_item['discount'] > 0 && $quantity > 0 ? wpinv_round_amount( ( (float)$cart_item['discount'] / $quantity ) ) : 0;
1661
-            $discount_decrease  = $discount > 0 && $subtotal > 0 && (float)$cart_item['discount'] > $discount ? (float)$cart_item['discount'] - $discount : $discount_decrease; 
1662
-            $tax_decrease       = (float)$cart_item['tax'] > 0 && $quantity > 0 ? wpinv_round_amount( ( (float)$cart_item['tax'] / $quantity ) ) : 0;
1663
-            $tax_decrease       = $tax > 0 && $subtotal > 0 && (float)$cart_item['tax'] > $tax ? (float)$cart_item['tax'] - $tax : $tax_decrease;
1660
+            $discount_decrease  = (float) $cart_item['discount'] > 0 && $quantity > 0 ? wpinv_round_amount(((float) $cart_item['discount'] / $quantity)) : 0;
1661
+            $discount_decrease  = $discount > 0 && $subtotal > 0 && (float) $cart_item['discount'] > $discount ? (float) $cart_item['discount'] - $discount : $discount_decrease; 
1662
+            $tax_decrease       = (float) $cart_item['tax'] > 0 && $quantity > 0 ? wpinv_round_amount(((float) $cart_item['tax'] / $quantity)) : 0;
1663
+            $tax_decrease       = $tax > 0 && $subtotal > 0 && (float) $cart_item['tax'] > $tax ? (float) $cart_item['tax'] - $tax : $tax_decrease;
1664 1664
             
1665 1665
             // The total increase equals the number removed * the item_price
1666
-            $total_decrease     = wpinv_round_amount( $item_price );
1666
+            $total_decrease     = wpinv_round_amount($item_price);
1667 1667
             
1668
-            if ( wpinv_prices_include_tax() ) {
1669
-                $subtotal -= wpinv_round_amount( $tax );
1668
+            if (wpinv_prices_include_tax()) {
1669
+                $subtotal -= wpinv_round_amount($tax);
1670 1670
             }
1671 1671
 
1672
-            $total              = $subtotal - $discount + $tax;
1672
+            $total = $subtotal - $discount + $tax;
1673 1673
 
1674 1674
             // Do not allow totals to go negative
1675
-            if( $total < 0 ) {
1675
+            if ($total < 0) {
1676 1676
                 $total = 0;
1677 1677
             }
1678 1678
             
@@ -1691,16 +1691,16 @@  discard block
 block discarded – undo
1691 1691
             
1692 1692
             $this->cart_details[$found_cart_key] = $cart_item;
1693 1693
             
1694
-            $remove_item = end( $this->cart_details );
1694
+            $remove_item = end($this->cart_details);
1695 1695
         } else {
1696 1696
             $item_price     = $cart_item['item_price'];
1697
-            $discount       = !empty( $cart_item['discount'] ) ? $cart_item['discount'] : 0;
1698
-            $tax            = !empty( $cart_item['tax'] ) ? $cart_item['tax'] : 0;
1697
+            $discount       = !empty($cart_item['discount']) ? $cart_item['discount'] : 0;
1698
+            $tax            = !empty($cart_item['tax']) ? $cart_item['tax'] : 0;
1699 1699
         
1700
-            $subtotal_decrease  = ( $item_price * $quantity ) - $discount;
1700
+            $subtotal_decrease  = ($item_price * $quantity) - $discount;
1701 1701
             $tax_decrease       = $tax;
1702 1702
 
1703
-            unset( $this->cart_details[$found_cart_key] );
1703
+            unset($this->cart_details[$found_cart_key]);
1704 1704
             
1705 1705
             $remove_item             = $args;
1706 1706
             $remove_item['id']       = $item_id;
@@ -1711,8 +1711,8 @@  discard block
 block discarded – undo
1711 1711
         $remove_item['action']      = 'remove';
1712 1712
         $this->pending['items'][]   = $remove_item;
1713 1713
                
1714
-        $this->decrease_subtotal( $subtotal_decrease );
1715
-        $this->decrease_tax( $tax_decrease );
1714
+        $this->decrease_subtotal($subtotal_decrease);
1715
+        $this->decrease_tax($tax_decrease);
1716 1716
         
1717 1717
         return true;
1718 1718
     }
@@ -1720,7 +1720,7 @@  discard block
 block discarded – undo
1720 1720
     public function update_items($temp = false) {
1721 1721
         global $wpinv_euvat, $wpi_current_id, $wpi_item_id, $wpi_nosave;
1722 1722
         
1723
-        if ( !empty( $this->cart_details ) ) {
1723
+        if (!empty($this->cart_details)) {
1724 1724
             $wpi_nosave             = $temp;
1725 1725
             $cart_subtotal          = 0;
1726 1726
             $cart_discount          = 0;
@@ -1730,65 +1730,65 @@  discard block
 block discarded – undo
1730 1730
             $_POST['wpinv_country'] = $this->country;
1731 1731
             $_POST['wpinv_state']   = $this->state;
1732 1732
 
1733
-            foreach ( $this->cart_details as $key => $item ) {
1733
+            foreach ($this->cart_details as $key => $item) {
1734 1734
                 $item_price = $item['item_price'];
1735
-                $quantity   = wpinv_item_quantities_enabled() && $item['quantity'] > 0 ? absint( $item['quantity'] ) : 1;
1736
-                $amount     = wpinv_round_amount( $item_price * $quantity );
1735
+                $quantity   = wpinv_item_quantities_enabled() && $item['quantity'] > 0 ? absint($item['quantity']) : 1;
1736
+                $amount     = wpinv_round_amount($item_price * $quantity);
1737 1737
                 $subtotal   = $item_price * $quantity;
1738 1738
                 
1739 1739
                 $wpi_current_id         = $this->ID;
1740 1740
                 $wpi_item_id            = $item['id'];
1741 1741
                 
1742
-                $discount   = wpinv_get_cart_item_discount_amount( $item, $this->get_discounts() );
1742
+                $discount   = wpinv_get_cart_item_discount_amount($item, $this->get_discounts());
1743 1743
                 
1744
-                $tax_rate   = wpinv_get_tax_rate( $this->country, $this->state, $wpi_item_id );
1745
-                $tax_class  = $wpinv_euvat->get_item_class( $wpi_item_id );
1746
-                $tax        = $item_price > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
1744
+                $tax_rate   = wpinv_get_tax_rate($this->country, $this->state, $wpi_item_id);
1745
+                $tax_class  = $wpinv_euvat->get_item_class($wpi_item_id);
1746
+                $tax        = $item_price > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
1747 1747
 
1748
-                if ( ! $this->is_taxable() ) {
1748
+                if (!$this->is_taxable()) {
1749 1749
                     $tax = 0;
1750 1750
                 }
1751 1751
 
1752
-                if ( wpinv_prices_include_tax() ) {
1753
-                    $subtotal -= wpinv_round_amount( $tax );
1752
+                if (wpinv_prices_include_tax()) {
1753
+                    $subtotal -= wpinv_round_amount($tax);
1754 1754
                 }
1755 1755
 
1756
-                $total      = $subtotal - $discount + $tax;
1756
+                $total = $subtotal - $discount + $tax;
1757 1757
 
1758 1758
                 // Do not allow totals to go negative
1759
-                if( $total < 0 ) {
1759
+                if ($total < 0) {
1760 1760
                     $total = 0;
1761 1761
                 }
1762 1762
 
1763 1763
                 $cart_details[] = array(
1764 1764
                     'id'          => $item['id'],
1765 1765
                     'name'        => $item['name'],
1766
-                    'item_price'  => wpinv_round_amount( $item_price ),
1767
-                    'custom_price'=> ( isset( $item['custom_price'] ) ? $item['custom_price'] : '' ),
1766
+                    'item_price'  => wpinv_round_amount($item_price),
1767
+                    'custom_price'=> (isset($item['custom_price']) ? $item['custom_price'] : ''),
1768 1768
                     'quantity'    => $quantity,
1769 1769
                     'discount'    => $discount,
1770
-                    'subtotal'    => wpinv_round_amount( $subtotal ),
1771
-                    'tax'         => wpinv_round_amount( $tax ),
1772
-                    'price'       => wpinv_round_amount( $total ),
1770
+                    'subtotal'    => wpinv_round_amount($subtotal),
1771
+                    'tax'         => wpinv_round_amount($tax),
1772
+                    'price'       => wpinv_round_amount($total),
1773 1773
                     'vat_rate'    => $tax_rate,
1774 1774
                     'vat_class'   => $tax_class,
1775 1775
                     'meta'        => isset($item['meta']) ? $item['meta'] : array(),
1776 1776
                     'fees'        => isset($item['fees']) ? $item['fees'] : array(),
1777 1777
                 );
1778 1778
 
1779
-                $cart_subtotal  += (float)($subtotal - $discount); // TODO
1780
-                $cart_discount  += (float)($discount);
1781
-                $cart_tax       += (float)($tax);
1779
+                $cart_subtotal  += (float) ($subtotal - $discount); // TODO
1780
+                $cart_discount  += (float) ($discount);
1781
+                $cart_tax       += (float) ($tax);
1782 1782
             }
1783
-            if ( $cart_subtotal < 0 ) {
1783
+            if ($cart_subtotal < 0) {
1784 1784
                 $cart_subtotal = 0;
1785 1785
             }
1786
-            if ( $cart_tax < 0 ) {
1786
+            if ($cart_tax < 0) {
1787 1787
                 $cart_tax = 0;
1788 1788
             }
1789
-            $this->subtotal = wpinv_round_amount( $cart_subtotal );
1790
-            $this->tax      = wpinv_round_amount( $cart_tax );
1791
-            $this->discount = wpinv_round_amount( $cart_discount );
1789
+            $this->subtotal = wpinv_round_amount($cart_subtotal);
1790
+            $this->tax      = wpinv_round_amount($cart_tax);
1791
+            $this->discount = wpinv_round_amount($cart_discount);
1792 1792
             
1793 1793
             $this->recalculate_total();
1794 1794
             
@@ -1800,177 +1800,177 @@  discard block
 block discarded – undo
1800 1800
     
1801 1801
     public function recalculate_totals($temp = false) {        
1802 1802
         $this->update_items($temp);
1803
-        $this->save( true );
1803
+        $this->save(true);
1804 1804
         
1805 1805
         return $this;
1806 1806
     }
1807 1807
     
1808 1808
     public function needs_payment() {
1809
-        $valid_invoice_statuses = apply_filters( 'wpinv_valid_invoice_statuses_for_payment', array( 'wpi-pending' ), $this );
1809
+        $valid_invoice_statuses = apply_filters('wpinv_valid_invoice_statuses_for_payment', array('wpi-pending'), $this);
1810 1810
 
1811
-        if ( $this->has_status( $valid_invoice_statuses ) && ( $this->get_total() > 0 || $this->is_free_trial() || $this->is_free() || $this->is_initial_free() ) ) {
1811
+        if ($this->has_status($valid_invoice_statuses) && ($this->get_total() > 0 || $this->is_free_trial() || $this->is_free() || $this->is_initial_free())) {
1812 1812
             $needs_payment = true;
1813 1813
         } else {
1814 1814
             $needs_payment = false;
1815 1815
         }
1816 1816
 
1817
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this, $valid_invoice_statuses );
1817
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this, $valid_invoice_statuses);
1818 1818
     }
1819 1819
     
1820
-    public function get_checkout_payment_url( $with_key = false, $secret = false ) {
1820
+    public function get_checkout_payment_url($with_key = false, $secret = false) {
1821 1821
         $pay_url = wpinv_get_checkout_uri();
1822 1822
 
1823
-        if ( is_ssl() ) {
1824
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1823
+        if (is_ssl()) {
1824
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1825 1825
         }
1826 1826
         
1827 1827
         $key = $this->get_key();
1828 1828
 
1829
-        if ( $with_key ) {
1830
-            $pay_url = add_query_arg( 'invoice_key', $key, $pay_url );
1829
+        if ($with_key) {
1830
+            $pay_url = add_query_arg('invoice_key', $key, $pay_url);
1831 1831
         } else {
1832
-            $pay_url = add_query_arg( array( 'wpi_action' => 'pay_for_invoice', 'invoice_key' => $key ), $pay_url );
1832
+            $pay_url = add_query_arg(array('wpi_action' => 'pay_for_invoice', 'invoice_key' => $key), $pay_url);
1833 1833
         }
1834 1834
         
1835
-        if ( $secret ) {
1836
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $key ) ), $pay_url );
1835
+        if ($secret) {
1836
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $key)), $pay_url);
1837 1837
         }
1838 1838
 
1839
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $with_key, $secret );
1839
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $with_key, $secret);
1840 1840
     }
1841 1841
     
1842
-    public function get_view_url( $with_key = false ) {
1843
-        $invoice_url = get_permalink( $this->ID );
1842
+    public function get_view_url($with_key = false) {
1843
+        $invoice_url = get_permalink($this->ID);
1844 1844
 
1845
-        if ( $with_key ) {
1846
-            $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1845
+        if ($with_key) {
1846
+            $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1847 1847
         }
1848 1848
 
1849
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this, $with_key );
1849
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this, $with_key);
1850 1850
     }
1851 1851
     
1852
-    public function generate_key( $string = '' ) {
1853
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1854
-        return strtolower( md5( $string . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) );  // Unique key
1852
+    public function generate_key($string = '') {
1853
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1854
+        return strtolower(md5($string . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))); // Unique key
1855 1855
     }
1856 1856
     
1857 1857
     public function is_recurring() {
1858
-        if ( empty( $this->cart_details ) ) {
1858
+        if (empty($this->cart_details)) {
1859 1859
             return false;
1860 1860
         }
1861 1861
         
1862 1862
         $has_subscription = false;
1863
-        foreach( $this->cart_details as $cart_item ) {
1864
-            if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] )  ) {
1863
+        foreach ($this->cart_details as $cart_item) {
1864
+            if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) {
1865 1865
                 $has_subscription = true;
1866 1866
                 break;
1867 1867
             }
1868 1868
         }
1869 1869
         
1870
-        if ( count( $this->cart_details ) > 1 ) {
1870
+        if (count($this->cart_details) > 1) {
1871 1871
             $has_subscription = false;
1872 1872
         }
1873 1873
 
1874
-        return apply_filters( 'wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details );
1874
+        return apply_filters('wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details);
1875 1875
     }
1876 1876
 
1877 1877
     public function is_free_trial() {
1878 1878
         $is_free_trial = false;
1879 1879
         
1880
-        if ( $this->is_parent() && $item = $this->get_recurring( true ) ) {
1881
-            if ( !empty( $item ) && $item->has_free_trial() ) {
1880
+        if ($this->is_parent() && $item = $this->get_recurring(true)) {
1881
+            if (!empty($item) && $item->has_free_trial()) {
1882 1882
                 $is_free_trial = true;
1883 1883
             }
1884 1884
         }
1885 1885
 
1886
-        return apply_filters( 'wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this );
1886
+        return apply_filters('wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this);
1887 1887
     }
1888 1888
 
1889 1889
     public function is_initial_free() {
1890 1890
         $is_initial_free = false;
1891 1891
         
1892
-        if ( ! ( (float)wpinv_round_amount( $this->get_total() ) > 0 ) && $this->is_parent() && $this->is_recurring() && ! $this->is_free_trial() && ! $this->is_free() ) {
1892
+        if (!((float) wpinv_round_amount($this->get_total()) > 0) && $this->is_parent() && $this->is_recurring() && !$this->is_free_trial() && !$this->is_free()) {
1893 1893
             $is_initial_free = true;
1894 1894
         }
1895 1895
 
1896
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->cart_details );
1896
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->cart_details);
1897 1897
     }
1898 1898
     
1899
-    public function get_recurring( $object = false ) {
1899
+    public function get_recurring($object = false) {
1900 1900
         $item = NULL;
1901 1901
         
1902
-        if ( empty( $this->cart_details ) ) {
1902
+        if (empty($this->cart_details)) {
1903 1903
             return $item;
1904 1904
         }
1905 1905
         
1906
-        foreach( $this->cart_details as $cart_item ) {
1907
-            if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] )  ) {
1906
+        foreach ($this->cart_details as $cart_item) {
1907
+            if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) {
1908 1908
                 $item = $cart_item['id'];
1909 1909
                 break;
1910 1910
             }
1911 1911
         }
1912 1912
         
1913
-        if ( $object ) {
1914
-            $item = $item ? new WPInv_Item( $item ) : NULL;
1913
+        if ($object) {
1914
+            $item = $item ? new WPInv_Item($item) : NULL;
1915 1915
             
1916
-            apply_filters( 'wpinv_invoice_get_recurring_item', $item, $this );
1916
+            apply_filters('wpinv_invoice_get_recurring_item', $item, $this);
1917 1917
         }
1918 1918
 
1919
-        return apply_filters( 'wpinv_invoice_get_recurring_item_id', $item, $this );
1919
+        return apply_filters('wpinv_invoice_get_recurring_item_id', $item, $this);
1920 1920
     }
1921 1921
 
1922 1922
     public function get_subscription_name() {
1923
-        $item = $this->get_recurring( true );
1923
+        $item = $this->get_recurring(true);
1924 1924
 
1925
-        if ( empty( $item ) ) {
1925
+        if (empty($item)) {
1926 1926
             return NULL;
1927 1927
         }
1928 1928
 
1929
-        if ( !($name = $item->get_name()) ) {
1929
+        if (!($name = $item->get_name())) {
1930 1930
             $name = $item->post_name;
1931 1931
         }
1932 1932
 
1933
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $name, $this );
1933
+        return apply_filters('wpinv_invoice_get_subscription_name', $name, $this);
1934 1934
     }
1935 1935
 
1936 1936
     public function get_subscription_id() {
1937
-        $subscription_id = $this->get_meta( '_wpinv_subscr_profile_id', true );
1937
+        $subscription_id = $this->get_meta('_wpinv_subscr_profile_id', true);
1938 1938
 
1939
-        if ( empty( $subscription_id ) && !empty( $this->parent_invoice ) ) {
1940
-            $parent_invoice = wpinv_get_invoice( $this->parent_invoice );
1939
+        if (empty($subscription_id) && !empty($this->parent_invoice)) {
1940
+            $parent_invoice = wpinv_get_invoice($this->parent_invoice);
1941 1941
 
1942
-            $subscription_id = $parent_invoice->get_meta( '_wpinv_subscr_profile_id', true );
1942
+            $subscription_id = $parent_invoice->get_meta('_wpinv_subscr_profile_id', true);
1943 1943
         }
1944 1944
         
1945 1945
         return $subscription_id;
1946 1946
     }
1947 1947
     
1948 1948
     public function is_parent() {
1949
-        $is_parent = empty( $this->parent_invoice ) ? true : false;
1949
+        $is_parent = empty($this->parent_invoice) ? true : false;
1950 1950
 
1951
-        return apply_filters( 'wpinv_invoice_is_parent', $is_parent, $this );
1951
+        return apply_filters('wpinv_invoice_is_parent', $is_parent, $this);
1952 1952
     }
1953 1953
     
1954 1954
     public function is_renewal() {
1955 1955
         $is_renewal = $this->parent_invoice && $this->parent_invoice != $this->ID ? true : false;
1956 1956
 
1957
-        return apply_filters( 'wpinv_invoice_is_renewal', $is_renewal, $this );
1957
+        return apply_filters('wpinv_invoice_is_renewal', $is_renewal, $this);
1958 1958
     }
1959 1959
     
1960 1960
     public function get_parent_payment() {
1961 1961
         $parent_payment = NULL;
1962 1962
         
1963
-        if ( $this->is_renewal() ) {
1964
-            $parent_payment = wpinv_get_invoice( $this->parent_invoice );
1963
+        if ($this->is_renewal()) {
1964
+            $parent_payment = wpinv_get_invoice($this->parent_invoice);
1965 1965
         }
1966 1966
         
1967 1967
         return $parent_payment;
1968 1968
     }
1969 1969
     
1970 1970
     public function is_paid() {
1971
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
1971
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
1972 1972
 
1973
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
1973
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
1974 1974
     }
1975 1975
 
1976 1976
     /**
@@ -1983,23 +1983,23 @@  discard block
 block discarded – undo
1983 1983
     }
1984 1984
     
1985 1985
     public function is_refunded() {
1986
-        $is_refunded = $this->has_status( array( 'wpi-refunded' ) );
1986
+        $is_refunded = $this->has_status(array('wpi-refunded'));
1987 1987
 
1988
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
1988
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
1989 1989
     }
1990 1990
     
1991 1991
     public function is_free() {
1992 1992
         $is_free = false;
1993 1993
         
1994
-        if ( !( (float)wpinv_round_amount( $this->get_total() ) > 0 ) ) {
1995
-            if ( $this->is_parent() && $this->is_recurring() ) {
1996
-                $is_free = (float)wpinv_round_amount( $this->get_recurring_details( 'total' ) ) > 0 ? false : true;
1994
+        if (!((float) wpinv_round_amount($this->get_total()) > 0)) {
1995
+            if ($this->is_parent() && $this->is_recurring()) {
1996
+                $is_free = (float) wpinv_round_amount($this->get_recurring_details('total')) > 0 ? false : true;
1997 1997
             } else {
1998 1998
                 $is_free = true;
1999 1999
             }
2000 2000
         }
2001 2001
         
2002
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2002
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2003 2003
     }
2004 2004
     
2005 2005
     public function has_vat() {
@@ -2007,41 +2007,41 @@  discard block
 block discarded – undo
2007 2007
         
2008 2008
         $requires_vat = false;
2009 2009
         
2010
-        if ( $this->country ) {
2010
+        if ($this->country) {
2011 2011
             $wpi_country        = $this->country;
2012 2012
             
2013
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2013
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2014 2014
         }
2015 2015
         
2016
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2016
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2017 2017
     }
2018 2018
     
2019 2019
     public function refresh_item_ids() {
2020 2020
         $item_ids = array();
2021 2021
         
2022
-        if ( !empty( $this->cart_details ) ) {
2023
-            foreach ( $this->cart_details as $key => $item ) {
2024
-                if ( !empty( $item['id'] ) ) {
2022
+        if (!empty($this->cart_details)) {
2023
+            foreach ($this->cart_details as $key => $item) {
2024
+                if (!empty($item['id'])) {
2025 2025
                     $item_ids[] = $item['id'];
2026 2026
                 }
2027 2027
             }
2028 2028
         }
2029 2029
         
2030
-        $item_ids = !empty( $item_ids ) ? implode( ',', array_unique( $item_ids ) ) : '';
2030
+        $item_ids = !empty($item_ids) ? implode(',', array_unique($item_ids)) : '';
2031 2031
         
2032
-        update_post_meta( $this->ID, '_wpinv_item_ids', $item_ids );
2032
+        update_post_meta($this->ID, '_wpinv_item_ids', $item_ids);
2033 2033
     }
2034 2034
     
2035
-    public function get_invoice_quote_type( $post_id ) {
2036
-        if ( empty( $post_id ) ) {
2035
+    public function get_invoice_quote_type($post_id) {
2036
+        if (empty($post_id)) {
2037 2037
             return '';
2038 2038
         }
2039 2039
 
2040
-        $type = get_post_type( $post_id );
2040
+        $type = get_post_type($post_id);
2041 2041
 
2042
-        if ( 'wpi_invoice' === $type ) {
2042
+        if ('wpi_invoice' === $type) {
2043 2043
             $post_type = __('Invoice', 'invoicing');
2044
-        } else{
2044
+        } else {
2045 2045
             $post_type = __('Quote', 'invoicing');
2046 2046
         }
2047 2047
 
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +469 added lines, -469 removed lines patch added patch discarded remove patch
@@ -4,99 +4,99 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Displays an invoice.
11 11
  * 
12 12
  * @param WPInv_Invoice $invoice.
13 13
  */
14
-function getpaid_invoice( $invoice ) {
15
-    if ( ! empty( $invoice ) ) {
16
-        wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) );
14
+function getpaid_invoice($invoice) {
15
+    if (!empty($invoice)) {
16
+        wpinv_get_template('invoice/invoice.php', compact('invoice'));
17 17
     }
18 18
 }
19
-add_action( 'getpaid_invoice', 'getpaid_invoice', 10 );
19
+add_action('getpaid_invoice', 'getpaid_invoice', 10);
20 20
 
21 21
 /**
22 22
  * Displays the invoice footer.
23 23
  */
24
-function getpaid_invoice_footer( $invoice ) {
25
-    if ( ! empty( $invoice ) ) {
26
-        wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) );
24
+function getpaid_invoice_footer($invoice) {
25
+    if (!empty($invoice)) {
26
+        wpinv_get_template('invoice/footer.php', compact('invoice'));
27 27
     }
28 28
 }
29
-add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 );
29
+add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10);
30 30
 
31 31
 /**
32 32
  * Displays the invoice top bar.
33 33
  */
34
-function getpaid_invoice_header( $invoice ) {
35
-    if ( ! empty( $invoice ) ) {
36
-        wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) );
34
+function getpaid_invoice_header($invoice) {
35
+    if (!empty($invoice)) {
36
+        wpinv_get_template('invoice/header.php', compact('invoice'));
37 37
     }
38 38
 }
39
-add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 );
39
+add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10);
40 40
 
41 41
 /**
42 42
  * Displays actions on the left side of the header.
43 43
  */
44
-function getpaid_invoice_header_left_actions( $invoice ) {
45
-    if ( ! empty( $invoice ) ) {
46
-        wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) );
44
+function getpaid_invoice_header_left_actions($invoice) {
45
+    if (!empty($invoice)) {
46
+        wpinv_get_template('invoice/header-left-actions.php', compact('invoice'));
47 47
     }
48 48
 }
49
-add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 );
49
+add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10);
50 50
 
51 51
 /**
52 52
  * Displays actions on the right side of the invoice top bar.
53 53
  */
54
-function getpaid_invoice_header_right_actions( $invoice ) {
55
-    if ( ! empty( $invoice ) ) {
56
-        wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) );
54
+function getpaid_invoice_header_right_actions($invoice) {
55
+    if (!empty($invoice)) {
56
+        wpinv_get_template('invoice/header-right-actions.php', compact('invoice'));
57 57
     }
58 58
 }
59
-add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 );
59
+add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10);
60 60
 
61 61
 /**
62 62
  * Displays the invoice title, watermark, logo etc.
63 63
  */
64
-function getpaid_invoice_details_top( $invoice ) {
65
-    if ( ! empty( $invoice ) ) {
66
-        wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) );
64
+function getpaid_invoice_details_top($invoice) {
65
+    if (!empty($invoice)) {
66
+        wpinv_get_template('invoice/details-top.php', compact('invoice'));
67 67
     }
68 68
 }
69
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 );
69
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10);
70 70
 
71 71
 /**
72 72
  * Displays the company logo.
73 73
  */
74
-function getpaid_invoice_logo( $invoice ) {
75
-    if ( ! empty( $invoice ) ) {
76
-        wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) );
74
+function getpaid_invoice_logo($invoice) {
75
+    if (!empty($invoice)) {
76
+        wpinv_get_template('invoice/invoice-logo.php', compact('invoice'));
77 77
     }
78 78
 }
79
-add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' );
79
+add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo');
80 80
 
81 81
 /**
82 82
  * Displays the type of invoice.
83 83
  */
84
-function getpaid_invoice_type( $invoice ) {
85
-    if ( ! empty( $invoice ) ) {
86
-        wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) );
84
+function getpaid_invoice_type($invoice) {
85
+    if (!empty($invoice)) {
86
+        wpinv_get_template('invoice/invoice-type.php', compact('invoice'));
87 87
     }
88 88
 }
89
-add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' );
89
+add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type');
90 90
 
91 91
 /**
92 92
  * Displays the invoice details.
93 93
  */
94
-function getpaid_invoice_details_main( $invoice ) {
95
-    if ( ! empty( $invoice ) ) {
96
-        wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) );
94
+function getpaid_invoice_details_main($invoice) {
95
+    if (!empty($invoice)) {
96
+        wpinv_get_template('invoice/details.php', compact('invoice'));
97 97
     }
98 98
 }
99
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 );
99
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50);
100 100
 
101 101
 /**
102 102
  * Returns a path to the templates directory.
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
126 126
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
127 127
  */
128
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
129
-    return getpaid_template()->display_template( $template_name, $args, $template_path, $default_path );
128
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
129
+    return getpaid_template()->display_template($template_name, $args, $template_path, $default_path);
130 130
 }
131 131
 
132 132
 /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
140 140
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
141 141
  */
142
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
143
-	return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
142
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
143
+	return getpaid_template()->get_template($template_name, $args, $template_path, $default_path);
144 144
 }
145 145
 
146 146
 /**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
  * @return string
150 150
  */
151 151
 function wpinv_template_path() {
152
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
152
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
153 153
 }
154 154
 
155 155
 /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * @return string
159 159
  */
160 160
 function wpinv_get_theme_template_dir_name() {
161
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
161
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
162 162
 }
163 163
 
164 164
 /**
@@ -170,56 +170,56 @@  discard block
 block discarded – undo
170 170
  * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
171 171
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
172 172
  */
173
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
174
-    return getpaid_template()->locate_template( $template_name, $template_path, $default_path );
173
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
174
+    return getpaid_template()->locate_template($template_name, $template_path, $default_path);
175 175
 }
176 176
 
177
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
178
-	do_action( 'get_template_part_' . $slug, $slug, $name );
177
+function wpinv_get_template_part($slug, $name = null, $load = true) {
178
+	do_action('get_template_part_' . $slug, $slug, $name);
179 179
 
180 180
 	// Setup possible parts
181 181
 	$templates = array();
182
-	if ( isset( $name ) )
182
+	if (isset($name))
183 183
 		$templates[] = $slug . '-' . $name . '.php';
184 184
 	$templates[] = $slug . '.php';
185 185
 
186 186
 	// Allow template parts to be filtered
187
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
187
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
188 188
 
189 189
 	// Return the part that is found
190
-	return wpinv_locate_tmpl( $templates, $load, false );
190
+	return wpinv_locate_tmpl($templates, $load, false);
191 191
 }
192 192
 
193
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
193
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
194 194
 	// No file found yet
195 195
 	$located = false;
196 196
 
197 197
 	// Try to find a template file
198
-	foreach ( (array)$template_names as $template_name ) {
198
+	foreach ((array) $template_names as $template_name) {
199 199
 
200 200
 		// Continue if template is empty
201
-		if ( empty( $template_name ) )
201
+		if (empty($template_name))
202 202
 			continue;
203 203
 
204 204
 		// Trim off any slashes from the template name
205
-		$template_name = ltrim( $template_name, '/' );
205
+		$template_name = ltrim($template_name, '/');
206 206
 
207 207
 		// try locating this template file by looping through the template paths
208
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
208
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
209 209
 
210
-			if( file_exists( $template_path . $template_name ) ) {
210
+			if (file_exists($template_path . $template_name)) {
211 211
 				$located = $template_path . $template_name;
212 212
 				break;
213 213
 			}
214 214
 		}
215 215
 
216
-		if( !empty( $located ) ) {
216
+		if (!empty($located)) {
217 217
 			break;
218 218
 		}
219 219
 	}
220 220
 
221
-	if ( ( true == $load ) && ! empty( $located ) )
222
-		load_template( $located, $require_once );
221
+	if ((true == $load) && !empty($located))
222
+		load_template($located, $require_once);
223 223
 
224 224
 	return $located;
225 225
 }
@@ -228,127 +228,127 @@  discard block
 block discarded – undo
228 228
 	$template_dir = wpinv_get_theme_template_dir_name();
229 229
 
230 230
 	$file_paths = array(
231
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
232
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
231
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
232
+		10 => trailingslashit(get_template_directory()) . $template_dir,
233 233
 		100 => wpinv_get_templates_dir()
234 234
 	);
235 235
 
236
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
236
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
237 237
 
238 238
 	// sort the file paths based on priority
239
-	ksort( $file_paths, SORT_NUMERIC );
239
+	ksort($file_paths, SORT_NUMERIC);
240 240
 
241
-	return array_map( 'trailingslashit', $file_paths );
241
+	return array_map('trailingslashit', $file_paths);
242 242
 }
243 243
 
244 244
 function wpinv_checkout_meta_tags() {
245 245
 
246 246
 	$pages   = array();
247
-	$pages[] = wpinv_get_option( 'success_page' );
248
-	$pages[] = wpinv_get_option( 'failure_page' );
249
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
250
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
247
+	$pages[] = wpinv_get_option('success_page');
248
+	$pages[] = wpinv_get_option('failure_page');
249
+	$pages[] = wpinv_get_option('invoice_history_page');
250
+	$pages[] = wpinv_get_option('invoice_subscription_page');
251 251
 
252
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
252
+	if (!wpinv_is_checkout() && !is_page($pages)) {
253 253
 		return;
254 254
 	}
255 255
 
256 256
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
257 257
 }
258
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
258
+add_action('wp_head', 'wpinv_checkout_meta_tags');
259 259
 
260
-function wpinv_add_body_classes( $class ) {
261
-	$classes = (array)$class;
260
+function wpinv_add_body_classes($class) {
261
+	$classes = (array) $class;
262 262
 
263
-	if( wpinv_is_checkout() ) {
263
+	if (wpinv_is_checkout()) {
264 264
 		$classes[] = 'wpinv-checkout';
265 265
 		$classes[] = 'wpinv-page';
266 266
 	}
267 267
 
268
-	if( wpinv_is_success_page() ) {
268
+	if (wpinv_is_success_page()) {
269 269
 		$classes[] = 'wpinv-success';
270 270
 		$classes[] = 'wpinv-page';
271 271
 	}
272 272
 
273
-	if( wpinv_is_failed_transaction_page() ) {
273
+	if (wpinv_is_failed_transaction_page()) {
274 274
 		$classes[] = 'wpinv-failed-transaction';
275 275
 		$classes[] = 'wpinv-page';
276 276
 	}
277 277
 
278
-	if( wpinv_is_invoice_history_page() ) {
278
+	if (wpinv_is_invoice_history_page()) {
279 279
 		$classes[] = 'wpinv-history';
280 280
 		$classes[] = 'wpinv-page';
281 281
 	}
282 282
 
283
-	if( wpinv_is_subscriptions_history_page() ) {
283
+	if (wpinv_is_subscriptions_history_page()) {
284 284
 		$classes[] = 'wpinv-subscription';
285 285
 		$classes[] = 'wpinv-page';
286 286
 	}
287 287
 
288
-	if( wpinv_is_test_mode() ) {
288
+	if (wpinv_is_test_mode()) {
289 289
 		$classes[] = 'wpinv-test-mode';
290 290
 		$classes[] = 'wpinv-page';
291 291
 	}
292 292
 
293
-	return array_unique( $classes );
293
+	return array_unique($classes);
294 294
 }
295
-add_filter( 'body_class', 'wpinv_add_body_classes' );
295
+add_filter('body_class', 'wpinv_add_body_classes');
296 296
 
297
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
298
-    $current     = date( 'Y' );
299
-    $start_year  = $current - absint( $years_before );
300
-    $end_year    = $current + absint( $years_after );
301
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
297
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
298
+    $current     = date('Y');
299
+    $start_year  = $current - absint($years_before);
300
+    $end_year    = $current + absint($years_after);
301
+    $selected    = empty($selected) ? date('Y') : $selected;
302 302
     $options     = array();
303 303
 
304
-    while ( $start_year <= $end_year ) {
305
-        $options[ absint( $start_year ) ] = $start_year;
304
+    while ($start_year <= $end_year) {
305
+        $options[absint($start_year)] = $start_year;
306 306
         $start_year++;
307 307
     }
308 308
 
309
-    $output = wpinv_html_select( array(
309
+    $output = wpinv_html_select(array(
310 310
         'name'             => $name,
311 311
         'selected'         => $selected,
312 312
         'options'          => $options,
313 313
         'show_option_all'  => false,
314 314
         'show_option_none' => false
315
-    ) );
315
+    ));
316 316
 
317 317
     return $output;
318 318
 }
319 319
 
320
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
320
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
321 321
 
322 322
     $options = array(
323
-        '1'  => __( 'January', 'invoicing' ),
324
-        '2'  => __( 'February', 'invoicing' ),
325
-        '3'  => __( 'March', 'invoicing' ),
326
-        '4'  => __( 'April', 'invoicing' ),
327
-        '5'  => __( 'May', 'invoicing' ),
328
-        '6'  => __( 'June', 'invoicing' ),
329
-        '7'  => __( 'July', 'invoicing' ),
330
-        '8'  => __( 'August', 'invoicing' ),
331
-        '9'  => __( 'September', 'invoicing' ),
332
-        '10' => __( 'October', 'invoicing' ),
333
-        '11' => __( 'November', 'invoicing' ),
334
-        '12' => __( 'December', 'invoicing' ),
323
+        '1'  => __('January', 'invoicing'),
324
+        '2'  => __('February', 'invoicing'),
325
+        '3'  => __('March', 'invoicing'),
326
+        '4'  => __('April', 'invoicing'),
327
+        '5'  => __('May', 'invoicing'),
328
+        '6'  => __('June', 'invoicing'),
329
+        '7'  => __('July', 'invoicing'),
330
+        '8'  => __('August', 'invoicing'),
331
+        '9'  => __('September', 'invoicing'),
332
+        '10' => __('October', 'invoicing'),
333
+        '11' => __('November', 'invoicing'),
334
+        '12' => __('December', 'invoicing'),
335 335
     );
336 336
 
337 337
     // If no month is selected, default to the current month
338
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
338
+    $selected = empty($selected) ? date('n') : $selected;
339 339
 
340
-    $output = wpinv_html_select( array(
340
+    $output = wpinv_html_select(array(
341 341
         'name'             => $name,
342 342
         'selected'         => $selected,
343 343
         'options'          => $options,
344 344
         'show_option_all'  => false,
345 345
         'show_option_none' => false
346
-    ) );
346
+    ));
347 347
 
348 348
     return $output;
349 349
 }
350 350
 
351
-function wpinv_html_select( $args = array() ) {
351
+function wpinv_html_select($args = array()) {
352 352
     $defaults = array(
353 353
         'options'          => array(),
354 354
         'name'             => null,
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
         'selected'         => 0,
358 358
         'placeholder'      => null,
359 359
         'multiple'         => false,
360
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
361
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
360
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
361
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
362 362
         'data'             => array(),
363 363
         'onchange'         => null,
364 364
         'required'         => false,
@@ -366,74 +366,74 @@  discard block
 block discarded – undo
366 366
         'readonly'         => false,
367 367
     );
368 368
 
369
-    $args = wp_parse_args( $args, $defaults );
369
+    $args = wp_parse_args($args, $defaults);
370 370
 
371 371
     $data_elements = '';
372
-    foreach ( $args['data'] as $key => $value ) {
373
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
372
+    foreach ($args['data'] as $key => $value) {
373
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
374 374
     }
375 375
 
376
-    if( $args['multiple'] ) {
376
+    if ($args['multiple']) {
377 377
         $multiple = ' MULTIPLE';
378 378
     } else {
379 379
         $multiple = '';
380 380
     }
381 381
 
382
-    if( $args['placeholder'] ) {
382
+    if ($args['placeholder']) {
383 383
         $placeholder = $args['placeholder'];
384 384
     } else {
385 385
         $placeholder = '';
386 386
     }
387 387
     
388 388
     $options = '';
389
-    if( !empty( $args['onchange'] ) ) {
390
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
389
+    if (!empty($args['onchange'])) {
390
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
391 391
     }
392 392
     
393
-    if( !empty( $args['required'] ) ) {
393
+    if (!empty($args['required'])) {
394 394
         $options .= ' required="required"';
395 395
     }
396 396
     
397
-    if( !empty( $args['disabled'] ) ) {
397
+    if (!empty($args['disabled'])) {
398 398
         $options .= ' disabled';
399 399
     }
400 400
     
401
-    if( !empty( $args['readonly'] ) ) {
401
+    if (!empty($args['readonly'])) {
402 402
         $options .= ' readonly';
403 403
     }
404 404
 
405
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
406
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
405
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
406
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
407 407
 
408
-    if ( $args['show_option_all'] ) {
409
-        if( $args['multiple'] ) {
410
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
408
+    if ($args['show_option_all']) {
409
+        if ($args['multiple']) {
410
+            $selected = selected(true, in_array(0, $args['selected']), false);
411 411
         } else {
412
-            $selected = selected( $args['selected'], 0, false );
412
+            $selected = selected($args['selected'], 0, false);
413 413
         }
414
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
414
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
415 415
     }
416 416
 
417
-    if ( !empty( $args['options'] ) ) {
417
+    if (!empty($args['options'])) {
418 418
 
419
-        if ( $args['show_option_none'] ) {
420
-            if( $args['multiple'] ) {
421
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
419
+        if ($args['show_option_none']) {
420
+            if ($args['multiple']) {
421
+                $selected = selected(true, in_array("", $args['selected']), false);
422 422
             } else {
423
-                $selected = selected( $args['selected'] === "", true, false );
423
+                $selected = selected($args['selected'] === "", true, false);
424 424
             }
425
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
425
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
426 426
         }
427 427
 
428
-        foreach( $args['options'] as $key => $option ) {
428
+        foreach ($args['options'] as $key => $option) {
429 429
 
430
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
431
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
430
+            if ($args['multiple'] && is_array($args['selected'])) {
431
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
432 432
             } else {
433
-                $selected = selected( $args['selected'], $key, false );
433
+                $selected = selected($args['selected'], $key, false);
434 434
             }
435 435
 
436
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
436
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
437 437
         }
438 438
     }
439 439
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     return $output;
443 443
 }
444 444
 
445
-function wpinv_item_dropdown( $args = array() ) {
445
+function wpinv_item_dropdown($args = array()) {
446 446
     $defaults = array(
447 447
         'name'              => 'wpi_item',
448 448
         'id'                => 'wpi_item',
@@ -450,14 +450,14 @@  discard block
 block discarded – undo
450 450
         'multiple'          => false,
451 451
         'selected'          => 0,
452 452
         'number'            => 100,
453
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
454
-        'data'              => array( 'search-type' => 'item' ),
453
+        'placeholder'       => __('Choose a item', 'invoicing'),
454
+        'data'              => array('search-type' => 'item'),
455 455
         'show_option_all'   => false,
456 456
         'show_option_none'  => false,
457 457
         'show_recurring'    => false,
458 458
     );
459 459
 
460
-    $args = wp_parse_args( $args, $defaults );
460
+    $args = wp_parse_args($args, $defaults);
461 461
 
462 462
     $item_args = array(
463 463
         'post_type'      => 'wpi_item',
@@ -466,44 +466,44 @@  discard block
 block discarded – undo
466 466
         'posts_per_page' => $args['number']
467 467
     );
468 468
 
469
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
469
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
470 470
 
471
-    $items      = get_posts( $item_args );
471
+    $items      = get_posts($item_args);
472 472
     $options    = array();
473
-    if ( $items ) {
474
-        foreach ( $items as $item ) {
475
-            $title = esc_html( $item->post_title );
473
+    if ($items) {
474
+        foreach ($items as $item) {
475
+            $title = esc_html($item->post_title);
476 476
             
477
-            if ( !empty( $args['show_recurring'] ) ) {
478
-                $title .= wpinv_get_item_suffix( $item->ID, false );
477
+            if (!empty($args['show_recurring'])) {
478
+                $title .= wpinv_get_item_suffix($item->ID, false);
479 479
             }
480 480
             
481
-            $options[ absint( $item->ID ) ] = $title;
481
+            $options[absint($item->ID)] = $title;
482 482
         }
483 483
     }
484 484
 
485 485
     // This ensures that any selected items are included in the drop down
486
-    if( is_array( $args['selected'] ) ) {
487
-        foreach( $args['selected'] as $item ) {
488
-            if( ! in_array( $item, $options ) ) {
489
-                $title = get_the_title( $item );
490
-                if ( !empty( $args['show_recurring'] ) ) {
491
-                    $title .= wpinv_get_item_suffix( $item, false );
486
+    if (is_array($args['selected'])) {
487
+        foreach ($args['selected'] as $item) {
488
+            if (!in_array($item, $options)) {
489
+                $title = get_the_title($item);
490
+                if (!empty($args['show_recurring'])) {
491
+                    $title .= wpinv_get_item_suffix($item, false);
492 492
                 }
493 493
                 $options[$item] = $title;
494 494
             }
495 495
         }
496
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
497
-        if ( ! in_array( $args['selected'], $options ) ) {
498
-            $title = get_the_title( $args['selected'] );
499
-            if ( !empty( $args['show_recurring'] ) ) {
500
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
496
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
497
+        if (!in_array($args['selected'], $options)) {
498
+            $title = get_the_title($args['selected']);
499
+            if (!empty($args['show_recurring'])) {
500
+                $title .= wpinv_get_item_suffix($args['selected'], false);
501 501
             }
502
-            $options[$args['selected']] = get_the_title( $args['selected'] );
502
+            $options[$args['selected']] = get_the_title($args['selected']);
503 503
         }
504 504
     }
505 505
 
506
-    $output = wpinv_html_select( array(
506
+    $output = wpinv_html_select(array(
507 507
         'name'             => $args['name'],
508 508
         'selected'         => $args['selected'],
509 509
         'id'               => $args['id'],
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
         'show_option_all'  => $args['show_option_all'],
515 515
         'show_option_none' => $args['show_option_none'],
516 516
         'data'             => $args['data'],
517
-    ) );
517
+    ));
518 518
 
519 519
     return $output;
520 520
 }
@@ -534,16 +534,16 @@  discard block
 block discarded – undo
534 534
     );
535 535
 
536 536
     $options = array();
537
-    if ( $items ) {
538
-        foreach ( $items as $item ) {
539
-            $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false );
537
+    if ($items) {
538
+        foreach ($items as $item) {
539
+            $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false);
540 540
         }
541 541
     }
542 542
 
543 543
     return $options;
544 544
 }
545 545
 
546
-function wpinv_html_checkbox( $args = array() ) {
546
+function wpinv_html_checkbox($args = array()) {
547 547
     $defaults = array(
548 548
         'name'     => null,
549 549
         'current'  => null,
@@ -554,17 +554,17 @@  discard block
 block discarded – undo
554 554
         )
555 555
     );
556 556
 
557
-    $args = wp_parse_args( $args, $defaults );
557
+    $args = wp_parse_args($args, $defaults);
558 558
 
559
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
559
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
560 560
     $options = '';
561
-    if ( ! empty( $args['options']['disabled'] ) ) {
561
+    if (!empty($args['options']['disabled'])) {
562 562
         $options .= ' disabled="disabled"';
563
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
563
+    } elseif (!empty($args['options']['readonly'])) {
564 564
         $options .= ' readonly';
565 565
     }
566 566
 
567
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
567
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
568 568
 
569 569
     return $output;
570 570
 }
@@ -572,30 +572,30 @@  discard block
 block discarded – undo
572 572
 /**
573 573
  * Displays a hidden field.
574 574
  */
575
-function getpaid_hidden_field( $name, $value ) {
576
-    $name  = sanitize_text_field( $name );
577
-    $value = esc_attr( $value );
575
+function getpaid_hidden_field($name, $value) {
576
+    $name  = sanitize_text_field($name);
577
+    $value = esc_attr($value);
578 578
 
579 579
     echo "<input type='hidden' name='$name' value='$value' />";
580 580
 }
581 581
 
582
-function wpinv_html_text( $args = array() ) {
582
+function wpinv_html_text($args = array()) {
583 583
     // Backwards compatibility
584
-    if ( func_num_args() > 1 ) {
584
+    if (func_num_args() > 1) {
585 585
         $args = func_get_args();
586 586
 
587 587
         $name  = $args[0];
588
-        $value = isset( $args[1] ) ? $args[1] : '';
589
-        $label = isset( $args[2] ) ? $args[2] : '';
590
-        $desc  = isset( $args[3] ) ? $args[3] : '';
588
+        $value = isset($args[1]) ? $args[1] : '';
589
+        $label = isset($args[2]) ? $args[2] : '';
590
+        $desc  = isset($args[3]) ? $args[3] : '';
591 591
     }
592 592
 
593 593
     $defaults = array(
594 594
         'id'           => '',
595
-        'name'         => isset( $name )  ? $name  : 'text',
596
-        'value'        => isset( $value ) ? $value : null,
597
-        'label'        => isset( $label ) ? $label : null,
598
-        'desc'         => isset( $desc )  ? $desc  : null,
595
+        'name'         => isset($name) ? $name : 'text',
596
+        'value'        => isset($value) ? $value : null,
597
+        'label'        => isset($label) ? $label : null,
598
+        'desc'         => isset($desc) ? $desc : null,
599 599
         'placeholder'  => '',
600 600
         'class'        => 'regular-text',
601 601
         'disabled'     => false,
@@ -605,51 +605,51 @@  discard block
 block discarded – undo
605 605
         'data'         => false
606 606
     );
607 607
 
608
-    $args = wp_parse_args( $args, $defaults );
608
+    $args = wp_parse_args($args, $defaults);
609 609
 
610
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
610
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
611 611
     $options = '';
612
-    if( $args['required'] ) {
612
+    if ($args['required']) {
613 613
         $options .= ' required="required"';
614 614
     }
615
-    if( $args['readonly'] ) {
615
+    if ($args['readonly']) {
616 616
         $options .= ' readonly';
617 617
     }
618
-    if( $args['readonly'] ) {
618
+    if ($args['readonly']) {
619 619
         $options .= ' readonly';
620 620
     }
621 621
 
622 622
     $data = '';
623
-    if ( !empty( $args['data'] ) ) {
624
-        foreach ( $args['data'] as $key => $value ) {
625
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
623
+    if (!empty($args['data'])) {
624
+        foreach ($args['data'] as $key => $value) {
625
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
626 626
         }
627 627
     }
628 628
 
629
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
630
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
631
-    if ( ! empty( $args['desc'] ) ) {
632
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
629
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
630
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
631
+    if (!empty($args['desc'])) {
632
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
633 633
     }
634 634
 
635
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] )  . '" autocomplete="' . esc_attr( $args['autocomplete'] )  . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
635
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
636 636
 
637 637
     $output .= '</span>';
638 638
 
639 639
     return $output;
640 640
 }
641 641
 
642
-function wpinv_html_date_field( $args = array() ) {
643
-    if( empty( $args['class'] ) ) {
642
+function wpinv_html_date_field($args = array()) {
643
+    if (empty($args['class'])) {
644 644
         $args['class'] = 'wpiDatepicker';
645
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
645
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
646 646
         $args['class'] .= ' wpiDatepicker';
647 647
     }
648 648
 
649
-    return wpinv_html_text( $args );
649
+    return wpinv_html_text($args);
650 650
 }
651 651
 
652
-function wpinv_html_textarea( $args = array() ) {
652
+function wpinv_html_textarea($args = array()) {
653 653
     $defaults = array(
654 654
         'name'        => 'textarea',
655 655
         'value'       => null,
@@ -660,31 +660,31 @@  discard block
 block discarded – undo
660 660
         'placeholder' => '',
661 661
     );
662 662
 
663
-    $args = wp_parse_args( $args, $defaults );
663
+    $args = wp_parse_args($args, $defaults);
664 664
 
665
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
665
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
666 666
     $disabled = '';
667
-    if( $args['disabled'] ) {
667
+    if ($args['disabled']) {
668 668
         $disabled = ' disabled="disabled"';
669 669
     }
670 670
 
671
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
672
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
673
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
671
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
672
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
673
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
674 674
 
675
-    if ( ! empty( $args['desc'] ) ) {
676
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
675
+    if (!empty($args['desc'])) {
676
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
677 677
     }
678 678
     $output .= '</span>';
679 679
 
680 680
     return $output;
681 681
 }
682 682
 
683
-function wpinv_html_ajax_user_search( $args = array() ) {
683
+function wpinv_html_ajax_user_search($args = array()) {
684 684
     $defaults = array(
685 685
         'name'        => 'user_id',
686 686
         'value'       => null,
687
-        'placeholder' => __( 'Enter username', 'invoicing' ),
687
+        'placeholder' => __('Enter username', 'invoicing'),
688 688
         'label'       => null,
689 689
         'desc'        => null,
690 690
         'class'       => '',
@@ -693,13 +693,13 @@  discard block
 block discarded – undo
693 693
         'data'        => false
694 694
     );
695 695
 
696
-    $args = wp_parse_args( $args, $defaults );
696
+    $args = wp_parse_args($args, $defaults);
697 697
 
698 698
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
699 699
 
700 700
     $output  = '<span class="wpinv_user_search_wrap">';
701
-        $output .= wpinv_html_text( $args );
702
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
701
+        $output .= wpinv_html_text($args);
702
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
703 703
     $output .= '</span>';
704 704
 
705 705
     return $output;
@@ -715,20 +715,20 @@  discard block
 block discarded – undo
715 715
  * 
716 716
  * @param string $template the template that is currently being used.
717 717
  */
718
-function wpinv_template( $template ) {
718
+function wpinv_template($template) {
719 719
     global $post;
720 720
 
721
-    if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) {
721
+    if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) {
722 722
 
723 723
         // If the user can view this invoice, display it.
724
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
724
+        if (wpinv_user_can_view_invoice($post->ID)) {
725 725
 
726
-            return wpinv_get_template_part( 'wpinv-invoice-print', false, false );
726
+            return wpinv_get_template_part('wpinv-invoice-print', false, false);
727 727
 
728 728
         // Else display an error message.
729 729
         } else {
730 730
 
731
-            return wpinv_get_template_part( 'wpinv-invalid-access', false, false );
731
+            return wpinv_get_template_part('wpinv-invalid-access', false, false);
732 732
 
733 733
         }
734 734
 
@@ -736,46 +736,46 @@  discard block
 block discarded – undo
736 736
 
737 737
     return $template;
738 738
 }
739
-add_filter( 'template_include', 'wpinv_template', 10, 1 );
739
+add_filter('template_include', 'wpinv_template', 10, 1);
740 740
 
741 741
 function wpinv_get_business_address() {
742 742
     $business_address   = wpinv_store_address();
743
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
743
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
744 744
     
745 745
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
746 746
     
747
-    return apply_filters( 'wpinv_get_business_address', $business_address );
747
+    return apply_filters('wpinv_get_business_address', $business_address);
748 748
 }
749 749
 
750 750
 /**
751 751
  * Displays the company address.
752 752
  */
753 753
 function wpinv_display_from_address() {
754
-    wpinv_get_template( 'invoice/company-address.php' );
754
+    wpinv_get_template('invoice/company-address.php');
755 755
 }
756
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 );
756
+add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10);
757 757
 
758
-function wpinv_watermark( $id = 0 ) {
759
-    $output = wpinv_get_watermark( $id );
760
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
758
+function wpinv_watermark($id = 0) {
759
+    $output = wpinv_get_watermark($id);
760
+    return apply_filters('wpinv_get_watermark', $output, $id);
761 761
 }
762 762
 
763
-function wpinv_get_watermark( $id ) {
764
-    if ( !$id > 0 ) {
763
+function wpinv_get_watermark($id) {
764
+    if (!$id > 0) {
765 765
         return NULL;
766 766
     }
767 767
 
768
-    $invoice = wpinv_get_invoice( $id );
768
+    $invoice = wpinv_get_invoice($id);
769 769
     
770
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
771
-        if ( $invoice->is_paid() ) {
772
-            return __( 'Paid', 'invoicing' );
770
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
771
+        if ($invoice->is_paid()) {
772
+            return __('Paid', 'invoicing');
773 773
         }
774
-        if ( $invoice->is_refunded() ) {
775
-            return __( 'Refunded', 'invoicing' );
774
+        if ($invoice->is_refunded()) {
775
+            return __('Refunded', 'invoicing');
776 776
         }
777
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
778
-            return __( 'Cancelled', 'invoicing' );
777
+        if ($invoice->has_status(array('wpi-cancelled'))) {
778
+            return __('Cancelled', 'invoicing');
779 779
         }
780 780
     }
781 781
     
@@ -785,30 +785,30 @@  discard block
 block discarded – undo
785 785
 /**
786 786
  * @deprecated
787 787
  */
788
-function wpinv_display_invoice_details( $invoice ) {
789
-    return getpaid_invoice_meta( $invoice );
788
+function wpinv_display_invoice_details($invoice) {
789
+    return getpaid_invoice_meta($invoice);
790 790
 }
791 791
 
792 792
 /**
793 793
  * Displays invoice meta.
794 794
  */
795
-function getpaid_invoice_meta( $invoice ) {
795
+function getpaid_invoice_meta($invoice) {
796 796
 
797
-    $invoice = new WPInv_Invoice( $invoice );
797
+    $invoice = new WPInv_Invoice($invoice);
798 798
 
799 799
     // Ensure that we have an invoice.
800
-    if ( 0 == $invoice->get_id() ) {
800
+    if (0 == $invoice->get_id()) {
801 801
         return;
802 802
     }
803 803
 
804 804
     // Get the invoice meta.
805
-    $meta = getpaid_get_invoice_meta( $invoice );
805
+    $meta = getpaid_get_invoice_meta($invoice);
806 806
 
807 807
     // Display the meta.
808
-    wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) );
808
+    wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta'));
809 809
 
810 810
 }
811
-add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 );
811
+add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10);
812 812
 
813 813
 /**
814 814
  * Retrieves the address markup to use on Invoices.
@@ -820,29 +820,29 @@  discard block
 block discarded – undo
820 820
  * @param  string $separator How to separate address lines.
821 821
  * @return string
822 822
  */
823
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
823
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
824 824
 
825 825
     // Retrieve the address markup...
826
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
827
-    $format = wpinv_get_full_address_format( $country );
826
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
827
+    $format = wpinv_get_full_address_format($country);
828 828
 
829 829
     // ... and the replacements.
830
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
830
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
831 831
 
832
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
832
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
833 833
     
834 834
 	// Remove unavailable tags.
835
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
835
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
836 836
 
837 837
     // Clean up white space.
838
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
839
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
838
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
839
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
840 840
     
841 841
     // Break newlines apart and remove empty lines/trim commas and white space.
842
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
842
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
843 843
 
844 844
     // Add html breaks.
845
-	$formatted_address = implode( $separator, $formatted_address );
845
+	$formatted_address = implode($separator, $formatted_address);
846 846
 
847 847
 	// We're done!
848 848
 	return $formatted_address;
@@ -854,88 +854,88 @@  discard block
 block discarded – undo
854 854
  * 
855 855
  * @param WPInv_Invoice $invoice
856 856
  */
857
-function wpinv_display_to_address( $invoice = 0 ) {
858
-    if ( ! empty( $invoice ) ) {
859
-        wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) );
857
+function wpinv_display_to_address($invoice = 0) {
858
+    if (!empty($invoice)) {
859
+        wpinv_get_template('invoice/billing-address.php', compact('invoice'));
860 860
     }
861 861
 }
862
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 );
862
+add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40);
863 863
 
864 864
 
865 865
 /**
866 866
  * Displays invoice line items.
867 867
  */
868
-function wpinv_display_line_items( $invoice_id = 0 ) {
868
+function wpinv_display_line_items($invoice_id = 0) {
869 869
 
870 870
     // Prepare the invoice.
871
-    $invoice = new WPInv_Invoice( $invoice_id );
871
+    $invoice = new WPInv_Invoice($invoice_id);
872 872
 
873 873
     // Abort if there is no invoice.
874
-    if ( 0 == $invoice->get_id() ) {
874
+    if (0 == $invoice->get_id()) {
875 875
         return;
876 876
     }
877 877
 
878 878
     // Line item columns.
879
-    $columns = getpaid_invoice_item_columns( $invoice );
880
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
879
+    $columns = getpaid_invoice_item_columns($invoice);
880
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
881 881
 
882
-    wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) );
882
+    wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns'));
883 883
 }
884
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 );
884
+add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10);
885 885
 
886 886
 /**
887 887
  * Displays invoice notices on invoices.
888 888
  */
889 889
 function wpinv_display_invoice_notice() {
890 890
 
891
-    $label  = wpinv_get_option( 'vat_invoice_notice_label' );
892
-    $notice = wpinv_get_option( 'vat_invoice_notice' );
891
+    $label  = wpinv_get_option('vat_invoice_notice_label');
892
+    $notice = wpinv_get_option('vat_invoice_notice');
893 893
 
894
-    if ( empty( $label ) && empty( $notice ) ) {
894
+    if (empty($label) && empty($notice)) {
895 895
         return;
896 896
     }
897 897
 
898 898
     echo '<div class="mt-4 mb-4 wpinv-vat-notice">';
899 899
 
900
-    if ( ! empty( $label ) ) {
901
-        $label = sanitize_text_field( $label );
900
+    if (!empty($label)) {
901
+        $label = sanitize_text_field($label);
902 902
         echo "<h5>$label</h5>";
903 903
     }
904 904
 
905
-    if ( ! empty( $notice ) ) {
906
-        echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>';
905
+    if (!empty($notice)) {
906
+        echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>';
907 907
     }
908 908
 
909 909
     echo '</div>';
910 910
 }
911
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 );
911
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100);
912 912
 
913 913
 /**
914 914
  * @param WPInv_Invoice $invoice
915 915
  */
916
-function wpinv_display_invoice_notes( $invoice ) {
916
+function wpinv_display_invoice_notes($invoice) {
917 917
 
918 918
     // Retrieve the notes.
919
-    $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' );
919
+    $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer');
920 920
 
921 921
     // Abort if we have non.
922
-    if ( empty( $notes ) ) {
922
+    if (empty($notes)) {
923 923
         return;
924 924
     }
925 925
 
926 926
     // Echo the note.
927 927
     echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">';
928
-    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>';
928
+    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>';
929 929
     echo '<ul class="getpaid-invoice-notes mt-4 p-0">';
930 930
 
931
-    foreach( $notes as $note ) {
932
-        wpinv_get_invoice_note_line_item( $note );
931
+    foreach ($notes as $note) {
932
+        wpinv_get_invoice_note_line_item($note);
933 933
     }
934 934
 
935 935
     echo '</ul>';
936 936
     echo '</div>';
937 937
 }
938
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 );
938
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60);
939 939
 
940 940
 /**
941 941
  * Loads scripts on our invoice templates.
@@ -943,32 +943,32 @@  discard block
 block discarded – undo
943 943
 function wpinv_display_style() {
944 944
 
945 945
     // Make sure that all scripts have been loaded.
946
-    if ( ! did_action( 'wp_enqueue_scripts' ) ) {
947
-        do_action( 'wp_enqueue_scripts' );
946
+    if (!did_action('wp_enqueue_scripts')) {
947
+        do_action('wp_enqueue_scripts');
948 948
     }
949 949
 
950 950
     // Register the invoices style.
951
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) );
951
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css'));
952 952
 
953 953
     // Load required styles
954
-    wp_print_styles( 'open-sans' );
955
-    wp_print_styles( 'wpinv-single-style' );
956
-    wp_print_styles( 'ayecode-ui' );
954
+    wp_print_styles('open-sans');
955
+    wp_print_styles('wpinv-single-style');
956
+    wp_print_styles('ayecode-ui');
957 957
 
958 958
     // Maybe load custom css.
959
-    $custom_css = wpinv_get_option( 'template_custom_css' );
959
+    $custom_css = wpinv_get_option('template_custom_css');
960 960
 
961
-    if ( isset( $custom_css ) && ! empty( $custom_css ) ) {
962
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
963
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
961
+    if (isset($custom_css) && !empty($custom_css)) {
962
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
963
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
964 964
         echo '<style type="text/css">';
965 965
         echo $custom_css;
966 966
         echo '</style>';
967 967
     }
968 968
 
969 969
 }
970
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
971
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
970
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
971
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
972 972
 
973 973
 
974 974
 /**
@@ -980,41 +980,41 @@  discard block
 block discarded – undo
980 980
     // Retrieve the current invoice.
981 981
     $invoice_id = getpaid_get_current_invoice_id();
982 982
 
983
-    if ( empty( $invoice_id ) ) {
983
+    if (empty($invoice_id)) {
984 984
 
985 985
         return aui()->alert(
986 986
             array(
987 987
                 'type'    => 'warning',
988
-                'content' => __( 'Invalid invoice', 'invoicing' ),
988
+                'content' => __('Invalid invoice', 'invoicing'),
989 989
             )
990 990
         );
991 991
 
992 992
     }
993 993
 
994 994
     // Can the user view this invoice?
995
-    if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) {
995
+    if (!wpinv_user_can_view_invoice($invoice_id)) {
996 996
 
997 997
         return aui()->alert(
998 998
             array(
999 999
                 'type'    => 'warning',
1000
-                'content' => __( 'You are not allowed to view this invoice', 'invoicing' ),
1000
+                'content' => __('You are not allowed to view this invoice', 'invoicing'),
1001 1001
             )
1002 1002
         );
1003 1003
 
1004 1004
     }
1005 1005
 
1006 1006
     // Ensure that it is not yet paid for.
1007
-    $invoice = new WPInv_Invoice( $invoice_id );
1007
+    $invoice = new WPInv_Invoice($invoice_id);
1008 1008
 
1009 1009
     // Maybe mark it as viewed.
1010
-    getpaid_maybe_mark_invoice_as_viewed( $invoice );
1010
+    getpaid_maybe_mark_invoice_as_viewed($invoice);
1011 1011
 
1012
-    if ( $invoice->is_paid() ) {
1012
+    if ($invoice->is_paid()) {
1013 1013
 
1014 1014
         return aui()->alert(
1015 1015
             array(
1016 1016
                 'type'    => 'success',
1017
-                'content' => __( 'This invoice has already been paid.', 'invoicing' ),
1017
+                'content' => __('This invoice has already been paid.', 'invoicing'),
1018 1018
             )
1019 1019
         );
1020 1020
 
@@ -1024,14 +1024,14 @@  discard block
 block discarded – undo
1024 1024
     $wpi_checkout_id = $invoice_id;
1025 1025
 
1026 1026
     // We'll display this invoice via the default form.
1027
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1027
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1028 1028
 
1029
-    if ( 0 == $form->get_id() ) {
1029
+    if (0 == $form->get_id()) {
1030 1030
 
1031 1031
         return aui()->alert(
1032 1032
             array(
1033 1033
                 'type'    => 'warning',
1034
-                'content' => __( 'Error loading the payment form', 'invoicing' ),
1034
+                'content' => __('Error loading the payment form', 'invoicing'),
1035 1035
             )
1036 1036
         );
1037 1037
 
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 
1040 1040
     // Set the invoice.
1041 1041
     $form->invoice = $invoice;
1042
-    $form->set_items( $invoice->get_items() );
1042
+    $form->set_items($invoice->get_items());
1043 1043
 
1044 1044
     // Generate the html.
1045 1045
     return $form->get_html();
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
 }
1048 1048
 
1049 1049
 function wpinv_empty_cart_message() {
1050
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1050
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1051 1051
 }
1052 1052
 
1053 1053
 /**
@@ -1064,38 +1064,38 @@  discard block
 block discarded – undo
1064 1064
         )
1065 1065
     );
1066 1066
 }
1067
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1067
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1068 1068
 
1069
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1070
-    $invoice = wpinv_get_invoice( $invoice_id );
1069
+function wpinv_receipt_billing_address($invoice_id = 0) {
1070
+    $invoice = wpinv_get_invoice($invoice_id);
1071 1071
 
1072
-    if ( empty( $invoice ) ) {
1072
+    if (empty($invoice)) {
1073 1073
         return NULL;
1074 1074
     }
1075 1075
 
1076 1076
     $billing_details = $invoice->get_user_info();
1077
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1077
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1078 1078
 
1079 1079
     ob_start();
1080 1080
     ?>
1081 1081
     <table class="table table-bordered table-sm wpi-billing-details">
1082 1082
         <tbody>
1083 1083
             <tr class="wpi-receipt-name">
1084
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1085
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1084
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1085
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1086 1086
             </tr>
1087 1087
             <tr class="wpi-receipt-email">
1088
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1089
-                <td><?php echo $billing_details['email'] ;?></td>
1088
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1089
+                <td><?php echo $billing_details['email']; ?></td>
1090 1090
             </tr>
1091 1091
             <tr class="wpi-receipt-address">
1092
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1093
-                <td><?php echo $address_row ;?></td>
1092
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1093
+                <td><?php echo $address_row; ?></td>
1094 1094
             </tr>
1095
-            <?php if ( $billing_details['phone'] ) { ?>
1095
+            <?php if ($billing_details['phone']) { ?>
1096 1096
             <tr class="wpi-receipt-phone">
1097
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1098
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1097
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1098
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1099 1099
             </tr>
1100 1100
             <?php } ?>
1101 1101
         </tbody>
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
     <?php
1104 1104
     $output = ob_get_clean();
1105 1105
     
1106
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1106
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1107 1107
 
1108 1108
     echo $output;
1109 1109
 }
@@ -1111,66 +1111,66 @@  discard block
 block discarded – undo
1111 1111
 /**
1112 1112
  * Filters the receipt page.
1113 1113
  */
1114
-function wpinv_filter_success_page_content( $content ) {
1114
+function wpinv_filter_success_page_content($content) {
1115 1115
 
1116 1116
     // Ensure this is our page.
1117
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1117
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1118 1118
 
1119
-        $gateway = sanitize_text_field( $_GET['payment-confirm'] );
1120
-        return apply_filters( "wpinv_payment_confirm_$gateway", $content );
1119
+        $gateway = sanitize_text_field($_GET['payment-confirm']);
1120
+        return apply_filters("wpinv_payment_confirm_$gateway", $content);
1121 1121
 
1122 1122
     }
1123 1123
 
1124 1124
     return $content;
1125 1125
 }
1126
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1126
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1127 1127
 
1128
-function wpinv_invoice_link( $invoice_id ) {
1129
-    $invoice = wpinv_get_invoice( $invoice_id );
1128
+function wpinv_invoice_link($invoice_id) {
1129
+    $invoice = wpinv_get_invoice($invoice_id);
1130 1130
 
1131
-    if ( empty( $invoice ) ) {
1131
+    if (empty($invoice)) {
1132 1132
         return NULL;
1133 1133
     }
1134 1134
 
1135
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1135
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1136 1136
 
1137
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1137
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1138 1138
 }
1139 1139
 
1140
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
1141
-    if ( empty( $note ) ) {
1140
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
1141
+    if (empty($note)) {
1142 1142
         return NULL;
1143 1143
     }
1144 1144
 
1145
-    if ( is_int( $note ) ) {
1146
-        $note = get_comment( $note );
1145
+    if (is_int($note)) {
1146
+        $note = get_comment($note);
1147 1147
     }
1148 1148
 
1149
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
1149
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
1150 1150
         return NULL;
1151 1151
     }
1152 1152
 
1153
-    $note_classes   = array( 'note' );
1154
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
1153
+    $note_classes   = array('note');
1154
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
1155 1155
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
1156
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
1157
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
1156
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
1157
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
1158 1158
 
1159 1159
     ob_start();
1160 1160
     ?>
1161
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3">
1161
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3">
1162 1162
         <div class="note_content bg-light border position-relative p-4">
1163 1163
 
1164
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
1164
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
1165 1165
 
1166
-            <?php if ( ! is_admin() ) : ?>
1166
+            <?php if (!is_admin()) : ?>
1167 1167
                 <em class="meta position-absolute form-text">
1168 1168
                     <?php
1169 1169
                         printf(
1170
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1170
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1171 1171
                             $note->comment_author,
1172
-                            getpaid_format_date_value( $note->comment_date ),
1173
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1172
+                            getpaid_format_date_value($note->comment_date),
1173
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1174 1174
                         );
1175 1175
                     ?>
1176 1176
                 </em>
@@ -1178,21 +1178,21 @@  discard block
 block discarded – undo
1178 1178
 
1179 1179
         </div>
1180 1180
 
1181
-        <?php if ( is_admin() ) : ?>
1181
+        <?php if (is_admin()) : ?>
1182 1182
 
1183 1183
             <p class="meta px-4 py-2">
1184
-                <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>">
1184
+                <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>">
1185 1185
                     <?php
1186 1186
                         printf(
1187
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1187
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1188 1188
                             $note->comment_author,
1189
-                            getpaid_format_date_value( $note->comment_date ),
1190
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1189
+                            getpaid_format_date_value($note->comment_date),
1190
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1191 1191
                         );
1192 1192
                     ?>
1193 1193
                 </abbr>&nbsp;&nbsp;
1194
-                <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?>
1195
-                    <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
1194
+                <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?>
1195
+                    <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
1196 1196
                 <?php } ?>
1197 1197
             </p>
1198 1198
 
@@ -1201,9 +1201,9 @@  discard block
 block discarded – undo
1201 1201
     </li>
1202 1202
     <?php
1203 1203
     $note_content = ob_get_clean();
1204
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
1204
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
1205 1205
 
1206
-    if ( $echo ) {
1206
+    if ($echo) {
1207 1207
         echo $note_content;
1208 1208
     } else {
1209 1209
         return $note_content;
@@ -1213,36 +1213,36 @@  discard block
 block discarded – undo
1213 1213
 function wpinv_invalid_invoice_content() {
1214 1214
     global $post;
1215 1215
 
1216
-    $invoice = wpinv_get_invoice( $post->ID );
1216
+    $invoice = wpinv_get_invoice($post->ID);
1217 1217
 
1218
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
1219
-    if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
1220
-        if ( is_user_logged_in() ) {
1221
-            if ( wpinv_require_login_to_checkout() ) {
1222
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1223
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
1218
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
1219
+    if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
1220
+        if (is_user_logged_in()) {
1221
+            if (wpinv_require_login_to_checkout()) {
1222
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1223
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
1224 1224
                 }
1225 1225
             }
1226 1226
         } else {
1227
-            if ( wpinv_require_login_to_checkout() ) {
1228
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1229
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
1227
+            if (wpinv_require_login_to_checkout()) {
1228
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1229
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
1230 1230
                 }
1231 1231
             }
1232 1232
         }
1233 1233
     } else {
1234
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
1234
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
1235 1235
     }
1236 1236
     ?>
1237 1237
     <div class="row wpinv-row-invalid">
1238 1238
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
1239
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
1239
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
1240 1240
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
1241 1241
         </div>
1242 1242
     </div>
1243 1243
     <?php
1244 1244
 }
1245
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
1245
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
1246 1246
 
1247 1247
 /**
1248 1248
  * Function to get privacy policy text.
@@ -1251,21 +1251,21 @@  discard block
 block discarded – undo
1251 1251
  * @return string
1252 1252
  */
1253 1253
 function wpinv_get_policy_text() {
1254
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
1254
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
1255 1255
 
1256
-    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ));
1256
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
1257 1257
 
1258
-    if(!$privacy_page_id){
1259
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
1258
+    if (!$privacy_page_id) {
1259
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
1260 1260
     }
1261 1261
 
1262
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
1262
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
1263 1263
 
1264 1264
     $find_replace = array(
1265 1265
         '[wpinv_privacy_policy]' => $privacy_link,
1266 1266
     );
1267 1267
 
1268
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
1268
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
1269 1269
 
1270 1270
     return wp_kses_post(wpautop($privacy_text));
1271 1271
 }
@@ -1273,21 +1273,21 @@  discard block
 block discarded – undo
1273 1273
 function wpinv_oxygen_fix_conflict() {
1274 1274
     global $ct_ignore_post_types;
1275 1275
 
1276
-    if ( ! is_array( $ct_ignore_post_types ) ) {
1276
+    if (!is_array($ct_ignore_post_types)) {
1277 1277
         $ct_ignore_post_types = array();
1278 1278
     }
1279 1279
 
1280
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
1280
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
1281 1281
 
1282
-    foreach ( $post_types as $post_type ) {
1282
+    foreach ($post_types as $post_type) {
1283 1283
         $ct_ignore_post_types[] = $post_type;
1284 1284
 
1285 1285
         // Ignore post type
1286
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
1286
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
1287 1287
     }
1288 1288
 
1289
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
1290
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
1289
+    remove_filter('template_include', 'wpinv_template', 10, 1);
1290
+    add_filter('template_include', 'wpinv_template', 999, 1);
1291 1291
 }
1292 1292
 
1293 1293
 /**
@@ -1295,10 +1295,10 @@  discard block
 block discarded – undo
1295 1295
  * 
1296 1296
  * @param GetPaid_Payment_Form $form
1297 1297
  */
1298
-function getpaid_display_payment_form( $form ) {
1298
+function getpaid_display_payment_form($form) {
1299 1299
 
1300
-    if ( is_numeric( $form ) ) {
1301
-        $form = new GetPaid_Payment_Form( $form );
1300
+    if (is_numeric($form)) {
1301
+        $form = new GetPaid_Payment_Form($form);
1302 1302
     }
1303 1303
 
1304 1304
     $form->display();
@@ -1308,55 +1308,55 @@  discard block
 block discarded – undo
1308 1308
 /**
1309 1309
  * Helper function to display a item payment form on the frontend.
1310 1310
  */
1311
-function getpaid_display_item_payment_form( $items ) {
1311
+function getpaid_display_item_payment_form($items) {
1312 1312
 
1313
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1314
-    $form->set_items( $items );
1313
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1314
+    $form->set_items($items);
1315 1315
 
1316
-    if ( 0 == count( $form->get_items() ) ) {
1316
+    if (0 == count($form->get_items())) {
1317 1317
         echo aui()->alert(
1318 1318
 			array(
1319 1319
 				'type'    => 'warning',
1320
-				'content' => __( 'No published items found', 'invoicing' ),
1320
+				'content' => __('No published items found', 'invoicing'),
1321 1321
 			)
1322 1322
         );
1323 1323
         return;
1324 1324
     }
1325 1325
 
1326
-    $form_items = esc_attr( getpaid_convert_items_to_string( $items ) );
1326
+    $form_items = esc_attr(getpaid_convert_items_to_string($items));
1327 1327
     $form_items = "<input type='hidden' name='getpaid-form-items' value='$form_items' />";
1328
-    $form->display( $form_items );
1328
+    $form->display($form_items);
1329 1329
 }
1330 1330
 
1331 1331
 /**
1332 1332
  * Helper function to display an invoice payment form on the frontend.
1333 1333
  */
1334
-function getpaid_display_invoice_payment_form( $invoice_id ) {
1334
+function getpaid_display_invoice_payment_form($invoice_id) {
1335 1335
 
1336
-    $invoice = wpinv_get_invoice( $invoice_id );
1336
+    $invoice = wpinv_get_invoice($invoice_id);
1337 1337
 
1338
-    if ( empty( $invoice ) ) {
1338
+    if (empty($invoice)) {
1339 1339
 		echo aui()->alert(
1340 1340
 			array(
1341 1341
 				'type'    => 'warning',
1342
-				'content' => __( 'Invoice not found', 'invoicing' ),
1342
+				'content' => __('Invoice not found', 'invoicing'),
1343 1343
 			)
1344 1344
         );
1345 1345
         return;
1346 1346
     }
1347 1347
 
1348
-    if ( $invoice->is_paid() ) {
1348
+    if ($invoice->is_paid()) {
1349 1349
 		echo aui()->alert(
1350 1350
 			array(
1351 1351
 				'type'    => 'warning',
1352
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1352
+				'content' => __('Invoice has already been paid', 'invoicing'),
1353 1353
 			)
1354 1354
         );
1355 1355
         return;
1356 1356
     }
1357 1357
 
1358
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1359
-    $form->set_items( $invoice->get_items() );
1358
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1359
+    $form->set_items($invoice->get_items());
1360 1360
 
1361 1361
     $form->display();
1362 1362
 }
@@ -1364,23 +1364,23 @@  discard block
 block discarded – undo
1364 1364
 /**
1365 1365
  * Helper function to convert item string to array.
1366 1366
  */
1367
-function getpaid_convert_items_to_array( $items ) {
1368
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
1367
+function getpaid_convert_items_to_array($items) {
1368
+    $items    = array_filter(array_map('trim', explode(',', $items)));
1369 1369
     $prepared = array();
1370 1370
 
1371
-    foreach ( $items as $item ) {
1372
-        $data = array_map( 'trim', explode( '|', $item ) );
1371
+    foreach ($items as $item) {
1372
+        $data = array_map('trim', explode('|', $item));
1373 1373
 
1374
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
1374
+        if (empty($data[0]) || !is_numeric($data[0])) {
1375 1375
             continue;
1376 1376
         }
1377 1377
 
1378 1378
         $quantity = 1;
1379
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
1379
+        if (isset($data[1]) && is_numeric($data[1])) {
1380 1380
             $quantity = (int) $data[1];
1381 1381
         }
1382 1382
 
1383
-        $prepared[ $data[0] ] = $quantity;
1383
+        $prepared[$data[0]] = $quantity;
1384 1384
 
1385 1385
     }
1386 1386
 
@@ -1390,13 +1390,13 @@  discard block
 block discarded – undo
1390 1390
 /**
1391 1391
  * Helper function to convert item array to string.
1392 1392
  */
1393
-function getpaid_convert_items_to_string( $items ) {
1393
+function getpaid_convert_items_to_string($items) {
1394 1394
     $prepared = array();
1395 1395
 
1396
-    foreach ( $items as $item => $quantity ) {
1396
+    foreach ($items as $item => $quantity) {
1397 1397
         $prepared[] = "$item|$quantity";
1398 1398
     }
1399
-    return implode( ',', $prepared );
1399
+    return implode(',', $prepared);
1400 1400
 }
1401 1401
 
1402 1402
 /**
@@ -1404,21 +1404,21 @@  discard block
 block discarded – undo
1404 1404
  * 
1405 1405
  * Provide a label and one of $form, $items or $invoice.
1406 1406
  */
1407
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
1408
-    $label = sanitize_text_field( $label );
1407
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
1408
+    $label = sanitize_text_field($label);
1409 1409
 
1410
-    if ( ! empty( $form ) ) {
1411
-        $form  = esc_attr( $form );
1410
+    if (!empty($form)) {
1411
+        $form = esc_attr($form);
1412 1412
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; 
1413 1413
     }
1414 1414
 	
1415
-	if ( ! empty( $items ) ) {
1416
-        $items  = esc_attr( $items );
1415
+	if (!empty($items)) {
1416
+        $items = esc_attr($items);
1417 1417
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; 
1418 1418
     }
1419 1419
     
1420
-    if ( ! empty( $invoice ) ) {
1421
-        $invoice  = esc_attr( $invoice );
1420
+    if (!empty($invoice)) {
1421
+        $invoice = esc_attr($invoice);
1422 1422
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; 
1423 1423
     }
1424 1424
 
@@ -1429,17 +1429,17 @@  discard block
 block discarded – undo
1429 1429
  *
1430 1430
  * @param WPInv_Invoice $invoice
1431 1431
  */
1432
-function getpaid_the_invoice_description( $invoice ) {
1432
+function getpaid_the_invoice_description($invoice) {
1433 1433
     $description = $invoice->get_description();
1434 1434
 
1435
-    if ( empty( $description ) ) {
1435
+    if (empty($description)) {
1436 1436
         return;
1437 1437
     }
1438 1438
 
1439
-    $description = wp_kses_post( $description );
1439
+    $description = wp_kses_post($description);
1440 1440
     echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>";
1441 1441
 }
1442
-add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 );
1442
+add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100);
1443 1443
 
1444 1444
 /**
1445 1445
  * Render element on a form.
@@ -1447,60 +1447,60 @@  discard block
 block discarded – undo
1447 1447
  * @param array $element
1448 1448
  * @param GetPaid_Payment_Form $form
1449 1449
  */
1450
-function getpaid_payment_form_element( $element, $form ) {
1450
+function getpaid_payment_form_element($element, $form) {
1451 1451
 
1452 1452
     // Set up the args.
1453
-    $element_type    = trim( $element['type'] );
1453
+    $element_type    = trim($element['type']);
1454 1454
     $element['form'] = $form;
1455
-    extract( $element );
1455
+    extract($element);
1456 1456
 
1457 1457
     // Try to locate the appropriate template.
1458
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
1458
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
1459 1459
     
1460 1460
     // Abort if this is not our element.
1461
-    if ( empty( $located ) || ! file_exists( $located ) ) {
1461
+    if (empty($located) || !file_exists($located)) {
1462 1462
         return;
1463 1463
     }
1464 1464
 
1465 1465
     // Generate the class and id of the element.
1466
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
1467
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
1466
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
1467
+    $id            = isset($id) ? $id : uniqid('gp');
1468 1468
 
1469 1469
     // Echo the opening wrapper.
1470 1470
     echo "<div class='getpaid-payment-form-element $wrapper_class'>";
1471 1471
 
1472 1472
     // Fires before displaying a given element type's content.
1473
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
1473
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
1474 1474
 
1475 1475
     // Include the template for the element.
1476 1476
     include $located;
1477 1477
 
1478 1478
     // Fires after displaying a given element type's content.
1479
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
1479
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
1480 1480
 
1481 1481
     // Echo the closing wrapper.
1482 1482
     echo '</div>';
1483 1483
 }
1484
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
1484
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
1485 1485
 
1486 1486
 /**
1487 1487
  * Render an element's edit page.
1488 1488
  *
1489 1489
  * @param WP_Post $post
1490 1490
  */
1491
-function getpaid_payment_form_edit_element_template( $post ) {
1491
+function getpaid_payment_form_edit_element_template($post) {
1492 1492
 
1493 1493
     // Retrieve all elements.
1494
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1494
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1495 1495
 
1496
-    foreach ( $all_elements as $element ) {
1496
+    foreach ($all_elements as $element) {
1497 1497
 
1498 1498
         // Try to locate the appropriate template.
1499
-        $element = sanitize_key( $element );
1500
-        $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" );
1499
+        $element = sanitize_key($element);
1500
+        $located = wpinv_locate_template("payment-forms-admin/edit/$element.php");
1501 1501
 
1502 1502
         // Continue if this is not our element.
1503
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1503
+        if (empty($located) || !file_exists($located)) {
1504 1504
             continue;
1505 1505
         }
1506 1506
 
@@ -1511,7 +1511,7 @@  discard block
 block discarded – undo
1511 1511
     }
1512 1512
 
1513 1513
 }
1514
-add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' );
1514
+add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template');
1515 1515
 
1516 1516
 /**
1517 1517
  * Render an element's preview.
@@ -1520,16 +1520,16 @@  discard block
 block discarded – undo
1520 1520
 function getpaid_payment_form_render_element_preview_template() {
1521 1521
 
1522 1522
     // Retrieve all elements.
1523
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1523
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1524 1524
 
1525
-    foreach ( $all_elements as $element ) {
1525
+    foreach ($all_elements as $element) {
1526 1526
 
1527 1527
         // Try to locate the appropriate template.
1528
-        $element = sanitize_key( $element );
1529
-        $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" );
1528
+        $element = sanitize_key($element);
1529
+        $located = wpinv_locate_template("payment-forms-admin/previews/$element.php");
1530 1530
 
1531 1531
         // Continue if this is not our element.
1532
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1532
+        if (empty($located) || !file_exists($located)) {
1533 1533
             continue;
1534 1534
         }
1535 1535
 
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
     }
1541 1541
 
1542 1542
 }
1543
-add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' );
1543
+add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template');
1544 1544
 
1545 1545
 /**
1546 1546
  * Shows a list of gateways that support recurring payments.
@@ -1548,17 +1548,17 @@  discard block
 block discarded – undo
1548 1548
 function wpinv_get_recurring_gateways_text() {
1549 1549
     $gateways = array();
1550 1550
 
1551
-    foreach ( wpinv_get_payment_gateways() as $key => $gateway ) {
1552
-        if ( wpinv_gateway_support_subscription( $key ) ) {
1553
-            $gateways[] = sanitize_text_field( $gateway['admin_label'] );
1551
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
1552
+        if (wpinv_gateway_support_subscription($key)) {
1553
+            $gateways[] = sanitize_text_field($gateway['admin_label']);
1554 1554
         }
1555 1555
     }
1556 1556
 
1557
-    if ( empty( $gateways ) ) {
1558
-        return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>";
1557
+    if (empty($gateways)) {
1558
+        return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>";
1559 1559
     }
1560 1560
 
1561
-    return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>";
1561
+    return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>";
1562 1562
 
1563 1563
 }
1564 1564
 
@@ -1568,7 +1568,7 @@  discard block
 block discarded – undo
1568 1568
  * @return GetPaid_Template
1569 1569
  */
1570 1570
 function getpaid_template() {
1571
-    return getpaid()->get( 'template' );
1571
+    return getpaid()->get('template');
1572 1572
 }
1573 1573
 
1574 1574
 /**
@@ -1577,23 +1577,23 @@  discard block
 block discarded – undo
1577 1577
  * @param array args
1578 1578
  * @return string
1579 1579
  */
1580
-function getpaid_paginate_links( $args ) {
1580
+function getpaid_paginate_links($args) {
1581 1581
 
1582 1582
     $args['type']     = 'array';
1583 1583
     $args['mid_size'] = 1;
1584
-    $pages        = paginate_links( $args );
1584
+    $pages = paginate_links($args);
1585 1585
 
1586
-    if ( ! is_array( $pages ) ) {
1586
+    if (!is_array($pages)) {
1587 1587
         return '';
1588 1588
     }
1589 1589
 
1590 1590
     $_pages = array();
1591
-    foreach ( $pages as $page ) {
1592
-        $_pages[] = str_replace( 'page-numbers', 'page-link text-decoration-none', $page );
1591
+    foreach ($pages as $page) {
1592
+        $_pages[] = str_replace('page-numbers', 'page-link text-decoration-none', $page);
1593 1593
     }
1594 1594
 
1595 1595
     $links  = "<nav>\n\t<ul class='pagination justify-content-end m-0'>\n\t\t<li class='page-item'>";
1596
-    $links .= join( "</li>\n\t\t<li class='page-item'>", $_pages );
1596
+    $links .= join("</li>\n\t\t<li class='page-item'>", $_pages);
1597 1597
     $links .= "</li>\n\t</ul>\n</nav>\n";
1598 1598
 
1599 1599
     return $links;
@@ -1606,21 +1606,21 @@  discard block
 block discarded – undo
1606 1606
  * @param string state
1607 1607
  * @return string
1608 1608
  */
1609
-function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12' ) {
1609
+function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12') {
1610 1610
 
1611
-    $states = wpinv_get_country_states( $country );
1612
-    $uniqid = uniqid( '_' );
1611
+    $states = wpinv_get_country_states($country);
1612
+    $uniqid = uniqid('_');
1613 1613
 
1614
-    if ( ! empty( $states ) ) {
1614
+    if (!empty($states)) {
1615 1615
 
1616
-        return aui()->select( array(
1616
+        return aui()->select(array(
1617 1617
             'options'          => $states,
1618 1618
             'name'             => 'wpinv_state',
1619 1619
             'id'               => 'wpinv_state' . $uniqid,
1620
-            'value'            => sanitize_text_field( $state ),
1620
+            'value'            => sanitize_text_field($state),
1621 1621
             'placeholder'      => $placeholder,
1622 1622
             'required'         => $required,
1623
-            'label'            => wp_kses_post( $label ),
1623
+            'label'            => wp_kses_post($label),
1624 1624
             'label_type'       => 'vertical',
1625 1625
             'help_text'        => $help_text,
1626 1626
             'class'            => 'getpaid-address-field wpinv_state',
@@ -1636,10 +1636,10 @@  discard block
 block discarded – undo
1636 1636
             'id'          => 'wpinv_state' . $uniqid,
1637 1637
             'placeholder' => $placeholder,
1638 1638
             'required'    => $required,
1639
-            'label'       => wp_kses_post( $label ),
1639
+            'label'       => wp_kses_post($label),
1640 1640
             'label_type'  => 'vertical',
1641 1641
             'help_text'   => $help_text,
1642
-            'value'       => sanitize_text_field( $state ),
1642
+            'value'       => sanitize_text_field($state),
1643 1643
             'class'       => 'getpaid-address-field wpinv_state',
1644 1644
             'wrap_class'  => "$wrapper_class getpaid-address-field-wrapper__state",
1645 1645
             'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state',
@@ -1654,16 +1654,16 @@  discard block
 block discarded – undo
1654 1654
  * @param array $element
1655 1655
  * @return string
1656 1656
  */
1657
-function getpaid_get_form_element_grid_class( $element ) {
1657
+function getpaid_get_form_element_grid_class($element) {
1658 1658
 
1659 1659
     $class = "col-12";
1660
-    $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width'];
1660
+    $width = empty($element['grid_width']) ? 'full' : $element['grid_width'];
1661 1661
 
1662
-    if ( $width == 'half' ) {
1662
+    if ($width == 'half') {
1663 1663
         $class = "col-12 col-md-6";
1664 1664
     }
1665 1665
 
1666
-    if ( $width == 'third' ) {
1666
+    if ($width == 'third') {
1667 1667
         $class = "col-12 col-md-4";
1668 1668
     }
1669 1669
 
Please login to merge, or discard this patch.